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

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

Introduction

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

Prototype

public void astore(int iArg) 

Source Link

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.BytecodeTransformer.java

License:Open Source License

/**
 * Add a byte code sequence that is a placeholder for chaining the
 * marker arg if the current method is copied lateron.
 * (See class comment in class ExplicitConstructorCall).
 *
 * @param scope/*from   w w  w  .ja  v  a 2  s  . c  o m*/
 * @param codeStream
 * @param chainTSuperMarkArgPos position that a marker arg will get when added.
 */
public static void addChainingPlaceholder(BlockScope scope, CodeStream codeStream, int chainTSuperMarkArgPos) {
    // create local variable "Object _OT$chainArg"
    // at the very position that will be taken by an added
    // marker argument:
    LocalVariableBinding nullVar = new LocalVariableBinding("_OT$chainArg".toCharArray(), //$NON-NLS-1$
            scope.getJavaLangObject(), 0, false);
    nullVar.resolvedPosition = chainTSuperMarkArgPos;
    nullVar.useFlag = LocalVariableBinding.USED;
    nullVar.declaringScope = scope.methodScope();
    codeStream.record(nullVar);
    codeStream.addVisibleLocalVariable(nullVar);
    // add dummy code sequence "aconst_null; astore <i>"
    // which will be changed by BytecodeTransformer.replaceChainArg
    // to "nop; aload <i>" with the same <i>.
    codeStream.aconst_null();
    codeStream.astore(chainTSuperMarkArgPos); // optimize small indices?
    // record positions for local varaible table.
    nullVar.recordInitializationStartPC(0);
    if (nullVar.initializationPCs != null)
        nullVar.recordInitializationEndPC(codeStream.position);
}