Differences From Artifact [271574033e4f3a71]:
- File
polemy/eval.d
- 2010-11-27 14:28:33 - part of checkin [950fc6d3d4] on branch trunk - no. lift _|_ for corecursion checking again. Current choices is, if it failed we instead assing _|_ itself. Maybe the better choice is to give up memoization when it failed to lift... (user: kinaba) [annotate]
To Artifact [969111acf2042a22]:
- File
polemy/eval.d
- 2010-11-27 23:46:51 - part of checkin [576c494e53] on branch trunk - fixed: literal "..." is now lifted in user-defined layers (user: kinaba) [annotate]
225 225
226 226 override Layer layerID()
227 227 {
228 228 return theID;
229 229 }
230 230 override Value eval_( Die e, Table ctx, bool ctxMod )
231 231 {
232 - return new BottomValue;
232 + return this.lift(new BottomValue, ctx, e.pos);
233 233 }
234 234 override Value eval_( Str e, Table ctx, bool ctxMod )
235 235 {
236 236 return this.lift(super.eval_(e,ctx,ctxMod), ctx, e.pos);
237 237 }
238 238 override Value eval_( Int e, Table ctx, bool ctxMod )
239 239 {
................................................................................
411 411 if( !isUserDefinedLayer(lay) )
412 412 return nonMemoizedRun();
413 413
414 414 // automatic memoized co-recursive execution
415 415 MemokeyType memokey = new MemokeyType(cast(void*)ast, lay, ctx);
416 416 if(auto p = memokey in memo)
417 417 {
418 - (*p)[1] ++;
419 - return (*p)[0];
418 + if( ++(*p)[1] >= 2 ) // [TODO] is 2 really enough??
419 + return (*p)[0];
420 420 }
421 - else {
421 + else
422 + {
422 423 Value v;
423 424 try { v = evlay.lift(new BottomValue, ctx, pos); } catch { v = new BottomValue; }
424 425 memo[memokey] = tuple(v, 0);
425 426 }
426 427
427 428 Value r = nonMemoizedRun();
428 -
429 - int touched = memo[memokey][1];
430 - memo[memokey] = tuple(r, 12345678);
429 + memo[memokey] = tuple(r, 9999);
431 430 return r;
432 431 }
433 432 }
434 433 return new UserDefinedFunValue(e,ctx);
435 434 }
436 435
437 436 public: