Differences From Artifact [bc3c32f1d9aafc10]:
- File        
polemy/eval.d
- 2010-11-24 17:44:58 - part of checkin [b993a8ad16] on branch trunk - auto memo and re-run feature of non @value/@macro layers re-re-re-implemented. (user: kinaba) [annotate]
 
 
To Artifact [74dd93745d781116]:
- File        
polemy/eval.d
- 2010-11-26 05:03:10 - part of checkin [207cea338a] on branch trunk - changed hiding mechanizem of x in let x = ... for @macro layer. Old: set(x,ValueLayer,undefined) Nee: set(x,NoopLayer,null) (user: kinaba) [annotate]
 
 
  114          Value eval( Fun e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx )      114          Value eval( Fun e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx )
  115          {                                                                            115          {
  116                  if( isASTLayer(lay) )                                                116                  if( isASTLayer(lay) )
  117                  {                                                                    117                  {
  118                          // need this for correct scoping (outer scope macro vari     118                          // need this for correct scoping (outer scope macro vari
  119                          Table newCtx = new Table(ctx, Table.Kind.NotPropagateSet     119                          Table newCtx = new Table(ctx, Table.Kind.NotPropagateSet
  120                          foreach(p; e.params)                                         120                          foreach(p; e.params)
  121                                  newCtx.set(p.name, ValueLayer, new UndefinedValu |   121                                  newCtx.set(p.name, NoopLayer, null);
  122                          return ast2table(e, (AST e){return eval(e,lay,newCtx);})     122                          return ast2table(e, (AST e){return eval(e,lay,newCtx);})
  123                  }                                                                    123                  }
  124                  else                                                                 124                  else
  125                          return createNewFunction(e, ctx);                            125                          return createNewFunction(e, ctx);
  126          }                                                                            126          }
  127                                                                                       127  
  128          Value eval( Lay e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx )      128          Value eval( Lay e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx )
................................................................................................................................................................................
  136          Value eval( Let e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx )      136          Value eval( Let e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx )
  137          {                                                                            137          {
  138                  Table newCtx = overwriteCtx ? ctx : new Table(ctx, Table.Kind.No     138                  Table newCtx = overwriteCtx ? ctx : new Table(ctx, Table.Kind.No
  139                  if( isASTLayer(lay) )                                                139                  if( isASTLayer(lay) )
  140                          return ast2table(e, (AST ee){                                140                          return ast2table(e, (AST ee){
  141                                  // need this for correct scoping (outer scope ma     141                                  // need this for correct scoping (outer scope ma
  142                                  if(ee is e.expr)                                     142                                  if(ee is e.expr)
  143                                          newCtx.set(e.name, ValueLayer, new Undef |   143                                          newCtx.set(e.name, NoopLayer, null);
  144                                  return eval(ee,lay,newCtx);                          144                                  return eval(ee,lay,newCtx);
  145                          });                                                          145                          });
  146                  else                                                                 146                  else
  147                  {                                                                    147                  {
  148                          Value ri = eval(e.init, lay, newCtx);                        148                          Value ri = eval(e.init, lay, newCtx);
  149                          newCtx.set(e.name, e.layer.empty ? lay : e.layer, ri);       149                          newCtx.set(e.name, e.layer.empty ? lay : e.layer, ri);
  150                          return eval(e.expr, lay, newCtx, OverwriteCtx);              150                          return eval(e.expr, lay, newCtx, OverwriteCtx);
................................................................................................................................................................................
  216          {                                                                            216          {
  217                  assert( !isASTLayer(lay), "lift to the @macro layer should never     217                  assert( !isASTLayer(lay), "lift to the @macro layer should never
  218                                                                                       218  
  219                  // functions are automatically lifterd                               219                  // functions are automatically lifterd
  220                  if( cast(FunValue) v )                                               220                  if( cast(FunValue) v )
  221                          return v;                                                    221                          return v;
  222                                                                                       222  
  223                  if( !ctx.has(lay, SystemLayer) )                                 |   223                  if( !ctx.has(lay, LiftLayer) )
  224                          throw genex!RuntimeException(pos, "lift function for "~l     224                          throw genex!RuntimeException(pos, "lift function for "~l
  225                                                                                       225  
  226                  // similar to invokeFunction, but with only one argument bound t     226                  // similar to invokeFunction, but with only one argument bound t
  227                  auto _f = ctx.get(lay, SystemLayer, pos);                        |   227                  auto _f = ctx.get(lay, LiftLayer, pos);
  228                  if(auto f = cast(FunValue)_f)                                        228                  if(auto f = cast(FunValue)_f)
  229                  {                                                                    229                  {
  230                          Table newCtx = new Table(f.definitionContext(), Table.Ki     230                          Table newCtx = new Table(f.definitionContext(), Table.Ki
  231                          auto ps = f.params();                                        231                          auto ps = f.params();
  232                          if( ps.length != 1 )                                         232                          if( ps.length != 1 )
  233                                  throw genex!RuntimeException(pos,                    233                                  throw genex!RuntimeException(pos,
  234                                          text("lift function for", lay, " must ta     234                                          text("lift function for", lay, " must ta