Negacion::Negacion(Expresion* expr) { SetExpr(expr); }
void CSL_Interpr::EvalTrans(MAE_TransContext* aContext, CAE_EBase* aExpContext, const string& aTrans) { iContext = aContext; iExprs.clear(); iExpContext = aExpContext; TInt logspecdata = iExpContext->GetLogSpecData(KBaseLe_Trans); size_t pb = 0, pe = 0; TBool fin = EFalse; iLine = 0; do { iLine++; pb = aTrans.find_first_not_of("\n\t ", pe); if (pb == string::npos) break; pe = aTrans.find('\n', pb); if (pe == string::npos) { pe = aTrans.size(); fin = ETrue; } string line = aTrans.substr(pb, pe - pb); // Select keyword size_t kwpe = line.find(' '); string kw = line.substr(0, kwpe); if (kw.compare("rem") == 0) { } else if (kw.compare("let") == 0) { // Definition size_t nmpb, nmpe; nmpb = line.find_first_not_of(' ', kwpe + 1); nmpe = line.find(' ', nmpb); string name = line.substr(nmpb, nmpe-nmpb); size_t qpb, qpe; qpb = line.find_first_of(':', nmpe + 1); qpe = line.find(' ', qpb); string funarg = line.substr(nmpe, qpb - nmpe); string qual = line.substr(qpb, qpe-qpb); if (qual.compare("::") == 0) { // Type definition size_t tpb, tpe; tpb = line.find_first_not_of(' ', qpe + 1); tpe = line.find(":=", tpb); string type = line.substr(tpb, tpe-tpb); size_t epb, epe; epb = tpe + 2; epe = line.find('\n', epb); string data = line.substr(epb, epe-epb); vector<string> args; CSL_ExprBase::ParseTerms(data, args); vector<string>::iterator argsrest = args.begin(); CSL_ExprBase* res = NULL; vector<string> stype; CSL_ExprBase::ParseTerms(type, stype); string rtype = stype.at(0); if (funarg.find_first_not_of(' ') != string::npos) { // Function CSL_ExprBase* fun = new CSL_FunBase(type, funarg, data); SetExpr(name, fun); } else { // Expression CSL_ExprBase::EvalArgs(*this, rtype, args, argsrest, res); if (res != NULL) { SetExpr(name, res); if (logspecdata & KBaseDa_Trex ) { Logger()->WriteFormat("[%s] = %s", name.c_str(), res->ToString().c_str()); } } else { Logger()->WriteFormat("Error evaluating [%s] as [%s]", name.c_str(), data.c_str()); } } // TODO [YB] To check type } } else { // Expression // TODO [YB] To cleanup here CAE_StateBase* state = aExpContext->GetFbObj(state); string state_dtype = DataType(*state); if (state_dtype.empty()) { Logger()->WriteFormat("Couldn't get state data type"); } /* size_t tpb, tpe; tpb = line.find_first_not_of(' ', kwpe + 1); tpe = line.find('\n', tpb); string data = line.substr(tpb, tpe-tpb); */ vector<string> args; CSL_ExprBase::ParseTerms(line, args); vector<string>::iterator argsrest = args.begin(); CSL_ExprBase* res = NULL; CSL_ExprBase::EvalArgs(*this, state_dtype, args, argsrest, res); if (res != NULL) { CAE_StateEx* stateext = state->GetFbObj(stateext); if (stateext != NULL) { stateext->Set(res); } else { state->SetFromStr(res->Data()); } delete res; } else { Logger()->WriteFormat("Error evaluating [%s]", line.c_str()); } } } while (!fin); }
SumaUnaria::SumaUnaria(Expresion* expr) { SetExpr(expr); }