/* e.g. overlay <- ScreenOverlay bounds <- rightScreenBounds overlay bounds bounds overlay show */ // We're using SynchronizedList as a list wrapper sclass GazelleV_LeftArrowScript extends SynchronizedList<GazelleV_LeftArrowScript.Evaluable> is GazelleV_LeftArrowScript.Evaluable { interface Evaluable { public O get(VarContext ctx default new); } *() { super(new L); } public O get(VarContext ctx) { O result = null; for (step : this) result = step.get(ctx); ret result; } toString { ret pnlToLines(this); } srecord noeq FunctionDef(S name, LS args, Evaluable body) {} srecord noeq Assignment(S var, Evaluable expression) is Evaluable { public O get(VarContext ctx) { O o = expression.get(ctx); ctx.set(var, o); ret o; } toString { ret var + " <- " + expression; } } persistable sclass NewObject is Evaluable { Class c; L<Evaluable> args; *(Class *c) {} *(Class *c, L<Evaluable> *args) {} public O get(VarContext ctx) { ret callConstructor(c, mapToArray(args, arg -> arg.get(ctx))); } toString { ret "new " + formatFunctionCall(className(c), args); } } srecord noeq CallFunction(FunctionDef f, L<Evaluable> args) is Evaluable { public O get(VarContext ctx) { var ctx2 = new VarContext(ctx); for (S declared, Evaluable actual : unpair zipLists(f.args, args)) ctx2.put(declared, actual.get(ctx)); print ifdef GazelleV_LeftArrowScript_debug(ctx2 := ctx2.vars); ret f.body.get(ctx2); } toString { ret formatFunctionCall(f.name, args); } } srecord noeq GetVar(S var) is Evaluable { public O get(VarContext ctx) { ret ctx.get(var); } toString { ret var; } } srecord noeq Const(O value) is Evaluable { public O get(VarContext ctx) { ret value; } toString { ret strOrClassName(value); } } srecord CallMethod(Evaluable target, S methodName, L<Evaluable> args) is Evaluable { public O get(VarContext ctx) { ret call(target.get(ctx), methodName, mapToArray(args, arg -> arg.get(ctx))); } toString { ret target + "." + formatFunctionCall(methodName, args); } } }
Began life as a copy of #1033981
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034041 |
Snippet name: | GazelleV_LeftArrowScript (rewrite rejected by Java compiler) |
Eternal ID of this version: | #1034041/1 |
Text MD5: | cff0d0996751ef1e2dd04f2e867599d3 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-18 02:17:40 |
Source code size: | 2339 bytes / 87 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 117 / 145 |
Referenced in: | [show references] |