void visitClassImpl(ClassImpl *p) { int stop; m_symboltable->open_scope(); Symbol * symPtr = new Symbol; // = new ClassNode; Symbol * symp;// = new Symbol; ClassIDImpl * ClassIdP = dynamic_cast<ClassIDImpl*>(p->m_classid_1); ClassIDImpl * ClassIdP2 = dynamic_cast<ClassIDImpl*>(p->m_classid_2); char * key1 = strdup(ClassIdP->m_classname->spelling()); symPtr->classType.classID = ClassIdP->m_classname->spelling(); char * progFinder = strdup("Program"); ClassName * nm = new ClassName(key1); if(progger == true){ t_error(no_program, p->m_attribute); } if(std::string(key1) == std::string(progFinder)){ progger = true; } //char * key2 = strdup(ClassIdP2->m_classname->spelling()); if(m_classtable->exist(key1)){ t_error(dup_ident_name, p->m_attribute); } else{ if(ClassIdP2->m_classname != NULL){ char * key2 = strdup(ClassIdP2->m_classname->spelling()); ClassName * nm2 = new ClassName(key2); // cout<<"inserted class: " <<key1 <<" from :"<<key2 <<endl; m_classtable->insert(nm, nm2, p, m_symboltable->get_scope()); ClassNode * clasp = m_classtable->getParentOf(key2); // cout<<"Class: " <<key1 <<", Super class: "<<clasp->name->spelling()<<endl; } else{ // cout<< "instered this in class table: "<< key1 <<endl; m_classtable->insert(nm, NULL, p, m_symboltable->get_scope()); } } m_symboltable->insert((char *)"xxx", symPtr); p->visit_children(this); m_symboltable->close_scope(); //WRITE ME }
void visitDiv(Div * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); p->m_attribute.m_basetype = bt_integer; checkset_arithexpr(p,p->m_expr_1, p->m_expr_2); }
void visitUminus(Uminus * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); checkset_uminus(p, p->m_expr); p->m_attribute.m_basetype = bt_integer; }
void visitMagnitude(Magnitude * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); checkset_absolute(p, p->m_expr); p->m_attribute.m_basetype = bt_integer; }
void visitBoolLit(BoolLit * p) { p -> m_attribute.m_scope = m_st->get_scope(); p -> visit_children(this); p -> m_attribute.m_basetype = bt_boolean; }
void visitCompare(Compare * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); p->m_attribute.m_basetype = bt_boolean; checkset_equalityexpr(p,p->m_expr_1, p->m_expr_2); }
void visitLteq(Lteq * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); p->m_attribute.m_basetype = bt_boolean; checkset_relationalexpr(p,p->m_expr_1, p->m_expr_2); }
void visitProgramImpl(ProgramImpl * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); check_for_one_main(p); m_st -> dump(stdout); }
void visitNot(Not * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); checkset_not(p, p->m_expr); p->m_attribute.m_basetype = bt_boolean; }
void visitForLoop(ForLoop * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); if(!is_assignment(p->m_stat_1)) this->t_error(for_assign_err, p->m_attribute); if(!is_assignment(p->m_stat_2)) this->t_error(for_assign_err, p->m_attribute); check_for_pred(p->m_expr); }
void visitFuncImpl(FuncImpl * p) { p->m_attribute.m_scope = m_st->get_scope(); p->m_type->accept(this); add_func_symbol(p); m_st->open_scope(); p->visit_children(this); m_st->close_scope(); check_return_type(p); }
void visitIdent(Ident * p) { p -> m_attribute.m_scope = m_st->get_scope(); p -> visit_children(this); Symbol *newSym; newSym = m_st->lookup( p->m_symname->spelling()); if(!newSym) this->t_error(var_undef, p->m_attribute); p->m_attribute.m_basetype = newSym->m_basetype; }
void visitDeclarationImpl(DeclarationImpl *p) { // cout<< "this is my first variable : "<< VarIdP->m_symname->spelling()<<endl; p->visit_children(this); Symbol * symp = new Symbol; Symbol * test; SymScope * sync; typename std::list<VariableID_ptr>::iterator it = p->m_variableid_list->begin(); for( ; it != p->m_variableid_list->end(); ++it) { VariableIDImpl * VarIdP = dynamic_cast<VariableIDImpl*>(*it); char * key = strdup(VarIdP->m_symname->spelling()); sync = m_symboltable->get_scope(); // cout<<key<<endl; // p->m_attribute.m_type.baseType = p->m_type->m_attribute.m_type.baseType; // i think this is setting the type of the assignment node // test = m_symboltable->lookup(key); if(m_symboltable->exist(key))//~!~!~!~!~!~!~!~ place here t_error(dup_ident_name, p->m_attribute); else{ test = InScope(key); if(test != NULL){ t_error(dup_ident_name, p->m_attribute); } m_symboltable->insert(key, symp); symp->baseType = p->m_type->m_attribute.m_type.baseType; if(symp->baseType == 8){ symp->classType.classID = p->m_type->m_attribute.m_type.classType.classID; } // cout<< "Decla; key: "<< key <<" type : "<< symp->baseType<<endl; } }//forloop //cout<<"declaration TYPE: "<<p->m_type->m_attribute.m_type.baseType<<endl; //WRITE ME }
void visitNested_blockImpl(Nested_blockImpl * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); }
void visitAnd(And * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); checkset_boolexpr(p,p->m_expr_1, p->m_expr_2); }
void visitIntLit(IntLit * p) { p -> m_attribute.m_scope = m_st->get_scope(); p -> visit_children(this); p -> m_attribute.m_basetype = bt_integer; }
void visitFunction_blockImpl(Function_blockImpl * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); check_return_location(p); }
void visitAssignment(Assignment * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); check_assignment(p); }
void visitDeclImpl(DeclImpl * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); add_decl_symbol(p); }
void visitCall(Call * p) { p->m_attribute.m_scope = m_st->get_scope(); check_call(p); p->visit_children(this); }
void visitReturn(Return * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); }
void visitIfWithElse(IfWithElse * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); check_if_pred(p->m_expr); }
void visitNone(None * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); }
void visitTIntArray(TIntArray * p) { p->m_attribute.m_scope = m_st->get_scope(); p->visit_children(this); p->m_attribute.m_basetype = bt_intarray; }