From 44a00eb7fcb82bff0e3d471f89206e70273a0ac5 Mon Sep 17 00:00:00 2001 From: vsc Date: Mon, 4 Mar 2002 03:25:41 +0000 Subject: [PATCH] compiler would break with g :- a:[u]. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@396 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/compiler.c | 21 ++++++++++----------- C/stdpreds.c | 16 ++++++++++++++++ C/tracer.c | 2 +- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/C/compiler.c b/C/compiler.c index d8783956e..68883143a 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -1130,16 +1130,7 @@ c_goal(Term Goal, int mod) if (IsVarTerm(Goal)) { Goal = MkApplTerm(FunctorCall, 1, &Goal); } - if (IsNumTerm(Goal)) { - FAIL("goal can not be a number", TYPE_ERROR_CALLABLE, Goal); - } - else if (IsRefTerm(Goal)) { - Error_TYPE = TYPE_ERROR_DBREF; - Error_Term = Goal; - FAIL("goal argument in static procedure can not be a data base reference", TYPE_ERROR_CALLABLE, Goal); - } else if (IsPairTerm(Goal)) { - Goal = MkApplTerm(FunctorCall, 1, &Goal); - } else if (IsApplTerm(Goal) && FunctorOfTerm(Goal) == FunctorModule) { + if (IsApplTerm(Goal) && FunctorOfTerm(Goal) == FunctorModule) { Term M = ArgOfTerm(1, Goal); if (IsVarTerm(M) || !IsAtomTerm(M)) { @@ -1152,7 +1143,15 @@ c_goal(Term Goal, int mod) Goal = ArgOfTerm(2, Goal); mod = LookupModule(M); } - if (IsVarTerm(Goal)) { + if (IsNumTerm(Goal)) { + FAIL("goal can not be a number", TYPE_ERROR_CALLABLE, Goal); + } else if (IsRefTerm(Goal)) { + Error_TYPE = TYPE_ERROR_DBREF; + Error_Term = Goal; + FAIL("goal argument in static procedure can not be a data base reference", TYPE_ERROR_CALLABLE, Goal); + } else if (IsPairTerm(Goal)) { + Goal = MkApplTerm(FunctorCall, 1, &Goal); + } else if (IsVarTerm(Goal)) { Goal = MkApplTerm(FunctorCall, 1, &Goal); } if (IsAtomTerm(Goal)) { diff --git a/C/stdpreds.c b/C/stdpreds.c index 91768b81a..d08426502 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -2071,6 +2071,19 @@ p_dump_active_goals(void) { } #endif +#ifdef INES +static Int +p_euc_dist(void) { + Term t1 = Deref(ARG1); + Term t2 = Deref(ARG2); + double d1 = (double)(IntegerOfTerm(ArgOfTerm(1,t1))-IntegerOfTerm(ArgOfTerm(1,t2))); + double d2 = (double)(IntegerOfTerm(ArgOfTerm(2,t1))-IntegerOfTerm(ArgOfTerm(2,t2))); + double d3 = (double)(IntegerOfTerm(ArgOfTerm(3,t1))-IntegerOfTerm(ArgOfTerm(3,t2))); + Int result = (Int)sqrt(d1*d1+d2*d2+d3*d3); + return(unify(ARG3,MkIntegerTerm(result))); +} +#endif + void InitBackCPreds(void) { @@ -2146,6 +2159,9 @@ InitCPreds(void) #ifndef YAPOR InitCPred("$default_sequential", 1, p_default_sequential, SafePredFlag|SyncPredFlag); #endif +#ifdef INES + InitCPred("euc_dist", 3, p_euc_dist, SafePredFlag); +#endif #ifdef DEBUG InitCPred("dump_active_goals", 0, p_dump_active_goals, SafePredFlag|SyncPredFlag); #endif diff --git a/C/tracer.c b/C/tracer.c index db810fcfa..ac3c09afb 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -112,7 +112,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) /* extern int gc_calls; */ vsc_count++; - if (vsc_count < 84600) return; + /* if (vsc_count < 84600) return; */ /* if (vsc_count == 6469) { printf("Here I go\n"); }