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


C++ POETCode类代码示例

本文整理汇总了C++中POETCode的典型用法代码示例。如果您正苦于以下问题:C++ POETCode类的具体用法?C++ POETCode怎么用?C++ POETCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: visitLocalVar

 virtual void visitLocalVar(LocalVar* var) 
   {
      LvarSymbolTable::Entry e = var->get_entry();
      POETCode *restr = e.get_restr();
      if (restr == 0) {
         CollectInfoVisitor::visitLocalVar(var);
         return;
      }
      if (restr->get_enum() == SRC_CVAR) {
         CodeVar* cvar = static_cast<CodeVar*>(restr);
         POETCode* code = e.get_code();
         if (code!=0 && !match_AST(code, cvar,MATCH_AST_EQ)) {
            CodeVar* tmp = ASTFactory::inst()->new_codeRef(cvar->get_entry(), code); 
            tmp->visit(this); 
            return; 
         }
      }
      else if (restr->get_enum() == SRC_OP) {
          POETOperator* op = static_cast<POETOperator*>(restr);
          if (op->get_op() == POET_OP_LIST || op->get_op()==POET_OP_LIST1)  {
              POETCode* _listsep = listsep;
              CodeVar* _listelem = listelem;
              int save = align;
              align = start_pos;
              listsep = op->get_arg(1);
              listelem=dynamic_cast<CodeVar*>(op->get_arg(0));
              CollectInfoVisitor::visitLocalVar(var);
              align = save; listsep = _listsep; listelem = _listelem;
              return;
           }
      }
      CollectInfoVisitor::visitLocalVar(var);
   }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:33,代码来源:codegen.cpp

示例2: set_code_xform_parameters

void set_code_xform_parameters( Entry e, POETCode* par) 
{
   POETCode* p = e.get_param();
   if (p == 0) 
      e.set_param(par); 
   else {
     if (p != par && !match_AST(p, par, MATCH_AST_EQ))  {
       std::cerr << "par=" << par << "; p = " << p << "\n";
        SYM_DIFF_DEFINED(par->get_className() + ":" + par->toString(OUTPUT_VAR_VAL), p->get_className() + ":" + p->toString(OUTPUT_VAR_VAL)); 
     }
     return;
   }
   switch (par->get_enum()) {
   case SRC_LVAR:  
      static_cast<LocalVar*>(par)->get_entry().set_code(ASTFactory::inst()->new_iconst(0));
      break;
   case SRC_TUPLE: {
      POETTuple* vec = static_cast<POETTuple*>(par);
      for (unsigned i = 0; i < vec->size(); ++i)
       {
         LocalVar* cur_par = dynamic_cast<LocalVar*>(vec->get_entry(i));
         assert (cur_par != 0);
         cur_par->get_entry().set_code(ASTFactory::inst()->new_iconst(i) );
       }
      break;
   }
   default:
      assert(false);
   }
}
开发者ID:LoggerMN,项目名称:rose,代码行数:30,代码来源:driver.cpp

示例3: set_local_static

LocalVar* POETProgram::
set_local_static(LvarSymbolTable* local, POETCode* id, 
                 LocalVarType t, POETCode* code, POETCode * restr, bool insert)
{
  assert(local != 0);
  LocalVar* lvar = local->find(id);
  POETCode* orig = 0;
  if (lvar == 0) {
     if (insert) {
       lvar = local->insert(id, t);
       lvar->get_entry().set_code(code);
       lvar->get_entry().set_restr(restr);
     }
     else SYM_UNDEFINED(id->toString()+"="+code->toString());
  }
  else if (code != 0 && (orig = lvar->get_entry().get_code()) != 0 && orig != code && !match_AST(orig, code, MATCH_AST_EQ)) {
       SYM_DIFF_DEFINED(id->toString()+"="+code->toString(), orig->toString());
   }
  else {
      if (code != 0)
         lvar->get_entry().set_code(code);
      if (restr != 0)
          lvar->get_entry().set_restr(restr);
  }
  return lvar;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:26,代码来源:poet_AST.cpp

示例4: eval_readInput_nosyntax

POETCode* EvaluatePOET::
eval_readInput_nosyntax(POETCode* inputFiles, POETCode* codeType, POETCode* inputInline)
{ 
  inputFiles = eval_AST(inputFiles);
  std::cerr << "Using ROSE Parser for " << inputFiles->toString() << "\n";
  std::vector<std::string> argvList;
  argvList.push_back("pcg_rose");

  for (std::list<std::string>::const_iterator p_lib = lib_dir.begin();
        p_lib != lib_dir.end(); ++p_lib) {
     std::string cur_dir=(*p_lib);
     argvList.push_back("-I"+cur_dir);
  }
  for (POETCode* p = inputFiles; p != 0; p = get_tail(p))
  {
     std::string curname = p->toString(OUTPUT_NO_DEBUG);
     assert(curname != "");
     if (curname.find("/") == curname.npos) {
        for (std::list<std::string>::const_iterator p_lib = lib_dir.begin();
             p_lib != lib_dir.end(); ++p_lib) {
            std::string cur_dir=(*p_lib) + "/" + curname;
            if (access(cur_dir.c_str(), R_OK) == 0) 
               { curname = cur_dir; break;}
        }
     }
     argvList.push_back(curname);
  }
  assert(argvList.size() > 1);
  SgProject *sageProject = new SgProject ( argvList);

/*TODO: must add support for inserting trace handles. optimization won't work otherwise*/

  return POETAstInterface::Ast2POET(sageProject);
}
开发者ID:faizurahman,项目名称:rose,代码行数:34,代码来源:eval_ext_rose.cpp

示例5: visitList

 virtual void visitList(POETList* l) 
   {
      POETCode* cur = l->get_first();
      cur->visit(this) ; 
      if (l->get_rest() != 0) {
          if (listsep != 0)
             listsep->visit(this);
          l->get_rest()->visit(this); 
      }
   }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:10,代码来源:codegen.cpp

示例6: get_matchEnum

 POETEnum get_matchEnum(POETCode* v2first)
  {
    POETEnum v2first_enum = v2first->get_enum();
    if (v2first_enum == SRC_ASSIGN) {
       POETCode* c  = static_cast<POETAssign*>(v2first)->get_rhs();
       if (c != 0) {
           v2first_enum = c->get_enum();
       }
    }
    return v2first_enum;
  }
开发者ID:LindaLovelace,项目名称:rose,代码行数:11,代码来源:parse.cpp

示例7: visitOperator

 virtual void visitOperator(POETOperator *op)
 {
  if (op->get_op() == POET_OP_TYPEMATCH || op->get_op() == POET_OP_TYPEMATCH_Q) 
  {
     POETBop* bop = dynamic_cast<POETBop*>(op);
     assert(bop != 0);
     POETCode* arg = bop->get_arg1();
     arg->visit(this); 
     if (arg != res) bop->set_arg1(res);
     res = op;
   }
 }
开发者ID:mshahriarinia,项目名称:POET-C-Compiler,代码行数:12,代码来源:evalAST.cpp

示例8: visitLocalVar

 virtual void visitLocalVar(LocalVar* v)
 {
    LvarSymbolTable::Entry e =v->get_entry();
    POETCode* code = e.get_code();
    if (code != v && code != 0)  code->visit(this); 
    else {
       POETCode* restr =  e.get_restr();
       if (restr != 0) restr->visit(this);
       else SYM_UNDEFINED(v->toString());
       e.set_code(res);
    }
 }
开发者ID:LindaLovelace,项目名称:rose,代码行数:12,代码来源:parse.cpp

示例9: visitTuple

 virtual void visitTuple(POETTuple* l)
  {
    out << "("; print_linebreak();
    int size=l->size();
    for (int i = 0; i < size; ++i) {
       POETCode* cur = l->get_entry(i);
       if (cur == 0) out << "NULL,";
       else if (cur->get_enum() == SRC_LIST) 
           { col+=2; out << "(";  cur->visit(this); 
             out << ")"; col-=2; }
       else cur->visit(this); 
       if (i < size-1) { out << ","; print_linebreak(); }
     }
     out << ")"; 
  }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:15,代码来源:codegen.cpp

示例10: visitList

  virtual void visitList(POETList* l) 
    {
       POETCode* cur = l->get_first();
/*
       if (cur->get_enum() != SRC_LIST &&
           listelem != 0 && !match_AST(cur, listelem,MATCH_AST_EQ)) {
          cur = ASTFactory::inst()->new_codeRef(listelem->get_entry(), cur);
       }
*/
       cur->visit(this) ; 
       if (l->get_rest() != 0) {
           if (listsep != 0)
              listsep->visit(this);
           l->get_rest()->visit(this); 
       }
    }
开发者ID:LindaLovelace,项目名称:rose,代码行数:16,代码来源:codegen.cpp

示例11: toString

std::string POETTuple :: toString(ASTOutputEnum config)
{ 
    std:: stringstream r;
    r << "(";
    for (unsigned i = 0; i < impl.size(); ++i) {
       POETCode* cur = impl[i];
       if (cur == 0) r << "NULL,";
       else if (cur->get_enum() == SRC_LIST) 
           r << "(" << cur->toString(config) << "),";
       else
           r << cur->toString(config) << ",";
    }
    std::string str = r.str();
    str[str.size()-1] = ')' ; 
    return str;
  }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:16,代码来源:poet_AST.cpp

示例12: visitTupleAccess

 virtual void visitTupleAccess(TupleAccess* fc) 
    { 
     try {
      POETCode* tuple = apply(fc->get_tuple());
      POETCode* tuple1 = EvalTrace(tuple);
      if (tuple1 == 0) SYM_UNDEFINED(tuple->toString())
      else tuple = tuple1;
      POETCode* access= EvalTrace(fc->get_access()); 
      switch (tuple->get_enum()) {
        case SRC_TUPLE: {
           access= apply(access);
           if (access->get_enum() == SRC_LVAR) {
             LvarSymbolTable::Entry e = static_cast<LocalVar*>(access)->get_entry();
             if (e.get_entry_type() == LVAR_OUTPUT) access = e.get_code(); 
             else TUPLE_ACC_MISMATCH(fc, tuple,access);
           }
           res = eval_tuple_access(tuple,access);
           if (res == 0) { TUPLE_ACC_MISMATCH(fc, tuple,access); }
           return;
         }
        case SRC_MAP: {
           POETMap* m = static_cast<POETMap*>(tuple);
           access= apply(access);
           res = m->find(access);
           if (res == 0) 
               res = EMPTY;
           return;
        }
        case SRC_CVAR: {
           CodeVar* cv = static_cast<CodeVar*>(tuple);
           CvarSymbolTable::Entry cv_e = cv->get_entry();
           LvarSymbolTable* symTable = cv_e.get_symTable();
           res = eval_cvar_access(cv, access);
           return;
        }
        default: { 
           res = eval_tuple_access(tuple,access);
           if (res == 0)
            TUPLE_ACC_MISMATCH( fc, tuple, access); 
          }
       }
     }
     catch (Error err) { std::cerr << "From invoking " << SHORT(fc->toString(),500) << "\n"; throw err; }
    } 
开发者ID:mshahriarinia,项目名称:POET-C-Compiler,代码行数:44,代码来源:evalAST.cpp

示例13: EraseTrace

POETCode* EraseTrace(POETCode* vars, POETCode* res)
{
  std::vector<LocalVar*> vec;
  switch (vars->get_enum()) {
  case SRC_LVAR: {
     vars = eval_AST(vars);
     if (vars->get_enum() != SRC_LVAR) break;
     LocalVar* lvar = static_cast<LocalVar*>(vars);
     if (lvar->get_entry().get_entry_type() == LVAR_TRACE)
        vec.push_back(lvar);
     break;
  }
 case SRC_LIST: {
   POETList* l = static_cast<POETList*>(vars);
   while (l != 0) {
     POETCode* cur = l->get_first();
     if (cur->get_enum() == SRC_LVAR) {
        cur = eval_AST(cur);
        if (cur->get_enum() == SRC_LVAR) {
           LocalVar* cur_lvar = static_cast<LocalVar*>(cur);
           if (cur_lvar->get_entry().get_entry_type() == LVAR_TRACE) 
                vec.push_back(cur_lvar);
        }
     }
     l = dynamic_cast<POETList*>(l->get_rest());
   }
  }
  break;
 default: return res;
 }
 int size = vec.size();
 if (size == 0) return res;
 for (int i = size-1; i >= 0; --i) {
   LvarSymbolTable::Entry e = vec[i]->get_entry();
   assert (e.get_entry_type() == LVAR_TRACE); 
   e.set_entry_type(LVAR_TRACE_OUTDATE);
 }
 res = ReplInfoVisitor().apply(res);
 for (int i = size-1; i >= 0; --i) {
   LvarSymbolTable::Entry e = vec[i]->get_entry();
   e.set_entry_type(LVAR_TRACE);
 }
 return res;
}
开发者ID:mshahriarinia,项目名称:POET-C-Compiler,代码行数:44,代码来源:evalAST.cpp

示例14: output

 void output(POETString* s) {  
       ASTFactory* fac = ASTFactory::inst();
       std::string r = s->get_content();
       if (r == "\n") {
           for (int i = 0; i < align; ++i) r = r + " ";
           s = fac->new_string(r);
       }
       if (output_xform == 0) 
            output_content(r,r); 
       else {
          POETCode* args = fac->new_pair(s, fac->new_iconst(cur_pos));
          if (!match_parameters(output_xform->get_entry().get_param(), args,
                        MATCH_PAR_MOD_CODE))
               INCORRECT_XFORM_DEF("output(string,cur_pos)", output_xform->toString()); 
          XformVarInvoke invoke(output_xform->get_entry(), output_xform->get_config(), args);
          POETCode* res = invoke.eval(0);
          output_content(res->toString(OUTPUT_NO_DEBUG),r);
       }
    }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:19,代码来源:codegen.cpp

示例15: apply

 void apply (POETCode* output)
 {
  while (output != 0) {
     POETList* outputList = dynamic_cast<POETList*>(output);
     if (outputList != 0) {
        apply(outputList->get_first());
        output = outputList->get_rest();
     }
     else {
        if (output->get_enum() == SRC_STRING) {
           out << output->toString(OUTPUT_NO_DEBUG);
        }
        else {
           POETCode* res = eval_AST(output);
           res->visit(this);
        }
        output = 0;
    }
  }
 }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:20,代码来源:codegen.cpp


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