コード例 #1
0
 def initialize_globals(self, code_builder: OpCodeBuilder):
     for decl in self.spl_file.declarations:  # Extra iteration over decls to add globals to context
         if isinstance(decl, VarDecl):
             code_builder.get_global(decl.id_number)
     for decl in self.spl_file.declarations:
         if isinstance(decl, VarDecl):
             assert decl.id_number is not None, 'Var declaration ID should be set during binding analysis'
             decl.expression.generate_code(code_builder)
             glob = code_builder.get_global(decl.id_number)
             code_builder.add(codes.StGlob(glob))
コード例 #2
0
ファイル: fields.py プロジェクト: davidkerkkamp/spl-compiler
 def generate_storage_code(self, code_builder: OpCodeBuilder):
     if code_builder.is_global(self.id_number):
         glob = code_builder.get_global(self.id_number)
         code_builder.add(codes.StGlob(glob))
     else:
         loc = code_builder.get_local(self.id_number)
         code_builder.add(codes.StLoc(loc))