|
67 | 67 | :- dynamic(symbol_impl_not_exists/3). |
68 | 68 | :- discontiguous(symbol_impl_only/3). |
69 | 69 |
|
| 70 | +current_predicate_fast(FA):- |
| 71 | + current_predicate(FA). |
| 72 | + |
70 | 73 | %self_eval0(X):- var(X),!,fail. |
71 | 74 | self_eval0(X):- \+ callable(X),!. |
72 | 75 | self_eval0(X):- is_valid_nb_state(X),!. |
|
1845 | 1848 |
|
1846 | 1849 |
|
1847 | 1850 | eval_space(Eq,RetType,_Dpth,_Slf,['add-atom',Space,PredDecl],Res):- !, |
1848 | | - do_metta(python,load,Space,PredDecl,TF),make_nop(RetType,TF,Res),check_returnval(Eq,RetType,Res). |
| 1851 | + do_metta(python,load,Space,PredDecl,TF),make_nop(RetType,TF,Res),check_returnval(Eq,RetType,Res). |
| 1852 | + |
1849 | 1853 |
|
1850 | 1854 | eval_space(Eq,RetType,_Dpth,_Slf,['remove-atom',Space,PredDecl],Res):- !, |
1851 | 1855 | do_metta(python,unload_all,Space,PredDecl,TF), |
|
2346 | 2350 | into_listoid(AtomC,Atom):- is_list(AtomC),!,Atom=AtomC. |
2347 | 2351 | into_listoid(AtomC,Atom):- typed_list(AtomC,_,Atom),!. |
2348 | 2352 |
|
2349 | | -:- if( \+ current_predicate( typed_list / 3 )). |
| 2353 | +:- if( \+ current_predicate_fast( typed_list / 3 )). |
2350 | 2354 | typed_list(Cmpd,Type,List):- compound(Cmpd), Cmpd\=[_|_], compound_name_arguments(Cmpd,Type,[List|_]),is_list(List). |
2351 | 2355 | :- endif. |
2352 | 2356 |
|
|
3075 | 3079 | current_function_arity(FF_mc,A). |
3076 | 3080 | */ |
3077 | 3081 |
|
| 3082 | + |
3078 | 3083 | current_predicate_arity(F,A):- |
3079 | 3084 | metta_atom('&self',[:,F,[->|Args]]), |
3080 | 3085 | !, |
3081 | 3086 | length(Args,A). |
3082 | 3087 | current_predicate_arity(F,A):- |
3083 | | - current_predicate(F/A). |
| 3088 | + current_predicate_fast(F/A). |
3084 | 3089 |
|
3085 | 3090 | current_function_arity(F,A):- |
3086 | 3091 | current_predicate_arity(F,PA) |
|
3123 | 3128 | %((ignore(pfcRemove(do_compile(KB,X,_))), |
3124 | 3129 | % pfcWatch, |
3125 | 3130 | pfcAdd_Now(do_compile(KB,X,_)), |
3126 | | - if_t( \+ current_predicate(X/_), |
| 3131 | + if_t( \+ current_predicate_fast(X/_), |
3127 | 3132 | forall(metta_defn(KB,[X | Args] ,BodyFn), |
3128 | 3133 | compile_metta_defn(KB,X,Len,Args,BodyFn,_Clause))), |
3129 | | - if_t( \+ current_predicate(X/_), |
| 3134 | + if_t( \+ current_predicate_fast(X/_), |
3130 | 3135 | (ignore(nortrace),forall(metta_defn(KB,[X | Args] ,BodyFn), |
3131 | 3136 | (maybe_trace(compile_metta_defn),compile_metta_defn(KB,X,Len,Args,BodyFn,_ClauseU))))), |
3132 | 3137 | % pfcNoWatch, |
|
3158 | 3163 | len_or_unbound(More,Len), |
3159 | 3164 |
|
3160 | 3165 | must_det_ll(( |
3161 | | - current_predicate(AE/Arity), |
| 3166 | + current_predicate_fast(AE/Arity), |
3162 | 3167 | maplist(as_prolog_x(Depth,Self), More , Adjusted))),!, |
3163 | 3168 | eval_201(Eq,RetType,Depth,Self,MettaPred,Adjusted,Arity,Len,Res), |
3164 | 3169 | nonvar(Res), |
|
3320 | 3325 | %must_use_eval(_,2):- fail. |
3321 | 3326 |
|
3322 | 3327 | call_as_p2a(F2,A,B):- unnegate_f2(F2,P2),!, \+ call_as_p2(P2,A,B). |
3323 | | -call_as_p2a(P2,A,B):- current_predicate(P2/2),!,call(P2,A,B). |
3324 | | -call_as_p2a(P2,A,B):- current_predicate(P2/3),!,call(P2,A,B,RetVal),f2_success(RetVal,A,B). |
| 3328 | +call_as_p2a(P2,A,B):- current_predicate_fast(P2/2),!,call(P2,A,B). |
| 3329 | +call_as_p2a(P2,A,B):- current_predicate_fast(P2/3),!,call(P2,A,B,RetVal),f2_success(RetVal,A,B). |
3325 | 3330 | call_as_p2a(F,X,Y):- must_use_eval(F,2), !, |
3326 | 3331 | once(eval([F,X,Y],RetVal)), |
3327 | 3332 | f2_success(RetVal,X,Y). |
|
3331 | 3336 |
|
3332 | 3337 | f2_success(RetVal,A,B):- once(RetVal=='True';RetVal==A;RetVal==B). |
3333 | 3338 |
|
3334 | | -eval_as_f2(F2,A,B,RetVal):- current_predicate(F2/3),!,call(F2,A,B,RetVal),!. |
| 3339 | +eval_as_f2(F2,A,B,RetVal):- current_predicate_fast(F2/3),!,call(F2,A,B,RetVal),!. |
3335 | 3340 | eval_as_f2(F2,A,B,RetVal):- f2_to_p3(F2,P3),!,call(P3,A,B,RetVal). |
3336 | 3341 | eval_as_f2(F2,A,B,RetVal):- once(eval([F2,A,B],TF)), |
3337 | 3342 | (TF == 'True'-> RetVal=A ; |
|
3636 | 3641 | if_t(var(Type),member(Type,['mx','mi','mc'])), |
3637 | 3642 | if_t(var(Len),between(1,10,Len)), |
3638 | 3643 | format(atom(Fn),'~w__1_~w_~w',[Type,Len,Sym]), |
3639 | | - succ(Len,LenP1), current_predicate(Fn/LenP1), |
| 3644 | + succ(Len,LenP1), current_predicate_fast(Fn/LenP1), |
3640 | 3645 | ok_call_predicate(Sym,Len,Type). |
3641 | 3646 |
|
3642 | 3647 | transpiler_peek_impl(Sym,Len,Type,Fn, Min, restAsList):- |
|
3646 | 3651 | if_t(var(Min),between(0,Len, Min)), |
3647 | 3652 | (format(atom(Fn),'~w_n_~w__~w',[Type,Min,Sym]); |
3648 | 3653 | format(atom(Fn),'~w__1_~w+_~w',[Type,Min,Sym])), |
3649 | | - succ(Min,N1),succ(N1,LenP1), current_predicate(Fn/LenP1), |
| 3654 | + succ(Min,N1),succ(N1,LenP1), current_predicate_fast(Fn/LenP1), |
3650 | 3655 | ok_call_predicate(Sym,Len,Type). |
3651 | 3656 |
|
3652 | 3657 | /* |
3653 | 3658 | transpiler_peek_impl(Sym,Len,Type,Fn, Min, restAsList):- |
3654 | 3659 | between(0,Len, Min), |
3655 | 3660 | if_t(var(Type),member(Type,['mx','mi','mc'])), |
3656 | 3661 | format(atom(Fn),'~w_n_~w__~w',[Type,Min,Sym]), |
3657 | | - succ(Min,N1),succ(N1,LenP1), current_predicate(Fn/LenP1), |
| 3662 | + succ(Min,N1),succ(N1,LenP1), current_predicate_fast(Fn/LenP1), |
3658 | 3663 | ok_call_predicate(Sym,Len,Type). |
3659 | 3664 | */ |
3660 | 3665 |
|
|
3924 | 3929 | % predicate inherited by system |
3925 | 3930 | eval_40(Eq,RetType,Depth,Self,[AE|More],TF):- allow_host_functions, |
3926 | 3931 | is_host_predicate([AE|More],Pred,Len), |
3927 | | - current_predicate(Pred/Len),!, |
| 3932 | + current_predicate_fast(Pred/Len),!, |
3928 | 3933 | %fake_notrace( \+ is_user_defined_goal(Self,[AE|More])),!, |
3929 | 3934 | % adjust_args(Depth,Self,AE,More,Adjusted), |
3930 | 3935 | maplist(as_prolog_x(Depth,Self), More , Adjusted), |
|
3996 | 4001 | % function inherited from system |
3997 | 4002 | eval_40(Eq,RetType,Depth,Self,[AE|More],Res):- allow_host_functions, |
3998 | 4003 | is_host_function([AE|More],Pred,Len), % thus maybe -fn or ! |
3999 | | - Len1 is Len+1, current_predicate(Pred/Len1), !, |
| 4004 | + Len1 is Len+1, current_predicate_fast(Pred/Len1), !, |
4000 | 4005 | %fake_notrace( \+ is_user_defined_goal(Self,[AE|More])),!, |
4001 | 4006 | %adjust_args(Depth,Self,AE,More,Adjusted),!, |
4002 | 4007 | %Len1 is Len+1, |
4003 | | - %current_predicate(Pred/Len1), |
| 4008 | + %current_predicate_fast(Pred/Len1), |
4004 | 4009 | maplist(as_prolog_x(Depth,Self),More,Adjusted), |
4005 | 4010 | append(Adjusted,[Res],Args),!, |
4006 | 4011 | if_trace(host;prolog,ppt(apply(Pred,Args))), |
|
0 commit comments