#ifndef OBJECT_H #define OBJECT_H #include #include #include #include #include "common.h" // Class for storing identifiers class OId: public ObjectBase { std::string name; public: OId(const std::string* t):name(*t) {} ~OId() {} // Pure virtual overrides ObjectBase* Copy() const override { COUT(WARNING)<<"OId::Copy: this call must never be happens."<Copy(); else return 0; } void UsedIdents(UsedType& ids) const override {ids.insert(name);} // Own functions std::string Name() const {return name;} // void SetName(const std::string& s) {name=s;} }; // Class for storing functions class OFunc: public ObjectBase { std::string name; ObjectList* args; public: OFunc(const std::string* t, ObjectBase* p):name(*t) { if(IS_OTYPE(p,ObjectList)) args=dynamic_cast(p); else args=new ObjectList(p); } OFunc(const char* t, ObjectBase* p):name(t) { if(IS_OTYPE(p,ObjectList)) args=dynamic_cast(p); else args=new ObjectList(p); } ~OFunc() {if(args!=0) delete args;} // Pure virtual overrides ObjectBase* Copy() const override { COUT(WARNING)<<"OFunc::Copy: this call must never be happens."<Copy()); } bool Print() const override {return false;} std::string Type() const override {return "FUNC";} // Non-default overrides std::string Dump() const override {return Name()+args->Dump();}; ObjectBase* Evaluate(bool* err) override; ObjectBase* ReplaceVar(const std::string& vname, ObjectBase* ob) override {return args->ReplaceVar(vname,ob);} void UsedFuncs(UsedType& funcs) const override {funcs.insert(name); args->UsedFuncs(funcs);} void UsedIdents(UsedType& ids) const override {args->UsedIdents(ids);} // Own functions std::string Name() const {return name;} // void SetName(std::string s) {name=s;} }; #endif