diff --git a/CXX/yapi.cpp b/CXX/yapi.cpp index fd2efac16..e0c17f5e5 100644 --- a/CXX/yapi.cpp +++ b/CXX/yapi.cpp @@ -377,7 +377,7 @@ char *YAPAtom::getName(void) { YAPPredicate::YAPPredicate(const char *s, Term **outp, YAPTerm &vnames) throw (int) { CACHE_REGS vnames = Yap_NewSlots(1 PASS_REGS); - Term t = Yap_StringToTerm(s, strlen(s)+1, vnames); + Term t = Yap_StringToTerm(s, strlen(s)+1, Yap_GetFromSlot( vnames.t PASS_REGS)); if (t == 0L) throw YAPError::YAP_SYNTAX_ERROR; ap = getPred( t, outp ); @@ -478,7 +478,7 @@ YAPQuery::YAPQuery(YAPPredicate p, YAPTerm t[]): YAPPredicate(p.ap) YAPListTerm YAPQuery::namedVars() { CACHE_REGS - Term o = Yap_GetFromSlot( vnames PASS_REGS ); + Term o = Yap_GetFromSlot( this->vnames.t PASS_REGS ); return YAPListTerm( o ); } @@ -625,3 +625,5 @@ YAPQuery *YAPEngine::query( char *s ) { YAPQuery *n = new YAPQuery( s ); return n; } + + diff --git a/CXX/yapi.hh b/CXX/yapi.hh index cfc1bf1f7..9ee26dd44 100644 --- a/CXX/yapi.hh +++ b/CXX/yapi.hh @@ -484,7 +484,7 @@ class YAPQuery: public YAPPredicate { int q_flags; YAP_dogoalinfo q_h; YAPQuery *oq; - yhandle_t vnames; + YAPTerm vnames; void initQuery( Term ts[] ); void initQuery( YAPTerm t[], arity_t arity ); public: @@ -503,12 +503,24 @@ public: /// It is given a functor, and an array of terms that must have at least /// the same arity as the functor. Works within the current module. YAPQuery(YAPFunctor f, YAPTerm t[]); + /// string constructor without varnames + /// + /// It is given a string, calls the parser and obtains a Prolog term that should be a callable + /// goal. It does not ask for a list of variables. + inline YAPQuery(char *s): YAPPredicate(s, &this->q_g) + { + this->vnames = vnames; + Term *ts = this->q_g; + + initQuery( ts ); + } /// string constructor with varnames /// /// It is given a string, calls the parser and obtains a Prolog term that should be a callable /// goal and a list of variables. Useful for top-level simulation. Works within the current module. - inline YAPQuery(char *s): YAPPredicate(s, &this->q_g, vnames) + inline YAPQuery(char *s, YAPTerm &vnames): YAPPredicate(s, &this->q_g, vnames) { + this->vnames = vnames; Term *ts = this->q_g; initQuery( ts ); @@ -583,7 +595,7 @@ public: YAPQuery *query( char *s ); }; -/* +/** * @} * */ diff --git a/CXX/yapie.hh b/CXX/yapie.hh index 00d9741c3..126007572 100644 --- a/CXX/yapie.hh +++ b/CXX/yapie.hh @@ -1,12 +1,4 @@ -class YAPEngine; -class YAPAtom; -class YAPFunctor; -class YAPApplTerm; -class YAPPairTerm; -class YAPQuery; -class YAPPredicate; - class YAPError { public: