diff --git a/index.html b/index.html deleted file mode 100644 index 06a376a..0000000 --- a/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/runtime/t.wat b/runtime/t.wat deleted file mode 100644 index c189168..0000000 --- a/runtime/t.wat +++ /dev/null @@ -1,6 +0,0 @@ -(module - (import "gyehoek" "say-hi" (func $say-hi)) - (func (export "main") - (call $say-hi) - (call $say-hi) - (call $say-hi))) diff --git a/t.js b/t.js deleted file mode 100644 index a3d8ac2..0000000 --- a/t.js +++ /dev/null @@ -1,18 +0,0 @@ -const imports = { - guppy: { - print: (arg) => console.log (arg) - } -} - -// Assume add.wasm file exists that contains a single function adding 2 provided arguments -const fs = require('node:fs'); - -// Use the readFileSync function to read the contents of the "add.wasm" file -const wasmBuffer = fs.readFileSync('u.wasm'); - -// Use the WebAssembly.instantiate method to instantiate the WebAssembly module -WebAssembly.instantiate(wasmBuffer, imports).then(wasmModule => { - // Exported function lives under instance.exports object - const { main } = wasmModule.instance.exports; - main () -}); diff --git a/t.wat b/t.wat deleted file mode 100644 index 972cff1..0000000 --- a/t.wat +++ /dev/null @@ -1,61 +0,0 @@ -(module - (import - "gyehoek" - "write" - (func $gh-write (param (ref eq)))) - (import - "gyehoek" - "to-bool" - (func $gh-to-bool (param (ref eq)) (result i32))) - (type $heap-object (sub (struct (field $hash (mut i32))))) - (type $cont-type (func (param i32))) - (type $cont-stack-type (array (mut (ref null $cont-type)))) - (global $cont-stack-top (mut i32) (i32.const 0)) - (global - $cont-stack - (ref $cont-stack-type) - (array.new_default $cont-stack-type (i32.const 128))) - (type $arg-array-type (array (mut (ref null eq)))) - (global - $arg-array - (ref $arg-array-type) - (array.new_default $arg-array-type (i32.const 32))) - (global $result (mut (ref null eq)) (ref.null eq)) - (func - $halt - (param i32) - (global.get $arg-array) - (i32.const 0) - (array.get $arg-array-type) - ref.as_non_null - (global.set $result)) - (func - $scm-entry - (param i32) - (local (ref eq) (ref eq) (ref eq) (ref eq) (ref eq)) - (i32.const 3) - ref.i31 - (call $gh-to-bool) - (if - (then - (global.get $arg-array) - (global.get 0) - (i32.const 777) - (i32.const 1) - i32.shl - ref.i31 - (array.set $arg-array-type) - (return_call $halt (i32.const 1))) - (else - (global.get $arg-array) - (global.get 0) - (i32.const 555) - (i32.const 1) - i32.shl - ref.i31 - (array.set $arg-array-type) - (return_call $halt (i32.const 1))))) - (func - (export "main") - (call $scm-entry (i32.const 0)) - (call $gh-write (ref.as_non_null (global.get $result))))) diff --git a/t2.wat b/t2.wat deleted file mode 100644 index bd27cf8..0000000 --- a/t2.wat +++ /dev/null @@ -1,65 +0,0 @@ -(module - (type $heap-object (sub (struct (field (mut i32))))) - (type $open-procedure (func (param i32))) - (type $closure (sub $heap-object - (struct (field (mut i32)) - (field (ref $open-procedure))))) - (type $cont-stack-type (array (mut (ref null $open-procedure)))) - (type $arg-array-type (array (mut eqref))) - (type (func (result (ref eq)))) - (global $cont-stack-top (mut i32) (i32.const 0)) - (global $cont-stack (ref $cont-stack-type) - (array.new_default $cont-stack-type (i32.const 128))) - (global $arg-array (ref $arg-array-type) - (array.new_default $arg-array-type (i32.const 32))) - (global (mut eqref) (ref.null eq)) - (elem declare funcref (ref.func 1)) - (func $halt (param i32) - (local (ref eq) (ref eq) (ref eq) (ref eq) (ref eq)) - (global.set 3 - (ref.as_non_null - (array.get $arg-array-type - (global.get $arg-array) - (i32.const 0))))) - (func $f1 (param i32) - (local (ref eq) (ref eq) (ref eq) (ref eq) (ref eq)) - ;; pop arg 0 - (local.set - 1 - (ref.as_non_null - (array.get $arg-array-type - (global.get $arg-array) - (i32.const 0)))) - ;; push arg 0 - (array.set $arg-array-type - (global.get $arg-array) - (i32.const 0) - (local.get 1)) - ;; pop continuation - (return_call_ref - $open-procedure - (i32.const 1) - (ref.as_non_null (array.get $cont-stack-type - (global.get $cont-stack) - (global.get $cont-stack-top))) - (global.set $cont-stack-top - (i32.sub - (global.get $cont-stack-top) - (i32.const 1))))) - (func $f2 (type $open-procedure) (param i32) - (local (ref eq) (ref eq) (ref eq) (ref eq) (ref eq)) - (local.set 1 - (struct.new $closure - (i32.const 0) - (ref.func $f1))) - (array.set $arg-array-type - (global.get $arg-array) - (i32.const 0) - (local.get 1)) - (i32.const 1) - (return_call $f1)) - (func $main (export "main") (result (ref eq)) - (local (ref eq) (ref eq) (ref eq) (ref eq) (ref eq)) - (call $f2 (i32.const 0)) - (ref.as_non_null - (global.get 3)))) diff --git a/u.wasm b/u.wasm deleted file mode 100644 index 702623c..0000000 Binary files a/u.wasm and /dev/null differ diff --git a/u.wat b/u.wat deleted file mode 100644 index c4cd5c7..0000000 --- a/u.wat +++ /dev/null @@ -1,78 +0,0 @@ -(module - (func $print (import "guppy" "print") (param i32)) - (table 2 funcref) - (elem (i32.const 0) $halt) - - (type $cont (func (param i32))) - (type $cont-stack-type (array (mut (ref null $cont)))) - (global $cont-stack (ref $cont-stack-type) - (array.new_default $cont-stack-type (i32.const 128))) - (global $cont-stack-top (mut i32) (i32.const 0)) - - (type $arg-array-type (array (mut (ref null eq)))) - (global $arg-array (ref $arg-array-type) - (array.new_default $arg-array-type (i32.const 32))) - - ;; (memory $memory i32 1) - ;; (global $arg-stack-base i32 (i32.const 0)) - ;; (global $arg-stack-ptr i32 (global.get $arg-stack-base)) - ;; (global $cont-stack-base i32 (i32.const 32)) - ;; (global $cont-stack-ptr i32 (global.get $cont-stack-base)) - - (func $add (param $nargs i32) - (local $x (ref eq)) - (local $y (ref eq)) - (local $return (ref $cont)) - (local.set $x (ref.as_non_null - (array.get $arg-array-type - (global.get $arg-array) - (i32.const 0)))) - (local.set $y (ref.as_non_null - (array.get $arg-array-type - (global.get $arg-array) - (i32.const 1)))) - (array.set $arg-array-type - (global.get $arg-array) - (i32.const 0) - (ref.i31 - (i32.add (i31.get_s (ref.cast (ref i31) (local.get $x))) - (i31.get_s (ref.cast (ref i31) (local.get $y)))))) - (return_call_ref - $cont - (i32.const 1) - (block (result (ref $cont)) - (ref.as_non_null - (array.get $cont-stack-type - (global.get $cont-stack) - (global.get $cont-stack-top))) - (global.set $cont-stack-top - (i32.sub (global.get $cont-stack-top) - (i32.const 1)))))) - (func $halt (param $nargs i32) - (call $print - (i31.get_s - (ref.cast - (ref i31) - (ref.as_non_null - (array.get $arg-array-type - (global.get $arg-array) - (i32.const 0))))))) - (func (export "main") - ;; push args - (array.set $arg-array-type - (global.get $arg-array) - (i32.const 0) - (ref.i31 (i32.const 4))) - (array.set $arg-array-type - (global.get $arg-array) - (i32.const 1) - (ref.i31 (i32.const 5))) - ;; push return continuation - (array.set $cont-stack-type - (global.get $cont-stack) - (i32.const 0) - (ref.func $halt)) - ;; make call }:) - (return_call $add - ;; inform $add how many arguments we called it with - (i32.const 2))))