diff --git a/stepper.py b/stepper.py index a85f3ef..5a22281 100644 --- a/stepper.py +++ b/stepper.py @@ -317,7 +317,13 @@ def eval_oper(operand, ssa_env, global_env): elif isinstance(operand, ll.Const): return operand.val 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): id = operand.val try: @@ -325,6 +331,7 @@ def eval_oper(operand, ssa_env, global_env): except KeyError: err('Unable to find %{} in environment:\n{}' .format(id, ssa_env)) + return 0 def eval_binop(bop, left, right): @@ -464,6 +471,7 @@ def base_ty2size(base_ty): .format(ll.ty2s(base_ty))) return 1 + def alloc_globals(gdecls, heap): def alloc_global(ginit): next_idx = len(heap)