Beispiel #1
0
 def gen(self, context: Context, target: str):
     """Code generation for assignment: calculate into register,
     then store into memory
     """
     log.debug("Generating code for assignment")
     var_symbol = context.get_var_symbol(self.var.name)
     self.expr.gen(context, target)
     context.add_line("\tSTORE  {},{}".format(target, var_symbol))
Beispiel #2
0
 def gen(self, context: Context, target: str):
     """Code generation for a variable reference.
     Generates code to load the value of that variable
     from memory.
     """
     log.debug("Generating code for reference to variable {}".format(
         self.name))
     symbol = context.get_var_symbol(self.name)
     context.add_line("\tLOAD {},{}".format(target, symbol))
     return