@@ -20,11 +20,12 @@ static int&get_qap_fallback_counter(){static int counter=0;return counter;}
2020struct t_fallback {
2121 struct t_rec {bool E;bool ok;bool D;};
2222 i_dev_base&dev;
23- bool & ok;
23+ bool ok;
2424 size_t pos;
2525 const char *const ptr;
2626 const char *const ptr2;
2727 int err_count;
28+ #ifdef QAP_LOAD_DEV_WITH_STACK
2829 struct t_err {
2930 int M=-1 ;
3031 int maxpos=0 ;
@@ -34,11 +35,12 @@ struct t_fallback{
3435 };
3536 vector<t_err> errs;
3637 t_err best_err;
37- t_scope_tool mandatory;
38- t_scope_tool optional;
3938 bool keep_errs=false ;
39+ #endif
40+ // t_scope_tool mandatory;
41+ // t_scope_tool optional;
4042 // int mode=0;
41- t_fallback (i_dev_base&dev,const char *const ptr,const char *const ptr2=nullptr ):dev(dev),ok(mandatory.ok),ptr(ptr),ptr2(ptr2),pos(-1 ),err_count(0 ){
43+ t_fallback (i_dev_base&dev,const char *const ptr,const char *const ptr2=nullptr ):dev(dev)/* ,ok(mandatory.ok)*/ ,ptr(ptr),ptr2(ptr2),pos(-1 ),err_count(0 ){
4244 if (ptr)dev.push (this );
4345 }
4446 ~t_fallback (){
@@ -51,6 +53,7 @@ struct t_fallback{
5153 void log_clear (){err_count=0 ;}
5254 int getErr ()const {return err_count;}
5355 // void operator()(int M){mode=M;}
56+ #ifdef QAP_LOAD_DEV_WITH_STACK
5457 void operator ()(bool ok,const char *perr){
5558 if (ok){
5659 // log_clear();
@@ -67,6 +70,9 @@ struct t_fallback{
6770 errs.push_back (curerr);
6871 }
6972 }
73+ #else
74+ void operator ()(...){}
75+ #endif
7076};
7177
7278struct t_load_dev ;
@@ -199,20 +205,24 @@ public:
199205 void push (t_fallback*ptr)override {
200206 QapAssert (ptr);
201207 // for(int i=0;i<stack.size();i++)QapAssert(stack[i]!=ptr);
208+ #ifdef QAP_LOAD_DEV_WITH_STACK
202209 stack.push_back (ptr);
210+ #endif
203211 ptr->pos =this ->pos ;
204- ptr->mandatory .ok =true ;
205- ptr->mandatory .scope =ptr;
206- ptr->optional .ok =false ;
207- ptr->optional .scope =ptr;
212+ // ptr->mandatory.ok=true;
213+ // ptr->mandatory.scope=ptr;
214+ // ptr->optional.ok=false;
215+ // ptr->optional.scope=ptr;
208216 maxpos=std::max (maxpos,pos);
209217 }
210218 void pop (t_fallback*ptr)override {
211219 maxpos_pop=std::max (maxpos_pop,pos);
212220 QapAssert (ptr);
213221 QapAssert (!stack.empty ());
222+ #ifdef QAP_LOAD_DEV_WITH_STACK
214223 QapAssert (stack.back ()==ptr);
215224 stack.pop_back ();
225+ #endif
216226 t_fallback::t_rec status;
217227 auto &fb=*ptr;
218228 bool skip=pos==fb.pos ;
@@ -222,6 +232,15 @@ public:
222232 status.E =error;
223233 status.ok =ok;
224234 status.D =dep_err;
235+ #ifndef QAP_LOAD_DEV_WITH_STACK
236+ stack.back ()->add_status (status);
237+ if (ptr->ok )return ;
238+ if (this ->pos ==ptr->pos )return ;
239+ /* QapAssert(!stack.empty());*/
240+ // stack.back()->log.err(SToS(ptr->ptr)+" ["+IToS(this->pos)+"=>"+IToS(ptr->pos)+"]");
241+ this ->pos =ptr->pos ;
242+ return ;
243+ #else
225244 auto &b=*stack.back ();
226245 b.add_status (status);
227246 if (fb.ok &&!fb.keep_errs )return ;
@@ -240,6 +259,7 @@ public:
240259 }
241260 if (all_failed||ok)return ;
242261 pos=fb.pos ;
262+ #endif
243263 }
244264 void setPos (int pos)override {this ->pos =pos;}
245265 void getPos (int &pos)override {pos=this ->pos ;}
@@ -571,13 +591,13 @@ public:
571591public:
572592 void push (t_fallback*ptr){
573593 QapAssert (ptr);
574- for (int i=0 ;i<stack.size ();i++)QapAssert (stack[i]!=ptr);
594+ // for(int i=0;i<stack.size();i++)QapAssert(stack[i]!=ptr);
575595 stack.push_back (ptr);
576596 ptr->pos =this ->mem .size ();
577- ptr->mandatory .ok =true ;
578- ptr->mandatory .scope =ptr;
579- ptr->optional .ok =false ;
580- ptr->optional .scope =ptr;
597+ // ptr->mandatory.ok=true;
598+ // ptr->mandatory.scope=ptr;
599+ // ptr->optional.ok=false;
600+ // ptr->optional.scope=ptr;
581601 }
582602 void pop (t_fallback*ptr){
583603 QapAssert (ptr);
@@ -1207,7 +1227,9 @@ static bool internal_go_for_vec_lt(i_dev&dev,vector<TYPE>&arr){
12071227 QapAssert (CheckTAutoPtrIsNotEmpty (tmp));
12081228 arr.push_back (std::move (tmp));
12091229 }
1230+ #ifdef QAP_LOAD_DEV_WITH_STACK
12101231 scope.keep_errs =arr.size ();
1232+ #endif
12111233 ok=!arr.empty ();
12121234 return ok;
12131235}
@@ -1341,7 +1363,7 @@ bool load_obj(/*IEnvRTTI&Env,*/TYPE&out,const string&data,int*pmaxpos=nullptr,st
13411363{
13421364 out=std::move (TYPE{});
13431365 t_load_dev dev (data);auto &ldev=dev;
1344- bool ok=dev.go_auto (out);
1366+ bool ok=dev.go_auto (out);if (pmaxpos){*pmaxpos=dev. pos ;}
13451367 if (ok)
13461368 {
13471369 #ifdef QAP_LOAD_OBJ_DEBUG
@@ -1369,6 +1391,7 @@ bool load_obj(/*IEnvRTTI&Env,*/TYPE&out,const string&data,int*pmaxpos=nullptr,st
13691391 }
13701392 if (!ok&&perrmsg){
13711393 auto &b=*dev.stack .back ();
1394+ #ifdef QAP_LOAD_DEV_WITH_STACK
13721395 QapAssert (b.best_err .M >=0 );
13731396 if (pmaxpos)*pmaxpos=b.best_err .maxpos ;
13741397 set<string> s;map<string,string> m;vector<string> arr;
@@ -1386,6 +1409,7 @@ bool load_obj(/*IEnvRTTI&Env,*/TYPE&out,const string&data,int*pmaxpos=nullptr,st
13861409 }
13871410 vector<string> arr2;for (auto &ex:m)arr2.push_back (ex.second );
13881411 *perrmsg+=join (arr2," \n " );
1412+ #endif
13891413 }
13901414 return ok;
13911415}
0 commit comments