Print when evaluating terminators.
This commit is contained in:
parent
7213c32f93
commit
344609e54b
22
ll.py
22
ll.py
|
@ -106,3 +106,25 @@ def insn2s(insn):
|
|||
# TODO
|
||||
print('insn2s: Unknown insn: {}'
|
||||
.format(insn))
|
||||
|
||||
def terminator2s(terminator):
|
||||
if isinstance(terminator, Ret):
|
||||
if terminator.oper is None:
|
||||
return ('ret {}'
|
||||
.format(ty2s(terminator.ty)))
|
||||
else:
|
||||
return ('ret {} {}'
|
||||
.format(ty2s(terminator.ty),
|
||||
oper2s(terminator.oper)))
|
||||
elif isinstance(terminator, Br):
|
||||
return ('br label %{}'
|
||||
.format(terminator.label))
|
||||
elif isinstance(terminator, Cbr):
|
||||
return ('br {} {}, label %{}, label %{}'
|
||||
.format(ty2s(terminator.ty),
|
||||
oper2s(terminator.oper),
|
||||
terminator.then_label,
|
||||
terminator.else_label))
|
||||
else:
|
||||
print('terminator2s: Unknown terminator {}'
|
||||
.format(terminator))
|
||||
|
|
|
@ -69,12 +69,19 @@ def terminate(terminator, blocks, stack_frames, ssa_env, global_env, memory):
|
|||
if id is not None and id in ssa_env:
|
||||
del ssa_env[id]
|
||||
|
||||
print('Evaluating {}'
|
||||
.format(ll.terminator2s(terminator)))
|
||||
|
||||
if isinstance(terminator, ll.Ret):
|
||||
oper = terminator.oper
|
||||
if oper is None:
|
||||
oper_v = None
|
||||
else:
|
||||
oper_v = eval_oper(oper, ssa_env, global_env)
|
||||
|
||||
# TODO
|
||||
print('Returning {}'
|
||||
.format(oper_v))
|
||||
if len(stack_frames) == 0:
|
||||
new_insns = []
|
||||
new_terminator = None
|
||||
|
@ -97,6 +104,7 @@ def terminate(terminator, blocks, stack_frames, ssa_env, global_env, memory):
|
|||
# blocks.
|
||||
clear_block_from_ssa_env(new_insns, ssa_env)
|
||||
|
||||
# TODO
|
||||
print('Jumping unconditionally to {}'
|
||||
.format(label))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user