match系(Horn節の検索時のunifyを切り離した)の関数を追加
Cut述語のパフォーマンスが悪いがとりあえずコミット
@@ -65,6 +65,30 @@ | ||
65 | 65 | return true; |
66 | 66 | } |
67 | 67 | |
68 | +template <class V, class T> bool inline vmatch_h_g(const V &horn, const T &goal, ExecContextRoot *c, VLocal *hlocal) | |
69 | +{ | |
70 | + const PObject *item = (*hlocal)[horn.idx]; | |
71 | + if ( item == 0 ) { | |
72 | + (*hlocal)[horn.idx] = &goal; | |
73 | + return true; | |
74 | + } else { | |
75 | + return item->match_h_g(goal, c); | |
76 | + } | |
77 | + return true; | |
78 | +} | |
79 | + | |
80 | +template <class V, class T> bool inline vmatch_g_h(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal) | |
81 | +{ | |
82 | + const PObject *item = (*glocal)[goal.idx]; | |
83 | + if ( item == 0 ) { | |
84 | + (*glocal)[goal.idx] = &horn; | |
85 | + return true; | |
86 | + } else { | |
87 | + return item->match_g_h(horn, c); | |
88 | + } | |
89 | + return true; | |
90 | +} | |
91 | + | |
68 | 92 | template <class V, class T> bool inline vunify_getval(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) |
69 | 93 | { |
70 | 94 | const PObject *gitem = (*glocal)[goal.idx]; |
@@ -75,15 +99,45 @@ | ||
75 | 99 | } else { |
76 | 100 | return gitem->unify( horn, c, glocal, hlocal); |
77 | 101 | } |
102 | + return true; | |
103 | +} | |
78 | 104 | |
79 | -#if 1 | |
105 | +template <class V, class T> bool inline vmatch_getval_h_g(const V &horn, const T &goal, ExecContextRoot *c, VLocal *hlocal) | |
106 | +{ | |
107 | + const PObject *item = (*hlocal)[horn.idx]; | |
108 | + if ( item == 0 ) { | |
109 | + const PObject *p = goal.getval2(c, c->gl); // getvalに置き換え可能(getval_gl,getval_hlを作成後置き換える | |
110 | + (*hlocal)[horn.idx] = p; | |
111 | + if ( p->isc() ) { | |
112 | + return true; | |
113 | + } | |
114 | + } else { | |
115 | + return item->match_h_g( goal, c); | |
116 | + } | |
80 | 117 | if ( c->pafterunify != 0 ) { |
81 | 118 | c->pafterunify->push_back(c->uidx); |
82 | 119 | } |
83 | -#endif | |
84 | 120 | return true; |
85 | 121 | } |
86 | 122 | |
123 | +template <class V, class T> bool inline vmatch_getval_g_h(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal) | |
124 | +{ | |
125 | + const PObject *item = (*glocal)[goal.idx]; | |
126 | + if ( item == 0 ) { | |
127 | + const PObject *p = horn.getval2(c, c->hl); | |
128 | + if ( p->isc() ) { | |
129 | + (*glocal)[goal.idx] = p; | |
130 | + return true; | |
131 | + } | |
132 | + } else { | |
133 | + return item->match_g_h( horn, c); | |
134 | + } | |
135 | + if ( c->pafterunify != 0 ) { | |
136 | + c->pafterunify->push_back(c->uidx); | |
137 | + } | |
138 | + return true; | |
139 | +} | |
140 | + | |
87 | 141 | template <class V, class T> bool inline vunify_ver(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) |
88 | 142 | { |
89 | 143 | const PObject *gval = (*glocal)[goal.idx]; |
@@ -92,21 +146,39 @@ | ||
92 | 146 | if ( hval != 0 ) { |
93 | 147 | return hval->unify( *gval, c, hlocal, glocal); |
94 | 148 | } else { |
95 | - const PObject *p = gval->getval2(c, glocal); | |
149 | + const PObject *p = gval->getval2(c, c->gl); | |
96 | 150 | (*hlocal)[horn.idx] = p; |
97 | 151 | if ( p->isc() ) return true; |
98 | 152 | } |
99 | 153 | } else if ( hval != 0 ) { |
100 | - const PObject *p = hval->getval2(c, hlocal); | |
154 | + const PObject *p = hval->getval2(c, c->hl); // hlocal -> c->hl? | |
101 | 155 | (*glocal)[goal.idx] = p; |
102 | 156 | if ( p->isc() ) return true; |
103 | 157 | } |
158 | + return true; | |
159 | +} | |
104 | 160 | |
105 | -#if 1 | |
161 | +template <class V, class T> bool inline vmatch_ver_g_h(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) | |
162 | +{ | |
163 | + const PObject *gval = (*glocal)[goal.idx]; | |
164 | + const PObject *hval = (*hlocal)[horn.idx]; | |
165 | + if ( gval != 0 ) { | |
166 | + if ( hval != 0 ) { | |
167 | + return hval->match_h_g( *gval, c); | |
168 | + } else { | |
169 | + const PObject *p = gval->getval2(c, c->gl); // getvalに置き換え可能(getval_gl,getval_hlを作成後置き換える | |
170 | + (*hlocal)[horn.idx] = p; | |
171 | + if ( p->isc() ) return true; | |
172 | + } | |
173 | + } else if ( hval != 0 ) { | |
174 | + const PObject *p = hval->getval2(c, c->hl); | |
175 | + (*glocal)[goal.idx] = p; | |
176 | + if ( p->isc() ) return true; | |
177 | + } | |
178 | + | |
106 | 179 | if ( c->pafterunify != 0 ) { |
107 | 180 | c->pafterunify->push_back(c->uidx); |
108 | 181 | } |
109 | -#endif | |
110 | 182 | return true; |
111 | 183 | } |
112 | 184 |
@@ -122,6 +194,17 @@ | ||
122 | 194 | bool PNil::unify(const PVeriable &horn, ExecContextRoot *c) const { return vunify(horn, *this, c, c->hl, c->gl); } |
123 | 195 | bool PNil::unify(const PEVeriable &horn, ExecContextRoot *c) const { return vunify(horn, *this, c, horn.vl, c->gl); } |
124 | 196 | |
197 | +bool PNil::match_h_g(const PObject &goal, ExecContextRoot *c) const { return goal.match_g_h(*this, c); } | |
198 | +bool PNil::match_h_g(const PNil &goal, ExecContextRoot *c) const { return true; } | |
199 | +bool PNil::match_h_g(const PList &goal, ExecContextRoot *c) const { return goal.match_g_h( *this, c); } | |
200 | +bool PNil::match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return vmatch_g_h(goal, *this, c, c->hl); } | |
201 | +bool PNil::match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return vmatch_g_h(goal, *this, c, goal.vl); } | |
202 | + | |
203 | +bool PNil::match_g_h(const PNil &horn, ExecContextRoot *c) const { return true; } | |
204 | +bool PNil::match_g_h(const PList &horn, ExecContextRoot *c) const { return horn.match_h_g( *this, c); } | |
205 | +bool PNil::match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return vmatch_h_g(horn, *this, c, c->hl); } | |
206 | +bool PNil::match_g_h(const PEVeriable &horn, ExecContextRoot *c) const { return vmatch_h_g(horn, *this, c, horn.vl); } | |
207 | + | |
125 | 208 | /*************************************** PString ******************************************/ |
126 | 209 | bool PString::unify(const PObject &goal, ExecContextRoot *c, VLocal *hlocal, VLocal *glocal) const { return goal.unify(*this, c, glocal, hlocal); } |
127 | 210 | bool PString::unify(const PString &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return strcmp( value.c_str(), horn.value.c_str()) == 0; } |
@@ -132,6 +215,15 @@ | ||
132 | 215 | bool PString::unify(const PVeriable &horn, ExecContextRoot *c) const { return vunify(horn, *this, c, c->hl, c->gl); } |
133 | 216 | bool PString::unify(const PEVeriable &horn, ExecContextRoot *c) const { return vunify(horn, *this, c, horn.vl, c->gl); } |
134 | 217 | |
218 | +bool PString::match_h_g(const PObject &goal, ExecContextRoot *c) const { return goal.match_g_h(*this, c); } | |
219 | +bool PString::match_h_g(const PString &goal, ExecContextRoot *c) const { return strcmp( value.c_str(), goal.value.c_str()) == 0; } | |
220 | +bool PString::match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return vmatch_g_h(goal, *this, c, c->hl); } | |
221 | +bool PString::match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return vmatch_g_h(goal, *this, c, goal.vl); } | |
222 | + | |
223 | +bool PString::match_g_h(const PString &horn, ExecContextRoot *c) const { return strcmp( value.c_str(), horn.value.c_str()) == 0; } | |
224 | +bool PString::match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return vmatch_h_g(horn, *this, c, c->hl); } | |
225 | +bool PString::match_g_h(const PEVeriable &horn, ExecContextRoot *c) const{ return vmatch_h_g(horn, *this, c, horn.vl); } | |
226 | + | |
135 | 227 | /*************************************** PDouble ******************************************/ |
136 | 228 | bool PDouble::unify(const PObject &goal, ExecContextRoot *c, VLocal *hlocal, VLocal *glocal) const { return goal.unify(*this, c, glocal, hlocal); } |
137 | 229 | bool PDouble::unify(const PDouble &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return fabs(value - (double)horn.value) < DBL_EPSILON; } |
@@ -138,6 +230,7 @@ | ||
138 | 230 | bool PDouble::unify(const PInteger &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return fabs(value - (double)horn.value) < DBL_EPSILON; } |
139 | 231 | bool PDouble::unify(const PVeriable &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return vunify(horn, *this, c, hlocal, glocal); } |
140 | 232 | bool PDouble::unify(const PEVeriable &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return vunify(horn, *this, c, horn.vl, glocal); } |
233 | + | |
141 | 234 | bool PDouble::unify(const PObject &goal, ExecContextRoot *c) const { return goal.unify(*this, c); } |
142 | 235 | bool PDouble::unify(const PDouble &horn, ExecContextRoot *c) const { return fabs(value - (double)horn.value) < DBL_EPSILON; } |
143 | 236 | bool PDouble::unify(const PInteger &horn, ExecContextRoot *c) const { return fabs(value - (double)horn.value) < DBL_EPSILON; } |
@@ -144,6 +237,18 @@ | ||
144 | 237 | bool PDouble::unify(const PVeriable &horn, ExecContextRoot *c) const { return vunify(horn, *this, c, c->hl, c->gl); } |
145 | 238 | bool PDouble::unify(const PEVeriable &horn, ExecContextRoot *c) const { return vunify(horn, *this, c, horn.vl, c->gl); } |
146 | 239 | |
240 | +bool PDouble::match_h_g(const PObject &goal, ExecContextRoot *c) const { return goal.match_g_h(*this, c); } | |
241 | +bool PDouble::match_h_g(const PDouble &goal, ExecContextRoot *c) const { return fabs(value - (double)goal.value) < DBL_EPSILON; } | |
242 | +bool PDouble::match_h_g(const PInteger &goal, ExecContextRoot *c) const { return fabs(value - (double)goal.value) < DBL_EPSILON; } | |
243 | +bool PDouble::match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return vmatch_g_h(goal, *this, c, c->hl); } | |
244 | +bool PDouble::match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return vmatch_g_h(goal, *this, c, goal.vl); } | |
245 | + | |
246 | +bool PDouble::match_g_h(const PDouble &horn, ExecContextRoot *c) const { return fabs(value - (double)horn.value) < DBL_EPSILON; } | |
247 | +bool PDouble::match_g_h(const PInteger &horn, ExecContextRoot *c) const { return fabs(value - (double)horn.value) < DBL_EPSILON; } | |
248 | +bool PDouble::match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return vmatch_h_g(horn, *this, c, c->hl); } | |
249 | +bool PDouble::match_g_h(const PEVeriable &horn, ExecContextRoot *c) const { return vmatch_h_g(horn, *this, c, horn.vl); } | |
250 | + | |
251 | + | |
147 | 252 | /*************************************** PInteger ******************************************/ |
148 | 253 | bool PInteger::unify(const PObject &goal, ExecContextRoot *c, VLocal *hlocal, VLocal *glocal) const { return goal.unify(*this, c, glocal, hlocal); } |
149 | 254 | bool PInteger::unify(const PDouble &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return fabs(value - (double)horn.value) < DBL_EPSILON; } |
@@ -150,6 +255,7 @@ | ||
150 | 255 | bool PInteger::unify(const PInteger &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return value == horn.value; } |
151 | 256 | bool PInteger::unify(const PVeriable &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return vunify(horn, *this, c, hlocal, glocal); } |
152 | 257 | bool PInteger::unify(const PEVeriable &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return vunify(horn, *this, c, horn.vl, glocal); } |
258 | + | |
153 | 259 | bool PInteger::unify(const PObject &goal, ExecContextRoot *c) const { return goal.unify(*this, c); } |
154 | 260 | bool PInteger::unify(const PDouble &horn, ExecContextRoot *c) const { return fabs(value - (double)horn.value) < DBL_EPSILON; } |
155 | 261 | bool PInteger::unify(const PInteger &horn, ExecContextRoot *c) const { return value == horn.value; } |
@@ -156,10 +262,21 @@ | ||
156 | 262 | bool PInteger::unify(const PVeriable &horn, ExecContextRoot *c) const { return vunify(horn, *this, c, c->hl, c->gl); } |
157 | 263 | bool PInteger::unify(const PEVeriable &horn, ExecContextRoot *c) const { return vunify(horn, *this, c, horn.vl, c->gl); } |
158 | 264 | |
265 | +bool PInteger::match_h_g(const PObject &goal, ExecContextRoot *c) const { return goal.match_g_h(*this, c); } | |
266 | +bool PInteger::match_h_g(const PDouble &goal, ExecContextRoot *c) const { return fabs(value - (double)goal.value) < DBL_EPSILON; } | |
267 | +bool PInteger::match_h_g(const PInteger &goal, ExecContextRoot *c) const { return value == goal.value; } | |
268 | +bool PInteger::match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return vmatch_g_h(goal, *this, c, c->hl); } | |
269 | +bool PInteger::match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return vmatch_g_h(goal, *this, c, goal.vl); } | |
270 | + | |
271 | +bool PInteger::match_g_h(const PDouble &horn, ExecContextRoot *c) const { return fabs(value - (double)horn.value) < DBL_EPSILON; } | |
272 | +bool PInteger::match_g_h(const PInteger &horn, ExecContextRoot *c) const { return value == horn.value; } | |
273 | +bool PInteger::match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return vmatch_h_g(horn, *this, c, c->hl); } | |
274 | +bool PInteger::match_g_h(const PEVeriable &horn, ExecContextRoot *c) const { return vmatch_h_g(horn, *this, c, horn.vl); } | |
275 | + | |
159 | 276 | /*************************************** PList ******************************************/ |
160 | -static inline bool PList_unify(const PList &goal, const PNil &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) | |
277 | +static inline bool PList_unify(const PList &list) | |
161 | 278 | { |
162 | - if ( typeid(*goal.lvalue) == typeid(PNil) && typeid(*goal.rvalue) == typeid(PNil) ) return true; | |
279 | + if ( typeid(*list.lvalue) == typeid(PNil) && typeid(*list.rvalue) == typeid(PNil) ) return true; | |
163 | 280 | return false; |
164 | 281 | } |
165 | 282 | static inline bool PList_unify(const PList &goal, const PList &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) |
@@ -168,18 +285,35 @@ | ||
168 | 285 | return false; |
169 | 286 | } |
170 | 287 | |
288 | +static inline bool PList_match(const PList &goal, const PList &horn, ExecContextRoot *c) | |
289 | +{ | |
290 | + if ( horn.lvalue->match_h_g( *goal.lvalue, c) && horn.rvalue->match_h_g( *goal.rvalue, c) ) return true; | |
291 | + return false; | |
292 | +} | |
293 | + | |
294 | + | |
171 | 295 | bool PList::unify(const PObject &goal, ExecContextRoot *c, VLocal *hlocal, VLocal *glocal) const { return goal.unify(*this, c, glocal, hlocal); } |
172 | -bool PList::unify(const PNil &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return PList_unify( *this, horn, c, glocal, hlocal); } | |
296 | +bool PList::unify(const PNil &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return PList_unify(*this); } | |
173 | 297 | bool PList::unify(const PList &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const{ return PList_unify( *this, horn, c, glocal, hlocal); } |
174 | 298 | bool PList::unify(const PVeriable &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return vunify_getval(horn, *this, c, hlocal, glocal); } |
175 | 299 | bool PList::unify(const PEVeriable &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return vunify_getval(horn, *this, c, horn.vl, glocal); } |
176 | 300 | bool PList::unify(const PObject &goal, ExecContextRoot *c) const { return goal.unify(*this, c); } |
177 | -bool PList::unify(const PNil &horn, ExecContextRoot *c) const { return PList_unify( *this, horn, c, c->gl, c->hl); } | |
301 | +bool PList::unify(const PNil &horn, ExecContextRoot *c) const { return PList_unify( *this); } | |
178 | 302 | bool PList::unify(const PList &horn, ExecContextRoot *c) const { return PList_unify( *this, horn, c, c->gl, c->hl); } |
179 | 303 | bool PList::unify(const PVeriable &horn, ExecContextRoot *c) const { return vunify_getval(horn, *this, c, c->hl, c->gl); } |
180 | 304 | bool PList::unify(const PEVeriable &horn, ExecContextRoot *c) const { return vunify_getval(horn, *this, c, horn.vl, c->gl); } |
181 | 305 | |
306 | +bool PList::match_h_g(const PObject &goal, ExecContextRoot *c) const { return goal.match_g_h(*this, c); } | |
307 | +bool PList::match_h_g(const PNil &goal, ExecContextRoot *c) const { return PList_unify( *this); } | |
308 | +bool PList::match_h_g(const PList &goal, ExecContextRoot *c) const { return PList_match( goal, *this, c); } | |
309 | +bool PList::match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return vmatch_getval_g_h(goal, *this, c, c->hl); } | |
310 | +bool PList::match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return vmatch_getval_g_h(goal, *this, c, goal.vl); } | |
182 | 311 | |
312 | +bool PList::match_g_h(const PNil &horn, ExecContextRoot *c) const { return PList_unify( *this); } | |
313 | +bool PList::match_g_h(const PList &horn, ExecContextRoot *c) const { return PList_match( *this, horn, c); } | |
314 | +bool PList::match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return vmatch_getval_h_g(horn, *this, c, c->hl); } | |
315 | +bool PList::match_g_h(const PEVeriable &horn, ExecContextRoot *c) const { return vmatch_getval_h_g(horn, *this, c, horn.vl); } | |
316 | + | |
183 | 317 | /*************************************** PArray ******************************************/ |
184 | 318 | static inline bool PArray_unify(const PArray &goal, const PArray &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) |
185 | 319 | { |
@@ -231,6 +365,56 @@ | ||
231 | 365 | return true; |
232 | 366 | } |
233 | 367 | |
368 | +static inline bool PArray_match(const PArray &goal, const PArray &horn, ExecContextRoot *c) | |
369 | +{ | |
370 | + size_t gsiz = goal.value.size(); | |
371 | + size_t hsiz = horn.value.size(); | |
372 | + | |
373 | + c->ao = 0; | |
374 | + // 引数の数が同じ場合 | |
375 | + if ( gsiz == hsiz ) { | |
376 | + for ( size_t i = 0; i < gsiz; i++ ) { | |
377 | + c->uidx = i; | |
378 | + if ( !horn.value[i]->match_h_g( *goal.value[i], c) ) { | |
379 | + return false; | |
380 | + } | |
381 | + } | |
382 | + } else if ( gsiz < hsiz && goal.args == true && horn.args == false ) { | |
383 | + // 引数の数が異なる場合、片方に@がある場合、可変長引数の対応を行う。 | |
384 | + size_t m = gsiz - 1; | |
385 | + // @変数の前まで普通にマッチングさせる | |
386 | + for ( size_t i = 0; i < m; i++ ) { | |
387 | + c->uidx = i; | |
388 | + if ( !horn.value[i]->match_h_g( *goal.value[i], c) ) { | |
389 | + return false; | |
390 | + } | |
391 | + } | |
392 | + // @用の配列を作成する | |
393 | + c->uidx = m; | |
394 | + c->ao = pmm.newPArray(c->pobjs, horn, m, hsiz); | |
395 | + return goal.value[m]->match_g_h( *c->ao, c); | |
396 | + | |
397 | + } else if ( gsiz > hsiz && goal.args == false && horn.args == true ) { | |
398 | + // 引数の数が異なる場合、片方に@がある場合、可変長引数の対応を行う。 | |
399 | + size_t m = hsiz - 1; | |
400 | + // @変数の前まで普通にマッチングさせる | |
401 | + for ( size_t i = 0; i < m; i++ ) { | |
402 | + c->uidx = i; | |
403 | + if ( !horn.value[i]->match_h_g( *goal.value[i], c) ) { | |
404 | + return false; | |
405 | + } | |
406 | + } | |
407 | + // @用の配列を作成する | |
408 | + c->uidx = m; | |
409 | + c->ao = pmm.newPArray(c->pobjs, goal, m, gsiz); | |
410 | + return horn.value[m]->match_h_g( *c->ao, c); | |
411 | + } else { | |
412 | + return false; | |
413 | + } | |
414 | + | |
415 | + return true; | |
416 | +} | |
417 | + | |
234 | 418 | bool PArray::unify(const PObject &goal, ExecContextRoot *c, VLocal *hlocal, VLocal *glocal) const { return goal.unify(*this, c, glocal, hlocal); } |
235 | 419 | bool PArray::unify(const PNil &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { if ( value.empty() ) return true; return false; } |
236 | 420 | bool PArray::unify(const PArray &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return PArray_unify( *this, horn, c, glocal, hlocal); } |
@@ -242,6 +426,17 @@ | ||
242 | 426 | bool PArray::unify(const PVeriable &horn, ExecContextRoot *c) const { return vunify_getval(horn, *this, c, c->hl, c->gl); } |
243 | 427 | bool PArray::unify(const PEVeriable &horn, ExecContextRoot *c) const { return vunify_getval(horn, *this, c, horn.vl, c->gl); } |
244 | 428 | |
429 | +bool PArray::match_h_g(const PObject &goal, ExecContextRoot *c) const { return goal.match_g_h(*this, c); } | |
430 | +bool PArray::match_h_g(const PNil &goal, ExecContextRoot *c) const { if ( value.empty() ) return true; return false; } | |
431 | +bool PArray::match_h_g(const PArray &goal, ExecContextRoot *c) const { return PArray_match( goal, *this, c); } | |
432 | +bool PArray::match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return vmatch_getval_g_h(goal, *this, c, c->hl); } | |
433 | +bool PArray::match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return vmatch_getval_g_h(goal, *this, c, goal.vl); } | |
434 | + | |
435 | +bool PArray::match_g_h(const PNil &horn, ExecContextRoot *c) const { if ( value.empty() ) return true; return false; } | |
436 | +bool PArray::match_g_h(const PArray &horn, ExecContextRoot *c) const { return PArray_match( *this, horn, c); } | |
437 | +bool PArray::match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return vmatch_getval_h_g(horn, *this, c, c->hl); } | |
438 | +bool PArray::match_g_h(const PEVeriable &horn, ExecContextRoot *c) const { return vmatch_getval_h_g(horn, *this, c, horn.vl); } | |
439 | + | |
245 | 440 | /*************************************** PPredicate ******************************************/ |
246 | 441 | static inline bool PPredicate_unify(const PPredicate &goal, const PPredicate &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) |
247 | 442 | { |
@@ -252,6 +447,15 @@ | ||
252 | 447 | return goal.arglist.unify( horn.arglist, c, glocal, hlocal); // horn.arglistがPObjectでない場合はこのように呼び出す |
253 | 448 | } |
254 | 449 | |
450 | +static inline bool PPredicate_match(const PPredicate &goal, const PPredicate &horn, ExecContextRoot *c) | |
451 | +{ | |
452 | + // 呼び出し側(goal)がnamespaceを指定した場合、namespaceが一致している必要がある。 | |
453 | + if ( !goal.nspace.empty() && strcmp( horn.nspace.c_str(), goal.nspace.c_str()) != 0 ) { return false; } | |
454 | + | |
455 | + if ( !horn.name->match_h_g( *goal.name, c) ) { return false; } | |
456 | + return goal.arglist.match_g_h( horn.arglist, c); // horn.arglistがPObjectでない場合はこのように呼び出す | |
457 | +} | |
458 | + | |
255 | 459 | bool PPredicate::unify(const PObject &goal, ExecContextRoot *c, VLocal *hlocal, VLocal *glocal) const { return goal.unify(*this, c, glocal, hlocal); } |
256 | 460 | bool PPredicate::unify(const PPredicate &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return PPredicate_unify( *this, horn, c, glocal, hlocal); } |
257 | 461 | bool PPredicate::unify(const PVeriable &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return vunify_getval(horn, *this, c, hlocal, glocal); } |
@@ -261,7 +465,15 @@ | ||
261 | 465 | bool PPredicate::unify(const PVeriable &horn, ExecContextRoot *c) const { return vunify_getval(horn, *this, c, c->hl, c->gl); } |
262 | 466 | bool PPredicate::unify(const PEVeriable &horn, ExecContextRoot *c) const { return vunify_getval(horn, *this, c, horn.vl, c->gl); } |
263 | 467 | |
468 | +bool PPredicate::match_h_g(const PObject &goal, ExecContextRoot *c) const { return goal.match_g_h(*this, c); } | |
469 | +bool PPredicate::match_h_g(const PPredicate &goal, ExecContextRoot *c) const { return PPredicate_match( goal, *this, c); } | |
470 | +bool PPredicate::match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return vmatch_getval_g_h(goal, *this, c, c->hl); } | |
471 | +bool PPredicate::match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return vmatch_getval_g_h(goal, *this, c, goal.vl); } | |
264 | 472 | |
473 | +bool PPredicate::match_g_h(const PPredicate &horn, ExecContextRoot *c) const { return PPredicate_match( *this, horn, c); } | |
474 | +bool PPredicate::match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return vmatch_getval_h_g(horn, *this, c, c->hl); } | |
475 | +bool PPredicate::match_g_h(const PEVeriable &horn, ExecContextRoot *c) const { return vmatch_getval_h_g(horn, *this, c, horn.vl); } | |
476 | + | |
265 | 477 | /*************************************** PVeriable ******************************************/ |
266 | 478 | bool PVeriable::unify(const PObject &goal, ExecContextRoot *c, VLocal *hlocal, VLocal *glocal) const { return goal.unify(*this, c, glocal, hlocal); } |
267 | 479 | bool PVeriable::unify(const PNil &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) const { return vunify(*this, horn, c, glocal, hlocal); } |
@@ -284,6 +496,27 @@ | ||
284 | 496 | bool PVeriable::unify(const PVeriable &horn, ExecContextRoot *c) const { return vunify_ver(*this, horn, c, c->gl, c->hl); } |
285 | 497 | bool PVeriable::unify(const PEVeriable &horn, ExecContextRoot *c) const { return vunify_ver(*this, horn, c, c->gl, horn.vl); } |
286 | 498 | |
499 | +bool PVeriable::match_h_g(const PObject &goal, ExecContextRoot *c) const { return goal.match_g_h(*this, c); } | |
500 | +bool PVeriable::match_h_g(const PNil &goal, ExecContextRoot *c) const { return vmatch_h_g(*this, goal, c, c->hl); } | |
501 | +bool PVeriable::match_h_g(const PString &goal, ExecContextRoot *c) const { return vmatch_h_g(*this, goal, c, c->hl); } | |
502 | +bool PVeriable::match_h_g(const PDouble &goal, ExecContextRoot *c) const { return vmatch_h_g(*this, goal, c, c->hl); } | |
503 | +bool PVeriable::match_h_g(const PInteger &goal, ExecContextRoot *c) const { return vmatch_h_g(*this, goal, c, c->hl); } | |
504 | +bool PVeriable::match_h_g(const PList &goal, ExecContextRoot *c) const { return vmatch_getval_h_g(*this, goal, c, c->hl); } | |
505 | +bool PVeriable::match_h_g(const PArray &goal, ExecContextRoot *c) const { return vmatch_getval_h_g(*this, goal, c, c->hl); } | |
506 | +bool PVeriable::match_h_g(const PPredicate &goal, ExecContextRoot *c) const { return vmatch_getval_h_g(*this, goal, c, c->hl); } | |
507 | +bool PVeriable::match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return vmatch_ver_g_h(goal, *this, c, c->gl, c->hl); } | |
508 | +bool PVeriable::match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return vmatch_ver_g_h(goal, *this, c, goal.vl, c->hl); } | |
509 | + | |
510 | +bool PVeriable::match_g_h(const PNil &horn, ExecContextRoot *c) const { return vmatch_g_h(*this, horn, c, c->gl); } | |
511 | +bool PVeriable::match_g_h(const PString &horn, ExecContextRoot *c) const { return vmatch_g_h(*this, horn, c, c->gl); } | |
512 | +bool PVeriable::match_g_h(const PDouble &horn, ExecContextRoot *c) const { return vmatch_g_h(*this, horn, c, c->gl); } | |
513 | +bool PVeriable::match_g_h(const PInteger &horn, ExecContextRoot *c) const { return vmatch_g_h(*this, horn, c, c->gl); } | |
514 | +bool PVeriable::match_g_h(const PList &horn, ExecContextRoot *c) const { return vmatch_getval_g_h(*this, horn, c, c->gl); } | |
515 | +bool PVeriable::match_g_h(const PArray &horn, ExecContextRoot *c) const { return vmatch_getval_g_h(*this, horn, c, c->gl); } | |
516 | +bool PVeriable::match_g_h(const PPredicate &horn, ExecContextRoot *c) const { return vmatch_getval_g_h(*this, horn, c, c->gl); } | |
517 | +bool PVeriable::match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return vmatch_ver_g_h(*this, horn, c, c->gl, c->hl); } | |
518 | +bool PVeriable::match_g_h(const PEVeriable &horn, ExecContextRoot *c) const { return vmatch_ver_g_h(*this, horn, c, c->gl, horn.vl); } | |
519 | + | |
287 | 520 | /*************************************** PEVeriable ******************************************/ |
288 | 521 | bool PEVeriable::unify(const PObject &goal, ExecContextRoot *c, VLocal *hlocal, VLocal *glocal) const { return goal.unify(*this, c, glocal, hlocal); } |
289 | 522 | bool PEVeriable::unify(const PNil &horn, ExecContextRoot *c, VLocal *, VLocal *hlocal) const { return vunify(*this, horn, c, vl, hlocal); } |
@@ -306,14 +539,36 @@ | ||
306 | 539 | bool PEVeriable::unify(const PVeriable &horn, ExecContextRoot *c) const { return vunify_ver(*this, horn, c, vl, c->hl); } |
307 | 540 | bool PEVeriable::unify(const PEVeriable &horn, ExecContextRoot *c) const { return vunify_ver(*this, horn, c, vl, horn.vl); } |
308 | 541 | |
542 | +bool PEVeriable::match_h_g(const PObject &goal, ExecContextRoot *c) const { return goal.match_g_h(*this, c); } | |
543 | +bool PEVeriable::match_h_g(const PNil &goal, ExecContextRoot *c) const { return vmatch_h_g(*this, goal, c, vl); } | |
544 | +bool PEVeriable::match_h_g(const PString &goal, ExecContextRoot *c) const { return vmatch_h_g(*this, goal, c, vl); } | |
545 | +bool PEVeriable::match_h_g(const PDouble &goal, ExecContextRoot *c) const { return vmatch_h_g(*this, goal, c, vl); } | |
546 | +bool PEVeriable::match_h_g(const PInteger &goal, ExecContextRoot *c) const { return vmatch_h_g(*this, goal, c, vl); } | |
547 | +bool PEVeriable::match_h_g(const PList &goal, ExecContextRoot *c) const { return vmatch_getval_h_g(*this, goal, c, vl); } | |
548 | +bool PEVeriable::match_h_g(const PArray &goal, ExecContextRoot *c) const { return vmatch_getval_h_g(*this, goal, c, vl); } | |
549 | +bool PEVeriable::match_h_g(const PPredicate &goal, ExecContextRoot *c) const { return vmatch_getval_h_g(*this, goal, c, vl); } | |
550 | +bool PEVeriable::match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return vmatch_ver_g_h(goal, *this, c, c->gl, vl); } | |
551 | +bool PEVeriable::match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return vmatch_ver_g_h(goal, *this, c, goal.vl, vl); } | |
552 | + | |
553 | +bool PEVeriable::match_g_h(const PNil &horn, ExecContextRoot *c) const { return vmatch_g_h(*this, horn, c, vl); } | |
554 | +bool PEVeriable::match_g_h(const PString &horn, ExecContextRoot *c) const { return vmatch_g_h(*this, horn, c, vl); } | |
555 | +bool PEVeriable::match_g_h(const PDouble &horn, ExecContextRoot *c) const { return vmatch_g_h(*this, horn, c, vl); } | |
556 | +bool PEVeriable::match_g_h(const PInteger &horn, ExecContextRoot *c) const { return vmatch_g_h(*this, horn, c, vl); } | |
557 | +bool PEVeriable::match_g_h(const PList &horn, ExecContextRoot *c) const { return vmatch_getval_g_h(*this, horn, c, vl); } | |
558 | +bool PEVeriable::match_g_h(const PArray &horn, ExecContextRoot *c) const { return vmatch_getval_g_h(*this, horn, c, vl); } | |
559 | +bool PEVeriable::match_g_h(const PPredicate &horn, ExecContextRoot *c) const { return vmatch_getval_g_h(*this, horn, c, vl); } | |
560 | +bool PEVeriable::match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return vmatch_ver_g_h(*this, horn, c, vl, c->hl); } | |
561 | +bool PEVeriable::match_g_h(const PEVeriable &horn, ExecContextRoot *c) const { return vmatch_ver_g_h(*this, horn, c, vl, horn.vl); } | |
562 | + | |
563 | + | |
309 | 564 | /*************************************** uphorn ******************************************/ |
310 | 565 | bool PHorn::upHorn(const PPredicate &goal, ExecContext &c, bool skipnamechk) |
311 | 566 | { |
312 | 567 | if ( skipnamechk ) { |
313 | 568 | // ホーン節頭部の述語名の確認は既に終わっている |
314 | - return goal.arglist.unify( head.arglist, &c, c.gl, c.hl ); // horn.arglistがPObjextでない場合はこのように呼び出す | |
569 | + return goal.arglist.match_g_h( head.arglist, &c); // horn.arglistがPObjectでない場合はこのように呼び出す | |
315 | 570 | } else { |
316 | - return goal.unify(head, &c, c.gl, c.hl); | |
571 | + return goal.match_g_h(head, &c); // horn.arglistがPObjectでない場合はこのように呼び出す | |
317 | 572 | } |
318 | 573 | } |
319 | 574 |
@@ -172,10 +172,32 @@ | ||
172 | 172 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const { return false; } |
173 | 173 | virtual bool unify(const PWildCard &horn, ExecContextRoot *c) const { return true; } |
174 | 174 | |
175 | + //ホーン節検索時のマッチング | |
176 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const { return false; } | |
177 | + virtual bool match_h_g(const PNil &goal, ExecContextRoot *c) const { return false; } | |
178 | + virtual bool match_h_g(const PString &goal, ExecContextRoot *c) const { return false; } | |
179 | + virtual bool match_h_g(const PDouble &goal, ExecContextRoot *c) const { return false; } | |
180 | + virtual bool match_h_g(const PInteger &goal, ExecContextRoot *c) const { return false; } | |
181 | + virtual bool match_h_g(const PList &goal, ExecContextRoot *c) const { return false; } | |
182 | + virtual bool match_h_g(const PArray &goal, ExecContextRoot *c) const { return false; } | |
183 | + virtual bool match_h_g(const PPredicate &goal, ExecContextRoot *c) const { return false; } | |
184 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return false; } | |
185 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const { return false; } | |
186 | + virtual bool match_h_g(const PWildCard &goal, ExecContextRoot *c) const { return true; } | |
187 | + virtual bool match_g_h(const PNil &horn, ExecContextRoot *c) const { return false; } | |
188 | + virtual bool match_g_h(const PString &horn, ExecContextRoot *c) const { return false; } | |
189 | + virtual bool match_g_h(const PDouble &horn, ExecContextRoot *c) const { return false; } | |
190 | + virtual bool match_g_h(const PInteger &horn, ExecContextRoot *c) const { return false; } | |
191 | + virtual bool match_g_h(const PList &horn, ExecContextRoot *c) const { return false; } | |
192 | + virtual bool match_g_h(const PArray &horn, ExecContextRoot *c) const { return false; } | |
193 | + virtual bool match_g_h(const PPredicate &horn, ExecContextRoot *c) const { return false; } | |
194 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return false; } | |
195 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const { return false; } | |
196 | + virtual bool match_g_h(const PWildCard &horn, ExecContextRoot *c) const { return true; } | |
175 | 197 | |
176 | 198 | // 値の取得(unify時に使用、必要なら代入用の変更PEVariableを作成する) |
177 | 199 | virtual const PObject *getval( ExecContextRoot *) const { return this; } |
178 | - virtual const PObject *getval2( ExecContextRoot *, VLocal *) const { return this; } | |
200 | + virtual const PObject *getval2( ExecContextRoot *, VLocal *) const { return this; } | |
179 | 201 | |
180 | 202 | // 値の取得 |
181 | 203 | virtual const char *c_str() const { return 0; }; |
@@ -298,6 +320,17 @@ | ||
298 | 320 | virtual bool unify(const PVeriable &horn, ExecContextRoot *c) const; |
299 | 321 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const; |
300 | 322 | |
323 | + //ホーン節検索時のマッチング | |
324 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const; | |
325 | + virtual bool match_h_g(const PNil &goal, ExecContextRoot *c) const; | |
326 | + virtual bool match_h_g(const PList &goal, ExecContextRoot *c) const; | |
327 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const; | |
328 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const; | |
329 | + virtual bool match_g_h(const PNil &horn, ExecContextRoot *c) const; | |
330 | + virtual bool match_g_h(const PList &horn, ExecContextRoot *c) const; | |
331 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const; | |
332 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const; | |
333 | + | |
301 | 334 | // 変換して値を取得 |
302 | 335 | virtual bool cnv_string(string &value) const { return true; }; |
303 | 336 |
@@ -391,6 +424,15 @@ | ||
391 | 424 | virtual bool unify(const PVeriable &horn, ExecContextRoot *c) const; |
392 | 425 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const; |
393 | 426 | |
427 | + //ホーン節検索時のマッチング | |
428 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const; | |
429 | + virtual bool match_h_g(const PString &goal, ExecContextRoot *c) const; | |
430 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const; | |
431 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const; | |
432 | + virtual bool match_g_h(const PString &horn, ExecContextRoot *c) const; | |
433 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const; | |
434 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const; | |
435 | + | |
394 | 436 | // 値の取得 |
395 | 437 | virtual const char *c_str() const { return value.c_str(); }; |
396 | 438 |
@@ -504,6 +546,17 @@ | ||
504 | 546 | virtual bool unify(const PVeriable &horn, ExecContextRoot *c) const; |
505 | 547 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const; |
506 | 548 | |
549 | + //ホーン節検索時のマッチング | |
550 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const; | |
551 | + virtual bool match_h_g(const PDouble &goal, ExecContextRoot *c) const; | |
552 | + virtual bool match_h_g(const PInteger &goal, ExecContextRoot *c) const; | |
553 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const; | |
554 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const; | |
555 | + virtual bool match_g_h(const PDouble &horn, ExecContextRoot *c) const; | |
556 | + virtual bool match_g_h(const PInteger &horn, ExecContextRoot *c) const; | |
557 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const; | |
558 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const; | |
559 | + | |
507 | 560 | //値の取得 |
508 | 561 | virtual const double *c_double() const { return &value; }; |
509 | 562 |
@@ -624,6 +677,18 @@ | ||
624 | 677 | virtual bool unify(const PVeriable &horn, ExecContextRoot *c) const; |
625 | 678 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const; |
626 | 679 | |
680 | + //ホーン節検索時のマッチング | |
681 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const; | |
682 | + virtual bool match_h_g(const PDouble &goal, ExecContextRoot *c) const; | |
683 | + virtual bool match_h_g(const PInteger &goal, ExecContextRoot *c) const; | |
684 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const; | |
685 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const; | |
686 | + virtual bool match_g_h(const PDouble &horn, ExecContextRoot *c) const; | |
687 | + virtual bool match_g_h(const PInteger &horn, ExecContextRoot *c) const; | |
688 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const; | |
689 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const; | |
690 | + | |
691 | + | |
627 | 692 | // 値の取得 |
628 | 693 | mutable PINTEGER32 value32; |
629 | 694 | virtual const PINTEGER32 *p_integer32(ExecContextRoot *) const { |
@@ -828,6 +893,17 @@ | ||
828 | 893 | virtual bool unify(const PVeriable &horn, ExecContextRoot *c) const; |
829 | 894 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const; |
830 | 895 | |
896 | + //ホーン節検索時のマッチング | |
897 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const; | |
898 | + virtual bool match_h_g(const PNil &goal, ExecContextRoot *c) const; | |
899 | + virtual bool match_h_g(const PList &goal, ExecContextRoot *c) const; | |
900 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const; | |
901 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const; | |
902 | + virtual bool match_g_h(const PNil &horn, ExecContextRoot *c) const; | |
903 | + virtual bool match_g_h(const PList &horn, ExecContextRoot *c) const; | |
904 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const; | |
905 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const; | |
906 | + | |
831 | 907 | // 値の取得 |
832 | 908 | virtual const PObject *getval( ExecContextRoot *) const; |
833 | 909 | virtual const PObject *getval2( ExecContextRoot *c, VLocal *vlocal) const; |
@@ -1135,6 +1211,18 @@ | ||
1135 | 1211 | virtual bool unify(const PVeriable &horn, ExecContextRoot *c) const; |
1136 | 1212 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const; |
1137 | 1213 | |
1214 | + //ホーン節検索時のマッチング | |
1215 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const; | |
1216 | + virtual bool match_h_g(const PNil &goal, ExecContextRoot *c) const; | |
1217 | + virtual bool match_h_g(const PArray &goal, ExecContextRoot *c) const; | |
1218 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const; | |
1219 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const; | |
1220 | + virtual bool match_g_h(const PNil &horn, ExecContextRoot *c) const; | |
1221 | + virtual bool match_g_h(const PArray &horn, ExecContextRoot *c) const; | |
1222 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const; | |
1223 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const; | |
1224 | + | |
1225 | + | |
1138 | 1226 | // 値の取得 |
1139 | 1227 | virtual const PObject *getval( ExecContextRoot *c) const; |
1140 | 1228 | virtual const PObject *getval2( ExecContextRoot *c, VLocal *vlocal) const; |
@@ -1372,6 +1460,15 @@ | ||
1372 | 1460 | virtual bool unify(const PVeriable &horn, ExecContextRoot *c) const; |
1373 | 1461 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const; |
1374 | 1462 | |
1463 | + //ホーン節検索時のマッチング | |
1464 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const; | |
1465 | + virtual bool match_h_g(const PPredicate &goal, ExecContextRoot *c) const; | |
1466 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const; | |
1467 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const; | |
1468 | + virtual bool match_g_h(const PPredicate &horn, ExecContextRoot *c) const; | |
1469 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const; | |
1470 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const; | |
1471 | + | |
1375 | 1472 | // 値の取得 |
1376 | 1473 | virtual const PObject *getval( ExecContextRoot *c) const; |
1377 | 1474 | virtual const PObject *getval2( ExecContextRoot *c, VLocal *vlocal) const; |
@@ -1470,6 +1567,27 @@ | ||
1470 | 1567 | virtual bool unify(const PVeriable &horn, ExecContextRoot *c) const; |
1471 | 1568 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const; |
1472 | 1569 | |
1570 | + //ホーン節検索時のマッチング | |
1571 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const; | |
1572 | + virtual bool match_h_g(const PNil &goal, ExecContextRoot *c) const; | |
1573 | + virtual bool match_h_g(const PString &goal, ExecContextRoot *c) const; | |
1574 | + virtual bool match_h_g(const PDouble &goal, ExecContextRoot *c) const; | |
1575 | + virtual bool match_h_g(const PInteger &goal, ExecContextRoot *c) const; | |
1576 | + virtual bool match_h_g(const PList &goal, ExecContextRoot *c) const; | |
1577 | + virtual bool match_h_g(const PArray &goal, ExecContextRoot *c) const; | |
1578 | + virtual bool match_h_g(const PPredicate &goal, ExecContextRoot *c) const; | |
1579 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const; | |
1580 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const; | |
1581 | + virtual bool match_g_h(const PNil &horn, ExecContextRoot *c) const; | |
1582 | + virtual bool match_g_h(const PString &horn, ExecContextRoot *c) const; | |
1583 | + virtual bool match_g_h(const PDouble &horn, ExecContextRoot *c) const; | |
1584 | + virtual bool match_g_h(const PInteger &horn, ExecContextRoot *c) const; | |
1585 | + virtual bool match_g_h(const PList &horn, ExecContextRoot *c) const; | |
1586 | + virtual bool match_g_h(const PArray &horn, ExecContextRoot *c) const; | |
1587 | + virtual bool match_g_h(const PPredicate &horn, ExecContextRoot *c) const; | |
1588 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const; | |
1589 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const; | |
1590 | + | |
1473 | 1591 | // 値の取得 |
1474 | 1592 | virtual const PObject *getval( ExecContextRoot *c) const ; |
1475 | 1593 | virtual const PObject *getval2( ExecContextRoot *c, VLocal *vlocal) const ; |
@@ -1558,6 +1676,29 @@ | ||
1558 | 1676 | virtual bool unify(const PWildCard &horn, ExecContextRoot *c) const { return true; } |
1559 | 1677 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const{ return true; } |
1560 | 1678 | |
1679 | + //ホーン節検索時のマッチング | |
1680 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const { return true; } | |
1681 | + virtual bool match_h_g(const PNil &goal, ExecContextRoot *c) const { return true; } | |
1682 | + virtual bool match_h_g(const PString &goal, ExecContextRoot *c) const { return true; } | |
1683 | + virtual bool match_h_g(const PDouble &goal, ExecContextRoot *c) const { return true; } | |
1684 | + virtual bool match_h_g(const PInteger &goal, ExecContextRoot *c) const { return true; } | |
1685 | + virtual bool match_h_g(const PList &goal, ExecContextRoot *c) const { return true; } | |
1686 | + virtual bool match_h_g(const PArray &goal, ExecContextRoot *c) const { return true; } | |
1687 | + virtual bool match_h_g(const PPredicate &goal, ExecContextRoot *c) const { return true; } | |
1688 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const { return true; } | |
1689 | + virtual bool match_h_g(const PWildCard &goal, ExecContextRoot *c) const { return true; } | |
1690 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const{ return true; } | |
1691 | + virtual bool match_g_h(const PNil &horn, ExecContextRoot *c) const { return true; } | |
1692 | + virtual bool match_g_h(const PString &horn, ExecContextRoot *c) const { return true; } | |
1693 | + virtual bool match_g_h(const PDouble &horn, ExecContextRoot *c) const { return true; } | |
1694 | + virtual bool match_g_h(const PInteger &horn, ExecContextRoot *c) const { return true; } | |
1695 | + virtual bool match_g_h(const PList &horn, ExecContextRoot *c) const { return true; } | |
1696 | + virtual bool match_g_h(const PArray &horn, ExecContextRoot *c) const { return true; } | |
1697 | + virtual bool match_g_h(const PPredicate &horn, ExecContextRoot *c) const { return true; } | |
1698 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const { return true; } | |
1699 | + virtual bool match_g_h(const PWildCard &horn, ExecContextRoot *c) const { return true; } | |
1700 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const{ return true; } | |
1701 | + | |
1561 | 1702 | // 値の取得 |
1562 | 1703 | // 代入 |
1563 | 1704 |
@@ -1638,6 +1779,27 @@ | ||
1638 | 1779 | virtual bool unify(const PVeriable &horn, ExecContextRoot *c) const; |
1639 | 1780 | virtual bool unify(const PEVeriable &horn, ExecContextRoot *c) const; |
1640 | 1781 | |
1782 | + //ホーン節検索時のマッチング | |
1783 | + virtual bool match_h_g(const PObject &goal, ExecContextRoot *c) const; | |
1784 | + virtual bool match_h_g(const PNil &goal, ExecContextRoot *c) const; | |
1785 | + virtual bool match_h_g(const PString &goal, ExecContextRoot *c) const; | |
1786 | + virtual bool match_h_g(const PDouble &goal, ExecContextRoot *c) const; | |
1787 | + virtual bool match_h_g(const PInteger &goal, ExecContextRoot *c) const; | |
1788 | + virtual bool match_h_g(const PList &goal, ExecContextRoot *c) const; | |
1789 | + virtual bool match_h_g(const PArray &goal, ExecContextRoot *c) const; | |
1790 | + virtual bool match_h_g(const PPredicate &goal, ExecContextRoot *c) const; | |
1791 | + virtual bool match_h_g(const PVeriable &goal, ExecContextRoot *c) const; | |
1792 | + virtual bool match_h_g(const PEVeriable &goal, ExecContextRoot *c) const; | |
1793 | + virtual bool match_g_h(const PNil &horn, ExecContextRoot *c) const; | |
1794 | + virtual bool match_g_h(const PString &horn, ExecContextRoot *c) const; | |
1795 | + virtual bool match_g_h(const PDouble &horn, ExecContextRoot *c) const; | |
1796 | + virtual bool match_g_h(const PInteger &horn, ExecContextRoot *c) const; | |
1797 | + virtual bool match_g_h(const PList &horn, ExecContextRoot *c) const; | |
1798 | + virtual bool match_g_h(const PArray &horn, ExecContextRoot *c) const; | |
1799 | + virtual bool match_g_h(const PPredicate &horn, ExecContextRoot *c) const; | |
1800 | + virtual bool match_g_h(const PVeriable &horn, ExecContextRoot *c) const; | |
1801 | + virtual bool match_g_h(const PEVeriable &horn, ExecContextRoot *c) const; | |
1802 | + | |
1641 | 1803 | // 値の取得 |
1642 | 1804 | virtual const PObject *getval( ExecContextRoot *c) const; |
1643 | 1805 | virtual const PObject *getval2( ExecContextRoot *c, VLocal *) const; |
@@ -705,10 +705,11 @@ | ||
705 | 705 | // 親のローカル変数の値をcloneする、 |
706 | 706 | for ( size_t i = 0; i < p->hlocal.size(); i++ ) { |
707 | 707 | const PObject *o = p->hlocal[i]; |
708 | - if ( o != 0 && !o->isc() ) { | |
708 | + if ( o != 0 /*&& !o->isc()*/ ) { | |
709 | 709 | p->hlocal[i] = o->getval2(p,&p->hlocal)->clone(&p->objs); |
710 | 710 | } |
711 | 711 | } |
712 | + | |
712 | 713 | for ( size_t i = 0; i < p->goalidx; i++ ) { |
713 | 714 | ExecContextRoot *e = p->ecs[i]; |
714 | 715 | if ( e ) { |
@@ -23,12 +23,12 @@ | ||
23 | 23 | |
24 | 24 | // 定数 |
25 | 25 | #ifdef ___X64____ |
26 | -#define VERSION_TEXT "ADP Ver 0.82.0294 X64 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n" | |
26 | +#define VERSION_TEXT "ADP Ver 0.82.0295 X64 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n" | |
27 | 27 | #else |
28 | 28 | #if _WIN32 |
29 | -#define VERSION_TEXT "ADP Ver 0.82.0294 x86 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n" | |
29 | +#define VERSION_TEXT "ADP Ver 0.82.0295 x86 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n" | |
30 | 30 | #else |
31 | -#define VERSION_TEXT "ADP Ver 0.82.0294 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n" | |
31 | +#define VERSION_TEXT "ADP Ver 0.82.0295 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n" | |
32 | 32 | #endif |
33 | 33 | #endif |
34 | 34 |