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