| | 7202 | % arithmetic predicates (portability checks) |
| | 7203 | |
| | 7204 | '$lgt_tr_body'(_ is Exp, _, _, _) :- |
| | 7205 | '$lgt_check_non_portable_functions'(Exp), |
| | 7206 | fail. |
| | 7207 | '$lgt_tr_body'(Exp1 =:= Exp2, _, _, _) :- |
| | 7208 | '$lgt_check_non_portable_functions'(Exp1), |
| | 7209 | '$lgt_check_non_portable_functions'(Exp2), |
| | 7210 | fail. |
| | 7211 | '$lgt_tr_body'(Exp1 =\= Exp2, _, _, _) :- |
| | 7212 | '$lgt_check_non_portable_functions'(Exp1), |
| | 7213 | '$lgt_check_non_portable_functions'(Exp2), |
| | 7214 | fail. |
| | 7215 | '$lgt_tr_body'(Exp1 < Exp2, _, _, _) :- |
| | 7216 | '$lgt_check_non_portable_functions'(Exp1), |
| | 7217 | '$lgt_check_non_portable_functions'(Exp2), |
| | 7218 | fail. |
| | 7219 | '$lgt_tr_body'(Exp1 =< Exp2, _, _, _) :- |
| | 7220 | '$lgt_check_non_portable_functions'(Exp1), |
| | 7221 | '$lgt_check_non_portable_functions'(Exp2), |
| | 7222 | fail. |
| | 7223 | '$lgt_tr_body'(Exp1 > Exp2, _, _, _) :- |
| | 7224 | '$lgt_check_non_portable_functions'(Exp1), |
| | 7225 | '$lgt_check_non_portable_functions'(Exp2), |
| | 7226 | fail. |
| | 7227 | '$lgt_tr_body'(Exp1 >= Exp2, _, _, _) :- |
| | 7228 | '$lgt_check_non_portable_functions'(Exp1), |
| | 7229 | '$lgt_check_non_portable_functions'(Exp2), |
| | 7230 | fail. |
| | 7231 | |
| | 7232 | |
| | 7588 | |
| | 7589 | |
| | 7590 | |
| | 7591 | % '$lgt_check_non_portable_functions'(@term) |
| | 7592 | % |
| | 7593 | % checks an arithmetic expression for calls to non-standard Prolog functions |
| | 7594 | |
| | 7595 | |
| | 7596 | '$lgt_check_non_portable_functions'(Exp) :- |
| | 7597 | var(Exp), |
| | 7598 | !. |
| | 7599 | |
| | 7600 | '$lgt_check_non_portable_functions'(Exp) :- |
| | 7601 | number(Exp), |
| | 7602 | !. |
| | 7603 | |
| | 7604 | '$lgt_check_non_portable_functions'(Exp) :- |
| | 7605 | '$lgt_iso_spec_function'(Exp), |
| | 7606 | !, |
| | 7607 | Exp =.. [_| Exps], |
| | 7608 | '$lgt_check_non_portable_function_args'(Exps). |
| | 7609 | |
| | 7610 | '$lgt_check_non_portable_functions'(Exp) :- |
| | 7611 | functor(Exp, Functor, Arity), |
| | 7612 | ( '$lgt_non_portable_function_'(Functor, Arity) -> |
| | 7613 | true |
| | 7614 | ; assertz('$lgt_non_portable_function_'(Functor, Arity)) |
| | 7615 | ), |
| | 7616 | Exp =.. [_| Exps], |
| | 7617 | '$lgt_check_non_portable_function_args'(Exps). |
| | 7618 | |
| | 7619 | |
| | 7620 | '$lgt_check_non_portable_function_args'([]). |
| | 7621 | |
| | 7622 | '$lgt_check_non_portable_function_args'([Exp| Exps]) :- |
| | 7623 | '$lgt_check_non_portable_functions'(Exp), |
| | 7624 | '$lgt_check_non_portable_function_args'(Exps). |
| | 10226 | |
| | 10227 | |
| | 10228 | |
| | 10229 | % report non-portable arithmetic function calls in the body of object and category predicates |
| | 10230 | |
| | 10231 | '$lgt_report_non_portable_functions' :- |
| | 10232 | '$lgt_compiler_flag'(portability, warning), |
| | 10233 | setof(Functor/Arity, '$lgt_non_portable_function_'(Functor, Arity), Functions), |
| | 10234 | '$lgt_inc_compile_warnings_counter', |
| | 10235 | nl, |
| | 10236 | ( Functions = [_] -> |
| | 10237 | write(' WARNING! Call to non-standard Prolog built-in arithmetic function: ') |
| | 10238 | ; write(' WARNING! Calls to non-standard Prolog built-in arithmetic functions: ') |
| | 10239 | ), |
| | 10240 | '$lgt_writeq_list'(Functions), |
| | 10241 | !. |
| | 10242 | |
| | 10243 | '$lgt_report_non_portable_functions'. |
| | 12797 | |
| | 12798 | |
| | 12799 | |
| | 12800 | |
| | 12801 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| | 12802 | % |
| | 12803 | % table of ISO specified arithmetic functions |
| | 12804 | % |
| | 12805 | % (used for portability checking) |
| | 12806 | % |
| | 12807 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| | 12808 | |
| | 12809 | |
| | 12810 | |
| | 12811 | '$lgt_iso_spec_function'('-'(_)). |
| | 12812 | '$lgt_iso_spec_function'('+'(_, _)). |
| | 12813 | '$lgt_iso_spec_function'('-'(_, _)). |
| | 12814 | '$lgt_iso_spec_function'('*'(_, _)). |
| | 12815 | '$lgt_iso_spec_function'('/'(_, _)). |
| | 12816 | '$lgt_iso_spec_function'('//'(_, _)). |
| | 12817 | '$lgt_iso_spec_function'(rem(_, _)). |
| | 12818 | '$lgt_iso_spec_function'(mod(_, _)). |
| | 12819 | '$lgt_iso_spec_function'('/\\'(_, _)). |
| | 12820 | '$lgt_iso_spec_function'('\\/'(_, _)). |
| | 12821 | '$lgt_iso_spec_function'('\\'(_, _)). |
| | 12822 | '$lgt_iso_spec_function'('<<'(_, _)). |
| | 12823 | '$lgt_iso_spec_function'('>>'(_, _)). |
| | 12824 | '$lgt_iso_spec_function'('**'(_, _)). |
| | 12825 | |
| | 12826 | '$lgt_iso_spec_function'(abs(_)). |
| | 12827 | '$lgt_iso_spec_function'(sign(_)). |
| | 12828 | '$lgt_iso_spec_function'(sqrt(_)). |
| | 12829 | '$lgt_iso_spec_function'(atan(_)). |
| | 12830 | '$lgt_iso_spec_function'(cos(_)). |
| | 12831 | '$lgt_iso_spec_function'(sin(_)). |
| | 12832 | '$lgt_iso_spec_function'(exp(_)). |
| | 12833 | '$lgt_iso_spec_function'(log(_)). |
| | 12834 | '$lgt_iso_spec_function'(float(_)). |
| | 12835 | '$lgt_iso_spec_function'(ceiling(_)). |
| | 12836 | '$lgt_iso_spec_function'(floor(_)). |
| | 12837 | '$lgt_iso_spec_function'(round(_)). |
| | 12838 | '$lgt_iso_spec_function'(truncate(_)). |
| | 12839 | '$lgt_iso_spec_function'(float_fractional_part(_)). |
| | 12840 | '$lgt_iso_spec_function'(float_integer_part(_)). |