diff --git a/C/pl-yap.c b/C/pl-yap.c index f95760531..2351bfc11 100644 --- a/C/pl-yap.c +++ b/C/pl-yap.c @@ -623,7 +623,8 @@ currentOperator(Module m, atom_t name, int kind, int *type, int *priority) int numberVars(term_t t, nv_options *opts, int n ARG_LD) { - return Yap_NumberVars(YAP_GetFromSlot(t), n, TRUE); + + return Yap_NumberVars(YAP_GetFromSlot(t), n, opts->singletons); } /******************************* diff --git a/C/utilpreds.c b/C/utilpreds.c index ab2face96..a0bf851b5 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -4254,7 +4254,7 @@ numbervar(Int id) { Term ts[1]; ts[0] = MkIntegerTerm(id); - return Yap_MkApplTerm(FunctorVar, 1, ts); + return Yap_MkApplTerm(LOCAL_FunctorVar, 1, ts); } static Term @@ -4262,7 +4262,7 @@ numbervar_singleton(void) { Term ts[1]; ts[0] = MkIntegerTerm(-1); - return Yap_MkApplTerm(FunctorVar, 1, ts); + return Yap_MkApplTerm(LOCAL_FunctorVar, 1, ts); } static void diff --git a/C/write.c b/C/write.c index 5bcdf8122..37f9c8ccd 100644 --- a/C/write.c +++ b/C/write.c @@ -1013,7 +1013,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str wrputc(')', wglb->stream); lastw = separator; } - } else if (wglb->Handle_vars && functor == FunctorVar) { + } else if (wglb->Handle_vars && functor == LOCAL_FunctorVar) { Term ti = ArgOfTerm(1, t); if (lastw == alphanum) { wrputc(' ', wglb->stream); diff --git a/H/dlocals.h b/H/dlocals.h index 2ddd91f16..fe264da61 100644 --- a/H/dlocals.h +++ b/H/dlocals.h @@ -427,4 +427,6 @@ #define LOCAL_FPreds LOCAL->FPreds_ #define REMOTE_FPreds(wid) REMOTE(wid)->FPreds_ #endif /* LOW_PROF */ +#define LOCAL_FunctorVar LOCAL->FunctorVar_ +#define REMOTE_FunctorVar(wid) REMOTE(wid)->FunctorVar_ diff --git a/H/hlocals.h b/H/hlocals.h index c71a0355b..c55a5e4f9 100644 --- a/H/hlocals.h +++ b/H/hlocals.h @@ -240,4 +240,5 @@ typedef struct worker_local { FILE* FProf_; FILE* FPreds_; #endif /* LOW_PROF */ + Functor FunctorVar_; } w_local; diff --git a/H/iatoms.h b/H/iatoms.h index af72f9f4d..de3159edd 100644 --- a/H/iatoms.h +++ b/H/iatoms.h @@ -311,6 +311,7 @@ AtomUserOut = Yap_LookupAtom("user_output"); AtomVBar = Yap_LookupAtom("|"); AtomVar = Yap_FullLookupAtom("$VAR"); + AtomHiddenVar = Yap_FullLookupAtom("$V"); AtomVariable = Yap_LookupAtom("variable"); AtomVersionNumber = Yap_FullLookupAtom("$version_name"); AtomWakeUpGoal = Yap_FullLookupAtom("$wake_up_goal"); @@ -428,3 +429,4 @@ FunctorUPlus = Yap_MkFunctor(AtomPlus,1); FunctorVBar = Yap_MkFunctor(AtomVBar,2); FunctorVar = Yap_MkFunctor(AtomVar,1); + FunctorHiddenVar = Yap_MkFunctor(AtomHiddenVar,1); diff --git a/H/ilocals.h b/H/ilocals.h index 6c3ea292e..5fd0d935a 100644 --- a/H/ilocals.h +++ b/H/ilocals.h @@ -240,4 +240,5 @@ static void InitWorker(int wid) { REMOTE_FProf(wid) = NULL; REMOTE_FPreds(wid) = NULL; #endif /* LOW_PROF */ + REMOTE_FunctorVar(wid) = FunctorVar; } diff --git a/H/ratoms.h b/H/ratoms.h index 7f7124d5b..913ef73a3 100644 --- a/H/ratoms.h +++ b/H/ratoms.h @@ -311,6 +311,7 @@ AtomUserOut = AtomAdjust(AtomUserOut); AtomVBar = AtomAdjust(AtomVBar); AtomVar = AtomAdjust(AtomVar); + AtomHiddenVar = AtomAdjust(AtomHiddenVar); AtomVariable = AtomAdjust(AtomVariable); AtomVersionNumber = AtomAdjust(AtomVersionNumber); AtomWakeUpGoal = AtomAdjust(AtomWakeUpGoal); @@ -428,3 +429,4 @@ FunctorUPlus = FuncAdjust(FunctorUPlus); FunctorVBar = FuncAdjust(FunctorVBar); FunctorVar = FuncAdjust(FunctorVar); + FunctorHiddenVar = FuncAdjust(FunctorHiddenVar); diff --git a/H/rlocals.h b/H/rlocals.h index a27432bda..90a66d373 100644 --- a/H/rlocals.h +++ b/H/rlocals.h @@ -240,4 +240,5 @@ static void RestoreWorker(int wid USES_REGS) { #endif /* LOW_PROF */ + } diff --git a/H/tatoms.h b/H/tatoms.h index ce5498ff0..16318620e 100644 --- a/H/tatoms.h +++ b/H/tatoms.h @@ -620,6 +620,8 @@ #define AtomVBar Yap_heap_regs->AtomVBar_ Atom AtomVar_; #define AtomVar Yap_heap_regs->AtomVar_ + Atom AtomHiddenVar_; +#define AtomHiddenVar Yap_heap_regs->AtomHiddenVar_ Atom AtomVariable_; #define AtomVariable Yap_heap_regs->AtomVariable_ Atom AtomVersionNumber_; @@ -854,3 +856,5 @@ #define FunctorVBar Yap_heap_regs->FunctorVBar_ Functor FunctorVar_; #define FunctorVar Yap_heap_regs->FunctorVar_ + Functor FunctorHiddenVar_; +#define FunctorHiddenVar Yap_heap_regs->FunctorHiddenVar_ diff --git a/misc/ATOMS b/misc/ATOMS index aa8c4edf6..339022b8a 100644 --- a/misc/ATOMS +++ b/misc/ATOMS @@ -316,6 +316,7 @@ A UserIn N "user_input" A UserOut N "user_output" A VBar N "|" A Var F "$VAR" +A HiddenVar F "$V" A Variable N "variable" A VersionNumber F "$version_name" A WakeUpGoal F "$wake_up_goal" @@ -433,4 +434,5 @@ F UMinus Minus 1 F UPlus Plus 1 F VBar VBar 2 F Var Var 1 +F HiddenVar HiddenVar 1 diff --git a/misc/LOCALS b/misc/LOCALS index 534da8de5..dacd39c32 100644 --- a/misc/LOCALS +++ b/misc/LOCALS @@ -269,4 +269,6 @@ FILE* FProf =NULL FILE* FPreds =NULL #endif /* LOW_PROF */ +Functor FunctorVar =FunctorVar + END_WORKER_LOCAL diff --git a/os/pl-write.c b/os/pl-write.c index 6b7c5813e..ad6e31d6d 100644 --- a/os/pl-write.c +++ b/os/pl-write.c @@ -490,9 +490,15 @@ pl_write_canonical2(term_t stream, term_t term) options.functor = FUNCTOR_isovar1; options.on_attvar = AV_SKIP; options.singletons = TRUE; +#if __YAP_PROLOG__ + LOCAL_FunctorVar = FunctorHiddenVar; +#endif numberVars(term, &options, 0 PASS_LD); rc = do_write2(stream, term, PL_WRT_QUOTED|PL_WRT_IGNOREOPS|PL_WRT_NUMBERVARS); +#if __YAP_PROLOG__ + LOCAL_FunctorVar = FunctorVar; +#endif PL_discard_foreign_frame(fid); return rc;