mirror of
https://github.com/remko/waforth
synced 2024-12-26 09:59:09 +01:00
compileDo: Rearrange
This commit is contained in:
parent
f48dd6b86d
commit
2dbe2e00dd
1 changed files with 9 additions and 6 deletions
|
@ -2192,6 +2192,11 @@
|
|||
(call $compileEndDests (local.get $tos)))
|
||||
|
||||
(func $compileDo (param $tos i32) (result i32)
|
||||
;; Save branch nesting
|
||||
(i32.store (local.get $tos) (global.get $branchNesting))
|
||||
(local.set $tos (i32.add (local.get $tos) (i32.const 4)))
|
||||
(global.set $branchNesting (i32.const 0))
|
||||
|
||||
;; 1: $diff_i = end index - current index
|
||||
;; 2: $end_i
|
||||
(global.set $currentLocal (i32.add (global.get $currentLocal) (i32.const 2)))
|
||||
|
@ -2199,11 +2204,6 @@
|
|||
(then
|
||||
(global.set $lastLocal (global.get $currentLocal))))
|
||||
|
||||
;; Save branch nesting
|
||||
(i32.store (local.get $tos) (global.get $branchNesting))
|
||||
(local.set $tos (i32.add (local.get $tos) (i32.const 4)))
|
||||
(global.set $branchNesting (i32.const 0))
|
||||
|
||||
;; $1 = current index (temporary)
|
||||
(call $compilePop)
|
||||
(call $emitSetLocal (i32.sub (global.get $currentLocal) (i32.const 1)))
|
||||
|
@ -2211,6 +2211,10 @@
|
|||
(call $compilePop)
|
||||
(call $emitSetLocal (global.get $currentLocal))
|
||||
|
||||
;; Already emit the block, so we can jump out of it before starting DO
|
||||
;; in the conditional case
|
||||
(call $emitBlock)
|
||||
|
||||
;; startDo $1
|
||||
(call $emitGetLocal (i32.sub (global.get $currentLocal) (i32.const 1)))
|
||||
(call $emitICall (i32.const 1) (i32.const 0x1 (; = START_DO_INDEX ;)))
|
||||
|
@ -2221,7 +2225,6 @@
|
|||
(call $emitSub)
|
||||
(call $emitSetLocal (i32.sub (global.get $currentLocal) (i32.const 1)))
|
||||
|
||||
(call $emitBlock)
|
||||
(call $emitLoop)
|
||||
(local.get $tos))
|
||||
|
||||
|
|
Loading…
Reference in a new issue