diff --git a/src/debug.h b/src/debug.h index c67e7c5..854d5df 100644 --- a/src/debug.h +++ b/src/debug.h @@ -3,7 +3,7 @@ #include #include "common.h" -enum debug_level {INTERNALREQUEST,MOREDEBUG,DEBUG,INFO,WARNING,ERROR}; +enum debug_level {INTERNALREQUEST,MOREDEBUG,DEBUG,INFO,NORMAL,WARNING,ERROR}; EXPORT std::ostream& COUT(debug_level dl); diff --git a/src/deptree.cpp b/src/deptree.cpp index 1f8597b..6f0de72 100644 --- a/src/deptree.cpp +++ b/src/deptree.cpp @@ -193,6 +193,7 @@ void TreeEvaluate(std::mutex* mtx, int* errflag, DepTree::LeafVector* leafs, con // mtx[1] - mutex for manipulating with tree DepTree* leaf; ObjectBase *ob,*eob; + ObjectList* ol; bool err; while(true) { @@ -213,12 +214,42 @@ void TreeEvaluate(std::mutex* mtx, int* errflag, DepTree::LeafVector* leafs, con if(DepTree::SAVE==leaf->type) { - COUT(INFO)<<"save ("<index]->Dump()<<")"<index]; + ol->Evaluate(&err); // For list Evaluate always return 0; + if(err) + { + COUT(ERROR)<<" in instruction save"<Dump()<<")"<type) { - COUT(INFO)<<"print ("<index]->Dump()<<")"<index]; + ol->Evaluate(&err); // For list Evaluate always return 0; + if(err) + { + COUT(ERROR)<<" in instruction print"<Dump()<<")"<type) @@ -273,6 +304,7 @@ void TreeEvaluate(int* errflag, DepTree::LeafVector* leafs) { DepTree* leaf; ObjectBase *ob,*eob; + ObjectList* ol; bool err; while(0!=leafs->size()) { @@ -283,12 +315,39 @@ void TreeEvaluate(int* errflag, DepTree::LeafVector* leafs) if(DepTree::SAVE==leaf->type) { - COUT(INFO)<<"save ("<index]->Dump()<<")"<index]; + ol->Evaluate(&err); // For list Evaluate always return 0; + if(err) + { + COUT(ERROR)<<" in instruction save"<Dump()<<")"<type) { - COUT(INFO)<<"print ("<index]->Dump()<<")"<index]; + ol->Evaluate(&err); // For list Evaluate always return 0; + if(err) + { + COUT(ERROR)<<" in instruction print"<Dump()<<")"<type) @@ -307,7 +366,7 @@ void TreeEvaluate(int* errflag, DepTree::LeafVector* leafs) // eob is evaluated object if(0!=eob) delete ob; else eob=ob; - G_vars.erase(leaf->name); // Concurrent access is safe + G_vars.erase(leaf->name); for(auto& i:leaf->parents) { // leaf not children of anyone diff --git a/src/globals.cpp b/src/globals.cpp index d460156..b849bd4 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -28,3 +28,60 @@ void RegisterFunction(const std::string& name, Func func) { G_funcs.emplace(name,func); } + + +bool Save(ObjectList* input) +{ + ObjectList::ListValues::size_type sz=input->Size(), i; + if(sz<2 || sz%2==1 ) + { + COUT(ERROR)<<"Number of save arguments must not be "<At(i*2+1); + if(!IS_OTYPE(arg1,ObjectString)) + { + COUT(ERROR)<<"Save format is save(object_1,file_1,...,object_n,file_n) where file_i is string"<At(i*2); + arg2=dynamic_cast(input->At(i*2+1)); + if(!arg1->Save(arg2->Value().c_str())) + { + COUT(ERROR)<<"Can't save object "<Dump()<<" to file "<Value()<Size(), i; + if(sz==0) return true; + + // Print + for(i=0;iAt(i)->Print()) + { + COUT(ERROR)<<"Unprintable object "<At(i)->Dump()<Type()<Type()< ListValues; +private: std::shared_ptr vals; public: @@ -205,8 +206,8 @@ public: bool Print() const override { if(!Exist()) return false; - COUT(INFO)<<"Object type: "<size();}