Compile push & pop using global TOS.

This commit is contained in:
Remko Tronçon 2018-05-30 22:49:16 +02:00
parent 7c2bd40293
commit 98dbf19a45

View file

@ -1667,12 +1667,22 @@ EOF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(func $compilePushConst (param $n i32)
(call $emitGetGlobal (i32.const !tosIndex))
(call $emitConst (get_local $n))
(call $emitICall (i32.const 1) (i32.const !pushIndex)))
(call $emitStore)
(call $emitGetGlobal (i32.const !tosIndex))
(call $emitConst (i32.const 4))
(call $emitAdd)
(call $emitSetGlobal (i32.const !tosIndex)))
(func $compilePushLocal (param $n i32)
(call $emitGetGlobal (i32.const !tosIndex))
(call $emitGetLocal (get_local $n))
(call $emitICall (i32.const 1) (i32.const !pushIndex)))
(call $emitStore)
(call $emitGetGlobal (i32.const !tosIndex))
(call $emitConst (i32.const 4))
(call $emitAdd)
(call $emitSetGlobal (i32.const !tosIndex)))
(func $compileIf
(call $compilePop)
@ -1798,7 +1808,12 @@ EOF
(set_global $cp (i32.add (get_global $cp) (i32.const 1))))
(func $compilePop
(call $emitICall (i32.const 2) (i32.const !popIndex)))
(call $emitGetGlobal (i32.const !tosIndex))
(call $emitConst (i32.const 4))
(call $emitSub)
(call $emitSetGlobal (i32.const !tosIndex))
(call $emitGetGlobal (i32.const !tosIndex))
(call $emitLoad))
(func $compileCall (param $findToken i32)