mirror of
https://github.com/remko/waforth
synced 2024-12-27 09:59:29 +01:00
compiler: fix bad local index offset
This commit is contained in:
parent
23b41a2c7f
commit
257d731b96
1 changed files with 9 additions and 3 deletions
|
@ -1978,8 +1978,8 @@
|
|||
(func $startColon (param $params i32)
|
||||
(i32.store8 (i32.const 0x1041 (; = MODULE_HEADER_FUNCTION_TYPE_BASE ;)) (local.get $params))
|
||||
(global.set $cp (i32.const 0x1060 (; = MODULE_BODY_BASE ;)))
|
||||
(global.set $currentLocal (i32.sub (local.get $params) (i32.const 1)))
|
||||
(global.set $lastLocal (i32.sub (local.get $params) (i32.const 1)))
|
||||
(global.set $currentLocal (local.get $params))
|
||||
(global.set $lastLocal (local.get $params))
|
||||
(global.set $branchNesting (i32.const -1)))
|
||||
|
||||
(func $endColon
|
||||
|
@ -2006,7 +2006,13 @@
|
|||
;; Update #locals
|
||||
(i32.store
|
||||
(i32.const 0x1059 (; = MODULE_HEADER_LOCAL_COUNT_BASE ;))
|
||||
(call $leb128-4p (i32.add (global.get $lastLocal) (i32.const 1))))
|
||||
(call $leb128-4p
|
||||
(i32.sub
|
||||
(global.get $lastLocal)
|
||||
;; Subtract the number of incoming parameters. We could use a global to keep track of
|
||||
;; the type, but for now getting this from the module header (where we stored this at
|
||||
;; start of compilation)
|
||||
(i32.load8_u (i32.const 0x1041 (; = MODULE_HEADER_FUNCTION_TYPE_BASE ;))))))
|
||||
|
||||
;; Update table offset
|
||||
(i32.store
|
||||
|
|
Loading…
Reference in a new issue