Handle load/store with null.
This commit is contained in:
parent
7deddce45d
commit
ce61eb151e
10
stepper.py
10
stepper.py
|
@ -77,6 +77,10 @@ def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, heap,
|
|||
' Current size is {}')
|
||||
.format(size))
|
||||
|
||||
if location_v == 0:
|
||||
err('You are not allowed to read from location 0')
|
||||
res = 0
|
||||
else:
|
||||
res = heap[location_v]
|
||||
elif isinstance(next_insn, ll.Store):
|
||||
ty = next_insn.ty
|
||||
|
@ -91,8 +95,9 @@ def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, heap,
|
|||
# TODO
|
||||
print('heap[{}] <- {}'
|
||||
.format(location_v, value_v))
|
||||
|
||||
if size == 1:
|
||||
if location_v == 0:
|
||||
err('You are not allowed to store at location 0 (Null)')
|
||||
elif size == 1:
|
||||
heap[location_v] = value_v
|
||||
else:
|
||||
err(('This emulator cannot store objects larger than 1 cell.'
|
||||
|
@ -407,7 +412,6 @@ define i64 @tigermain (i64 %U_mainSL_8, i64 %U_mainDummy_9) {
|
|||
terminator = first_block.terminator
|
||||
stack_frames = []
|
||||
ssa_env = {}
|
||||
# TODO: memory structure has not been decided yet
|
||||
heap = [None]
|
||||
call_res = []
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user