List of usage examples for org.eclipse.jdt.internal.compiler.codegen CodeStream record
public void record(LocalVariableBinding local)
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 ww .j ava 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); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.SyntheticRoleFieldAccess.java
License:Open Source License
private LocalVariableBinding createArgumentBinding(CodeStream codeStream, char[] argName, TypeBinding argType, int pos) { LocalVariableBinding argBinding = new LocalVariableBinding(argName, argType, 0, true); argBinding.resolvedPosition = pos;//from w ww.j ava2s . c o m // declaration needed because otherwise completeCodeAttributeForSyntheticMethod // would refuse to generate the local variable entry argBinding.declaration = new Argument(argName, 0, null, 0); codeStream.addVisibleLocalVariable(argBinding); codeStream.record(argBinding); argBinding.recordInitializationStartPC(0); return argBinding; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.SyntheticRoleFieldAccess.java
License:Open Source License
/** * Generate the sequence for invoking this accessor. * * PRE: the role instance is on the stack, for write access also the new value * POST: values from PRE have been consumed, for read access the value is on the stack * * @param codeStream/*from www . j a va 2 s. com*/ */ public byte prepareOrGenerateInvocation(CodeStream codeStream, byte opcode) { ReferenceBinding roleType = (ReferenceBinding) this.parameters[0]; if (roleType instanceof UnresolvedReferenceBinding) { try { roleType = ((UnresolvedReferenceBinding) roleType).resolve(Config.getLookupEnvironment(), false); } catch (NotConfiguredException e) { e.logWarning("Failed to generate accessor"); //$NON-NLS-1$ return opcode; } this.parameters[0] = roleType; } if (this.purpose == FieldReadAccess || this.purpose == SuperFieldReadAccess) { insertOuterAccess(codeStream, roleType); // role -> role,team codeStream.swap(); // role,team -> team,role codeStream.invoke(Opcodes.OPC_invokevirtual, this, // team,role -> result this.declaringClass); } else { TypeBinding targetType = this.targetWriteField.type; LocalVariableBinding arg = new LocalVariableBinding("<tmp>".toCharArray(), //$NON-NLS-1$ targetType, 0, false); arg.resolvedPosition = codeStream.maxLocals; arg.useFlag = LocalVariableBinding.USED; codeStream.record(arg); arg.recordInitializationStartPC(codeStream.position); codeStream.store(arg, false/*valueRequired*/); // role, arg -> role insertOuterAccess(codeStream, roleType); // role -> role,team codeStream.swap(); // role,team -> team,role codeStream.load(arg); // -> team,role,arg codeStream.invoke(Opcodes.OPC_invokevirtual, this, // -> <empty> this.declaringClass); if (arg.initializationPCs != null) // null checking is asymmetric in LocalVariableBinding. arg.recordInitializationEndPC(codeStream.position); } return 0; // done }