List of usage examples for org.eclipse.jdt.internal.compiler.ast Expression generateCode
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired)
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 {// www.j ava 2 s .co 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.util.AstGenerator.java
License:Open Source License
/** * Assemble an ifstatement with negated condition, that hides the branch instruction from the debugger, * even when stepping into the condition. *///from w ww . ja v a 2 s . co m public IfStatement stealthIfNotStatement(final Expression condition, Statement thenStatement) { // mark step-over after the condition: Expression recordingCondition = new Expression() { public StringBuffer printExpression(int indent, StringBuffer output) { return condition.print(indent, output); } public TypeBinding resolveType(BlockScope scope) { return condition.resolveType(scope); } public void computeConversion(Scope scope, TypeBinding runtimeType, TypeBinding compileTimeType) { condition.computeConversion(scope, runtimeType, compileTimeType); this.constant = condition.constant; this.bits = condition.bits; } public Constant optimizedBooleanConstant() { this.constant = condition.optimizedBooleanConstant(); this.bits = condition.bits; return this.constant; } public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, boolean valueRequired) { return condition.analyseCode(currentScope, flowContext, flowInfo, valueRequired); } public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { return condition.analyseCode(currentScope, flowContext, flowInfo); } public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { condition.generateCode(currentScope, codeStream, valueRequired); // payload: codeStream.pcToSourceMap[codeStream.pcToSourceMapSize++] = codeStream.position; codeStream.pcToSourceMap[codeStream.pcToSourceMapSize++] = STEP_OVER_LINENUMBER; } }; return new IfStatement(new UnaryExpression( // NOT recordingCondition, OperatorIds.NOT), thenStatement, this.sourceStart, this.sourceEnd); }