def __init__(self, tree, module_prefix=''): self.tree = tree self.module_prefix = module_prefix self.builtins = {} for b in get_builtins(): bname, b = b.name(), b.underlying_construct() self.builtins[bname] = b self.routines = {} self.external_routines = {}
def init_builtins(self): "Initialize a global context with types for all the builtins." for b in gbs_builtins.get_builtins(): bname, b = b.name(), b.underlying_construct() set_add(self.ribs[0], b.name()) self.global_context[b.name()] = b.gbstype() for type_name, gbs_type in gbs_type.BasicTypes.items(): self.global_context[type_name] = gbs_type()
def setup(self, tree): if self.explicit_board is None: entrypoint_tree = find_def(tree.children[2], is_entrypoint_def) self.explicit_board = len(entrypoint_tree.children[2].children) != 0 gbs_builtins.explicit_builtins = self.explicit_board for b in gbs_builtins.get_builtins(): self.symbol_table.add(b) for name, type in gbs_type.BasicTypes.items(): self.symbol_table.add(gbs_constructs.BuiltinType(name, type)) self.types += gbs_type.build_types(tree)