Diff
Not logged in

Differences From Artifact [9460508c714f0a1b]:

To Artifact [6063476e92f43069]:


181 { 181 { 182 return getLayerEval(e.layer).evalToNonNull(e.expr, ctx); 182 return getLayerEval(e.layer).evalToNonNull(e.expr, ctx); 183 } 183 } 184 override Value eval_( Let e, Table ctx, bool ctxMod ) 184 override Value eval_( Let e, Table ctx, bool ctxMod ) 185 { 185 { 186 if( !ctxMod ) 186 if( !ctxMod ) 187 ctx = new Table(ctx, Table.Kind.NotPropagateSet) 187 ctx = new Table(ctx, Table.Kind.NotPropagateSet) 188 Value ri = this.eval(e.init, ctx); | 188 Value ri = this.eval(e.vdef, ctx); 189 ctx.set(e.name, e.layer.empty ? layerID(): e.layer, ri); 189 ctx.set(e.name, e.layer.empty ? layerID(): e.layer, ri); 190 return this.eval(e.expr, ctx, OverwriteCtx); 190 return this.eval(e.expr, ctx, OverwriteCtx); 191 } 191 } 192 override Value eval_( App e, Table ctx, bool ctxMod ) 192 override Value eval_( App e, Table ctx, bool ctxMod ) 193 { 193 { 194 Value f = this.eval( e.fun, ctx, CascadeCtx ); 194 Value f = this.eval( e.fun, ctx, CascadeCtx ); 195 return this.invokeFunction(f, e.args, ctx, e.pos, getNam 195 return this.invokeFunction(f, e.args, ctx, e.pos, getNam ................................................................................................................................................................................ 199 return createNewFunction(e, ctx); 199 return createNewFunction(e, ctx); 200 } 200 } 201 override Value macroAndEval( AST e, Table ctx, bool ctxMod ) 201 override Value macroAndEval( AST e, Table ctx, bool ctxMod ) 202 { 202 { 203 // incremental execution of let-expressions 203 // incremental execution of let-expressions 204 if(auto le = cast(Let)e) 204 if(auto le = cast(Let)e) 205 { 205 { 206 AST ai = runMacro(le.init, ctx); | 206 AST ai = runMacro(le.vdef, ctx); 207 207 208 if( !ctxMod ) 208 if( !ctxMod ) 209 ctx = new Table(ctx, Table.Kind.NotPropa 209 ctx = new Table(ctx, Table.Kind.NotPropa 210 210 211 Value vi = this.eval(ai, ctx); 211 Value vi = this.eval(ai, ctx); 212 ctx.set(le.name, le.layer.empty ? layerID() : le 212 ctx.set(le.name, le.layer.empty ? layerID() : le 213 return this.macroAndEval(le.expr, ctx, Overwrite 213 return this.macroAndEval(le.expr, ctx, Overwrite ................................................................................................................................................................................ 239 { 239 { 240 return this.lift(super.eval_(e,ctx,ctxMod), ctx, e.pos); 240 return this.lift(super.eval_(e,ctx,ctxMod), ctx, e.pos); 241 } 241 } 242 override Value eval_( Var e, Table ctx, bool ctxMod ) 242 override Value eval_( Var e, Table ctx, bool ctxMod ) 243 { 243 { 244 if( ctx.has(e.name, layerID()) ) 244 if( ctx.has(e.name, layerID()) ) 245 return ctx.get(e.name, layerID()); 245 return ctx.get(e.name, layerID()); > 246 Value v; 246 return this.lift(ctx.get(e.name, ValueLayer, e.pos), ctx | 247 try { v = ctx.get(e.name, ValueLayer, e.pos); } > 248 catch ( RuntimeException ) { > 249 throw genex!RuntimeException(e.pos, e.name~" not > 250 } > 251 return this.lift(v, ctx, e.pos); 247 } 252 } 248 } 253 } 249 254 250 // Macro layer. For optimization, if AST didn't change it returns null 255 // Macro layer. For optimization, if AST didn't change it returns null 251 class MacroLayerEval : LayerEval 256 class MacroLayerEval : LayerEval 252 { 257 { 253 override Layer layerID() 258 override Layer layerID() ................................................................................................................................................................................ 282 return getLayerEval(e.layer).eval(e.expr,ctx); 287 return getLayerEval(e.layer).eval(e.expr,ctx); 283 } 288 } 284 override Value eval_( Let e, Table ctx, bool ctxMod ) 289 override Value eval_( Let e, Table ctx, bool ctxMod ) 285 { 290 { 286 if( !ctxMod ) 291 if( !ctxMod ) 287 ctx = new Table(ctx, Table.Kind.NotPropagateSet) 292 ctx = new Table(ctx, Table.Kind.NotPropagateSet) 288 293 289 Value ai = this.eval(e.init, ctx); | 294 Value ai = this.eval(e.vdef, ctx); 290 ctx.set(e.name, NoopLayer, null); 295 ctx.set(e.name, NoopLayer, null); 291 Value ae = this.eval(e.expr, ctx, OverwriteCtx); 296 Value ae = this.eval(e.expr, ctx, OverwriteCtx); 292 297 293 if( ai is null && ae is null ) return null; 298 if( ai is null && ae is null ) return null; 294 if( ai is null ) ai = ast2table(e.init); | 299 if( ai is null ) ai = ast2table(e.vdef); 295 if( ae is null ) ae = ast2table(e.expr); 300 if( ae is null ) ae = ast2table(e.expr); 296 301 297 return ast2table(e, delegate Value (AST _){ 302 return ast2table(e, delegate Value (AST _){ 298 if(_ is e.init) { return ai; } | 303 if(_ is e.vdef) { return ai; } 299 if(_ is e.expr) { return ae; } 304 if(_ is e.expr) { return ae; } 300 assert(false); 305 assert(false); 301 }); 306 }); 302 } 307 } 303 override Value eval_( App e, Table ctx, bool ctxMod ) 308 override Value eval_( App e, Table ctx, bool ctxMod ) 304 { 309 { 305 Value f = this.eval( e.fun, ctx ); 310 Value f = this.eval( e.fun, ctx );