|
|
|
@ -16,6 +16,8 @@
|
|
|
|
|
#define IS_OTYPE(quo,equ) (std::type_index(typeid(*quo))==std::type_index(typeid(equ))) |
|
|
|
|
#define IS_OTYPEI(quo,equ) (std::type_index(typeid(quo))==std::type_index(typeid(equ))) |
|
|
|
|
|
|
|
|
|
typedef std::set<std::string> UsedType; |
|
|
|
|
|
|
|
|
|
// Base class for all objects
|
|
|
|
|
class EXPORT ObjectBase |
|
|
|
|
{ |
|
|
|
@ -67,8 +69,8 @@ public:
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
virtual std::string Dump() const {return "%"+Type()+"%";} |
|
|
|
|
virtual void UsedFuncs(std::set<std::string>& funcs) const {} |
|
|
|
|
virtual void UsedIdents(std::set<std::string>& ids) const {} |
|
|
|
|
virtual void UsedFuncs(UsedType& funcs) const {} |
|
|
|
|
virtual void UsedIdents(UsedType& ids) const {} |
|
|
|
|
virtual ObjectBase* Copy() const=0; |
|
|
|
|
virtual ObjectBase* Evaluate(bool* err) {*err=false; return 0;} |
|
|
|
|
virtual ObjectBase* ReplaceVar(const std::string& vname, ObjectBase* ob) {return 0;} |
|
|
|
@ -120,7 +122,7 @@ typedef ObjectSimple<double> ObjectReal;
|
|
|
|
|
typedef ObjectSimple<std::string> ObjectString; |
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
inline const int8_t* ObjectSimple<std::string>::Blob(size_t* size) const |
|
|
|
|
inline const int8_t* ObjectString::Blob(size_t* size) const |
|
|
|
|
{ |
|
|
|
|
*size=val.length(); |
|
|
|
|
return reinterpret_cast<const int8_t*>(val.c_str()); |
|
|
|
@ -153,8 +155,8 @@ public:
|
|
|
|
|
const ObjectBase* Value() const {return val.get();} |
|
|
|
|
void SetPair(const std::string& n, ObjectBase* v) {if(!Exist()) {name=n; val.reset(v);}} |
|
|
|
|
std::string Dump() const override { return Name()+"="+val->Dump(); } |
|
|
|
|
void UsedFuncs(std::set<std::string>& funcs) const override {return val->UsedFuncs(funcs);} |
|
|
|
|
void UsedIdents(std::set<std::string>& ids) const override {return val->UsedIdents(ids);} |
|
|
|
|
void UsedFuncs(UsedType& funcs) const override {return val->UsedFuncs(funcs);} |
|
|
|
|
void UsedIdents(UsedType& ids) const override {return val->UsedIdents(ids);} |
|
|
|
|
ObjectBase* Copy() const override |
|
|
|
|
{ |
|
|
|
|
auto ret=new ObjectPair; |
|
|
|
@ -218,8 +220,8 @@ public:
|
|
|
|
|
if(vals->size()!=0) s.resize(s.length()-2); |
|
|
|
|
return s+")"; |
|
|
|
|
} |
|
|
|
|
void UsedFuncs(std::set<std::string>& funcs) const override {for(auto& i: *vals) i->UsedFuncs(funcs);} |
|
|
|
|
void UsedIdents(std::set<std::string>& ids) const override {for(auto& i: *vals) i->UsedIdents(ids);} |
|
|
|
|
void UsedFuncs(UsedType& funcs) const override {for(auto& i: *vals) i->UsedFuncs(funcs);} |
|
|
|
|
void UsedIdents(UsedType& ids) const override {for(auto& i: *vals) i->UsedIdents(ids);} |
|
|
|
|
ObjectBase* Copy() const override |
|
|
|
|
{ |
|
|
|
|
auto ret=new ObjectList; |
|
|
|
@ -287,7 +289,7 @@ public:
|
|
|
|
|
std::string Name() const {return name;} |
|
|
|
|
void SetName(const std::string& s) {name=s;} |
|
|
|
|
std::string Dump() const override {return name;}; |
|
|
|
|
void UsedIdents(std::set<std::string>& ids) const override {ids.insert(name);} |
|
|
|
|
void UsedIdents(UsedType& ids) const override {ids.insert(name);} |
|
|
|
|
ObjectBase* Copy() const override |
|
|
|
|
{ |
|
|
|
|
COUT(WARNING)<<"OId::Copy: this call must never be happens."<<std::endl; |
|
|
|
@ -328,8 +330,8 @@ public:
|
|
|
|
|
std::string Name() const {return name;} |
|
|
|
|
void SetName(std::string s) {name=s;} |
|
|
|
|
std::string Dump() const override {return Name()+args->Dump();}; |
|
|
|
|
void UsedFuncs(std::set<std::string>& funcs) const override {funcs.insert(name); args->UsedFuncs(funcs);} |
|
|
|
|
void UsedIdents(std::set<std::string>& ids) const override {args->UsedIdents(ids);} |
|
|
|
|
void UsedFuncs(UsedType& funcs) const override {funcs.insert(name); args->UsedFuncs(funcs);} |
|
|
|
|
void UsedIdents(UsedType& ids) const override {args->UsedIdents(ids);} |
|
|
|
|
ObjectBase* Copy() const override |
|
|
|
|
{ |
|
|
|
|
COUT(WARNING)<<"OFunc::Copy: this call must never be happens."<<std::endl; |
|
|
|
|