Diff
Not logged in

Differences From Artifact [9460508c714f0a1b]:

To Artifact [6063476e92f43069]:


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