|
329 | 329 | eval_001(Eq,RetType,Depth,Self,X,YO):- |
330 | 330 | eval_01(Eq,RetType,Depth,Self,X,YO). |
331 | 331 |
|
332 | | -overflow_depth(N,Depth):- Depth>(10_000-N). |
| 332 | +overflow_depth(N,Depth):- (10_000-N)=<Depth. |
333 | 333 | overflow_depth(Depth):- Depth>10_000. |
334 | 334 | deepen(Depth,Depth2):- succ(Depth,Depth2). |
335 | 335 |
|
|
341 | 341 |
|
342 | 342 | if_t((overflow_depth(Depth), trace_on_overflow), debug(metta(e))), |
343 | 343 |
|
344 | | - trace_eval(eval_10(Eq,RetType),e,Depth2,Self,X,M), |
| 344 | + trace_eval(eval_07(Eq,RetType),e,Depth2,Self,X,M), |
345 | 345 |
|
346 | 346 | ((M=@=XX;M==X;M=@=X) -> Y=M ; eval_03(Eq,RetType,Depth2,Self,M,Y)). |
347 | 347 |
|
|
465 | 465 | is_mettalog_tracing([X|_],Type):- !, is_mettalog_tracing(X,Type). |
466 | 466 | is_mettalog_tracing(H,Type):- woc(metta_atom(_,[mettalog_trace,HH,Type])), \+ \+ H=HH, !. |
467 | 467 |
|
468 | | -eval_08(Eq,RetType,Depth,Self,X,Y):- is_mettalog_tracing(X,Type),!, |
469 | | - with_debug(Type,eval_09(Eq,RetType,Depth,Self,X,Y)). |
470 | | -eval_08(Eq,RetType,Depth,Self,X,Y):- eval_09(Eq,RetType,Depth,Self,X,Y). |
| 468 | +eval_07(Eq,RetType,Depth,Self,X,Y):- is_mettalog_tracing(X,Type),!, |
| 469 | + with_debug(Type,eval_08(Eq,RetType,Depth,Self,X,Y)). |
| 470 | +eval_07(Eq,RetType,Depth,Self,X,Y):- eval_08(Eq,RetType,Depth,Self,X,Y). |
471 | 471 |
|
472 | | -%eval_09(_Eq,_RetType, Depth,_Slf,X,Y):- Depth< 0, !, X=Y, fail. |
473 | | -%eval_09(_Eq,_RetType, Depth,_Slf,X,Y):- Depth< 1, !, X=Y. |
474 | | -%eval_09(_Eq,_RetType, Depth,_Slf,_X,_Y):- Depth<1, if_trace(e,bt),!, fail. |
| 472 | +%eval_08(_Eq,_RetType, Depth,_Slf,X,Y):- Depth< 0, !, X=Y, fail. |
| 473 | +%eval_08(_Eq,_RetType, Depth,_Slf,X,Y):- Depth< 1, !, X=Y. |
| 474 | +%eval_08(_Eq,_RetType, Depth,_Slf,_X,_Y):- Depth<1, if_trace(e,bt),!, fail. |
475 | 475 |
|
476 | 476 | %hybrid_interp :- !. |
477 | 477 | hybrid_interp :- option_value(compile,hybrid),!. |
|
480 | 480 | hybrid_interp :- option_value(compile,full),!,fail. |
481 | 481 | hybrid_interp :- option_value(compile,true),!. |
482 | 482 |
|
| 483 | +get_symbol_impl_only(interp,Fn,Len):- symbol_impl_only(interp,Fn,Len),!. |
| 484 | +get_symbol_impl_only(interp,Fn,Len):- eval_at(fa(Fn,Len), interp), \+ eval_at(fa(Fn,Len), compiler),!. |
483 | 485 |
|
484 | | -eval_09(Eq,RetType,Depth,Self,X,Y):- |
| 486 | +eval_08(Eq,RetType,Depth,Self,X,Y):- option_value(compile, false), !, eval_09(Eq,RetType,Depth,Self,X,Y). |
| 487 | +eval_08(Eq,RetType,Depth,Self,X,Y):- \+ compound(X), !, eval_09(Eq,RetType,Depth,Self,X,Y). |
| 488 | +eval_08(Eq,RetType,Depth,Self,X,Y):- \+ is_list(X), !, eval_09(Eq,RetType,Depth,Self,X,Y). |
| 489 | +eval_08(Eq,RetType,Depth,Self,X,Y):- |
485 | 490 | nb_current('eval_in_only', interp), !, |
486 | | - woc(eval_10(Eq,RetType,Depth,Self,X,Y)). |
487 | | -eval_09(Eq,RetType,Depth,Self,X,Y):- hybrid_interp, !, |
| 491 | + eval_09(Eq,RetType,Depth,Self,X,Y). |
| 492 | +eval_08(Eq,RetType,Depth,Self,X,Y):- |
| 493 | + nb_current('eval_in_only', compiler), !, |
| 494 | + with_scope(Eq, RetType, Depth, Self, transpile_eval(X,Y)). |
| 495 | +eval_08(Eq,RetType,Depth,Self,X,Y):- |
| 496 | + nb_current('eval_in_only', rust), !, |
| 497 | + with_scope(Eq, RetType, Depth, Self, rust_metta_run(exec(X),Y)). |
| 498 | +eval_08(Eq,RetType,Depth,Self,X,Y):- X = [Fn|Args], length(Args,Len), eval_08(Fn,Len,Eq,RetType,Depth,Self,X,Y). |
| 499 | + |
| 500 | +eval_08(Fn,Len,Eq,RetType,Depth,Self,X,Y):- |
| 501 | + get_symbol_impl_only(interp,Fn,Len),!, eval_09(Eq,RetType,Depth,Self,X,Y). |
| 502 | +eval_08(Fn,Len,Eq,RetType,Depth,Self,X,Y):- |
| 503 | + symbol_impl_exists(interp, Fn, Len),!, eval_09(Eq,RetType,Depth,Self,X,Y). |
| 504 | +eval_08(Eq,RetType,Depth,Self,X,Y):- hybrid_interp, !, |
488 | 505 | eval_use_right_thing(Eq,RetType,Depth,Self,X,Y). |
489 | 506 | eval_09(Eq,RetType,Depth,Self,X,Y):- woc(eval_10(Eq,RetType,Depth,Self,X,Y)). |
490 | 507 |
|
491 | | -%eval_09(Eq,RetType,Depth,Self,X,Y):- !, no_repeats(X+Y,eval_10(Eq,RetType,Depth,Self,X,Y)). |
492 | | -eval_09_hide(Eq,RetType,Depth,Self,X,Y):- !, |
| 508 | + |
| 509 | +%eval_08(Eq,RetType,Depth,Self,X,Y):- !, no_repeats(X+Y,eval_10(Eq,RetType,Depth,Self,X,Y)). |
| 510 | +eval_08_hide(Eq,RetType,Depth,Self,X,Y):- !, |
493 | 511 | no_repeats_var(YY), |
494 | 512 | eval_to_name(X,XX),!, |
495 | 513 | eval_10(Eq,RetType,Depth,Self,X,Y), %break, |
|
772 | 790 | eval_20(_,_,_,_,['echo',Value],Value):- !. |
773 | 791 | %eval_20(=,Type,_,_,['coerce',Type,Value],Result):- !, coerce(Type,Value,Result). |
774 | 792 |
|
775 | | -eval_20(_Eq,RetType,Depth,Self,['py-atom-call!',[Sym|Specialize]|Args],Res):- is_list(Args), !, |
| 793 | +eval_20(_Eq,RetType,Depth,Self,['py-atom-call!',SymSpecialize|Args],Res):- is_list(Args), !, |
| 794 | + listify(SymSpecialize,[Sym|Specialize]), |
776 | 795 | maplist(as_prolog_x(Depth,Self), Args , Adjusted),!, |
777 | | - py_call_method_and_args_sig(RetType,[],Sym,Adjusted,Res). |
| 796 | + py_call_method_and_args_sig(RetType,Specialize,Sym,Adjusted,Res). |
| 797 | + |
778 | 798 | eval_40(Eq,RetType,Depth,Self,['py-atom-call',Sym|Args],Res):- |
779 | 799 | eval_20(Eq,RetType,Depth,Self,['py-atom-call!',Sym|Args],Res). |
780 | 800 |
|
|
1172 | 1192 |
|
1173 | 1193 |
|
1174 | 1194 |
|
1175 | | -eval_20(Eq,RetType,_Dpth,_Slf,['repl!'],Y):- !, repl,check_returnval(Eq,RetType,Y). |
| 1195 | +eval_20(Eq,RetType,_Dpth,_Slf,['repl!'],Y):- !, repl, check_returnval(Eq,RetType,Y). |
1176 | 1196 | %eval_20(Eq,RetType,Depth,Self,['enforce',Cond],Res):- !, enforce_true(Eq,RetType,Depth,Self,Cond,Res). |
1177 | 1197 |
|
1178 | 1198 | eval_20(Eq,RetType,Depth,Self,['trace!',A,B],C):- !, % writeln(trace(A)), |
|
3084 | 3104 | no_repeat_variant_var(Var):- no_repeats_var(Var). |
3085 | 3105 | %no_repeat_variant_var(Var):- no_repeats_var(variant_by_type,Var). |
3086 | 3106 |
|
3087 | | -eval_30(=,_RetType,_,_,[Var|Types],_):- var(Var), !, |
| 3107 | +eval_30(=,_RetType,_,_,[Var|Types],_):- var(Var), !, |
3088 | 3108 | throw(var_eval_30([Var|Types])). |
3089 | 3109 |
|
3090 | 3110 | eval_30(_Eq,_RetType,_Depth,_Self,[Space|More],[Space|More]):- |
|
3435 | 3455 | transpiler_peek(Sym,Len,TypeL,Fn, Min, SpreadArgs):- |
3436 | 3456 | is_list(TypeL), !, member(Type,TypeL), |
3437 | 3457 | transpiler_peek(Sym,Len,Type,Fn, Min, SpreadArgs). |
3438 | | - |
| 3458 | + |
3439 | 3459 | transpiler_peek(Sym,Len,Type,Fn, Min, exactArgs):- Len=Min, |
3440 | 3460 | if_t((var(Sym)),ignore(transpiler_predicate_store(_, Sym,_ , _, _, _, _))), |
3441 | 3461 | nonvar(Sym), |
|
3512 | 3532 | jiggle_args(Args,Res,Len,Min,AsList,PArgs), ! , |
3513 | 3533 | with_metta_ctx(Eq,RetType,Depth,Self,[Sym|Args],apply(Fn,PArgs)). |
3514 | 3534 |
|
3515 | | -eval_30(Eq, RetType, Depth, Self, [Sym | Args], Res) :- |
| 3535 | +eval_30(Eq, RetType, Depth, Self, [Sym | Args], Res) :- |
3516 | 3536 | fail, |
3517 | 3537 | \+ eval_at(Sym,interp), symbol(Sym), is_list(Args), |
3518 | 3538 | len_or_unbound(Args, Len), |
|
0 commit comments