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


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

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


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

示例1: visitParameterImpl

    void visitParameterImpl(ParameterImpl *p) {
      p->visit_children(this);
      Symbol *symp = new Symbol;
      Symbol * test;

      VariableIDImpl * VarIdP = dynamic_cast<VariableIDImpl*>(p->m_variableid);

      char * key = strdup(VarIdP->m_symname->spelling());
      test = InScope(key);
        if(test!=NULL){
            t_error(dup_ident_name, p->m_attribute);
          }
        else{
            symp->baseType = p->m_type->m_attribute.m_type.baseType;
        //    cout<< "param; key: "<< key <<" type : "<< symp->baseType<<endl;
            if(symp->baseType == 8){
              symp->classType.classID = p->m_type->m_attribute.m_type.classType.classID;
        //      cout<< "this is what i'm SEETTTING key: " << symp->classType.classID<<endl;

            }
            // cout<<"insertingthis var from param: "<<key <<endl;
            m_symboltable->insert(key, symp);
          }      

      //WRITE ME
    }
开发者ID:Kazanovitz,项目名称:compiler,代码行数:26,代码来源:typecheck.cpp

示例2: 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

示例3: visitClassImpl

  void visitClassImpl(ClassImpl *p) {
      ClassIDImpl * ClassIdP = dynamic_cast<ClassIDImpl*>(p->m_classid_1);
      char * key1 = strdup(ClassIdP->m_classname->spelling());
      Symbol * symPtr = new Symbol;
      symPtr->classType.classID = ClassIdP->m_classname->spelling();
      m_symboltable->insert((char *)"xxx", symPtr);

      p->visit_children(this);
         // WRITEME

  }
开发者ID:Kazanovitz,项目名称:compiler,代码行数:11,代码来源:codegen.cpp

示例4: add_decl_symbol

 // add symbol table information for all the declarations following
 void add_decl_symbol(DeclImpl *p)
 {
     
     list<SymName_ptr>::iterator iter;
     char *name; Symbol *s;
     
     for (iter = p->m_symname_list->begin(); iter != p->m_symname_list->end(); ++iter) {
         name = strdup((*iter)->spelling());
         s = new Symbol();
         s->m_basetype = p->m_type->m_attribute.m_basetype;
         
         if (! m_st->insert(name, s))
             this->t_error(dup_ident_name,  p->m_attribute);
     }
 }
开发者ID:tdaw61,项目名称:random,代码行数:16,代码来源:typecheck.cpp

示例5: add_func_symbol

  // create a symbol for the function and check there is none already existing
  void add_func_symbol(FuncImpl *p)
  {
      
      char *name; Symbol *s;
      
      name = strdup((p)->m_symname->spelling());
      
      s = new Symbol();
      s->m_basetype = bt_function;
      
      s->m_return_type = p->m_type->m_attribute.m_basetype;
      
      if (! m_st->insert(name, s))
          this->t_error(dup_ident_name,  p->m_attribute);


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

示例6: 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


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