コード例 #1
0
ファイル: parse.cpp プロジェクト: LindaLovelace/rose
 POETCode* match_eval(POETCode* v2, bool mod=true) {
    if (r1 == 0) { return res=match_AST(EMPTY, v2, MATCH_AST_PATTERN); }
    if (fullmatch == 0 || r1->get_enum() != SRC_LIST) {
       res = match_AST (r1, v2, MATCH_AST_PATTERN); 
       if (res != 0 && mod) { r1 = 0; }
    }
    else if (fullmatch == EMPTY || v2->get_enum() == SRC_CVAR) {
       assert ( r1->get_enum() == SRC_LIST); 
       POETList* r1_list = static_cast<POETList*>(r1);
       res = match_AST (r1_list->get_first(), v2, MATCH_AST_PATTERN);
       if (res != 0 && mod) { r1 = r1_list->get_rest() ; } 
    }
    return res;
 }
コード例 #2
0
ファイル: codegen.cpp プロジェクト: Federico2014/edg4x-rose
 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);
   }
コード例 #3
0
ファイル: driver.cpp プロジェクト: LoggerMN/rose
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);
   }
}
コード例 #4
0
ファイル: driver.cpp プロジェクト: LoggerMN/rose
extern "C" POETCode* make_localPar(POETCode* id, POETCode* restr, LocalVarType type)
{ 
 try {
    LvarSymbolTable* local = top_scope();
    assert(local != 0);
    LocalVar*  res = local->insert(id, type);
    POETCode* restr1 = res->get_entry().get_restr(); 
    if (restr != 0 && restr1 != 0 && restr != restr1 && !match_AST(restr,restr1, MATCH_AST_EQ))
    {
       SYM_DIFF_DEFINED(id->toString() + ":" + restr->get_className() + ":" + restr->toString(),restr1->get_className() + ":" + restr1->toString());
        return res;
    }
    if (restr != 0) res->get_entry().set_restr(restr);
    return res;
  }
  catch (Error err) { std::cerr << "\nAt line " << yylineno << " of file " << curfile->get_filename() << "\n"; exit(1); }
}
コード例 #5
0
ファイル: parse.cpp プロジェクト: LindaLovelace/rose
  void defaultVisit(POETCode* v2) {
     if (v2 == EMPTY) { res = EMPTY; return; }
     if (match_eval(v2)) return;

     if ( r1->get_enum() != SRC_LIST) { PARSE_MISMATCH(r1,v2,lineno) }
     POETList* r1_list = static_cast<POETList*>(r1);

            POETCode* after_stop;
            POETCode* before_stop = SubList(r1_list, fullmatch, after_stop); 
            if (after_stop == 0 || after_stop == EMPTY) {
                 PARSE_MISMATCH(r1,v2,lineno); // not found fullmatch
              }
            POETCode* r1Save = r1;
            r1 = before_stop;
            try { res = apply(v2,0); }
            catch (ParseError err) { r1=r1Save; throw err; }
            r1=r1Save; 
            if (res != 0) { r1 = after_stop; return; }
      res = match_AST(EMPTY, v2, MATCH_AST_PATTERN); 
     if (res == 0) {
        PARSE_MISMATCH(EMPTY,v2,lineno)
     }
  }
コード例 #6
0
ファイル: poet_AST.cpp プロジェクト: Federico2014/edg4x-rose
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;
}