Esempio n. 1
0
    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
Esempio n. 2
0
 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
Esempio n. 3
0
 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
Esempio n. 4
0
 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
Esempio n. 5
0
    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
Esempio n. 6
0
 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
Esempio n. 7
0
 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)
Esempio n. 8
0
    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
Esempio n. 9
0
 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
Esempio n. 10
0
    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]
Esempio n. 11
0
    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
Esempio n. 12
0
 def __init__(self, symbol):
     Symbol.__init__(self, symbol._mangled, 'FUNCDECL')
     self.fname = symbol.id
     self._mangled = symbol._mangled
     self.entry = symbol  # Symbol table entry
Esempio n. 13
0
 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
Esempio n. 14
0
 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
Esempio n. 15
0
 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
Esempio n. 16
0
 def __init__(self, lineno, expr):
     Symbol.__init__(self, None, 'CONST')
     self.expr = expr
     self.lineno = lineno
Esempio n. 17
0
 def __init__(self):
     Symbol.__init__(self, None, 'ARGLIST')
     self.count = 0 # Number of params
Esempio n. 18
0
 def __init__(self):
     Symbol.__init__(self, None, 'BOUNDLIST')
     self.size = 0  # Total number of array cells
     self.count = 0 # Number of bounds
Esempio n. 19
0
 def __init__(self):
     Symbol.__init__(self, None, 'BOUNDLIST')
     self.size = 0  # Total number of array cells
     self.count = 0  # Number of bounds
Esempio n. 20
0
 def __init__(self, new_type):
     Symbol.__init__(self, new_type, 'CAST')
     self.t = optemps.new_t()
     self._type = new_type
Esempio n. 21
0
 def __init__(self, symbol):
     Symbol.__init__(self, symbol._mangled, 'FUNCDECL')
     self.fname = symbol.id
     self._mangled = symbol._mangled
     self.entry = symbol # Symbol table entry
Esempio n. 22
0
 def __init__(self, lineno):
     Symbol.__init__(self, None, 'STRSLICE')
     self.lineno = lineno
     self._type = 'string'
     self.t = optemps.new_t()
Esempio n. 23
0
 def __init__(self, sentence):
     Symbol.__init__(self, None, sentence)
     self.args = None  # Must be set o an array of args. by make_sentence
Esempio n. 24
0
 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
Esempio n. 25
0
 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
Esempio n. 26
0
 def __init__(self, sentence):
     Symbol.__init__(self, None, sentence)
     self.args = None # Must be set o an array of args. by make_sentence
Esempio n. 27
0
 def __init__(self, symbol):
     Symbol.__init__(self, symbol._mangled, 'VARDECL')
     self._type = symbol._type
     self.size = symbol.size
     self.entry = symbol
Esempio n. 28
0
 def __init__(self, text):
     Symbol.__init__(self, text = text)
Esempio n. 29
0
 def __init__(self):
     Symbol.__init__(self, None, 'BLOCK')
Esempio n. 30
0
 def __init__(self, value, lineno):
     Symbol.__init__(self, value, 'STRING')
     self._type = 'string'
     self.lineno = lineno
     self.t = value
Esempio n. 31
0
 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
Esempio n. 32
0
 def __init__(self, category, dictionary):
     Symbol.__init__(self, category, dictionary, self)
     Scope.__init__(self)
Esempio n. 33
0
 def __init__(self, lower, upper):
     Symbol.__init__(self, None, 'BOUND')
     self.lower = lower
     self.upper = upper
     self.size = upper - lower + 1
Esempio n. 34
0
 def __init__(self, lineno):
     Symbol.__init__(self, None, "STRSLICE")
     self.lineno = lineno
     self._type = "string"
     self.t = optemps.new_t()
Esempio n. 35
0
 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
Esempio n. 36
0
 def __init__(self, asm, lineno):
     Symbol.__init__(self, asm, 'ASM')
     self.lineno = lineno
Esempio n. 37
0
 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