|
|
|
@ -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 ("<<G_tosave[leaf->index]->Dump()<<")"<<std::endl; |
|
|
|
|
err=false; |
|
|
|
|
ol=G_tosave[leaf->index]; |
|
|
|
|
ol->Evaluate(&err); // For list Evaluate always return 0;
|
|
|
|
|
if(err) |
|
|
|
|
{ |
|
|
|
|
COUT(ERROR)<<" in instruction save"<<ol->Dump()<<")"<<std::endl; |
|
|
|
|
*errflag=1; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(!Save(ol)) |
|
|
|
|
{ |
|
|
|
|
mtx[0].lock(); |
|
|
|
|
*errflag=1; |
|
|
|
|
mtx[0].unlock(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(DepTree::PRINT==leaf->type) |
|
|
|
|
{ |
|
|
|
|
COUT(INFO)<<"print ("<<G_toprint[leaf->index]->Dump()<<")"<<std::endl; |
|
|
|
|
err=false; |
|
|
|
|
ol=G_toprint[leaf->index]; |
|
|
|
|
ol->Evaluate(&err); // For list Evaluate always return 0;
|
|
|
|
|
if(err) |
|
|
|
|
{ |
|
|
|
|
COUT(ERROR)<<" in instruction print"<<ol->Dump()<<")"<<std::endl; |
|
|
|
|
*errflag=1; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(!Print(ol)) |
|
|
|
|
{ |
|
|
|
|
mtx[0].lock(); |
|
|
|
|
*errflag=1; |
|
|
|
|
mtx[0].unlock(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(DepTree::VAR==leaf->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 ("<<G_tosave[leaf->index]->Dump()<<")"<<std::endl; |
|
|
|
|
err=false; |
|
|
|
|
ol=G_tosave[leaf->index]; |
|
|
|
|
ol->Evaluate(&err); // For list Evaluate always return 0;
|
|
|
|
|
if(err) |
|
|
|
|
{ |
|
|
|
|
COUT(ERROR)<<" in instruction save"<<ol->Dump()<<")"<<std::endl; |
|
|
|
|
*errflag=1; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// eob is evaluated object
|
|
|
|
|
if(!Save(ol)) |
|
|
|
|
{ |
|
|
|
|
*errflag=1; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(DepTree::PRINT==leaf->type) |
|
|
|
|
{ |
|
|
|
|
COUT(INFO)<<"print ("<<G_toprint[leaf->index]->Dump()<<")"<<std::endl; |
|
|
|
|
err=false; |
|
|
|
|
ol=G_toprint[leaf->index]; |
|
|
|
|
ol->Evaluate(&err); // For list Evaluate always return 0;
|
|
|
|
|
if(err) |
|
|
|
|
{ |
|
|
|
|
COUT(ERROR)<<" in instruction print"<<ol->Dump()<<")"<<std::endl; |
|
|
|
|
*errflag=1; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(!Print(ol)) |
|
|
|
|
{ |
|
|
|
|
*errflag=1; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(DepTree::VAR==leaf->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
|
|
|
|
|