def __init__(self, value, lineno, offset=None): global SYMBOL_TABLE Symbol.__init__(self, value, 'ID') self.id = value self.filename = gl.FILENAME # In which file was first used self.lineno = lineno # In which line was first used self._class = None self._mangled = '_%s' % value # This value will be overriden later self.t = self._mangled self.declared = False # if declared (DIM var AS <type>) this must be True self._type = None # Unknown type self.offset = offset # For local variables, offset from top of the stack self.default_value = None # If defined, variable will be initialized with this value (Arrays = List of Bytes) self.scope = 'global' # One of 'global', 'parameter', 'local' self.byref = False # By default, it's a global var self.default_value = None # For variables, this is the default initalized value self.__kind = None # If not None, it should be one of 'function' or 'sub' self.addr = None # If not None, the address of this symbol (string) self.alias = None # If not None, this var is an alias of another self.aliased_by = [] # Which variables are an alias of this one self.referenced_by = [ ] # Which objects do use this one (e.g. sentences using this variable) self.references = [ ] # Objects referenced by this one (e.g. variables used in this sentence) self.accessed = False # Where this object has been accessed (if false it might be not compiled, since it is useless) self.caseins = OPTIONS.case_insensitive.value # Whether this ID is case insensitive or not
def __init__(self, symbol, _type): Symbol.__init__(self, symbol._mangled, "PARAMDECL") self.entry = symbol self.__size = TYPE_SIZES[self._type] self.__size = self.__size + (self.__size % 2) # Make it even-sized (Float and Byte) self.byref = OPTIONS.byref.value # By default all params By value (false) self.offset = None # Set by PARAMLIST, contains positive offset from top of the stack
def __init__(self, lineno, byref = False): ''' Initializes the argument data. Byref must be set to True if this Argument is passed by reference. ''' Symbol.__init__(self, None, 'ARGUMENT') self.lineno = lineno self.byref = byref
def __init__(self, symbol, _type): Symbol.__init__(self, symbol._mangled, 'PARAMDECL') self.entry = symbol self.__size = TYPE_SIZES[self._type] self.__size = self.__size + (self.__size % 2) # Make it even-sized (Float and Byte) self.byref = OPTIONS.byref.value # By default all params By value (false) self.offset = None # Set by PARAMLIST, contains positive offset from top of the stack
def __init__(self, value, lineno, offset=None): global SYMBOL_TABLE Symbol.__init__(self, value, "ID") self.id = value self.filename = gl.FILENAME # In which file was first used self.lineno = lineno # In which line was first used self._class = None self._mangled = "_%s" % value # This value will be overriden later self.t = self._mangled self.declared = False # if declared (DIM var AS <type>) this must be True self._type = None # Unknown type self.offset = offset # For local variables, offset from top of the stack self.default_value = None # If defined, variable will be initialized with this value (Arrays = List of Bytes) self.scope = "global" # One of 'global', 'parameter', 'local' self.byref = False # By default, it's a global var self.default_value = None # For variables, this is the default initalized value self.__kind = None # If not None, it should be one of 'function' or 'sub' self.addr = None # If not None, the address of this symbol (string) self.alias = None # If not None, this var is an alias of another self.aliased_by = [] # Which variables are an alias of this one self.referenced_by = [] # Which objects do use this one (e.g. sentences using this variable) self.references = [] # Objects referenced by this one (e.g. variables used in this sentence) self.accessed = ( False ) # Where this object has been accessed (if false it might be not compiled, since it is useless) self.caseins = OPTIONS.case_insensitive.value # Whether this ID is case insensitive or not
def __init__(self, lineno, byref=False): ''' Initializes the argument data. Byref must be set to True if this Argument is passed by reference. ''' Symbol.__init__(self, None, 'ARGUMENT') self.lineno = lineno self.byref = byref
def __init__(self, left, treedef_list): ''' Constructor. Requires Symbol S and a list [ ] of TreeDefs objects ''' Symbol.__init__(self) self.left = left # Tree symbol (left side of the rule, S symbol) self.defs = {} self.add_alternatives(treedef_list)
def __init__(self, terminal, arglist = None, generator = None): Symbol.__init__(self) self.first = terminal # 1st symbol in the right side self.arglist = arglist # Optional arglist # If no generator specified, a default one is created # which will just return a string of the terminal self.generator = generator # Optional generator function
def __init__(self, _type, lineno, implicit = False): ''' Implicit = True if this type has been "inferred" by default, or by the expression surrounding the ID. ''' Symbol.__init__(self, _type, 'TYPE') self._type = _type self.size = TYPE_SIZES[self._type] self.lineno = lineno self.implicit = implicit
def __init__(self, arglistOrTerminal, terminal = None): ''' Creates an argument list, by concatenaing an arglist + a terminal. If only a terminal is specified, then it is converted to a list. ''' Symbol.__init__(self) self.list = [] if terminal is None: self.list += [arglistOrTerminal] else: self.list = arglistOrTerminal.list + [terminal]
def __init__(self, value, _type = None, lineno = None): if lineno is None: raise ValueError # This should be changed to another exception Symbol.__init__(self, value, 'NUMBER') if int(value) == value: value = int(value) self.value = value if _type is not None: self._type = _type elif isinstance(value, float): if -32768.0 < value < 32767: self._type = 'fixed' else: self._type = 'float' elif isinstance(value, int): if 0 <= value < 256: self._type = 'u8' elif -128 <= value < 128: self._type = 'i8' elif 0 <= value < 65536: self._type = 'u16' elif -32768 <= value < 32768: self._type = 'i16' elif value < 0: self._type = 'i32' else: self._type = 'u32' self.t = value self.lineno = lineno
def __init__(self, symbol): Symbol.__init__(self, symbol._mangled, 'FUNCDECL') self.fname = symbol.id self._mangled = symbol._mangled self.entry = symbol # Symbol table entry
def __init__(self, oper, lineno): Symbol.__init__(self, oper, "UNARY") self.left = None # Must be set by make_unary self.t = optemps.new_t() self.lineno = lineno
def __init__(self, oper, lineno): Symbol.__init__(self, oper, 'BINARY') self.left = None # Must be set by make_binary self.right = None self.t = optemps.new_t() self.lineno = lineno
def __init__(self, lineno, symbol, name = 'FUNCCALL'): Symbol.__init__(self, symbol._mangled, name) # Func. call / array access self.entry = symbol self.t = optemps.new_t() self.lineno = lineno
def __init__(self, lineno, expr): Symbol.__init__(self, None, 'CONST') self.expr = expr self.lineno = lineno
def __init__(self): Symbol.__init__(self, None, 'ARGLIST') self.count = 0 # Number of params
def __init__(self): Symbol.__init__(self, None, 'BOUNDLIST') self.size = 0 # Total number of array cells self.count = 0 # Number of bounds
def __init__(self, new_type): Symbol.__init__(self, new_type, 'CAST') self.t = optemps.new_t() self._type = new_type
def __init__(self, lineno): Symbol.__init__(self, None, 'STRSLICE') self.lineno = lineno self._type = 'string' self.t = optemps.new_t()
def __init__(self, sentence): Symbol.__init__(self, None, sentence) self.args = None # Must be set o an array of args. by make_sentence
def __init__(self, symbol): Symbol.__init__(self, symbol._mangled, 'ARRAYDECL') self._type = symbol._type self.size = symbol.total_size # Total array cell + index size self.entry = symbol self.bounds = symbol.bounds
def __init__(self, symbol): Symbol.__init__(self, symbol._mangled, 'VARDECL') self._type = symbol._type self.size = symbol.size self.entry = symbol
def __init__(self, text): Symbol.__init__(self, text = text)
def __init__(self): Symbol.__init__(self, None, 'BLOCK')
def __init__(self, value, lineno): Symbol.__init__(self, value, 'STRING') self._type = 'string' self.lineno = lineno self.t = value
def __init__(self): Symbol.__init__(self, None, 'PARAMLIST') self.size = 0 # Will contain the sum of all the params size (byte params counts as 2 bytes) self.count = 0 # Counter of number of params
def __init__(self, category, dictionary): Symbol.__init__(self, category, dictionary, self) Scope.__init__(self)
def __init__(self, lower, upper): Symbol.__init__(self, None, 'BOUND') self.lower = lower self.upper = upper self.size = upper - lower + 1
def __init__(self, lineno): Symbol.__init__(self, None, "STRSLICE") self.lineno = lineno self._type = "string" self.t = optemps.new_t()
def __init__(self, asm, lineno): Symbol.__init__(self, asm, 'ASM') self.lineno = lineno