use of org.apache.tapestry5.plastic.InstructionBuilder in project tapestry-5 by apache.
the class PlasticFieldImpl method replaceFieldWriteAccess.
private void replaceFieldWriteAccess(String conduitFieldName) {
ensureNotPublic();
String setAccessName = plasticClass.makeUnique(plasticClass.methodNames, "conduit_set_" + node.name);
setAccess = new MethodNode(accessForMethod(), setAccessName, "(" + node.desc + ")V", null, null);
InstructionBuilder builder = plasticClass.newBuilder(setAccess);
pushFieldConduitOntoStack(conduitFieldName, builder);
builder.loadThis();
plasticClass.pushInstanceContextFieldOntoStack(builder);
// Take the value passed to this method and push it onto the stack.
builder.loadArgument(0);
builder.boxPrimitive(typeName);
builder.invoke(FieldConduit.class, void.class, "set", Object.class, InstanceContext.class, Object.class);
if (isWriteBehindEnabled()) {
builder.loadThis().loadArgument(0).putField(plasticClass.className, node.name, typeName);
}
builder.returnResult();
plasticClass.addMethod(setAccess);
plasticClass.redirectFieldWrite(node.name, isPrivate(), setAccess);
}
use of org.apache.tapestry5.plastic.InstructionBuilder in project tapestry-5 by apache.
the class PlasticFieldImpl method replaceFieldReadAccess.
private void replaceFieldReadAccess(String conduitFieldName) {
ensureNotPublic();
boolean writeBehindEnabled = isWriteBehindEnabled();
String getAccessName = plasticClass.makeUnique(plasticClass.methodNames, "conduit_get_" + node.name);
getAccess = new MethodNode(accessForMethod(), getAccessName, "()" + node.desc, null, null);
InstructionBuilder builder = plasticClass.newBuilder(getAccess);
// Get the correct FieldConduit object on the stack
pushFieldConduitOntoStack(conduitFieldName, builder);
builder.loadThis();
// Now push the instance context on the stack
plasticClass.pushInstanceContextFieldOntoStack(builder);
builder.invoke(FieldConduit.class, Object.class, "get", Object.class, InstanceContext.class).castOrUnbox(typeName);
if (writeBehindEnabled) {
if (isWide()) {
// Dupe this under the wide value, then pop the wide value
builder.dupeWide().loadThis().dupe(2).pop();
} else {
builder.dupe().loadThis().swap();
}
// At which point the stack is the result value, this, the result value
builder.putField(plasticClass.className, node.name, typeName);
// And now it is just the result value
}
builder.returnResult();
plasticClass.addMethod(getAccess);
plasticClass.redirectFieldRead(node.name, isPrivate(), getAccess);
}
use of org.apache.tapestry5.plastic.InstructionBuilder in project tapestry-5 by apache.
the class InstructionBuilderImpl method increment.
@Override
public InstructionBuilder increment(LocalVariable variable) {
check();
LVInfo info = state.locals.get(variable);
v.visitIincInsn(info.offset, 1);
return this;
}
use of org.apache.tapestry5.plastic.InstructionBuilder in project tapestry-5 by apache.
the class InstructionBuilderImpl method doWhile.
@Override
public InstructionBuilder doWhile(Condition condition, final WhileCallback callback) {
check();
assert condition != null;
assert callback != null;
Label doCheck = state.newLabel();
Label exitLoop = new Label();
callback.buildTest(this);
v.visitJumpInsn(conditionToOpcode.get(condition), exitLoop);
callback.buildBody(this);
v.visitJumpInsn(GOTO, doCheck);
v.visitLabel(exitLoop);
return this;
}
use of org.apache.tapestry5.plastic.InstructionBuilder in project tapestry-5 by apache.
the class InstructionBuilderImpl method loadTypeConstant.
@Override
public InstructionBuilder loadTypeConstant(Class clazz) {
check();
Type type = Type.getType(clazz);
v.visitLdcInsn(type);
return this;
}
Aggregations