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 114 Value eval( Fun e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx )
115 115 {
116 116 if( isASTLayer(lay) )
117 117 {
118 118 // need this for correct scoping (outer scope macro variables must be hidden!)
119 119 Table newCtx = new Table(ctx, Table.Kind.NotPropagateSet);
120 120 foreach(p; e.params)
121 - newCtx.set(p.name, ValueLayer, new UndefinedValue);
121 + newCtx.set(p.name, NoopLayer, null);
122 122 return ast2table(e, (AST e){return eval(e,lay,newCtx);});
123 123 }
124 124 else
125 125 return createNewFunction(e, ctx);
126 126 }
127 127
128 128 Value eval( Lay e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx )
................................................................................
136 136 Value eval( Let e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx )
137 137 {
138 138 Table newCtx = overwriteCtx ? ctx : new Table(ctx, Table.Kind.NotPropagateSet);
139 139 if( isASTLayer(lay) )
140 140 return ast2table(e, (AST ee){
141 141 // need this for correct scoping (outer scope macro variables must be hidden!)
142 142 if(ee is e.expr)
143 - newCtx.set(e.name, ValueLayer, new UndefinedValue);
143 + newCtx.set(e.name, NoopLayer, null);
144 144 return eval(ee,lay,newCtx);
145 145 });
146 146 else
147 147 {
148 148 Value ri = eval(e.init, lay, newCtx);
149 149 newCtx.set(e.name, e.layer.empty ? lay : e.layer, ri);
150 150 return eval(e.expr, lay, newCtx, OverwriteCtx);
................................................................................
216 216 {
217 217 assert( !isASTLayer(lay), "lift to the @macro layer should never happen" );
218 218
219 219 // functions are automatically lifterd
220 220 if( cast(FunValue) v )
221 221 return v;
222 222
223 - if( !ctx.has(lay, SystemLayer) )
223 + if( !ctx.has(lay, LiftLayer) )
224 224 throw genex!RuntimeException(pos, "lift function for "~lay~" is not registered" );
225 225
226 226 // similar to invokeFunction, but with only one argument bound to ValueLayer
227 - auto _f = ctx.get(lay, SystemLayer, pos);
227 + auto _f = ctx.get(lay, LiftLayer, pos);
228 228 if(auto f = cast(FunValue)_f)
229 229 {
230 230 Table newCtx = new Table(f.definitionContext(), Table.Kind.NotPropagateSet);
231 231 auto ps = f.params();
232 232 if( ps.length != 1 )
233 233 throw genex!RuntimeException(pos,
234 234 text("lift function for", lay, " must take exactly one argument of ", ValueLayer));