Exemplo n.º 1
0
    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
    }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
  void visitBoolLit(BoolLit * p)
  {
      p -> m_attribute.m_scope = m_st->get_scope();
      p -> visit_children(this);
      p -> m_attribute.m_basetype = bt_boolean;

  }
Exemplo n.º 6
0
  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);

  }
Exemplo n.º 7
0
  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);

  }
Exemplo n.º 8
0
  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);

  }
Exemplo n.º 9
0
  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;

  }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
 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);
 }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
    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
    }
Exemplo n.º 14
0
 void visitNested_blockImpl(Nested_blockImpl * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     p->visit_children(this);
 }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
 void visitIntLit(IntLit * p)
 {
     p -> m_attribute.m_scope = m_st->get_scope();
     p -> visit_children(this);
     p -> m_attribute.m_basetype = bt_integer;
 }
Exemplo n.º 17
0
 void visitFunction_blockImpl(Function_blockImpl * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     p->visit_children(this);
     check_return_location(p);
 } 
Exemplo n.º 18
0
 void visitAssignment(Assignment * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     p->visit_children(this);
     check_assignment(p);
 }
Exemplo n.º 19
0
 void visitDeclImpl(DeclImpl * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     p->visit_children(this);
     add_decl_symbol(p);
 }
Exemplo n.º 20
0
 void visitCall(Call * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     check_call(p);
     p->visit_children(this);
 }
Exemplo n.º 21
0
 void visitReturn(Return * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     p->visit_children(this);
 }
Exemplo n.º 22
0
 void visitIfWithElse(IfWithElse * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     p->visit_children(this);
     check_if_pred(p->m_expr);
 }
Exemplo n.º 23
0
 void visitNone(None * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     p->visit_children(this);
 }
Exemplo n.º 24
0
 void visitTIntArray(TIntArray * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     p->visit_children(this);
     p->m_attribute.m_basetype = bt_intarray;
 }