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 override Layer layerID() 226 override Layer layerID()
227 { 227 {
228 return theID; 228 return theID;
229 } 229 }
230 override Value eval_( Die e, Table ctx, bool ctxMod ) 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 override Value eval_( Str e, Table ctx, bool ctxMod ) 234 override Value eval_( Str e, Table ctx, bool ctxMod )
235 { 235 {
236 return this.lift(super.eval_(e,ctx,ctxMod), ctx, e.pos); 236 return this.lift(super.eval_(e,ctx,ctxMod), ctx, e.pos);
237 } 237 }
238 override Value eval_( Int e, Table ctx, bool ctxMod ) 238 override Value eval_( Int e, Table ctx, bool ctxMod )
239 { 239 {
................................................................................................................................................................................
411 if( !isUserDefinedLayer(lay) ) 411 if( !isUserDefinedLayer(lay) )
412 return nonMemoizedRun(); 412 return nonMemoizedRun();
413 413
414 // automatic memoized co-recursive execution 414 // automatic memoized co-recursive execution
415 MemokeyType memokey = new MemokeyType(cast(void* 415 MemokeyType memokey = new MemokeyType(cast(void*
416 if(auto p = memokey in memo) 416 if(auto p = memokey in memo)
417 { 417 {
418 (*p)[1] ++; | 418 if( ++(*p)[1] >= 2 ) // [TODO] is 2 real
419 return (*p)[0]; | 419 return (*p)[0];
420 } 420 }
421 else { | 421 else
> 422 {
422 Value v; 423 Value v;
423 try { v = evlay.lift(new BottomValue, ct 424 try { v = evlay.lift(new BottomValue, ct
424 memo[memokey] = tuple(v, 0); 425 memo[memokey] = tuple(v, 0);
425 } 426 }
426 427
427 Value r = nonMemoizedRun(); 428 Value r = nonMemoizedRun();
428 <
429 int touched = memo[memokey][1]; <
430 memo[memokey] = tuple(r, 12345678); | 429 memo[memokey] = tuple(r, 9999);
431 return r; 430 return r;
432 } 431 }
433 } 432 }
434 return new UserDefinedFunValue(e,ctx); 433 return new UserDefinedFunValue(e,ctx);
435 } 434 }
436 435
437 public: 436 public: