Warning: session_start(): open(/var/lib/php/sessions/sess_uclt7p8n2qpkhjh312gosffa7s, 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
!include once #1019934 // BCEL
sclass MethodMaker {
replace Type with org.apache.bcel.generic.Type.
ClassGen cg;
MethodGen mg;
new InstructionList il;
ConstantPoolGen cp;
InstructionFactory factory;
int frameSize;
*(ClassGen cg, Class returnType, S methodName, Class... argumentTypes) {
this(cg, methodName, returnType, argumentTypes);
}
*(ClassGen *cg, S methodName, Class returnType, Class... argumentTypes) {
cp = cg.getConstantPool();
factory = new InstructionFactory(cg);
Type[] argTypes = wrapTypes(argumentTypes);
mg = new MethodGen(Const.ACC_PUBLIC,
wrapType(returnType),
argTypes, null /* argNames */, methodName, cg.getClassName(), il, cp);
frameSize = l(argTypes)+1; // assume method is not static
}
Type[] wrapTypes(Class[] classes) {
Type[] types = new[l(classes)];
for i over classes:
types[i] = wrapType(classes[i]);
ret types;
}
Type wrapType(Class c) {
ret c == null ?: new ObjectType(className(c));
}
// create local variable and return its index
int newLocalVar() { ret frameSize++; }
selfType newObject(Class c, Class... argTypes) {
il.append(factory.createNew(className(c)));
il.append(InstructionConst.DUP);
Constructor ctor = findConstructor_precise_onTypes(c, argTypes);
il.append(factory.createInvoke(className(c), "",
Type.VOID, wrapTypes(ctor.getParameterTypes()),
Const.INVOKESPECIAL));
this;
}
selfType dup() {
il.append(InstructionConst.DUP);
this;
}
// store object in local variable
selfType astore(int var) {
il.append(new ASTORE(var));
this;
}
selfType aload(int var) {
il.append(new ALOAD(var));
this;
}
selfType stringConstant(S s) {
il.append(new PUSH(cp, s));
this;
}
selfType invokeVirtual(Class c, Class returnType, S methodName,
Class... argTypes) {
ret invokeVirtual(c, methodName, returnType, argTypes);
}
selfType invokeVirtual(Class c, S methodName, Class returnType,
Class... argTypes) {
Method m = findNonStaticMethod_precise_onTypes(c, methodName, argTypes);
if (m == null) fail("Method not found: " + className(c) + "."
+ formatFunctionCall(methodName, argTypes) + " returning " + className(returnType));
il.append(factory.createInvoke(className(c), methodName,
wrapType(m.getReturnType()),
wrapTypes(m.getParameterTypes()), Const.INVOKEVIRTUAL));
this;
}
selfType areturn() {
il.append(InstructionConst.ARETURN);
this;
}
void add(Instruction i) { il.add(i); }
void done() {
mg.stripAttributes(true);
mg.setMaxStack();
mg.setMaxLocals();
cg.addMethod(mg.getMethod());
}
}