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

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

Introduction

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

Prototype

byte OPC_putstatic

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

Click Source Link

Usage

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

License:Open Source License

public void generateBodyForWrite(FieldBinding fieldBinding, CodeStream codeStream) {
    if (fieldBinding.isStatic()) {
        fieldBinding = checkAdjustRoleFieldAccess(fieldBinding, codeStream);
        codeStream.load(fieldBinding.type, 1);
        codeStream.fieldAccess(Opcodes.OPC_putstatic, fieldBinding, fieldBinding.declaringClass);
    } else {/*from  w w w .  j  a  va 2 s .  com*/
        // prepare "this" and role args:
        LocalVariableBinding thisArg = createArgumentBinding(codeStream, "this".toCharArray(), //$NON-NLS-1$
                fieldBinding.declaringClass.enclosingType(), 0);
        char[] argName = typeNameToLower(this.parameters[0].sourceName());
        LocalVariableBinding arg1 = createArgumentBinding(codeStream, argName, this.parameters[0], 1);
        LocalVariableBinding arg2 = createArgumentBinding(codeStream, "value".toCharArray(), this.parameters[1], //$NON-NLS-1$
                2);

        codeStream.aload_1(); // not a static accessor, positions shifted by 1.
        fieldBinding = checkAdjustRoleFieldAccess(fieldBinding, codeStream);
        codeStream.load(fieldBinding.type, 2);
        codeStream.fieldAccess(Opcodes.OPC_putfield, fieldBinding, fieldBinding.declaringClass);

        // finish args:
        if ((codeStream.generateAttributes & (ClassFileConstants.ATTR_VARS
                | ClassFileConstants.ATTR_STACK_MAP_TABLE | ClassFileConstants.ATTR_STACK_MAP)) == 0)
            return; // avoid NPE below
        thisArg.recordInitializationEndPC(codeStream.position);
        arg1.recordInitializationEndPC(codeStream.position);
        arg2.recordInitializationEndPC(codeStream.position);
    }
}