Implement global identifiers.
This commit is contained in:
parent
6f64647852
commit
7cd2560956
10
stepper.py
10
stepper.py
|
@ -317,7 +317,13 @@ def eval_oper(operand, ssa_env, global_env):
|
||||||
elif isinstance(operand, ll.Const):
|
elif isinstance(operand, ll.Const):
|
||||||
return operand.val
|
return operand.val
|
||||||
elif isinstance(operand, ll.Gid):
|
elif isinstance(operand, ll.Gid):
|
||||||
TODO('eval_oper Gid')
|
gid = operand.val
|
||||||
|
try:
|
||||||
|
return global_env[gid]
|
||||||
|
except KeyError:
|
||||||
|
err('Unable to find @{} in environment:\n{}'
|
||||||
|
.format(global_env))
|
||||||
|
return 0
|
||||||
elif isinstance(operand, ll.Id):
|
elif isinstance(operand, ll.Id):
|
||||||
id = operand.val
|
id = operand.val
|
||||||
try:
|
try:
|
||||||
|
@ -325,6 +331,7 @@ def eval_oper(operand, ssa_env, global_env):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
err('Unable to find %{} in environment:\n{}'
|
err('Unable to find %{} in environment:\n{}'
|
||||||
.format(id, ssa_env))
|
.format(id, ssa_env))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def eval_binop(bop, left, right):
|
def eval_binop(bop, left, right):
|
||||||
|
@ -464,6 +471,7 @@ def base_ty2size(base_ty):
|
||||||
.format(ll.ty2s(base_ty)))
|
.format(ll.ty2s(base_ty)))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
def alloc_globals(gdecls, heap):
|
def alloc_globals(gdecls, heap):
|
||||||
def alloc_global(ginit):
|
def alloc_global(ginit):
|
||||||
next_idx = len(heap)
|
next_idx = len(heap)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user