Warning: session_start(): open(/var/lib/php/sessions/sess_7iv1fuojc0a24jnh8im154jb1b, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
set flag AllPublic. // so we can access main call()
srecord noeq LASToByteCode(MethodMaker m) {
replace Tb with GazelleV_LeftArrowScript. // Short for "Toolbox"
delegate Evaluable to Tb.
// parameter index of VarContext
settable int iVarContext = -1;
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
argumentsAsArray(code.args);
// call call()
m.invokeStatic(mainFunctionHolder call, O, "call", O, S, O[].class);
ret objValue;
} else if (code cast Tb.NewObject) {
// push class
m.classConstant(code.c);
argumentsAsArray(code.args);
// call nuObject()
m.invokeStatic(mainFunctionHolder nuObject, O, "nuObject", Class.class, O[].class);
ret objValue;
} else if (code cast Tb.Assignment) {
// Prepare VarContext.set()
assertTrue("Need VarContext", iVarContext >= 0);
m.aload(iVarContext);
m.stringConstant(code.var);
// evaluate expression
compileToObject(code.expression);
m.dup(); // to also return value
// call VarContext.set()
m.invokeVirtual(VarContext, void.class, "set", S, O);
ret objValue;
}
fail("Can't compile yet: " + className(code));
}
void argumentsAsArray(L args) {
int n = l(args);
m.intConst(n);
m.add(new ANEWARRAY(m.classRef(O)));
for iArg to n: {
m.dup(); // get array again
m.intConst(iArg);
compileToObject(args.get(iArg));
m.add(new AASTORE);
}
}
}