mirror of
https://github.com/kanaka/mal.git
synced 2024-11-11 00:52:44 +03:00
0a19c2f1c7
wasm: update to wat syntax as of Jan 2019. Examples: - get_local -> local.get - i32.wrap/i64 -> i32.warp_i64 - etc The distinction between wat and wast has been clarified: - wat: textual format for web assembly modules - wast: superset of wat used in the specification to define tests.
48 lines
899 B
Plaintext
48 lines
899 B
Plaintext
(module $step0_repl
|
|
|
|
;; READ
|
|
(func $READ (param $str i32) (result i32)
|
|
$str
|
|
)
|
|
|
|
(func $EVAL (param $ast i32) (param $env i32) (result i32)
|
|
$ast
|
|
)
|
|
|
|
;; PRINT
|
|
(func $PRINT (param $ast i32) (result i32)
|
|
$ast
|
|
)
|
|
|
|
;; REPL
|
|
(func $rep (param $line i32) (result i32)
|
|
($PRINT ($EVAL ($READ $line) 0))
|
|
)
|
|
|
|
(func $main (result i32)
|
|
;; Constant location/value definitions
|
|
(LET $line (STATIC_ARRAY 201))
|
|
|
|
;; DEBUG
|
|
;;($printf_1 "memoryBase: 0x%x\n" (global.get $memoryBase))
|
|
|
|
;; Start REPL
|
|
(block $repl_done
|
|
(loop $repl_loop
|
|
(br_if $repl_done (i32.eqz ($readline "user> " $line)))
|
|
(br_if $repl_loop (i32.eq (i32.load8_u $line) 0))
|
|
($printf_1 "%s\n" ($rep $line))
|
|
(br $repl_loop)
|
|
)
|
|
)
|
|
|
|
($print "\n")
|
|
0
|
|
)
|
|
|
|
|
|
(export "_main" (func $main))
|
|
(export "__post_instantiate" (func $init_printf_mem))
|
|
)
|
|
|