Example usage for org.eclipse.jdt.internal.compiler.codegen Opcodes OPC_invokestatic

List of usage examples for org.eclipse.jdt.internal.compiler.codegen Opcodes OPC_invokestatic

Introduction

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

Prototype

byte OPC_invokestatic

To view the source code for org.eclipse.jdt.internal.compiler.codegen Opcodes OPC_invokestatic.

Click Source Link

Usage

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   w  w  w  .j a  v  a  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();
    }
}