List of usage examples for org.eclipse.jdt.internal.compiler.codegen CodeStream aconst_null
public void aconst_null()
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. j av a2 s . c o 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.ast.RoleClassLiteralAccess.java
License:Open Source License
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { // simply delegate: if (this.send != null) this.send.generateCode(currentScope, codeStream, valueRequired); else if (valueRequired) codeStream.aconst_null(); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.TSuperMessageSend.java
License:Open Source License
@SuppressWarnings("hiding") @Override/* w ww . j a v a 2s .com*/ public void generateArguments(MethodBinding binding, Expression[] arguments, BlockScope currentScope, CodeStream codeStream) { super.generateArguments(binding, arguments, currentScope, codeStream); // check if we need to pass the marker arg, too: TypeBinding[] parameters = this.binding.parameters; TypeBinding tsuperMarkerBinding = parameters.length == 0 ? null : parameters[parameters.length - 1]; if (tsuperMarkerBinding == null || !TSuperHelper.isMarkerInterface(tsuperMarkerBinding)) return; codeStream.aconst_null(); codeStream.checkcast(tsuperMarkerBinding); }
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. ja v a 2 s . c om * @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.SyntheticBaseCallSurrogate.java
License:Open Source License
/** Directly generate the instruction for this method's body (no AST available). */ public void generateInstructions(CodeStream codeStream) { codeStream.new_(this.errorType); codeStream.dup();// ww w. j av a2 s . co m codeStream.ldc("Binding error: base-call impossible!"); //$NON-NLS-1$ MethodBinding ctorBinding = ((ReferenceBinding) this.errorType) .getExactConstructor(new TypeBinding[] { this.stringType }); codeStream.invoke(Opcodes.OPC_invokespecial, ctorBinding, this.errorType); codeStream.athrow(); codeStream.aconst_null(); // always generalized to Object codeStream.areturn(); }