srecord noeq LASToByteCode(MethodMaker m) { replace Tb with GazelleV_LeftArrowScript. // Short for "Toolbox" delegate none, objValue, intValue, doubleValue to JVMStackCellType. void convertToObject(JVMStackCellType stackTop) { m.convertToObject(stackTop); } void compileToObject(Tb.Evaluable code) { convertToObject(compile(code)); } JVMStackCellType compile(Tb.Evaluable code) { if (code cast Tb.Const) { O o = code.value; if (o == null) { m.add(new ACONST_NULL); ret objValue; } else if (o cast S) { m.stringConstant(o); ret objValue; } else if (o cast Int) { m.intConstant(o); ret intValue; } else if (o cast Double) { m.doubleConstant(o); ret doubleValue; } else if (o cast Class) { m.classConstant(o); ret objValue; } else fail("Can't compile const value: " + className(o)); } else if (code cast Tb.Script) { var stackTop = none; for (step : code.steps) { // pop result of last instruction if any if (stackTop != none) m.add(new POP); stackTop = compile(step); } ret stackTop; } else if (code cast Tb.CallMethod) { // push target compileToObject(code.target); // push method name m.stringConstant(code.methodName); // push argument array int n = l(code.args); m.intConst(n); m.add(new ANEWARRAY(m.classRef(O))); for iArg to n: { m.intConst(iArg); compileToObject(code.args.get(iArg)); m.add(new AASTORE); } // call call() m.invokeStatic(mainFunctionHolder call, O, "call", O, S, O[].class); ret objValue; } fail("Can't compile yet: " + className(code)); } }