This commit is contained in:
Remko Tronçon 2019-03-12 21:16:43 +01:00
parent 305c26fe1c
commit 0248e87dc3

View file

@ -1178,6 +1178,19 @@
(call $compileThen)) (call $compileThen))
(!def_word "THEN" "$then" !fImmediate) (!def_word "THEN" "$then" !fImmediate)
;; 6.1.2310 TYPE
(func $TYPE
(local $p i32)
(local $end i32)
(set_local $end (i32.add (call $pop) (tee_local $p (call $pop))))
(block $endLoop
(loop $loop
(br_if $endLoop (i32.eq (get_local $p) (get_local $end)))
(call $shell_emit (i32.load8_u (get_local $p)))
(set_local $p (i32.add (get_local $p) (i32.const 1)))
(br $loop))))
(!def_word "TYPE" "$TYPE" !fNone !typeIndex)
;; 6.2.2295 ;; 6.2.2295
(func $TO (func $TO
(call $word) (call $word)
@ -1508,12 +1521,14 @@ EOF
(call $shell_emit (i32.const 10)) (call $shell_emit (i32.const 10))
(call $ABORT)) (call $ABORT))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Interpreter ;; Interpreter
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Interprets the string in the input, until the end of string is reached. ;; Interprets the string in the input, until the end of string is reached.
;; Returns 0 if processed, 1 if still compiling, -1 if a word was not found. ;; Returns 0 if processed, 1 if still compiling, or traps if a word
;; was not found.
(func $interpret (result i32) (func $interpret (result i32)
(local $findResult i32) (local $findResult i32)
(local $findToken i32) (local $findToken i32)
@ -1664,13 +1679,9 @@ EOF
(i32.const !fData)) (i32.const !fData))
(then (then
(call $emitConst (i32.add (get_local $body) (i32.const 4))) (call $emitConst (i32.add (get_local $body) (i32.const 4)))
(call $emitICall (call $emitICall (i32.const 1) (i32.load (get_local $body))))
(i32.const 1)
(i32.load (get_local $body))))
(else (else
(call $emitICall (call $emitICall (i32.const 0) (i32.load (get_local $body))))))
(i32.const 0)
(i32.load (get_local $body))))))
(func $emitICall (param $type i32) (param $n i32) (func $emitICall (param $type i32) (param $n i32)
(call $emitConst (get_local $n)) (call $emitConst (get_local $n))
@ -1755,18 +1766,6 @@ EOF
(i32.load (get_global $tos))) (i32.load (get_global $tos)))
(elem (i32.const !popIndex) $pop) (elem (i32.const !popIndex) $pop)
(func $TYPE
(local $p i32)
(local $end i32)
(set_local $end (i32.add (call $pop) (tee_local $p (call $pop))))
(block $endLoop
(loop $loop
(br_if $endLoop (i32.eq (get_local $p) (get_local $end)))
(call $shell_emit (i32.load8_u (get_local $p)))
(set_local $p (i32.add (get_local $p) (i32.const 1)))
(br $loop))))
(!def_word "TYPE" "$TYPE" !fNone !typeIndex)
(func $pushDataAddress (param $d i32) (func $pushDataAddress (param $d i32)
(call $push (get_local $d))) (call $push (get_local $d)))
(elem (i32.const !pushDataAddressIndex) $pushDataAddress) (elem (i32.const !pushDataAddressIndex) $pushDataAddress)