diff --git a/lib/pinc_core/SymbolTable.ml b/lib/pinc_core/SymbolTable.ml index 01c40eb..c8633d0 100644 --- a/lib/pinc_core/SymbolTable.ml +++ b/lib/pinc_core/SymbolTable.ml @@ -14,8 +14,9 @@ and scope = Global let make () = { store = StringMap.empty; length = Int32.zero } let define_symbol t ~name = - let symbol = { name; scope = Global; address = t.length } in - { store = StringMap.add name symbol t.store; length = Int32.succ t.length } + let address = Int32.succ t.length in + let symbol = { name; scope = Global; address } in + { store = StringMap.add name symbol t.store; length = address } ;; let resolve_symbol t ~name = StringMap.find_opt name t.store diff --git a/test/vm/run.t b/test/vm/run.t index a0dc732..d7455a4 100644 --- a/test/vm/run.t +++ b/test/vm/run.t @@ -234,9 +234,9 @@ $ NO_COLOR="1" print_instructions . Let 0000 I_Constant 0x00000001 (00000001) 0005 I_Set_Global 0x00000001 (00000001) - 0010 I_Get_Global 0x00000000 (00000000) + 0010 I_Get_Global 0x00000001 (00000001) 0015 I_Set_Global 0x00000002 (00000002) - 0020 I_Get_Global 0x00000001 (00000001) + 0020 I_Get_Global 0x00000002 (00000002) 0025 I_Pop $ NO_COLOR="1" print_instructions . UnboundIdentifier