|
267 | 267 |
|
268 | 268 | %:- set_prolog_flag(optimise, false).
|
269 | 269 | %:- set_prolog_flag(access_level, system).
|
270 |
| -check_term_depth(X,Y):- find_term_cycles(X), X=Y. |
271 |
| -check_term_depth(X,Y):- find_term_cycles(Y), X=Y. |
| 270 | +check_term_depth(X,Y):- fail, (find_term_cycles(X);find_term_cycles(Y)), X=Y. |
272 | 271 | find_term_cycles(X):- find_term_cycles(100,X).
|
273 | 272 | find_term_cycles(_,X):- \+ acyclic_term_nat(X), notrace, nl,nl, writeq(X), nl,nl, break.
|
274 | 273 | find_term_cycles(N,X):- term_depth(X,Deep), Deep>N, notrace, nl,nl, writeq(X), nl,nl, break.
|
|
537 | 536 | ((copy_term(X+Y,YC), YC = YY) -> (debug(metta(todo),'no_repeat in ~w: ~q',[ThisNth,X->Y])) ; (debug(metta(todo),'repeats in ~w: ~q',[ThisNth,X->Y]),fail))),
|
538 | 537 | nb_setval(previous_nths,NthL)).
|
539 | 538 |
|
| 539 | + |
| 540 | +depth_overflow:- fail, notrace,ignore(nortrace), |
| 541 | + trace,dumpST,break,throw(depth_limit_exceeded). |
| 542 | + |
| 543 | +maybe_bt(Why):- Why == depth, depth_overflow,fail. |
540 | 544 | maybe_bt(Why):- maybe_trace(bt(Why)),!.
|
541 | 545 | % maybe_bt:- notrace,maybe_trace(depth),bt.
|
542 | 546 | /*
|
|
551 | 555 |
|
552 | 556 | eval_10(_Eq,_RetType,_Dpth,_Self,X,_YO):- X==[empty],!,fail.
|
553 | 557 | eval_10(_Eq,_RetType,_Dpth,_Self,X,_YO):- X==['Empty'],!,fail.
|
| 558 | +eval_10(_Eq,_RetType,_Dpth,_Self,X,Y):- X=@=['runreduction',_],!,Y=X. |
554 | 559 | eval_10(_Eq,_RetType,Depth,_Self,X,Y):- overflow_depth(Depth),maybe_bt(depth),!,unify_woc(X,Y).
|
555 | 560 | eval_10(Eq,RetType,Depth,Self,X,Y):- var(X), !, % sanity_check_eval(eval_10_var,X),
|
556 | 561 | eval_20(Eq,RetType,Depth,Self,X,Y).
|
|
2711 | 2716 | pop_scope_item(N,V):- ppp_default_value(N,V),!.
|
2712 | 2717 |
|
2713 | 2718 |
|
| 2719 | + |
| 2720 | +eval_10(Eq,RetType,Depth,Self,['with-pragma!',List,X],Y):- !, |
| 2721 | + setup_call_cleanup(maplist(undoable_set_pragma(Self),List,Restore), |
| 2722 | + eval_args(Eq,RetType,Depth,Self,X,Y), |
| 2723 | + maplist(set_pragma(Self),Restore)). |
| 2724 | + |
| 2725 | +% @TODO so someting with Self |
| 2726 | +set_pragma(_Self,[N,V]):- set_option_value_interp(N,V),!. |
| 2727 | +undoable_set_pragma(Self,[N,V],[N,Was]):- (option_value(N,Was)->true;Was='Empty'), set_pragma(Self,[N,V]),!. |
| 2728 | + |
2714 | 2729 | eval_20(Eq,RetType,Depth,Self,['pragma!',Other,Expr],RetVal):- !,
|
2715 | 2730 | must_det_lls((into_name(Self,Other,Name),nd_ignore((eval_args(Eq,RetType,Depth,Self,Expr,Value),
|
2716 |
| - set_option_value_interp(Name,Value))), make_nop(RetType,Value,RetVal), |
| 2731 | + set_pragma(Self,[Name,Value]))), make_nop(RetType,Value,RetVal), |
2717 | 2732 | check_returnval(Eq,RetType,RetVal))).
|
2718 | 2733 | eval_20(Eq,RetType,_Dpth,Self,['transfer!',File],RetVal):- !, must((include_metta(Self,File),
|
2719 | 2734 | make_nop(RetType,Self,RetVal),check_returnval(Eq,RetType,RetVal))).
|
|
3632 | 3647 | maybe_non_eval(AE,Len,N,Type):- assert(arg_type_n(AE,Len,N,eval(Type))),!.
|
3633 | 3648 |
|
3634 | 3649 |
|
3635 |
| -do_each_arg(_Eq, _RetType, _ResIn, _Depth, _Self, _AE, _Len, _N, [], []):-!. |
3636 |
| -do_each_arg(_Eq, _RetType, _ResIn, _Depth, _Self, _AE, Len, N, _, []) :- N > Len, !. |
| 3650 | +do_each_arg(_Eq, _RetType, _ResIn, _Depth, _Self, _AE, _Len, _N, [], Out):- !, Out=[]. |
| 3651 | +do_each_arg(_Eq, _RetType, _ResIn, _Depth, _Self, _AE, Len, N, _, Out) :- N > Len, !, Out=[]. |
3637 | 3652 | do_each_arg(Eq, RetType, ResIn, Depth, Self, AE, Len, N, [In|More], [Out|Adjusted]) :-
|
3638 | 3653 | do_arg(Eq, RetType, ResIn, Depth, Self, AE, Len, N, In, Out), succ(N, Np1),
|
3639 | 3654 | do_each_arg(Eq, RetType, ResIn, Depth, Self, AE, Len, Np1, More, Adjusted).
|
3640 | 3655 |
|
3641 |
| -do_arg(_Eq, _RetType, _RsIn, _Dpth, _Slf, AE, Len, N, InOut, InOut) :- nonvar(AE), arg_type_n(AE, Len, N, no_eval(_)), !. |
| 3656 | +do_arg(_Eq, _RetType, _RsIn, _Dpth, _Slf, AE, Len, N, InOut, InOut) :- nonvar(AE), arg_type_n(AE, Len, N, non_eval(_)), !. |
3642 | 3657 | do_arg( Eq, _RetType, _RsIn, Depth, Self, _AE, _Len, _N, In, Out) :-
|
3643 | 3658 | eval_args(Eq, _, Depth, Self, In, Out).
|
3644 | 3659 |
|
|
4126 | 4141 | BL\==[],!,
|
4127 | 4142 | must_or_die((
|
4128 | 4143 | member(H->B0,BL),%nl,
|
4129 |
| - print_templates(Depth,HC,rule(H,B0,_Nth,_Types)), |
| 4144 | + if_trace((e;eval;defn),print_templates(Depth,HC,rule(H,B0,_Nth,_Types))), |
4130 | 4145 | eval_args(Eq,RetType,Depth,Self,B0,BO))).
|
4131 | 4146 |
|
4132 | 4147 |
|
|
4158 | 4173 | variable_count(B0,Bc1),variable_count(XX,Xc1),
|
4159 | 4174 | if_trace(e,color_g_mesg('#773700',indentq2(Depth,defs_used(XX-->B0,def(USED))))),
|
4160 | 4175 | if_trace(e,color_g_mesg('#993700',indentq2(Depth,variable_count(xc0=Xc0,wc1=Xc1,bc0=Bc0,bc1=Bc1)))),
|
4161 |
| - if_trace(e,(( |
| 4176 | + nop((if_trace(e,(( |
4162 | 4177 | ignore(show_tf((Bc0*2>=Bc1))),
|
4163 |
| - ignore(show_tf((Xc0==Bc1)))))), |
| 4178 | + ignore(show_tf((Xc0==Bc1)))))))), |
4164 | 4179 | if_trace(occurs,((ignore(find_term_cycles(300,X))))),
|
4165 | 4180 | maybe_trace(eval_defn_success).
|
4166 | 4181 | /*
|
|
4297 | 4312 |
|
4298 | 4313 |
|
4299 | 4314 |
|
4300 |
| -eval_30(Eq,RetType,Depth,Self,X,Y):- \+ old_sys, !, must_or_die((mapl_eval_args(Eq,RetType,Depth,Self,X,Y))). |
4301 |
| -eval_30(Eq,RetType,Depth,Self,X,Y):- |
4302 |
| - subst_args_here(Eq,RetType,Depth,Self,X,Y). |
4303 |
| - |
| 4315 | +%eval_30(Eq,RetType,Depth,Self,X,Y):- \+ old_sys, !, must_or_die((mapl_eval_args(Eq,RetType,Depth,Self,X,Y))). |
| 4316 | +%eval_30(Eq,RetType,Depth,Self,X,Y):- subst_args_here(Eq,RetType,Depth,Self,X,Y). |
| 4317 | +eval_30(_Eq,_RetType,_Depth,_Self,X,Y):- unify_woc(X,Y). |
4304 | 4318 |
|
4305 | 4319 | % functs_to_preds([Eq, H, B], Preds)
|
4306 | 4320 | eval_40_disabled(_Eq,_RetType,_Dpth,_Slf,[H|PredDecl],Res):- fail,
|
4307 | 4321 | is_rust_operation([H|PredDecl]),!, % run
|
4308 | 4322 | must_det_ll((rust_metta_run(exec([H|PredDecl]),Res),
|
4309 | 4323 | nop(write_src(res(Res))))).
|
4310 | 4324 |
|
4311 |
| -eval_40(Eq,RetType,Depth,Self,X,Y):- \+ old_sys, !, mapl_eval_args(Eq,RetType,Depth,Self,X,Y). |
| 4325 | +eval_40(Eq,_RetType,Depth,Self,[AIn|More],[AE|More]):- nonvar(AE),!, |
| 4326 | + (eval_args(Eq, _, Depth, Self, AIn, AE) *-> true ; AIn=AE). |
| 4327 | + |
| 4328 | +eval_40(_Eq,_RetType,_Depth,_Self,X,Y):- unify_woc(X,Y). |
| 4329 | + |
| 4330 | +eval_40_disabled(Eq,RetType,Depth,Self,X,Y):- \+ old_sys, !, mapl_eval_args(Eq,RetType,Depth,Self,X,Y). |
4312 | 4331 |
|
4313 |
| -eval_40(Eq,RetType,Depth,Self,[H|PredDecl],Res):- |
| 4332 | +eval_40_disabled(Eq,RetType,Depth,Self,[H|PredDecl],Res):- |
4314 | 4333 | eval_args(Eq,_,Depth,Self,H,HH),
|
4315 | 4334 | % maybe_eval_subst ?
|
4316 | 4335 | subst_args_here(Eq,RetType,Depth,Self,[HH|PredDecl],Res).
|
|
0 commit comments