Beispiel #1
0
 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); 
      }
   }
Beispiel #2
0
 virtual void visitCodeVar(CodeVar* v) 
  {
    try {
      POETCode* _listsep = listsep;
      CodeVar* _listelem = listelem;
      POETCode* result = v->invoke_output(v->get_args());
      if (result != 0 && result != v) { 
          listsep = 0; listelem=0; 
          result->visit(this); 
          listsep = _listsep; listelem=_listelem;
          return; 
      }
      CvarSymbolTable::Entry e = v->get_entry();
      LvarSymbolTable *local = 0;
      POETCode* f = 0;
      POETCode *parse = e.get_parse();
      if (parse != 0 && parse->get_enum()==SRC_OP) { 
          POETOperator* op = static_cast<POETOperator*>(parse);
          if (op->get_op() == POET_OP_LIST || op->get_op()==POET_OP_LIST1)  {
              listsep = op->get_arg(1);
              listelem=dynamic_cast<CodeVar*>(op->get_arg(0));
              f = v->get_args();
           }
      }
      if (f == 0) { 
        listsep = 0; listelem=0;
        f = e.get_code();
        if (f == 0) { 
              if (parse==0) { CODE_SYNTAX_UNDEFINED(v->toString()); }
              else f = v->get_args(); 
        }
        else {
           local = e.get_symTable();
           if (local != 0) 
              local->push_table(false);
           POETCode* pars = e.get_param();
           if (pars != 0 && !match_parameters(pars, v->get_args(),MATCH_PAR_MOD_CODE))   
              CVAR_MISMATCH(v,pars, v->get_args());
           v->set_attr();
        }
      }
      if (f == 0) { CODE_SYNTAX_UNDEFINED(v->toString()); }
      int save = align;
      align = start_pos;
      f->visit(this); 
      align = save;
      if (local != 0)
          local->pop_table();
      listsep = _listsep; listelem=_listelem;
    }
    catch (Error err) { 
            std::cerr << " From unparsing code template " << SHORT(v->toString(),500) << "\n"; 
            throw err;
         }
    }
Beispiel #3
0
 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);
    }
 }
Beispiel #4
0
 virtual void visitList(POETList* l)
  {
     POETCode* first = l->get_first();
     int prevline = line;
     if (first->get_enum() == SRC_LIST) 
         {out << "("; first->visit(this); out << ")"; }
     else first->visit(this);
     if (line > prevline) print_linebreak(); 
     POETCode* rest = l->get_rest();
     if (rest != 0) {
        rest->visit(this);
     }
     else out << " NULL";
  }
Beispiel #5
0
 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 << ")"; 
  }
Beispiel #6
0
  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); 
       }
    }
Beispiel #7
0
 virtual void visitLocalVar(LocalVar* v)
  {
     POETCode* res = v->get_entry().get_code(); 
     if (res != 0 && res != v) {
         v->get_entry().set_code(0);
         out << v->get_entry().get_name()->toString(OUTPUT_NO_DEBUG) << "={";
         res->visit(this);
         out << "}";
         v->get_entry().set_code(res);
     }
  }
 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;
   }
 }
Beispiel #9
0
 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;
    }
  }
 }