/* e.g. overlay <- ScreenOverlay bounds <- rightScreenBounds overlay bounds bounds overlay show */ // We're using SynchronizedList as a list wrapper sclass GazelleV_LeftArrowScript extends SynchronizedList 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 args; *(Class *c) {} *(Class *c, L *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 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 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); } } }