unify系の整理が一通り終わった
@@ -28,7 +28,7 @@ | ||
28 | 28 | PObjectArray::const_iterator i = pred->begin(); |
29 | 29 | PObjectArray::const_iterator end = pred->end(); |
30 | 30 | for (; i < end; i++ ) { |
31 | - const PObject * item = (*i)->getval( this, gl); | |
31 | + const PObject * item = (*i)->getval( this); | |
32 | 32 | item->err(); |
33 | 33 | } |
34 | 34 | return true; |
@@ -42,7 +42,7 @@ | ||
42 | 42 | PObjectArray::const_iterator i = pred->begin(); |
43 | 43 | PObjectArray::const_iterator end = pred->end(); |
44 | 44 | for (; i < end; i++ ) { |
45 | - (*i)->getval( this, gl)->err(); | |
45 | + (*i)->getval( this)->err(); | |
46 | 46 | } |
47 | 47 | get_gc()->err("\n"); |
48 | 48 | return true; |
@@ -58,7 +58,7 @@ | ||
58 | 58 | PObjectArray::const_iterator i = pred->begin(); |
59 | 59 | PObjectArray::const_iterator end = pred->end(); |
60 | 60 | for (; i < end; i++ ) { |
61 | - (*i)->getval( this, gl)->prt(); | |
61 | + (*i)->getval( this)->prt(); | |
62 | 62 | } |
63 | 63 | return true; |
64 | 64 | }; |
@@ -72,7 +72,7 @@ | ||
72 | 72 | PObjectArray::const_iterator i = pred->begin(); |
73 | 73 | PObjectArray::const_iterator end = pred->end(); |
74 | 74 | for (; i < end; i++ ) { |
75 | - const PObject * item = (*i)->getval( this, gl); | |
75 | + const PObject * item = (*i)->getval( this); | |
76 | 76 | item->prt(); |
77 | 77 | } |
78 | 78 | get_gc()->prt("\n"); |
@@ -221,7 +221,7 @@ | ||
221 | 221 | if ( pred->size() != 2 ) return RERR_argment_number(excp, 2); |
222 | 222 | const PObject **args = &pred->arglist.value.front(); |
223 | 223 | |
224 | - const PINTEGER *a1 = args[0]->c_integer(this); | |
224 | + const PINTEGER *a1 = args[0]->p_integer(this); | |
225 | 225 | if ( a1 ) { |
226 | 226 | const PInteger *result = pmm.newPInteger( pobjs, - *a1); |
227 | 227 | return args[1]->unify( *result, this); |
@@ -279,8 +279,8 @@ | ||
279 | 279 | const PObject *args0 = args[0]; |
280 | 280 | const PObject *args1 = args[1]; |
281 | 281 | // 両方が整数の場合 |
282 | - const PINTEGER *a1 = args0->c_integer(this); | |
283 | - const PINTEGER *a2 = args1->c_integer(this); | |
282 | + const PINTEGER *a1 = args0->p_integer(this); | |
283 | + const PINTEGER *a2 = args1->p_integer(this); | |
284 | 284 | if ( a1 && a2 ) { |
285 | 285 | PObject *dst = pmm.newPInteger( pobjs, mypow(*a1, *a2)); |
286 | 286 | return args[2]->unify(*dst, this); |
@@ -320,8 +320,8 @@ | ||
320 | 320 | const PObject **args = &pred->arglist.value.front(); |
321 | 321 | |
322 | 322 | // 試しの最適化 |
323 | - const PINTEGER *a1 = args[0]->c_integer(this); | |
324 | - const PINTEGER *a2 = args[1]->c_integer(this); | |
323 | + const PINTEGER *a1 = args[0]->p_integer(this); | |
324 | + const PINTEGER *a2 = args[1]->p_integer(this); | |
325 | 325 | if ( a1 && a2 ) { |
326 | 326 | const PInteger *result = pmm.newPInteger( pobjs, sign(*a1 - *a2)); |
327 | 327 | return args[2]->unify( *result, this); |
@@ -342,8 +342,8 @@ | ||
342 | 342 | const PObject **args = &pred->arglist.value.front(); |
343 | 343 | |
344 | 344 | // 試しの最適化 |
345 | - const PINTEGER *a1 = args[0]->c_integer(this); | |
346 | - const PINTEGER *a2 = args[1]->c_integer(this); | |
345 | + const PINTEGER *a1 = args[0]->p_integer(this); | |
346 | + const PINTEGER *a2 = args[1]->p_integer(this); | |
347 | 347 | if ( a1 && a2 ) { |
348 | 348 | return *a1 < *a2; |
349 | 349 | } |
@@ -361,8 +361,8 @@ | ||
361 | 361 | const PObject **args = &pred->arglist.value.front(); |
362 | 362 | |
363 | 363 | // 試しの最適化 |
364 | - const PINTEGER *a1 = args[0]->c_integer(this); | |
365 | - const PINTEGER *a2 = args[1]->c_integer(this); | |
364 | + const PINTEGER *a1 = args[0]->p_integer(this); | |
365 | + const PINTEGER *a2 = args[1]->p_integer(this); | |
366 | 366 | if ( a1 && a2 ) { |
367 | 367 | return *a1 <= *a2; |
368 | 368 | } |
@@ -380,8 +380,8 @@ | ||
380 | 380 | const PObject **args = &pred->arglist.value.front(); |
381 | 381 | |
382 | 382 | // 試しの最適化 |
383 | - const PINTEGER *a1 = args[0]->c_integer(this); | |
384 | - const PINTEGER *a2 = args[1]->c_integer(this); | |
383 | + const PINTEGER *a1 = args[0]->p_integer(this); | |
384 | + const PINTEGER *a2 = args[1]->p_integer(this); | |
385 | 385 | if ( a1 && a2 ) { |
386 | 386 | return *a1 > *a2; |
387 | 387 | } |
@@ -399,8 +399,8 @@ | ||
399 | 399 | const PObject **args = &pred->arglist.value.front(); |
400 | 400 | |
401 | 401 | // 試しの最適化 |
402 | - const PINTEGER *a1 = args[0]->c_integer(this); | |
403 | - const PINTEGER *a2 = args[1]->c_integer(this); | |
402 | + const PINTEGER *a1 = args[0]->p_integer(this); | |
403 | + const PINTEGER *a2 = args[1]->p_integer(this); | |
404 | 404 | if ( a1 && a2 ) { |
405 | 405 | return *a1 >= *a2; |
406 | 406 | } |
@@ -451,7 +451,7 @@ | ||
451 | 451 | const PObject **args = &pred->arglist.value.front(); |
452 | 452 | |
453 | 453 | // 試しの最適化 |
454 | - const PINTEGER *a1 = args[0]->c_integer(this); | |
454 | + const PINTEGER *a1 = args[0]->p_integer(this); | |
455 | 455 | if ( a1 ) { |
456 | 456 | const PInteger *result = pmm.newPInteger( pobjs, ~*a1); |
457 | 457 | return args[1]->unify( *result, this); |
@@ -36,7 +36,7 @@ | ||
36 | 36 | time_t now_t; |
37 | 37 | time(&now_t); |
38 | 38 | if ( pred->size() == 2 ) { |
39 | - const PINTEGER *dif = (*pred)[0]->c_integer(this); | |
39 | + const PINTEGER *dif = (*pred)[0]->p_integer(this); | |
40 | 40 | if ( !dif ) return RERR_argment_type(excp, 0); |
41 | 41 | now_t += *dif; |
42 | 42 | } |
@@ -75,8 +75,8 @@ | ||
75 | 75 | } |
76 | 76 | } else if ( parameter->c_double() ) { |
77 | 77 | stmt, *parameter->c_double(); |
78 | - } else if ( parameter->c_integer32(this) ) { | |
79 | - stmt, *parameter->c_integer32(this); | |
78 | + } else if ( parameter->p_integer32(this) ) { | |
79 | + stmt, *parameter->p_integer32(this); | |
80 | 80 | } else if ( parameter->c_integer() ) { |
81 | 81 | stmt, *parameter->c_integer(); |
82 | 82 | } else { |
@@ -19,35 +19,37 @@ | ||
19 | 19 | #include "adp.h" |
20 | 20 | |
21 | 21 | /*************************************** GetValsOne/GetValuesTwo() ******************************************/ |
22 | -template<class RETURN, class V, class EC, class VL, class FUNC> inline RETURN GetValsOne( const V &v, EC args, VL local, FUNC fn) | |
22 | +template<class RETURN, class V, class ARG1, class VL, class FUNC> inline RETURN GetValsOne( const V &v, ARG1 arg, VL local, FUNC fn, RETURN def) | |
23 | 23 | { |
24 | 24 | assert( v.idx < local->size()); |
25 | 25 | const PObject *item = (*local)[v.idx]; |
26 | 26 | if ( item != 0 ) { |
27 | - return (item->*fn)(args); | |
27 | + return (item->*fn)(arg); | |
28 | 28 | } else { |
29 | - return 0; | |
29 | + return def; | |
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | -/*************************************** getPridicate() ******************************************/ | |
34 | -const PPredicate *PVeriable::getPredicate(VLocal *local) const { return ::GetValsOne<const PPredicate*>( *this, local, local, &PObject::getPredicate); } | |
35 | -const PPredicate *PEVeriable::getPredicate(VLocal *local) const { return ::GetValsOne<const PPredicate*>( *this, local, local, &PObject::getPredicate); } | |
36 | - | |
37 | -/*************************************** getPridicateName() ******************************************/ | |
38 | -template<class V> inline const string *getPredicateName( V &v, bool &docache, VLocal *local) | |
33 | +template<class RETURN, class V, class ARG1, class ARG2, class VL, class FUNC> inline RETURN GetValsTwo( const V &v, ARG1 arg1, ARG2 arg2, VL local, FUNC fn, RETURN def) | |
39 | 34 | { |
40 | - docache = false; | |
35 | + assert( v.idx < local->size()); | |
41 | 36 | const PObject *item = (*local)[v.idx]; |
42 | - if ( item == 0 ) { | |
43 | - return 0; | |
44 | - } else { | |
45 | - return item->getPredicateName(docache,local); | |
37 | + if ( item != 0 ) { | |
38 | + return (item->*fn)(arg1, arg2); | |
39 | + } else { | |
40 | + return def; | |
46 | 41 | } |
47 | 42 | } |
48 | -const string *PVeriable::getPredicateName(bool &docache, VLocal *local) const { return ::getPredicateName( *this, docache, local); } | |
49 | -const string *PEVeriable::getPredicateName(bool &docache, VLocal *local) const { return ::getPredicateName( *this, docache, local); } | |
50 | 43 | |
44 | + | |
45 | +/*************************************** getPridicate() ******************************************/ | |
46 | +const PPredicate *PVeriable::getPredicate(VLocal *local) const { return ::GetValsOne<const PPredicate*>( *this, local, local, &PObject::getPredicate, 0); } | |
47 | +const PPredicate *PEVeriable::getPredicate(VLocal *local) const { return ::GetValsOne<const PPredicate*>( *this, local, local, &PObject::getPredicate, 0); } | |
48 | + | |
49 | +/*************************************** getPridicateName() ******************************************/ | |
50 | +const string *PVeriable::getPredicateName(bool &docache, VLocal *local) const { docache = false; return ::GetValsTwo<const string *>( *this, docache, local, local, &PObject::getPredicateName, 0); } | |
51 | +const string *PEVeriable::getPredicateName(bool &docache, VLocal *local) const { docache = false; return ::GetValsTwo<const string *>( *this, docache, local, local, &PObject::getPredicateName, 0); } | |
52 | + | |
51 | 53 | /*************************************** unify ******************************************/ |
52 | 54 | |
53 | 55 | // 変項のunify本体で使うテンプレート関数 |
@@ -67,7 +69,7 @@ | ||
67 | 69 | { |
68 | 70 | const PObject *gitem = (*glocal)[goal.idx]; |
69 | 71 | if ( gitem == 0 ) { |
70 | - const PObject *p = horn.getval(c, hlocal); | |
72 | + const PObject *p = horn.getval2(c, hlocal); | |
71 | 73 | (*glocal)[goal.idx] = p; |
72 | 74 | if ( p->isc() ) return true; |
73 | 75 | } else { |
@@ -90,12 +92,12 @@ | ||
90 | 92 | if ( hval != 0 ) { |
91 | 93 | return hval->unify( *gval, c, hlocal, glocal); |
92 | 94 | } else { |
93 | - const PObject *p = gval->getval(c, glocal); | |
95 | + const PObject *p = gval->getval2(c, glocal); | |
94 | 96 | (*hlocal)[horn.idx] = p; |
95 | 97 | if ( p->isc() ) return true; |
96 | 98 | } |
97 | 99 | } else if ( hval != 0 ) { |
98 | - const PObject *p = hval->getval(c, hlocal); | |
100 | + const PObject *p = hval->getval2(c, hlocal); | |
99 | 101 | (*glocal)[goal.idx] = p; |
100 | 102 | if ( p->isc() ) return true; |
101 | 103 | } |
@@ -332,12 +334,12 @@ | ||
332 | 334 | return lo ? lo : this; |
333 | 335 | } |
334 | 336 | |
335 | -const PObject *PList::getval( ExecContextRoot *c, VLocal *vlocal) const | |
337 | +const PObject *PList::getval2( ExecContextRoot *c, VLocal *vlocal) const | |
336 | 338 | { |
337 | 339 | if ( constant ) return this; |
338 | 340 | PList *lo = 0; |
339 | - const PObject *l = lvalue->getval(c, vlocal); | |
340 | - const PObject *r = rvalue->getval(c, vlocal); | |
341 | + const PObject *l = lvalue->getval2(c, vlocal); | |
342 | + const PObject *r = rvalue->getval2(c, vlocal); | |
341 | 343 | if ( l != lvalue || r != rvalue ) { |
342 | 344 | lo = pmm.newPList(c->pobjs, const_cast<PObject*>(l), const_cast<PObject*>(r)); |
343 | 345 | } |
@@ -364,13 +366,13 @@ | ||
364 | 366 | } |
365 | 367 | |
366 | 368 | |
367 | -const PObject *PArray::getval( ExecContextRoot *c, VLocal *vlocal) const | |
369 | +const PObject *PArray::getval2( ExecContextRoot *c, VLocal *vlocal) const | |
368 | 370 | { |
369 | 371 | if ( constant ) return this; |
370 | 372 | PArray *po = 0; |
371 | 373 | |
372 | 374 | for ( PObjectArray::const_iterator i = value.begin(); i < value.end(); i++ ) { |
373 | - const PObject *p = (*i)->getval( c, vlocal); | |
375 | + const PObject *p = (*i)->getval2( c, vlocal); | |
374 | 376 | if ( p != *i && po == 0 ) { |
375 | 377 | po = pmm.newPArray(c->pobjs, *this); |
376 | 378 | } |
@@ -397,12 +399,12 @@ | ||
397 | 399 | return this; |
398 | 400 | } |
399 | 401 | |
400 | -const PObject *PPredicate::getval( ExecContextRoot *c, VLocal *vlocal) const | |
402 | +const PObject *PPredicate::getval2( ExecContextRoot *c, VLocal *vlocal) const | |
401 | 403 | { |
402 | 404 | if ( constant ) return this; |
403 | 405 | |
404 | - const PObject *no = name->getval(c, vlocal); | |
405 | - const PArray *ao = dynamic_cast<const PArray *>(arglist.getval( c, vlocal)); | |
406 | + const PObject *no = name->getval2(c, vlocal); | |
407 | + const PArray *ao = dynamic_cast<const PArray *>(arglist.getval2( c, vlocal)); | |
406 | 408 | |
407 | 409 | if ( no != name || ao != &arglist ) { |
408 | 410 | PPredicate *po = pmm.newPPredicate(c->pobjs,nspace,no,ao,opt); |
@@ -424,7 +426,7 @@ | ||
424 | 426 | } |
425 | 427 | } |
426 | 428 | |
427 | -const PObject *PVeriable::getval( ExecContextRoot *c, VLocal *vlocal) const | |
429 | +const PObject *PVeriable::getval2( ExecContextRoot *c, VLocal *vlocal) const | |
428 | 430 | { |
429 | 431 | assert( idx < vlocal->size()); |
430 | 432 | const PObject *item = (*vlocal)[idx]; |
@@ -432,78 +434,15 @@ | ||
432 | 434 | PObject *po = pmm.newPEVeriable(c->pobjs, *this, vlocal); |
433 | 435 | return po; |
434 | 436 | } else { |
435 | - return item->getval(c, vlocal); | |
437 | + return item->getval2(c, vlocal); | |
436 | 438 | } |
437 | 439 | } |
438 | 440 | |
439 | -const PObject *PEVeriable::getval( ExecContextRoot *c) const | |
440 | -{ | |
441 | - VLocal *local = vl; | |
442 | - const PObject *item = (*local)[idx]; | |
443 | - if ( item == 0 ) { | |
444 | - return this; | |
445 | - } else { | |
446 | - return item->getval(c); | |
447 | - } | |
448 | -} | |
441 | +const PObject *PEVeriable::getval( ExecContextRoot *c) const { return GetValsOne<const PObject *>( *this, c, vl, &PObject::getval, this); } | |
442 | +const PObject *PEVeriable::getval2( ExecContextRoot *c, VLocal *) const { return GetValsTwo<const PObject *>( *this, c, vl, vl, &PObject::getval2, this); } | |
449 | 443 | |
450 | -const PObject *PEVeriable::getval( ExecContextRoot *c, VLocal *) const | |
451 | -{ | |
452 | - VLocal *local = vl; | |
453 | - const PObject *item = (*local)[idx]; | |
454 | - if ( item == 0 ) { | |
455 | - return this; | |
456 | - } else { | |
457 | - return item->getval(c, local); | |
458 | - } | |
459 | -} | |
460 | - | |
461 | 444 | /*************************************** c_integer?? ******************************************/ |
462 | -const PINTEGER32 *PVeriable::c_integer32(ExecContextRoot *c) const | |
463 | -{ | |
464 | -// return GetValsOne<const PINTEGER32*, PVeriable, ExecContextRoot *, VLocal *, const PINTEGER32 *( PObject::* )(ExecContextRoot *) const> | |
465 | - return GetValsOne<const PINTEGER32*>( *this, c, c->gl, &PObject::c_integer32); | |
466 | -#if 0 | |
467 | - assert( idx < c->gl->size()); | |
468 | - const PObject *item = (*c->gl)[idx]; | |
469 | - if ( item == 0 ) { | |
470 | - return 0; | |
471 | - } else { | |
472 | - return item->c_integer32(c); | |
473 | - } | |
474 | -#endif | |
475 | -} | |
476 | - | |
477 | -const PINTEGER *PVeriable::c_integer(ExecContextRoot *c) const | |
478 | -{ | |
479 | - assert( idx < c->gl->size()); | |
480 | - const PObject *item = (*c->gl)[idx]; | |
481 | - if ( item == 0 ) { | |
482 | - return 0; | |
483 | - } else { | |
484 | - return item->c_integer(c); | |
485 | - } | |
486 | -} | |
487 | - | |
488 | -const PINTEGER32 *PEVeriable::c_integer32(ExecContextRoot *c) const | |
489 | -{ | |
490 | - VLocal *local = vl; | |
491 | - const PObject *item = (*local)[idx]; | |
492 | - if ( item == 0 ) { | |
493 | - return 0; | |
494 | - } else { | |
495 | - return item->c_integer32(c); | |
496 | - } | |
497 | -} | |
498 | - | |
499 | - | |
500 | -const PINTEGER *PEVeriable::c_integer(ExecContextRoot *c) const | |
501 | -{ | |
502 | - VLocal *local = vl; | |
503 | - const PObject *item = (*local)[idx]; | |
504 | - if ( item == 0 ) { | |
505 | - return 0; | |
506 | - } else { | |
507 | - return item->c_integer(c); | |
508 | - } | |
509 | -} | |
445 | +const PINTEGER32 *PVeriable::p_integer32(ExecContextRoot *c) const { return GetValsOne<const PINTEGER32*>( *this, c, c->gl, &PObject::p_integer32, 0); } | |
446 | +const PINTEGER *PVeriable::p_integer(ExecContextRoot *c) const { return GetValsOne<const PINTEGER*>( *this, c, c->gl, &PObject::p_integer, 0); } | |
447 | +const PINTEGER32 *PEVeriable::p_integer32(ExecContextRoot *c) const { return GetValsOne<const PINTEGER32*>( *this, c, vl, &PObject::p_integer32, 0); } | |
448 | +const PINTEGER *PEVeriable::p_integer(ExecContextRoot *c) const { return GetValsOne<const PINTEGER*>( *this, c, vl, &PObject::p_integer, 0); } |
@@ -176,19 +176,15 @@ | ||
176 | 176 | |
177 | 177 | // 値の取得(unify時に使用、必要なら代入用の変更PEVariableを作成する) |
178 | 178 | virtual const PObject *getval( ExecContextRoot *) const { return this; } |
179 | - virtual const PObject *getval( ExecContextRoot *, VLocal *) const { return this; } | |
179 | + virtual const PObject *getval2( ExecContextRoot *, VLocal *) const { return this; } | |
180 | 180 | |
181 | 181 | // 値の取得 |
182 | 182 | virtual const char *c_str() const { return 0; }; |
183 | 183 | virtual const double *c_double() const { return 0; }; |
184 | 184 | virtual const PINTEGER *c_integer() const { return 0; }; |
185 | - virtual const PINTEGER32 *c_integer32(ExecContextRoot *) const { return 0; }; | |
186 | - virtual const PINTEGER *c_integer(ExecContextRoot *) const { return 0; }; | |
185 | + virtual const PINTEGER *p_integer(ExecContextRoot *) const { return 0; }; | |
186 | + virtual const PINTEGER32 *p_integer32(ExecContextRoot *) const { return 0; }; | |
187 | 187 | |
188 | - typedef const PINTEGER32 *(func_c_integer32)(ExecContextRoot *) const; | |
189 | - typedef const PINTEGER *(func_c_integer)(ExecContextRoot *) const; | |
190 | - | |
191 | - | |
192 | 188 | // ラベルの取得(変数の名前の取得:PArrayのハッシュで使用) |
193 | 189 | virtual const char *label() const { return 0; }; |
194 | 190 |
@@ -636,7 +632,7 @@ | ||
636 | 632 | |
637 | 633 | // 値の取得 |
638 | 634 | mutable PINTEGER32 value32; |
639 | - virtual const PINTEGER32 *c_integer32(ExecContextRoot *) const { | |
635 | + virtual const PINTEGER32 *p_integer32(ExecContextRoot *) const { | |
640 | 636 | if ( value <= INT_MAX ) { |
641 | 637 | value32 = (PINTEGER32)value; |
642 | 638 | return &value32; |
@@ -645,7 +641,7 @@ | ||
645 | 641 | } |
646 | 642 | }; |
647 | 643 | virtual const PINTEGER *c_integer() const { return &value; }; |
648 | - virtual const PINTEGER *c_integer(ExecContextRoot *) const { return &value; }; | |
644 | + virtual const PINTEGER *p_integer(ExecContextRoot *) const { return &value; }; | |
649 | 645 | |
650 | 646 | // 変換して値を取得 |
651 | 647 | void NOALIAS_FUNC qcnv(char *buf, int &idx) const { |
@@ -840,7 +836,7 @@ | ||
840 | 836 | |
841 | 837 | // 値の取得 |
842 | 838 | virtual const PObject *getval( ExecContextRoot *) const; |
843 | - virtual const PObject *getval( ExecContextRoot *c, VLocal *vlocal) const; | |
839 | + virtual const PObject *getval2( ExecContextRoot *c, VLocal *vlocal) const; | |
844 | 840 | |
845 | 841 | |
846 | 842 | // 変換して値を取得 |
@@ -1153,7 +1149,7 @@ | ||
1153 | 1149 | |
1154 | 1150 | // 値の取得 |
1155 | 1151 | virtual const PObject *getval( ExecContextRoot *c) const; |
1156 | - virtual const PObject *getval( ExecContextRoot *c, VLocal *vlocal) const; | |
1152 | + virtual const PObject *getval2( ExecContextRoot *c, VLocal *vlocal) const; | |
1157 | 1153 | |
1158 | 1154 | // 変換して値を取得 |
1159 | 1155 | virtual bool cnv_string(string &value) const { |
@@ -1396,7 +1392,7 @@ | ||
1396 | 1392 | |
1397 | 1393 | // 値の取得 |
1398 | 1394 | virtual const PObject *getval( ExecContextRoot *c) const; |
1399 | - virtual const PObject *getval( ExecContextRoot *c, VLocal *vlocal) const; | |
1395 | + virtual const PObject *getval2( ExecContextRoot *c, VLocal *vlocal) const; | |
1400 | 1396 | |
1401 | 1397 | // メモリマネージャによるdelete |
1402 | 1398 | virtual void del(); |
@@ -1500,10 +1496,10 @@ | ||
1500 | 1496 | |
1501 | 1497 | // 値の取得 |
1502 | 1498 | virtual const PObject *getval( ExecContextRoot *c) const ; |
1503 | - virtual const PObject *getval( ExecContextRoot *c, VLocal *vlocal) const ; | |
1499 | + virtual const PObject *getval2( ExecContextRoot *c, VLocal *vlocal) const ; | |
1504 | 1500 | // 値の取得 |
1505 | - virtual const PINTEGER32 *c_integer32(ExecContextRoot *c) const ; | |
1506 | - virtual const PINTEGER *c_integer(ExecContextRoot *c) const ; | |
1501 | + virtual const PINTEGER32 *p_integer32(ExecContextRoot *c) const ; | |
1502 | + virtual const PINTEGER *p_integer(ExecContextRoot *c) const ; | |
1507 | 1503 | |
1508 | 1504 | // ラベルの取得(変数の名前の取得:PArrayのハッシュで使用) |
1509 | 1505 | virtual const char *label() const { return name.c_str(); }; |
@@ -1671,10 +1667,10 @@ | ||
1671 | 1667 | |
1672 | 1668 | // 値の取得 |
1673 | 1669 | virtual const PObject *getval( ExecContextRoot *c) const; |
1674 | - virtual const PObject *getval( ExecContextRoot *c, VLocal *) const; | |
1670 | + virtual const PObject *getval2( ExecContextRoot *c, VLocal *) const; | |
1675 | 1671 | // 値の取得 |
1676 | - virtual const PINTEGER32 *c_integer32(ExecContextRoot *c) const ; | |
1677 | - virtual const PINTEGER *c_integer(ExecContextRoot *c) const ; | |
1672 | + virtual const PINTEGER32 *p_integer32(ExecContextRoot *c) const ; | |
1673 | + virtual const PINTEGER *p_integer(ExecContextRoot *c) const ; | |
1678 | 1674 | |
1679 | 1675 | // メモリマネージャによるdelete |
1680 | 1676 | virtual void del(); |
@@ -84,7 +84,7 @@ | ||
84 | 84 | // Cの文字列を期待する(変換なし) |
85 | 85 | const char *get_charp(size_t idx) { |
86 | 86 | if ( pred->size() <= idx ) return 0; |
87 | - const PObject *obj = (*pred)[idx]->getval( this, gl); | |
87 | + const PObject *obj = (*pred)[idx]->getval( this); | |
88 | 88 | if ( obj == 0 ) return 0; |
89 | 89 | return obj->c_str(); |
90 | 90 | } |
@@ -91,7 +91,7 @@ | ||
91 | 91 | // Cの文字列を期待する(変換あり) |
92 | 92 | const char *cnv_charp(size_t idx, string& str) { |
93 | 93 | if ( pred->size() <= idx ) return 0; |
94 | - const PObject *obj = (*pred)[idx]->getval( this, gl); | |
94 | + const PObject *obj = (*pred)[idx]->getval( this); | |
95 | 95 | if ( obj == 0 ) return 0; |
96 | 96 | if ( obj->c_str() ) return obj->c_str(); |
97 | 97 |
@@ -307,8 +307,8 @@ | ||
307 | 307 | // Expression functions |
308 | 308 | PObject *add(const PObject *args0, const PObject *args1, PObjectArray *pobjs_, bool w) { |
309 | 309 | // 試しの最適化 |
310 | - const PINTEGER *a1 = args0->c_integer(this); | |
311 | - const PINTEGER *a2 = args1->c_integer(this); | |
310 | + const PINTEGER *a1 = args0->p_integer(this); | |
311 | + const PINTEGER *a2 = args1->p_integer(this); | |
312 | 312 | if ( a1 && a2 ) { |
313 | 313 | if ( w ) { |
314 | 314 | PInteger *ret = dynamic_cast<PInteger *>(const_cast<PObject*>(args0)); |
@@ -324,8 +324,8 @@ | ||
324 | 324 | |
325 | 325 | PObject *sub(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) { |
326 | 326 | // 試しの最適化 |
327 | - const PINTEGER *a1 = args0->c_integer(this); | |
328 | - const PINTEGER *a2 = args1->c_integer(this); | |
327 | + const PINTEGER *a1 = args0->p_integer(this); | |
328 | + const PINTEGER *a2 = args1->p_integer(this); | |
329 | 329 | if ( a1 && a2 ) { |
330 | 330 | return pmm.newPInteger( pobjs_, *a1 - *a2); |
331 | 331 | } |
@@ -334,8 +334,8 @@ | ||
334 | 334 | |
335 | 335 | PObject *mul(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) { |
336 | 336 | // 試しの最適化 |
337 | - const PINTEGER *a1 = args0->c_integer(this); | |
338 | - const PINTEGER *a2 = args1->c_integer(this); | |
337 | + const PINTEGER *a1 = args0->p_integer(this); | |
338 | + const PINTEGER *a2 = args1->p_integer(this); | |
339 | 339 | if ( a1 && a2 ) { |
340 | 340 | return pmm.newPInteger( pobjs_, *a1 * *a2); |
341 | 341 | } |
@@ -344,8 +344,8 @@ | ||
344 | 344 | |
345 | 345 | PObject *div(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) { |
346 | 346 | // 試しの最適化 |
347 | - const PINTEGER *a1 = args0->c_integer(this); | |
348 | - const PINTEGER *a2 = args1->c_integer(this); | |
347 | + const PINTEGER *a1 = args0->p_integer(this); | |
348 | + const PINTEGER *a2 = args1->p_integer(this); | |
349 | 349 | if ( a1 && a2 ) { |
350 | 350 | return pmm.newPInteger( pobjs_, *a1 / *a2); |
351 | 351 | } |
@@ -354,8 +354,8 @@ | ||
354 | 354 | |
355 | 355 | PObject *mod(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) { |
356 | 356 | // 試しの最適化 |
357 | - const PINTEGER *a1 = args0->c_integer(this); | |
358 | - const PINTEGER *a2 = args1->c_integer(this); | |
357 | + const PINTEGER *a1 = args0->p_integer(this); | |
358 | + const PINTEGER *a2 = args1->p_integer(this); | |
359 | 359 | if ( a1 && a2 ) { |
360 | 360 | return pmm.newPInteger( pobjs_, *a1 % *a2); |
361 | 361 | } |
@@ -363,8 +363,8 @@ | ||
363 | 363 | } |
364 | 364 | |
365 | 365 | PObject *_and(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) { |
366 | - const PINTEGER *a1 = args0->c_integer(this); | |
367 | - const PINTEGER *a2 = args1->c_integer(this); | |
366 | + const PINTEGER *a1 = args0->p_integer(this); | |
367 | + const PINTEGER *a2 = args1->p_integer(this); | |
368 | 368 | if ( a1 && a2 ) { |
369 | 369 | return pmm.newPInteger( pobjs_, *a1 & *a2); |
370 | 370 | } |
@@ -372,8 +372,8 @@ | ||
372 | 372 | } |
373 | 373 | |
374 | 374 | PObject *_or(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) { |
375 | - const PINTEGER *a1 = args0->c_integer(this); | |
376 | - const PINTEGER *a2 = args1->c_integer(this); | |
375 | + const PINTEGER *a1 = args0->p_integer(this); | |
376 | + const PINTEGER *a2 = args1->p_integer(this); | |
377 | 377 | if ( a1 && a2 ) { |
378 | 378 | return pmm.newPInteger( pobjs_, *a1 | *a2); |
379 | 379 | } |
@@ -381,8 +381,8 @@ | ||
381 | 381 | } |
382 | 382 | |
383 | 383 | PObject *_xor(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) { |
384 | - const PINTEGER *a1 = args0->c_integer(this); | |
385 | - const PINTEGER *a2 = args1->c_integer(this); | |
384 | + const PINTEGER *a1 = args0->p_integer(this); | |
385 | + const PINTEGER *a2 = args1->p_integer(this); | |
386 | 386 | if ( a1 && a2 ) { |
387 | 387 | return pmm.newPInteger( pobjs_, *a1 ^ *a2); |
388 | 388 | } |
@@ -482,7 +482,7 @@ | ||
482 | 482 | } |
483 | 483 | if ( !result ) return; |
484 | 484 | if ( record ) { |
485 | - const PObject *p = pred->getval( this, gl); | |
485 | + const PObject *p = pred->getval( this); | |
486 | 486 | cache->values.push_back(dynamic_cast<PPredicate*>(p->clone(&cache->objs))); |
487 | 487 | cache->result++; |
488 | 488 | } |
@@ -706,7 +706,7 @@ | ||
706 | 706 | for ( size_t i = 0; i < p->hlocal.size(); i++ ) { |
707 | 707 | const PObject *o = p->hlocal[i]; |
708 | 708 | if ( o != 0 && !o->isc() ) { |
709 | - p->hlocal[i] = o->getval(p,&p->hlocal)->clone(&p->objs); | |
709 | + p->hlocal[i] = o->getval2(p,&p->hlocal)->clone(&p->objs); | |
710 | 710 | } |
711 | 711 | } |
712 | 712 | for ( size_t i = 0; i < p->goalidx; i++ ) { |
@@ -78,7 +78,7 @@ | ||
78 | 78 | firstflg = false; |
79 | 79 | // キャッシュ |
80 | 80 | if ( pred->opt.cachable ) { |
81 | - pred_a = dynamic_cast<const PPredicate*>(pred->getval( this, gl)); | |
81 | + pred_a = dynamic_cast<const PPredicate*>(pred->getval( this)); | |
82 | 82 | PINTEGER hash = pred_a->chash(); |
83 | 83 | pcmap::iterator i = pccache.find(hash); |
84 | 84 | if ( i != pccache.end() && i->second.key->cmatch(pred_a) ) { |
@@ -666,7 +666,7 @@ | ||
666 | 666 | const PVeriable *v = dynamic_cast<const PVeriable*>((*pred)[*i]); |
667 | 667 | if ( v ) { |
668 | 668 | const PObject *p = (*gl)[v->idx]; |
669 | - if ( p ) (*gl)[v->idx] = p->getval(this,gl)->clone(&this->p->objs); | |
669 | + if ( p ) (*gl)[v->idx] = p->getval(this)->clone(&this->p->objs); | |
670 | 670 | } |
671 | 671 | } |
672 | 672 | #endif |
@@ -747,7 +747,7 @@ | ||
747 | 747 | const PVeriable *v = dynamic_cast<const PVeriable*>((*pred)[*i]); |
748 | 748 | if ( v ) { |
749 | 749 | const PObject *p = (*gl)[v->idx]; |
750 | - if ( p ) (*gl)[v->idx] = p->getval(this,gl)->clone(&this->p->objs); | |
750 | + if ( p ) (*gl)[v->idx] = p->getval(this)->clone(&this->p->objs); | |
751 | 751 | } |
752 | 752 | } |
753 | 753 | #endif |