Add size check to Store.
This commit is contained in:
parent
1dc258d26f
commit
f04d22c27e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user