Example usage for org.eclipse.jdt.internal.compiler.codegen CodeStream areturn

List of usage examples for org.eclipse.jdt.internal.compiler.codegen CodeStream areturn

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.codegen CodeStream areturn.

Prototype

public void areturn() 

Source Link

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.SyntheticBaseCallSurrogate.java

License:Open Source License

/** Directly generate the instruction for this method's body (no AST available). */
public void generateInstructions(CodeStream codeStream) {
    codeStream.new_(this.errorType);
    codeStream.dup();/*ww  w .  j  av a 2  s.c o  m*/
    codeStream.ldc("Binding error: base-call impossible!"); //$NON-NLS-1$
    MethodBinding ctorBinding = ((ReferenceBinding) this.errorType)
            .getExactConstructor(new TypeBinding[] { this.stringType });
    codeStream.invoke(Opcodes.OPC_invokespecial, ctorBinding, this.errorType);
    codeStream.athrow();
    codeStream.aconst_null(); // always generalized to Object
    codeStream.areturn();
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.SyntheticRoleBridgeMethodBinding.java

License:Open Source License

@Override
public void generateInstructions(CodeStream codeStream) {
    TypeBinding[] arguments = this.parameters;
    int argLen = arguments.length;
    TypeBinding[] targetParameters = this.targetMethod.parameters;
    int resolvedPosition = 0;
    int argIdx = 0;
    int targetIdx = 0;
    switch (this.purpose) {
    case RoleMethodBridgeInner:
        codeStream.aload_0(); // synthetic first arg is the receiver role
        codeStream.checkcast(this.targetMethod.declaringClass);
        resolvedPosition = 1; // first arg is processed
        argIdx = 1;/*from  ww  w  . j a  va 2  s  . c om*/
        if (this.targetMethod.isStatic()) {
            codeStream.iconst_0(); // dummy int
            codeStream.aload_2(); // pass synth. team arg
            argIdx += 2;
            resolvedPosition += 2;
        }
        break;
    case RoleMethodBridgeOuter:
        resolvedPosition = 1; // ignore team instance at 0
        argIdx = 0; // pass all args unchanged
        break;
    }
    while (argIdx < argLen) {
        TypeBinding parameter = targetParameters[targetIdx++];
        TypeBinding argument = arguments[argIdx++];
        codeStream.load(argument, resolvedPosition);
        if (TypeBinding.notEquals(argument, parameter))
            codeStream.checkcast(parameter);
        switch (parameter.id) {
        case TypeIds.T_long:
        case TypeIds.T_double:
            resolvedPosition += 2;
            break;
        default:
            resolvedPosition++;
            break;
        }
    }
    if (this.targetMethod.isStatic())
        codeStream.invoke(Opcodes.OPC_invokestatic, this.targetMethod, null);
    else
        codeStream.invoke(Opcodes.OPC_invokespecial, this.targetMethod, null); // non-static private role method
    switch (this.targetMethod.returnType.id) {
    case TypeIds.T_void:
        codeStream.return_();
        break;
    case TypeIds.T_boolean:
    case TypeIds.T_byte:
    case TypeIds.T_char:
    case TypeIds.T_short:
    case TypeIds.T_int:
        codeStream.ireturn();
        break;
    case TypeIds.T_long:
        codeStream.lreturn();
        break;
    case TypeIds.T_float:
        codeStream.freturn();
        break;
    case TypeIds.T_double:
        codeStream.dreturn();
        break;
    default:
        codeStream.areturn();
    }
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.RoleMigrationImplementor.java

License:Open Source License

static void genMigrateToTeamInstructions(CodeStream codeStream, SourceTypeBinding roleBinding) {
    // this.this$n = (MyTeam)otherTeam
    codeStream.aload_0(); // this
    codeStream.aload_1(); // otherTeam
    codeStream.checkcast(roleBinding.enclosingType());
    codeStream.fieldAccess(Opcodes.OPC_putfield, enclosingInstanceField(roleBinding), roleBinding);
    codeStream.aload_0();//from w w  w .  j av  a 2 s.c o m
    codeStream.areturn();
    // not handling caches here, cf. IProblem.MigrateBoundRole
}