int Assignement::execute(Env* e, Store* s) { Val v = eval(s,e); if(v.getType() == EMPTY) { return 1; } return 0; }
Val Call::eval(Store* s, Env* e) { function::Function *f = NULL; NFunction *nf = NULL; Val v = e->get(this->name); if(VERBOSE) cout << "call => " << name << endl; if(v.getType() == FUNCTION) { if(v.to_function()->getType() == NATIVE_FUNCTION) { nf = dynamic_cast<NFunction*>(v.to_function()); } else { f = dynamic_cast<function::Function*>(v.to_function()); } } else { f = ::getProgFunction(name); nf = ::getNativeFunction(name); } if(f != NULL) { Env *ne = new Env(f->getNbVar()); if(argument.size() != f->getArity()) { cout << "wrong arity during calling " << name << ", expected " << f->getArity() << ", " << argument.size() << " given " << endl; exit(1); } for(unsigned int i = 0; i < argument.size(); i++) { ne->set(i, argument[i]->eval(s,e), f->getVarName(i)); } f->execute(ne, s); Val v = ne->get(f->getNbVar()); delete ne; return v; } if(nf != NULL) { return nf->eval(s,e,argument, this->line(), this->file()); } cout << "undefined symbol " << name << endl; return Val(); }
inline static auto is(const Val& mV) noexcept { return mV.getType() == Val::Type::Arr && mV.getArr().size() == TS && TplIsHelper::areArrItemsOfType<TItem>(mV); }
inline static auto is(const Val& mV) noexcept { return mV.getType() == Val::Type::Arr && mV.getArr().size() == sizeof...(TArgs) && TplIsHelper::isTpl<0, TArgs...>(mV); }
inline static auto is(const Val& mV) noexcept { return mV.getType() == Val::Type::Arr && mV.getArr().size() == 2 && mV[0].isNoNum<T1>() && mV[1].isNoNum<T2>(); }
inline static auto is(const Val& mV) noexcept { return mV.getType() == Val::Type::Str; }
inline static auto is(const Val& mV) noexcept { return mV.getType() == Val::Type::Str && mV.getStr().size() == TS; }