Skip to content

Commit

Permalink
feat(stdlib)!: Add ** (pow) operator to Pervasives module (grain-la…
Browse files Browse the repository at this point in the history
…ng#1690)

* feat!: Move `Number.Pow` To Runtime and add operator to pervasives

* chore: Regen Docs

* chore: Regen Tests

* chore: Update Grain Doc

* chore: Regen Docs

---------

Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
  • Loading branch information
2 people authored and av8ta committed Apr 11, 2023
1 parent dedc527 commit 0ef22e2
Show file tree
Hide file tree
Showing 253 changed files with 2,308 additions and 2,227 deletions.
8 changes: 4 additions & 4 deletions compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ arrays › array_access
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
(global $x_1110 (mut i32) (i32.const 0))
(global $x_1113 (mut i32) (i32.const 0))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -44,7 +44,7 @@ arrays › array_access
(local.set $0
(block $compile_block.10 (result i32)
(block $compile_store.3
(global.set $x_1110
(global.set $x_1113
(tuple.extract 0
(tuple.make
(block $allocate_array.1 (result i32)
Expand Down Expand Up @@ -77,7 +77,7 @@ arrays › array_access
)
(call $decRef_0
(global.get $GRAIN$EXPORT$decRef_0)
(global.get $x_1110)
(global.get $x_1113)
)
)
)
Expand All @@ -90,7 +90,7 @@ arrays › array_access
(i32.const 1)
)
(local.set $2
(global.get $x_1110)
(global.get $x_1113)
)
(block $resolve_idx.8
(if
Expand Down
8 changes: 4 additions & 4 deletions compiler/test/__snapshots__/arrays.28fcc534.0.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ arrays › array_access4
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
(global $x_1110 (mut i32) (i32.const 0))
(global $x_1113 (mut i32) (i32.const 0))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -44,7 +44,7 @@ arrays › array_access4
(local.set $0
(block $compile_block.10 (result i32)
(block $compile_store.3
(global.set $x_1110
(global.set $x_1113
(tuple.extract 0
(tuple.make
(block $allocate_array.1 (result i32)
Expand Down Expand Up @@ -77,7 +77,7 @@ arrays › array_access4
)
(call $decRef_0
(global.get $GRAIN$EXPORT$decRef_0)
(global.get $x_1110)
(global.get $x_1113)
)
)
)
Expand All @@ -90,7 +90,7 @@ arrays › array_access4
(i32.const -3)
)
(local.set $2
(global.get $x_1110)
(global.get $x_1113)
)
(block $resolve_idx.8
(if
Expand Down
8 changes: 4 additions & 4 deletions compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ arrays › array_access2
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
(global $x_1110 (mut i32) (i32.const 0))
(global $x_1113 (mut i32) (i32.const 0))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -44,7 +44,7 @@ arrays › array_access2
(local.set $0
(block $compile_block.10 (result i32)
(block $compile_store.3
(global.set $x_1110
(global.set $x_1113
(tuple.extract 0
(tuple.make
(block $allocate_array.1 (result i32)
Expand Down Expand Up @@ -77,7 +77,7 @@ arrays › array_access2
)
(call $decRef_0
(global.get $GRAIN$EXPORT$decRef_0)
(global.get $x_1110)
(global.get $x_1113)
)
)
)
Expand All @@ -90,7 +90,7 @@ arrays › array_access2
(i32.const 3)
)
(local.set $2
(global.get $x_1110)
(global.get $x_1113)
)
(block $resolve_idx.8
(if
Expand Down
8 changes: 4 additions & 4 deletions compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ arrays › array_access3
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
(global $x_1110 (mut i32) (i32.const 0))
(global $x_1113 (mut i32) (i32.const 0))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -44,7 +44,7 @@ arrays › array_access3
(local.set $0
(block $compile_block.10 (result i32)
(block $compile_store.3
(global.set $x_1110
(global.set $x_1113
(tuple.extract 0
(tuple.make
(block $allocate_array.1 (result i32)
Expand Down Expand Up @@ -77,7 +77,7 @@ arrays › array_access3
)
(call $decRef_0
(global.get $GRAIN$EXPORT$decRef_0)
(global.get $x_1110)
(global.get $x_1113)
)
)
)
Expand All @@ -90,7 +90,7 @@ arrays › array_access3
(i32.const 5)
)
(local.set $2
(global.get $x_1110)
(global.get $x_1113)
)
(block $resolve_idx.8
(if
Expand Down
8 changes: 4 additions & 4 deletions compiler/test/__snapshots__/arrays.74d79181.0.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ arrays › array_access5
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
(global $x_1110 (mut i32) (i32.const 0))
(global $x_1113 (mut i32) (i32.const 0))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -44,7 +44,7 @@ arrays › array_access5
(local.set $0
(block $compile_block.10 (result i32)
(block $compile_store.3
(global.set $x_1110
(global.set $x_1113
(tuple.extract 0
(tuple.make
(block $allocate_array.1 (result i32)
Expand Down Expand Up @@ -77,7 +77,7 @@ arrays › array_access5
)
(call $decRef_0
(global.get $GRAIN$EXPORT$decRef_0)
(global.get $x_1110)
(global.get $x_1113)
)
)
)
Expand All @@ -90,7 +90,7 @@ arrays › array_access5
(i32.const -5)
)
(local.set $2
(global.get $x_1110)
(global.get $x_1113)
)
(block $resolve_idx.8
(if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ basic functionality › comp5
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$<\" (global $<_1111 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$<\" (global $<_1114 (mut i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"<\" (func $<_1111 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"<\" (func $<_1114 (param i32 i32 i32) (result i32)))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -42,10 +42,10 @@ basic functionality › comp5
(block $compile_block.5 (result i32)
(block $compile_store.2
(local.set $6
(call $<_1111
(call $<_1114
(call $incRef_0
(global.get $GRAIN$EXPORT$incRef_0)
(global.get $<_1111)
(global.get $<_1114)
)
(i32.const 5)
(i32.const 7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ basic functionality › modulo4
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$%\" (global $%_1110 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"%\" (func $%_1110 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32)))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -39,10 +39,10 @@ basic functionality › modulo4
(block $cleanup_locals.2 (result i32)
(local.set $0
(block $compile_block.1 (result i32)
(call $%_1110
(call $%_1113
(call $incRef_0
(global.get $GRAIN$EXPORT$incRef_0)
(global.get $%_1110)
(global.get $%_1113)
)
(i32.const -33)
(i32.const 35)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ basic functionality › land4
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$&\" (global $&_1110 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$&\" (global $&_1113 (mut i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"&\" (func $&_1110 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"&\" (func $&_1113 (param i32 i32 i32) (result i32)))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -39,10 +39,10 @@ basic functionality › land4
(block $cleanup_locals.2 (result i32)
(local.set $0
(block $compile_block.1 (result i32)
(call $&_1110
(call $&_1113
(call $incRef_0
(global.get $GRAIN$EXPORT$incRef_0)
(global.get $&_1110)
(global.get $&_1113)
)
(i32.const 1)
(i32.const 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ basic functionality › lxor1
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$^\" (global $^_1110 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$^\" (global $^_1113 (mut i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"^\" (func $^_1110 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"^\" (func $^_1113 (param i32 i32 i32) (result i32)))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -39,10 +39,10 @@ basic functionality › lxor1
(block $cleanup_locals.2 (result i32)
(local.set $0
(block $compile_block.1 (result i32)
(call $^_1110
(call $^_1113
(call $incRef_0
(global.get $GRAIN$EXPORT$incRef_0)
(global.get $^_1110)
(global.get $^_1113)
)
(i32.const 3)
(i32.const 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ basic functionality › lor1
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$|\" (global $|_1110 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$|\" (global $|_1113 (mut i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"|\" (func $|_1110 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"|\" (func $|_1113 (param i32 i32 i32) (result i32)))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -39,10 +39,10 @@ basic functionality › lor1
(block $cleanup_locals.2 (result i32)
(local.set $0
(block $compile_block.1 (result i32)
(call $|_1110
(call $|_1113
(call $incRef_0
(global.get $GRAIN$EXPORT$incRef_0)
(global.get $|_1110)
(global.get $|_1113)
)
(i32.const 3)
(i32.const 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ basic functionality › modulo6
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$%\" (global $%_1110 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"%\" (func $%_1110 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32)))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -39,10 +39,10 @@ basic functionality › modulo6
(block $cleanup_locals.2 (result i32)
(local.set $0
(block $compile_block.1 (result i32)
(call $%_1110
(call $%_1113
(call $incRef_0
(global.get $GRAIN$EXPORT$incRef_0)
(global.get $%_1110)
(global.get $%_1113)
)
(i32.const 35)
(i32.const 35)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ basic functionality › precedence1
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$*\" (global $*_1113 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$+\" (global $+_1110 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$*\" (global $*_1116 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"*\" (func $*_1113 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"+\" (func $+_1110 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"*\" (func $*_1116 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32)))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -48,10 +48,10 @@ basic functionality › precedence1
(local.set $6
(tuple.extract 0
(tuple.make
(call $*_1113
(call $*_1116
(call $incRef_0
(global.get $GRAIN$EXPORT$incRef_0)
(global.get $*_1113)
(global.get $*_1116)
)
(i32.const 9)
(i32.const 13)
Expand All @@ -66,10 +66,10 @@ basic functionality › precedence1
(block $do_backpatches.1
)
)
(call $+_1110
(call $+_1113
(call $incRef_0
(global.get $GRAIN$EXPORT$incRef_0)
(global.get $+_1110)
(global.get $+_1113)
)
(i32.const 7)
(call $incRef_0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ basic functionality › comp16
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1110 (mut i32)))
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32)))
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1110 (param i32 i32 i32) (result i32)))
(import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32)))
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
(elem $elem (global.get $relocBase_0))
(export \"memory\" (memory $0))
Expand Down Expand Up @@ -39,10 +39,10 @@ basic functionality › comp16
(block $cleanup_locals.2 (result i32)
(local.set $0
(block $compile_block.1 (result i32)
(call $==_1110
(call $==_1113
(call $incRef_0
(global.get $GRAIN$EXPORT$incRef_0)
(global.get $==_1110)
(global.get $==_1113)
)
(i32.const 2147483646)
(i32.const 2147483646)
Expand Down
Loading

0 comments on commit 0ef22e2

Please sign in to comment.