use of org.apache.xbean.asm9.Label in project jodd by oblac.
the class ProxettaAsmUtil method visitReturn.
// ---------------------------------------------------------------- return
/**
* Visits return opcodes.
*/
public static void visitReturn(MethodVisitor mv, MethodInfo methodInfo, boolean isLast) {
switch(methodInfo.getReturnOpcodeType()) {
case 'V':
if (isLast) {
mv.visitInsn(POP);
}
mv.visitInsn(RETURN);
break;
case 'B':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.byteValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'C':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.charValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'S':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.shortValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'I':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.intValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'Z':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.booleanValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'J':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(LCONST_0);
mv.visitInsn(LRETURN);
mv.visitLabel(label);
AsmUtil.longValue(mv);
}
mv.visitInsn(LRETURN);
break;
case 'F':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(FCONST_0);
mv.visitInsn(FRETURN);
mv.visitLabel(label);
AsmUtil.floatValue(mv);
}
mv.visitInsn(FRETURN);
break;
case 'D':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(DCONST_0);
mv.visitInsn(DRETURN);
mv.visitLabel(label);
AsmUtil.doubleValue(mv);
}
mv.visitInsn(DRETURN);
break;
default:
mv.visitInsn(ARETURN);
break;
}
}
use of org.apache.xbean.asm9.Label in project intellij-community by JetBrains.
the class AdvancedEnhancer method emitBindCallbacks.
private void emitBindCallbacks(ClassEmitter ce) {
CodeEmitter e = ce.begin_method(Constants.PRIVATE_FINAL_STATIC, BIND_CALLBACKS, null);
Local me = e.make_local();
e.load_arg(0);
e.checkcast_this();
e.store_local(me);
$Label end = e.make_label();
e.load_local(me);
e.getfield(BOUND_FIELD);
e.if_jump(e.NE, end);
e.load_local(me);
e.push(1);
e.putfield(BOUND_FIELD);
e.getfield(THREAD_CALLBACKS_FIELD);
e.invoke_virtual(THREAD_LOCAL, THREAD_LOCAL_GET);
e.dup();
$Label found_callback = e.make_label();
e.ifnonnull(found_callback);
e.pop();
e.getfield(STATIC_CALLBACKS_FIELD);
e.dup();
e.ifnonnull(found_callback);
e.pop();
e.goTo(end);
e.mark(found_callback);
e.checkcast(CALLBACK_ARRAY);
e.load_local(me);
e.swap();
for (int i = callbackTypes.length - 1; i >= 0; i--) {
if (i != 0) {
e.dup2();
}
e.aaload(i);
e.checkcast(callbackTypes[i]);
e.putfield(getCallbackField(i));
}
e.mark(end);
e.return_value();
e.end_method();
}
use of org.apache.xbean.asm9.Label in project googleads-java-lib by googleads.
the class GetActiveLabels method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
LabelServiceInterface labelService = adManagerServices.get(session, LabelServiceInterface.class);
// Create a statement to select labels.
StatementBuilder statementBuilder = new StatementBuilder().where("isActive = :isActive").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("isActive", true);
// Retrieve a small amount of labels at a time, paging through
// until all labels have been retrieved.
int totalResultSetSize = 0;
do {
LabelPage page = labelService.getLabelsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
// Print out some information for each label.
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Label label : page.getResults()) {
System.out.printf("%d) Label with ID %d and name '%s' was found.%n", i++, label.getId(), label.getName());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
use of org.apache.xbean.asm9.Label in project googleads-java-lib by googleads.
the class UpdateLabels method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param labelId the ID of the label to update.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long labelId) throws RemoteException {
// Get the LabelService.
LabelServiceInterface labelService = adManagerServices.get(session, LabelServiceInterface.class);
// Create a statement to only select a single label by ID.
StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", labelId);
// Get the label.
LabelPage page = labelService.getLabelsByStatement(statementBuilder.toStatement());
Label label = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
// Update the label description.
label.setDescription("New label description");
// Update the label on the server.
Label[] labels = labelService.updateLabels(new Label[] { label });
for (Label updatedLabel : labels) {
System.out.printf("Label with ID %d and name '%s' was updated.%n", updatedLabel.getId(), updatedLabel.getName());
}
}
use of org.apache.xbean.asm9.Label in project googleads-java-lib by googleads.
the class GetActiveLabels method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
LabelServiceInterface labelService = adManagerServices.get(session, LabelServiceInterface.class);
// Create a statement to select labels.
StatementBuilder statementBuilder = new StatementBuilder().where("isActive = :isActive").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("isActive", true);
// Retrieve a small amount of labels at a time, paging through
// until all labels have been retrieved.
int totalResultSetSize = 0;
do {
LabelPage page = labelService.getLabelsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
// Print out some information for each label.
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Label label : page.getResults()) {
System.out.printf("%d) Label with ID %d and name '%s' was found.%n", i++, label.getId(), label.getName());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Aggregations