From 4fca74304a3444d5f8d0767e0d3ca5925e248671 Mon Sep 17 00:00:00 2001 From: cfreksen Date: Sun, 29 Oct 2017 21:23:57 +0100 Subject: [PATCH] Implement store. --- stepper.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/stepper.py b/stepper.py index 1592f05..980845f 100644 --- a/stepper.py +++ b/stepper.py @@ -64,7 +64,18 @@ def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, heap, elif isinstance(next_insn, ll.Load): TODO('Load') elif isinstance(next_insn, ll.Store): - TODO('Store') + ty = next_insn.ty + value = next_insn.value + location = next_insn.location + + value_v = eval_oper(value, ssa_env, global_env) + location_v = eval_oper(location, ssa_env, global_env) + + # TODO + print('heap[{}] <- {}' + .format(location_v, value_v)) + + heap[location_v] = value_v elif isinstance(next_insn, ll.Icmp): cnd = next_insn.cnd left = next_insn.left @@ -333,7 +344,7 @@ def gogo(): data = r''' define i64 @tigermain (i64 %U_mainSL_8, i64 %U_mainDummy_9) { %a = alloca i64 - %b = alloca i64 + store i64 9, i64* %a ret i64 77 } '''