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

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

Introduction

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

Prototype

public void iconst_0() 

Source Link

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.PrivateRoleMethodCall.java

License:Open Source License

@Override
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
    // manually redirect to synth bridge:
    Expression receiverReference;
    boolean isCallinAccess = false;
    if (RoleTypeBinding.isRoleWithExplicitAnchor(this.actualReceiverType)) {
        // new receiver is the anchor denoting the base role's enclosing team instance:
        ITeamAnchor teamAnchor = ((RoleTypeBinding) this.actualReceiverType)._teamAnchor;
        TypeAnchorReference syntheticReceiver = this.gen.typeAnchorReference(teamAnchor);
        syntheticReceiver.isExpression = true;
        receiverReference = syntheticReceiver;
    } else {/*from w  w  w .ja  v  a 2 s.  co m*/
        isCallinAccess = true;
        // call from inside a otre-dyn callin wrapper: receiver is the current team:
        receiverReference = this.gen.thisReference();
    }
    receiverReference.resolve(currentScope);
    if (this.isCalloutToField)
        // for c-t-f this receiver *replaces* the original receiver,
        // role instance additionally exists as a visible method argument
        this.receiver = receiverReference;
    else
        // for method callout or callin to private *add* the team instance to the front of pushes
        // original role instance receiver will become the first implicit argument
        receiverReference.generateCode(currentScope, codeStream, true/*valueRequired*/);

    if (isCallinAccess) {
        // might need more synthetic args:
        if (this.binding.isStatic()) {
            codeStream.aconst_null(); // first arg in role bridge: (null) role
            codeStream.iconst_0(); // enclosingTeamInstance: dummy value 
            codeStream.aload_0(); // enclosingTeamInstance: team instance
        }
    }
    // directly use the accessor and its declaring class for the invoke instruction:
    this.binding = this.syntheticAccessor;
    this.actualReceiverType = this.syntheticAccessor.declaringClass;
    this.syntheticAccessor = null;
    super.generateCode(currentScope, codeStream, valueRequired);
}

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  ww. j a v  a2 s  . com*/
        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 genAddOrRemoveRole(CodeStream codeStream, Scope scope, ReferenceBinding iboundBase,
        boolean isAdding) {
    codeStream.aload_0(); // this
    // OTDYN: Slightly different methods depending on the weaving strategy:
    switch (scope.compilerOptions().weavingScheme) {
    case OTDRE:/*  w ww  .j a  v a  2s  .c  om*/
        // _OT$addOrRemoveRole(role, isAdding)
        if (isAdding)
            codeStream.iconst_1(); // isAdding=true
        else
            codeStream.iconst_0(); // isAdding=false   
        codeStream.invoke(Opcodes.OPC_invokeinterface,
                iboundBase.getMethod(scope, IOTConstants.ADD_REMOVE_ROLE), iboundBase);
        break;
    case OTRE:
        // _OT$addRole(role) or _OT$removeRole(role):
        codeStream.invoke(Opcodes.OPC_invokeinterface,
                isAdding ? iboundBase.getMethod(scope, IOTConstants.ADD_ROLE)
                        : iboundBase.getMethod(scope, IOTConstants.REMOVE_ROLE),
                iboundBase);
    }
}