예제 #1
0
  POETCode* eval_cvar_access(CodeVar* cv, POETCode* access)
  {
   POETCode* res = 0;
   CvarSymbolTable::Entry cv_e = cv->get_entry();
   LvarSymbolTable* symTable = cv_e.get_symTable();

   symTable->push_table(true); /* push symbol table for evaluation of access*/
   if (access->get_enum() != SRC_LVAR) 
      access= apply(access);
   switch (access->get_enum()) {
   case SRC_LVAR: {
      cv->get_entry().get_symTable()->pop_table();
      LocalVar* lv = static_cast<LocalVar*>(access);
      res = eval_cvar_attr(cv, lv);
      if (res == 0) { CVAR_ACC_MISMATCH( cv,access); }
      break;
   }
   case SRC_OP: {
     POETOperator* op = static_cast<POETOperator*>(access);
     if (op->get_op() == TYPE_TOR) {
        cv->get_entry().get_symTable()->pop_table();
        for (int i = 0; i < op->numOfArgs(); ++i) {
            POETCode* cur = apply(op->get_arg(i));
            LocalVar* lv = dynamic_cast<LocalVar*>(cur);
            if (lv == 0) { CVAR_ACC_MISMATCH( cv,access); }
            res = eval_cvar_attr(cv, lv);
            if (res != 0) return res;
        }
        CVAR_ACC_MISMATCH( cv,access); 
     }
   }
   default:
      if (cv->get_args() != 0) CVAR_ACC_MISMATCH( cv, access); 
       /*QY: access is used to set optional attribute values of code template;
            return a new code template object with the given attribute*/
      res = ASTFactory::inst()->build_codeRef(cv->get_entry(),0);
      cv->get_entry().get_symTable()->pop_table();
      break;
   }
   return res;
  }