Merge branch 'master' of gitosis@yap.dcc.fc.up.pt:yap-6
This commit is contained in:
commit
df6b9a8511
|
@ -3510,6 +3510,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
|||
if (!ystop_found &&
|
||||
cip->cpc->nextInst != NULL &&
|
||||
(cip->cpc->nextInst->op == mark_initialised_pvars_op ||
|
||||
cip->cpc->nextInst->op == mark_live_regs_op ||
|
||||
cip->cpc->nextInst->op == blob_op)) {
|
||||
ystop_found = TRUE;
|
||||
code_p = a_il((CELL)*entry_codep, _Ystop, code_p, pass_no, cip);
|
||||
|
|
12
C/arith1.c
12
C/arith1.c
|
@ -901,17 +901,7 @@ p_unary_op_as_integer(void)
|
|||
ExpEntry *p;
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 1)))) {
|
||||
Term ti[2];
|
||||
|
||||
/* error */
|
||||
ti[0] = t;
|
||||
ti[1] = MkIntTerm(1);
|
||||
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
"functor %s/%d for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE,2);
|
||||
P = FAILCODE;
|
||||
return(FALSE);
|
||||
return Yap_unify(ARG1,ARG2);
|
||||
}
|
||||
return Yap_unify_constant(ARG2,MkIntTerm(p->FOfEE));
|
||||
}
|
||||
|
|
12
C/arith2.c
12
C/arith2.c
|
@ -1242,17 +1242,7 @@ p_binary_op_as_integer(void)
|
|||
ExpEntry *p;
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 2)))) {
|
||||
Term ti[2];
|
||||
|
||||
/* error */
|
||||
ti[0] = t;
|
||||
ti[1] = MkIntTerm(1);
|
||||
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
"functor %s/%d for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE,2);
|
||||
P = FAILCODE;
|
||||
return(FALSE);
|
||||
return Yap_unify(ARG1,ARG2);
|
||||
}
|
||||
return Yap_unify_constant(ARG2,MkIntTerm(p->FOfEE));
|
||||
}
|
||||
|
|
23
C/cmppreds.c
23
C/cmppreds.c
|
@ -643,8 +643,11 @@ p_acomp(void)
|
|||
{ /* $a_compare(?R,+X,+Y) */
|
||||
Term t1 = Deref(ARG1);
|
||||
Term t2 = Deref(ARG2);
|
||||
Int out;
|
||||
|
||||
return a_cmp(t1, t2);
|
||||
out = a_cmp(t1, t2);
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out;
|
||||
}
|
||||
|
||||
static Int
|
||||
|
@ -675,42 +678,48 @@ a_eq(Term t1, Term t2)
|
|||
}
|
||||
}
|
||||
out = a_cmp(t1,t2);
|
||||
return !ArithError && (out == 0);
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out == 0;
|
||||
}
|
||||
|
||||
static Int
|
||||
a_dif(Term t1, Term t2)
|
||||
{
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
return !ArithError && out != 0;
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out != 0;
|
||||
}
|
||||
|
||||
static Int
|
||||
a_gt(Term t1, Term t2)
|
||||
{ /* A > B */
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
return !ArithError && out > 0;
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out > 0;
|
||||
}
|
||||
|
||||
static Int
|
||||
a_ge(Term t1, Term t2)
|
||||
{ /* A >= B */
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
return !ArithError && out >= 0;
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out >= 0;
|
||||
}
|
||||
|
||||
static Int
|
||||
a_lt(Term t1, Term t2)
|
||||
{ /* A < B */
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
return !ArithError && out < 0;
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out < 0;
|
||||
}
|
||||
|
||||
static Int
|
||||
a_le(Term t1, Term t2)
|
||||
{ /* A <= B */
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
return !ArithError && out <= 0;
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out <= 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# (EROOT for architecture-dependent files)
|
||||
#
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
ROOTDIR = $(prefix)
|
||||
EROOTDIR = @exec_prefix@
|
||||
#
|
||||
|
|
|
@ -65,8 +65,9 @@ static Int p_worker(void);
|
|||
#endif /* YAPOR */
|
||||
|
||||
#ifdef TABLING
|
||||
static Int p_freeze(void);
|
||||
static Int p_wake(void);
|
||||
static Int p_freeze_choice_point(void);
|
||||
static Int p_wake_choice_point(void);
|
||||
static Int p_abolish_all_frozen_choice_points(void);
|
||||
static Int p_table(void);
|
||||
static Int p_tabling_mode(void);
|
||||
static Int p_abolish_table(void);
|
||||
|
@ -139,8 +140,9 @@ void Yap_init_optyap_preds(void) {
|
|||
Yap_InitCPred("or_statistics", 0, p_or_statistics, SafePredFlag|SyncPredFlag);
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
Yap_InitCPred("freeze_choice_point", 1, p_freeze, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("wake_choice_point", 1, p_wake, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("freeze_choice_point", 1, p_freeze_choice_point, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("wake_choice_point", 1, p_wake_choice_point, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("abolish_all_frozen_choice_points", 0, p_abolish_all_frozen_choice_points, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$c_table", 2, p_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$c_tabling_mode", 3, p_tabling_mode, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$c_abolish_table", 2, p_abolish_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
|
@ -552,7 +554,8 @@ Int p_or_statistics(void) {
|
|||
|
||||
|
||||
#ifdef TABLING
|
||||
static Int p_freeze(void) {
|
||||
static
|
||||
Int p_freeze_choice_point(void) {
|
||||
Term term_arg, term_cp;
|
||||
|
||||
term_arg = Deref(ARG1);
|
||||
|
@ -565,7 +568,8 @@ static Int p_freeze(void) {
|
|||
}
|
||||
|
||||
|
||||
static Int p_wake(void) {
|
||||
static
|
||||
Int p_wake_choice_point(void) {
|
||||
Term term_arg;
|
||||
|
||||
term_arg = Deref(ARG1);
|
||||
|
@ -577,6 +581,13 @@ static Int p_wake(void) {
|
|||
}
|
||||
|
||||
|
||||
static
|
||||
Int p_abolish_all_frozen_choice_points(void) {
|
||||
abolish_all_frozen_cps();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
Int p_table(void) {
|
||||
Term mod, t;
|
||||
|
|
|
@ -35,6 +35,7 @@ STD_PROTO(static inline void free_subgoal_trie_hash_chain, (sg_hash_ptr));
|
|||
STD_PROTO(static inline void free_answer_trie_hash_chain, (ans_hash_ptr));
|
||||
STD_PROTO(static inline choiceptr freeze_current_cp, (void));
|
||||
STD_PROTO(static inline void resume_frozen_cp, (choiceptr));
|
||||
STD_PROTO(static inline void abolish_all_frozen_cps, (void));
|
||||
|
||||
#ifdef YAPOR
|
||||
STD_PROTO(static inline void pruning_over_tabling_data_structures, (void));
|
||||
|
@ -815,6 +816,15 @@ void resume_frozen_cp(choiceptr frozen_cp) {
|
|||
}
|
||||
|
||||
|
||||
static inline
|
||||
void abolish_all_frozen_cps(void) {
|
||||
B_FZ = B_BASE;
|
||||
H_FZ = H_BASE;
|
||||
TR_FZ = TR_BASE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef YAPOR
|
||||
static inline
|
||||
void pruning_over_tabling_data_structures(void) {
|
||||
|
|
|
@ -6871,7 +6871,7 @@ then
|
|||
YAPLIB="$DYNYAPLIB"
|
||||
DYNLIB_LD="$CC -dynamiclib -Wl,-install_name,$prefix/lib/libYap.dylib"
|
||||
PRE_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(abs_top_builddir)"
|
||||
EXTEND_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPBOOTDIR=\$(DESTDIR)\$(SHAREDIR)/pl YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
EXTEND_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
# CROSS_SIMULATOR="DYLD_LIBRARY_PATH=."
|
||||
;;
|
||||
*)
|
||||
|
@ -6886,7 +6886,7 @@ then
|
|||
JAVA_TARGET=sparc
|
||||
;;
|
||||
esac
|
||||
EXTEND_DYNLOADER_PATH="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPBOOTDIR=\$(DESTDIR)\$(SHAREDIR)/pl YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
EXTEND_DYNLOADER_PATH="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
PRE_DYNLOADER_PATH="LD_LIBRARY_PATH=\$(abs_top_builddir)"
|
||||
LDFLAGS="$LDFLAGS -Wl,-R,$JAVA_HOME/jre/lib/$JAVA_TARGET"
|
||||
DYNYAPLIB=libYap"$SHLIB_SUFFIX"
|
||||
|
@ -6895,7 +6895,7 @@ then
|
|||
esac
|
||||
else
|
||||
PRE_DYNLOADER_PATH=""
|
||||
EXTEND_DYNLOADER_PATH="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPBOOTDIR=\$(DESTDIR)\$(SHAREDIR)/pl YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
EXTEND_DYNLOADER_PATH="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
DYNYAPLIB=libYap.notused
|
||||
fi
|
||||
|
||||
|
|
|
@ -1016,7 +1016,7 @@ then
|
|||
YAPLIB="$DYNYAPLIB"
|
||||
DYNLIB_LD="$CC -dynamiclib -Wl,-install_name,$prefix/lib/libYap.dylib"
|
||||
PRE_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(abs_top_builddir)"
|
||||
EXTEND_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPBOOTDIR=\$(DESTDIR)\$(SHAREDIR)/pl YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
EXTEND_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
# CROSS_SIMULATOR="DYLD_LIBRARY_PATH=."
|
||||
;;
|
||||
*)
|
||||
|
@ -1031,7 +1031,7 @@ then
|
|||
JAVA_TARGET=sparc
|
||||
;;
|
||||
esac
|
||||
EXTEND_DYNLOADER_PATH="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPBOOTDIR=\$(DESTDIR)\$(SHAREDIR)/pl YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
EXTEND_DYNLOADER_PATH="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
PRE_DYNLOADER_PATH="LD_LIBRARY_PATH=\$(abs_top_builddir)"
|
||||
LDFLAGS="$LDFLAGS -Wl,-R,$JAVA_HOME/jre/lib/$JAVA_TARGET"
|
||||
DYNYAPLIB=libYap"$SHLIB_SUFFIX"
|
||||
|
@ -1040,7 +1040,7 @@ then
|
|||
esac
|
||||
else
|
||||
PRE_DYNLOADER_PATH=""
|
||||
EXTEND_DYNLOADER_PATH="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPBOOTDIR=\$(DESTDIR)\$(SHAREDIR)/pl YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
EXTEND_DYNLOADER_PATH="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
DYNYAPLIB=libYap.notused
|
||||
fi
|
||||
|
||||
|
|
68
pl/arith.yap
68
pl/arith.yap
|
@ -85,7 +85,8 @@ do_not_compile_expressions :- set_value('$c_arith',[]).
|
|||
'$do_c_built_in'(X is Y, M, P) :-
|
||||
primitive(X), !,
|
||||
'$do_c_built_in'(X =:= Y, M, P).
|
||||
'$do_c_built_in'(X is Y, M, (P,A=X)) :- nonvar(X), !,
|
||||
'$do_c_built_in'(X is Y, M, (P,A=X)) :-
|
||||
nonvar(X), !,
|
||||
'$do_c_built_in'(A is Y, M, P).
|
||||
'$do_c_built_in'(X is Y, _, P) :-
|
||||
nonvar(Y), % Don't rewrite variables
|
||||
|
@ -163,11 +164,11 @@ do_not_compile_expressions :- set_value('$c_arith',[]).
|
|||
'$expand_expr'(A, true, A) :-
|
||||
atomic(A), !.
|
||||
'$expand_expr'(T, E, V) :-
|
||||
'$unaryop'(T, O, A), !,
|
||||
T =.. [O, A], !,
|
||||
'$expand_expr'(A, Q, X),
|
||||
'$expand_expr'(O, X, V, Q, E).
|
||||
'$expand_expr'(T, E, V) :-
|
||||
'$binaryop'(T, O, A, B), !,
|
||||
T =.. [O, A, B], !,
|
||||
'$expand_expr'(A, Q, X),
|
||||
'$expand_expr'(B, R, Y),
|
||||
'$expand_expr'(O, X, Y, V, Q, S),
|
||||
|
@ -272,67 +273,6 @@ do_not_compile_expressions :- set_value('$c_arith',[]).
|
|||
'$preprocess_args_for_non_commutative'(X, Y, Z, W, E) :-
|
||||
'$do_and'(Z = X, Y = W, E).
|
||||
|
||||
|
||||
|
||||
% These are the unary arithmetic operators
|
||||
'$unaryop'(+X ,+ ,X).
|
||||
'$unaryop'(-X ,- ,X).
|
||||
'$unaryop'(\(X) ,\ ,X).
|
||||
'$unaryop'(exp(X) ,exp ,X).
|
||||
'$unaryop'(log(X) ,log ,X).
|
||||
'$unaryop'(log10(X) ,log10 ,X).
|
||||
'$unaryop'(sqrt(X) ,sqrt ,X).
|
||||
'$unaryop'(sin(X) ,sin ,X).
|
||||
'$unaryop'(cos(X) ,cos ,X).
|
||||
'$unaryop'(tan(X) ,tan ,X).
|
||||
'$unaryop'(asin(X) ,asin ,X).
|
||||
'$unaryop'(acos(X) ,acos ,X).
|
||||
'$unaryop'(atan(X) ,atan ,X).
|
||||
'$unaryop'(atan2(X) ,atan2 ,X).
|
||||
'$unaryop'(sinh(X) ,sinh ,X).
|
||||
'$unaryop'(cosh(X) ,cosh ,X).
|
||||
'$unaryop'(tanh(X) ,tanh ,X).
|
||||
'$unaryop'(asinh(X) ,asinh ,X).
|
||||
'$unaryop'(acosh(X) ,acosh ,X).
|
||||
'$unaryop'(atanh(X) ,atanh ,X).
|
||||
'$unaryop'(floor(X) ,floor ,X).
|
||||
'$unaryop'(abs(X) ,abs ,X).
|
||||
'$unaryop'(float(X) ,float ,X).
|
||||
'$unaryop'(+(X) ,+ ,X).
|
||||
'$unaryop'(integer(X) ,integer,X).
|
||||
'$unaryop'(truncate(X) ,truncate,X).
|
||||
'$unaryop'(round(X) ,round ,X).
|
||||
'$unaryop'(ceiling(X) ,ceiling,X).
|
||||
'$unaryop'(msb(X) ,msb ,X).
|
||||
'$unaryop'(sign(X) ,sign ,X).
|
||||
'$unaryop'(float_fractional_part(X) ,float_fractional_part ,X).
|
||||
'$unaryop'(float_integer_part(X) ,float_integer_part ,X).
|
||||
'$unaryop'(lgamma(X) ,lgamma ,X).
|
||||
'$unaryop'(erf(X) ,erf ,X).
|
||||
'$unaryop'(erfc(X) ,erfc ,X).
|
||||
|
||||
% These are the binary arithmetic operators
|
||||
'$binaryop'(X+Y ,+ ,X,Y).
|
||||
'$binaryop'(X-Y ,- ,X,Y).
|
||||
'$binaryop'(X*Y ,* ,X,Y).
|
||||
'$binaryop'(X/Y ,/ ,X,Y).
|
||||
'$binaryop'(X mod Y ,mod ,X,Y).
|
||||
'$binaryop'(X rem Y ,rem ,X,Y).
|
||||
'$binaryop'(X//Y ,// ,X,Y).
|
||||
'$binaryop'(X/\Y ,/\ ,X,Y).
|
||||
'$binaryop'(X\/Y ,\/ ,X,Y).
|
||||
'$binaryop'(X#Y ,'#' ,X,Y).
|
||||
'$binaryop'(X<<Y ,<< ,X,Y).
|
||||
'$binaryop'(X>>Y ,>> ,X,Y).
|
||||
'$binaryop'(X^Y ,^ ,X,Y).
|
||||
'$binaryop'(X**Y ,** ,X,Y).
|
||||
'$binaryop'(exp(X,Y) ,exp ,X,Y).
|
||||
'$binaryop'(max(X,Y) ,max ,X,Y).
|
||||
'$binaryop'(min(X,Y) ,min ,X,Y).
|
||||
'$binaryop'(gcd(X,Y) ,gcd ,X,Y).
|
||||
'$binaryop'(atan2(X,Y) ,atan2 ,X,Y).
|
||||
|
||||
|
||||
/* Arithmetics */
|
||||
|
||||
% M and N nonnegative integers, N is the successor of M
|
||||
|
|
|
@ -43,7 +43,7 @@ load_files(Files,Opts) :-
|
|||
'$check_files'(Files,Call) :-
|
||||
var(Files), !,
|
||||
'$do_error'(instantiation_error,Call).
|
||||
'$check_files'(M:Files,Call) :-
|
||||
'$check_files'(M:Files,Call) :- !,
|
||||
(var(M)
|
||||
->
|
||||
'$do_error'(instantiation_error,Call)
|
||||
|
|
Reference in New Issue