예제 #1
0
def p_varname(p):
    ''' VARNAME : Identifier '''

    p[0] = {}

    if sym_tab.exists(p[1]):

        p[0]['type'] = sym_tab.getAttri(p[1], 'type')

        # Here we have to load in the value of the variable
        if not p[1] in sym_tab.scope[len(sym_tab.scope) - 1]:

            # If an identifier is used, we assume that it is present in memory
            displayValue, offset = sym_tab.getAttri(
                p[1], 'scopeLevel'), sym_tab.getAttri(p[1], 'offset')
            p[0]['place'] = sym_tab.newTemp((displayValue, offset),
                                            variable=p[1],
                                            loadFromMemory=True)
            sym_tab.addAttribute(p[1], sym_tab.getCurrentScope(),
                                 p[0]['place'])
        else:
            p[0]['code'] = []
            p[0]['place'] = sym_tab.getAttri(
                p[1], sym_tab.scope[len(sym_tab.scope) - 1]['__scope__'])
    else:
        print "F**K OFF"
예제 #2
0
def p_complex169(p):
	'''complex169 : empty '''
	for args in p[-2] :
		print args
		sym_tab.addID(args['name'],args['type'])
		displayValue, offset = sym_tab.getAttri(args['name'], 'level'), sym_tab.getAttri(argument['name'], 'offset')
		place = sym_tab.new_temp((displayValue, offset), variable=argument['name'], loadFromMemory=True)
		sym_tab.addAttri(args['name'],  sym_tab.getCurrentScope(), place)
예제 #3
0
def p_complex145(p):
	'''complex145 : empty'''
	p[0] = {}
	p[0]['name_fun'] = sym_tab.get_name()
	
	sym_tab.addID(p[-1], "function")
	displayValue, offset = sym_tab.getAttri(p[-1], 'level'), sym_tab.getAttri(p[-1], 'offset')
	place = sym_tab.new_temp((displayValue, offset), variable=p[-1])
	sym_tab.add_attri(p[-1], sym_tab.getCurrentScope(), place)
	sym_tab.add_attri(p[-1], 'name_fun', p[0]['name_fun'])
	sym_tab.add_Sc(p[0]['name_fun'])
	TAC.code[p[0]['name_fun']] = []
	TAC.quad[p[0]['name_fun']] = 0
	TAC.nq[p[0]['name_fun']] = -1
예제 #4
0
def p_varname(p) :
	''' VARNAME : Identifier '''

	p[0] = {}
	p[0]['ptr'] = Leaf('id',p[1])
	
	if sym_tab.exists(p[1]):    

				p[0]['type'] = sym_tab.getAttri(p[1], 'type')  

				p[0]['code'] = ['']  
				if not p[1] in sym_tab.scope[len(sym_tab.scope)-1]:            
						displayValue = sym_tab.getAttri(p[1], 'scopeLevel')
						offset = sym_tab.getAttri(p[1], 'offset')
						p[0]['place'] = sym_tab.newTemp((displayValue, offset), variable=p[1], loadFromMemory=True)
						sym_tab.addAttribute(p[1], sym_tab.getCurrentScope(), p[0]['place'])
				else:
						p[0]['place'] = sym_tab.getAttri(p[1],sym_tab.scope[len(sym_tab.scope)-1]['__scope__'] )