当前位置: 首页>>代码示例>>C++>>正文


C++ SymTab::get_scope方法代码示例

本文整理汇总了C++中SymTab::get_scope方法的典型用法代码示例。如果您正苦于以下问题:C++ SymTab::get_scope方法的具体用法?C++ SymTab::get_scope怎么用?C++ SymTab::get_scope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SymTab的用法示例。


在下文中一共展示了SymTab::get_scope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: visitClassImpl

    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
    }
开发者ID:Kazanovitz,项目名称:compiler,代码行数:54,代码来源:typecheck.cpp

示例2: visitDiv

 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);
 }
开发者ID:tdaw61,项目名称:random,代码行数:7,代码来源:typecheck.cpp

示例3: visitUminus

 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;
 }
开发者ID:tdaw61,项目名称:random,代码行数:7,代码来源:typecheck.cpp

示例4: visitMagnitude

 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;
 }
开发者ID:tdaw61,项目名称:random,代码行数:7,代码来源:typecheck.cpp

示例5: visitBoolLit

  void visitBoolLit(BoolLit * p)
  {
      p -> m_attribute.m_scope = m_st->get_scope();
      p -> visit_children(this);
      p -> m_attribute.m_basetype = bt_boolean;

  }
开发者ID:tdaw61,项目名称:random,代码行数:7,代码来源:typecheck.cpp

示例6: visitCompare

  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);

  }
开发者ID:tdaw61,项目名称:random,代码行数:8,代码来源:typecheck.cpp

示例7: visitLteq

  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);

  }
开发者ID:tdaw61,项目名称:random,代码行数:8,代码来源:typecheck.cpp

示例8: visitProgramImpl

  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);

  }
开发者ID:tdaw61,项目名称:random,代码行数:8,代码来源:typecheck.cpp

示例9: visitNot

  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;

  }
开发者ID:tdaw61,项目名称:random,代码行数:9,代码来源:typecheck.cpp

示例10: visitForLoop

 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);
 }
开发者ID:tdaw61,项目名称:random,代码行数:10,代码来源:typecheck.cpp

示例11: visitFuncImpl

 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);
 }
开发者ID:tdaw61,项目名称:random,代码行数:10,代码来源:typecheck.cpp

示例12: visitIdent

 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;
 }
开发者ID:tdaw61,项目名称:random,代码行数:11,代码来源:typecheck.cpp

示例13: visitDeclarationImpl

    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
    }
开发者ID:Kazanovitz,项目名称:compiler,代码行数:41,代码来源:typecheck.cpp

示例14: visitNested_blockImpl

 void visitNested_blockImpl(Nested_blockImpl * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     p->visit_children(this);
 }
开发者ID:tdaw61,项目名称:random,代码行数:5,代码来源:typecheck.cpp

示例15: visitAnd

 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);
 }
开发者ID:tdaw61,项目名称:random,代码行数:6,代码来源:typecheck.cpp


注:本文中的SymTab::get_scope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。