Diff
Not logged in

Differences From Artifact [57b0a5dd9a9946f6]:

To Artifact [aeb12eeaab91afb4]:


76 // @macro run!!! 76 // @macro run!!! 77 if( lay == MacroLayer ) 77 if( lay == MacroLayer ) 78 return macroEval(ast.funbody, ctx, false); 78 return macroEval(ast.funbody, ctx, false); 79 /*TODO memo*/ AST macroMemo; 79 /*TODO memo*/ AST macroMemo; 80 if( macroMemo is null ) { 80 if( macroMemo is null ) { 81 // .prototype!, forced macro cannot access parameters 81 // .prototype!, forced macro cannot access parameters 82 ctx.kill = true; scope(exit)ctx.kill=false; 82 ctx.kill = true; scope(exit)ctx.kill=false; > 83 auto tbl = macroEval(ast.funbody, ctx, true); 83 macroMemo = tableToAST(ValueLayer,macroEval(ast.funbody, | 84 macroMemo = tableToAST(ValueLayer,tbl); 84 } 85 } 85 auto v = eval(macroMemo, ctx, true, lay); 86 auto v = eval(macroMemo, ctx, true, lay); 86 87 87 //auto v = eval(e.funbody, ctxNeo, true, lay); 88 //auto v = eval(e.funbody, ctxNeo, true, lay); 88 // auto memoization 89 // auto memoization 89 // if( lay != ValueLayer && lay != MacroLayer ) 90 // if( lay != ValueLayer && lay != MacroLayer ) 90 // memo[lay][args] = v; 91 // memo[lay][args] = v; ................................................................................................................................................................................ 340 case "var": 341 case "var": 341 if(auto v = t.access!StrValue(theLayer, "name")) 342 if(auto v = t.access!StrValue(theLayer, "name")) 342 return new VarExpression(pos, v.data); 343 return new VarExpression(pos, v.data); 343 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST 344 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST 344 case "lay": 345 case "lay": 345 if(auto v = t.access!StrValue(theLayer, "layer")) 346 if(auto v = t.access!StrValue(theLayer, "layer")) 346 if(auto e = t.access!Table(theLayer, "expr")) 347 if(auto e = t.access!Table(theLayer, "expr")) 347 return new LayeredExpression(pos, v.data, tableT | 348 return new LayExpression(pos, v.data, tableToAST 348 else 349 else 349 throw genex!RuntimeException(cast(LexPosition)nu 350 throw genex!RuntimeException(cast(LexPosition)nu 350 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST 351 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST 351 case "let": 352 case "let": 352 if(auto n = t.access!StrValue(theLayer, "name")) 353 if(auto n = t.access!StrValue(theLayer, "name")) 353 if(auto e = t.access!Table(theLayer, "init")) 354 if(auto e = t.access!Table(theLayer, "init")) 354 if(auto b = t.access!Table(theLayer, "expr")) 355 if(auto b = t.access!Table(theLayer, "expr")) ................................................................................................................................................................................ 360 if(auto l = t.access!StrValue(theLayer, "layer")) 361 if(auto l = t.access!StrValue(theLayer, "layer")) 361 lay = l.data; 362 lay = l.data; 362 return new LetExpression(pos, nn, lay, ee, bb); 363 return new LetExpression(pos, nn, lay, ee, bb); 363 } 364 } 364 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST 365 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST 365 case "app": 366 case "app": 366 if(auto f = t.access!Table(theLayer, "fun")) 367 if(auto f = t.access!Table(theLayer, "fun")) 367 if(auto a = t.access!Table(theLayer, "arg")) | 368 if(auto a = t.access!Table(theLayer, "args")) 368 return new FuncallExpression(pos, tableToAST(theLayer,f) 369 return new FuncallExpression(pos, tableToAST(theLayer,f) 369 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST | 370 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST 370 case "fun": 371 case "fun": 371 if(auto p = t.access!Table(theLayer, "param")) | 372 if(auto p = t.access!Table(theLayer, "params")) 372 if(auto b = t.access!Table(theLayer, "body")) | 373 if(auto b = t.access!Table(theLayer, "funbody")) 373 { 374 { 374 Parameter[] ps; 375 Parameter[] ps; 375 foreach(v; tableAsConsList(theLayer, p)) 376 foreach(v; tableAsConsList(theLayer, p)) 376 { 377 { 377 if(auto tt = cast(Table)v) 378 if(auto tt = cast(Table)v) 378 if(auto ss = tt.access!StrValue(theLayer, "name" 379 if(auto ss = tt.access!StrValue(theLayer, "name" 379 if(auto ll = tt.access!Table(theLayer, "layer")) | 380 if(auto ll = tt.access!Table(theLayer, "layers") 380 { 381 { 381 Layer[] ls; 382 Layer[] ls; 382 foreach(lll; tableAsConsList(theLayer, l 383 foreach(lll; tableAsConsList(theLayer, l 383 if(auto l = cast(StrValue)lll) 384 if(auto l = cast(StrValue)lll) 384 ls ~= l.data; 385 ls ~= l.data; 385 else 386 else 386 throw genex!RuntimeExcep 387 throw genex!RuntimeExcep