From f04d22c27eb5f9b59fe3eef281c2524329b1b6e6 Mon Sep 17 00:00:00 2001 From: cfreksen Date: Sun, 29 Oct 2017 21:33:57 +0100 Subject: [PATCH] Add size check to Store. --- stepper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stepper.py b/stepper.py index 980845f..aee0c88 100644 --- a/stepper.py +++ b/stepper.py @@ -65,6 +65,8 @@ def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, heap, TODO('Load') elif isinstance(next_insn, ll.Store): ty = next_insn.ty + base_ty = ty2base_ty(ty, tdecs) + size = base_ty2size(base_ty) value = next_insn.value location = next_insn.location @@ -75,7 +77,12 @@ def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, heap, print('heap[{}] <- {}' .format(location_v, value_v)) - heap[location_v] = value_v + if size == 1: + heap[location_v] = value_v + else: + err(('This emulator cannot store objects larger than 1 cell.' + ' Current size is {}') + .format(size)) elif isinstance(next_insn, ll.Icmp): cnd = next_insn.cnd left = next_insn.left