Example #1
0
def add_pointer(self, lspec):
    if not hasattr(lspec, 'ctype'):
        lspec.ctype = knodes.makeKCType('int', lspec.ctype)
    if not hasattr(lspec.ctype, 'push'):
        return False
    lspec.ctype.push(knodes.KPointerType())
    return True
Example #2
0
def add_ary(self, lspec, expr):
    if not hasattr(lspec, 'ctype') or lspec.ctype is None:
        lspec.ctype = knodes.makeKCType('int')
    if not hasattr(lspec, 'cur_paren'):
        lspec.cur_paren = []
        lspec.cur_paren.append(ref(lspec.ctype))
    lspec.cur_paren[-1]().push(knodes.KArrayType(expr))
    return True
Example #3
0
def open_params(self, lspec):
    if lspec.ctype is None:
        lspec.ctype = knodes.makeKCType('int')
    if not hasattr(lspec, 'cur_paren'):
        lspec.cur_paren = []
        lspec.cur_paren.append(ref(lspec.ctype))
    if not hasattr(lspec.cur_paren[-1](), '_params'):
        lspec.cur_paren[-1]()._params = []
    return True
Example #4
0
def add_paren(self, lspec):
    if not hasattr(lspec, 'ctype') or lspec.ctype is None:
        lspec.ctype = knodes.makeKCType('int')
    paren = knodes.KParenType()
    if not hasattr(lspec, 'cur_paren'):
        lspec.cur_paren = []
        lspec.cur_paren.append(ref(lspec.ctype))
    last = lspec.cur_paren.pop()
    lspec.cur_paren.append(ref(paren))
    lspec.cur_paren.append(last)
    lspec.ctype.push(paren)
    return True
Example #5
0
def new_decl_spec(self, lspec, i, current_block):
    idsetval = ""
    i_value = self.value(i)
    if i_value in Idset:
        idsetval = Idset[i_value]
    # don't f**k with reserved keywords
    if idsetval == "reserved":
        return False
    # not for asm or attribute
    if idsetval != "" and idsetval[0] != 'a':
        lspec.ctype = knodes.makeKCType(i_value, lspec.ctype)
        return True
    if ((hasattr(current_block.ref, 'types')
         and i_value in current_block.ref.types)):
        if lspec.ctype is None:
            lspec.ctype = knodes.KPrimaryType(i_value)
        else:
            lspec.ctype._identifier = i_value
        lspec.ctype._identifier = i_value
        return True
    return False
Example #6
0
def first_pointer(self, lspec):
    if not hasattr(lspec, 'ctype') or lspec.ctype is None:
        lspec.ctype = knodes.makeKCType('int', lspec.ctype)
    lspec.ctype.push(knodes.KPointerType())
    return True
Example #7
0
def add_attr_specifier(self, lspec, attrspec):
    if lspec.ctype is None:
        lspec.ctype = knodes.makeKCType('int', lspec.ctype)
    lspec.ctype.push(knodes.KAttrType(self.value(attrspec)))
    return True