|
574 | 574 | is_PyObject(Val), !, 'PyObject' = PyObject. |
575 | 575 | get_type_each(Depth, _Slf, _Type, _) :- |
576 | 576 | % Fail if recursion depth is exhausted. |
577 | | - Depth < 1, !, fail. |
| 577 | + overflow_depth(Depth), !, fail. |
578 | 578 | % get_type(Depth, Self, Val, Type) :- is_debugging(eval), |
579 | 579 | % ftrace(get_type_each(Depth, Self, Val, Type)), |
580 | 580 | % fail. |
|
584 | 584 | % Handle state monad expressions. |
585 | 585 | notrace(is_valid_nb_state(Expr)), !, |
586 | 586 | if_or_else(state_decltype(Expr, Type), nonvar(Type)), |
587 | | - ('get-state'(Expr, Val), !, Depth2 is Depth - 1, |
| 587 | + ('get-state'(Expr, Val), !, deepen(Depth, Depth2), |
588 | 588 | get_value_type(Depth2, Self, Val, Type)). |
589 | 589 | get_type_each(_Dpth, Self, Var, Type) :- |
590 | 590 | % Retrieve type from variable attributes. |
|
801 | 801 | symbolic_list_concat([Type, _ | _], ':', Val). |
802 | 802 | get_type_symb(Depth, Self, Op, Type) :- |
803 | 803 | % Evaluate arguments if the operator is defined. |
804 | | - Depth2 is Depth - 1, |
| 804 | + deepen(Depth, Depth2), |
805 | 805 | eval_args(Depth2, Self, Op, Val), |
806 | 806 | Op \=@= Val, !, |
807 | 807 | get_type(Depth2, Self, Val, Type). |
|
859 | 859 | % Curried Op |
860 | 860 | get_type_cmpd(Depth,Self,[[Op|Args]|Arg],Type,curried(W)):- |
861 | 861 | symbol(Op), |
862 | | - Depth2 is Depth-1, |
| 862 | + deepen(Depth, Depth2), |
863 | 863 | get_type_cmpd(Depth2,Self,[Op|Args],Type1,W), |
864 | 864 | get_type(Depth2,Self,Arg,ArgType), |
865 | 865 | ignore(sub_var_safely(ArgType,Type1)->true; |
|
894 | 894 | List\==[], |
895 | 895 | \+ badly_typed_expression(Depth,Self,List), |
896 | 896 | is_list(List), |
897 | | - Depth2 is Depth-1, |
| 897 | + deepen(Depth, Depth2), |
898 | 898 | maplist(get_type(Depth2,Self),List,Types), |
899 | 899 | \+ badly_typed_expression(Depth,Self,Types). |
900 | 900 |
|
901 | 901 | */ |
902 | 902 | get_type_cmpd(Depth,Self,EvalMe,Type,Eval_First):- |
903 | 903 | needs_eval(EvalMe), |
904 | | - Depth2 is Depth-1, |
| 904 | + deepen(Depth, Depth2), |
905 | 905 | eval_args_for_type(Depth2,Self,EvalMe,Val), |
906 | 906 | get_type_cmpd_eval(Depth2,Self,EvalMe,Val,Type,Eval_First). |
907 | 907 | get_type_cmpd(_Dpth,_Slf,_Cmpd,[],unknown). |
|
985 | 985 | get_value_type(_Dpth,Self,List,Type):- is_list(List),metta_type(Self,List,LType),last_element(LType,Type), nonvar(Type), |
986 | 986 | is_type(Type). |
987 | 987 |
|
988 | | -get_value_type(Depth,_Slf,Type,Type):- Depth<1,!. |
| 988 | +get_value_type(Depth,_Slf,Type,Type):- overflow_depth(Depth),!. |
989 | 989 | get_value_type(_Dpth,Self,List,Type):- is_list(List),metta_type(Self,Type,['->'|List]). |
990 | | -get_value_type(Depth,Self,List,Types):- List\==[], is_list(List),Depth2 is Depth-1,maplist(get_value_type(Depth2,Self),List,Types). |
| 990 | +get_value_type(Depth,Self,List,Types):- List\==[], is_list(List),deepen(Depth, Depth2),maplist(get_value_type(Depth2,Self),List,Types). |
991 | 991 | get_value_type(_Dpth,Self,Fn,Type):- symbol(Fn),metta_type(Self,Fn,Type),!. |
992 | | -%get_value_type(Depth,Self,Fn,Type):- nonvar(Fn),metta_type(Self,Fn,Type2),Depth2 is Depth-1,get_value_type(Depth2,Self,Type2,Type). |
| 992 | +%get_value_type(Depth,Self,Fn,Type):- nonvar(Fn),metta_type(Self,Fn,Type2),deepen(Depth, Depth2),get_value_type(Depth2,Self,Type2,Type). |
993 | 993 | %get_value_type(Depth,Self,Fn,Type):- Depth>0,nonvar(Fn),metta_type(Self,Type,Fn),!. %,!,last_element(List,Type). |
994 | 994 |
|
995 | | -%get_value_type(Depth,Self,Expr,Type):-Depth2 is Depth-1, |
| 995 | +%get_value_type(Depth,Self,Expr,Type):-deepen(Depth, Depth2), |
996 | 996 | % eval_args(Depth2,Self,Expr,Val), |
997 | 997 | % Expr\=@=Val,get_value_type(Depth2,Self,Val,Type). |
998 | 998 |
|
|
1003 | 1003 | %get_value_type(Depth,_Slf,Cmpd,Type):- compound(Cmpd), functor(Cmpd,Type,1),!. |
1004 | 1004 | %get_value_type(_Dpth,_Slf,Cmpd,Type):- \+ ground(Cmpd),!,Type=[]. |
1005 | 1005 | %get_value_type(_Dpth,_Slf,_,'%Undefined%'):- fail. |
1006 | | -%get_value_type(Depth,Self,Val,Type):- Depth2 is Depth-1, get_type_equals(Depth2,Self,Val,Type). |
| 1006 | +%get_value_type(Depth,Self,Val,Type):- deepen(Depth, Depth2), get_type_equals(Depth2,Self,Val,Type). |
1007 | 1007 | */ |
1008 | 1008 |
|
1009 | 1009 | %! as_prolog(+I, -O) is det. |
|
0 commit comments