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

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

Introduction

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

Prototype

byte OPC_getstatic

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

Click Source Link

Usage

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

License:Open Source License

public void generateBodyForRead(FieldBinding fieldBinding, CodeStream codeStream) {
    if (fieldBinding.isStatic()) {
        fieldBinding = checkAdjustRoleFieldAccess(fieldBinding, codeStream); // may insert cast, too.
        codeStream.fieldAccess(Opcodes.OPC_getstatic, fieldBinding, fieldBinding.declaringClass);
        // FIXME(SH): throw new InternalCompilerError("accessor for static field not applicable.");
    } else {//from  w ww.  ja  va  2  s  .  c o  m
        // 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);

        // generate code:
        codeStream.aload_1(); // not a static accessor, positions shifted by 1.
        fieldBinding = checkAdjustRoleFieldAccess(fieldBinding, codeStream); // may insert cast, too.
        codeStream.fieldAccess(Opcodes.OPC_getfield, 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);
    }
}