Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2013-01-06 13:23:29 -0500
committerStephan Herrmann2013-01-22 15:50:12 -0500
commit236d0b8394ded97d92ebdb4b79319b478b83f8fb (patch)
tree3af742141014c07ce873536aeb3bdd95ca3a0f17
parent15173638ebdf08e2718101b99052762b4748e736 (diff)
downloadorg.eclipse.objectteams-236d0b8394ded97d92ebdb4b79319b478b83f8fb.tar.gz
org.eclipse.objectteams-236d0b8394ded97d92ebdb4b79319b478b83f8fb.tar.xz
org.eclipse.objectteams-236d0b8394ded97d92ebdb4b79319b478b83f8fb.zip
Bug 397192 - Prepare OTDT for new (dynamic) weaver:
Further improvements for array translations: - don't use the _teamExpr of a liftcall for the inner call in a transform method (where it's always 'this'). - fix inner lift-call in callNext: fix types and add a cast - don't apply deferred resolving to lifting, only lowering Status: 2184/2/134 Can now compile o.e.o.otdt (tricky class: OTTypeHierarchies).
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLifting.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLowering.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayTranslations.java18
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java8
4 files changed, 22 insertions, 11 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLifting.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLifting.java
index 677ddb03b..7525a9d77 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLifting.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLifting.java
@@ -24,6 +24,7 @@ import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.objectteams.otdt.internal.core.compiler.util.AstGenerator;
/**
* @author stephan
@@ -47,9 +48,9 @@ public class ArrayLifting extends ArrayTranslations {
Expression translation(
Expression rhs,
TypeBinding providedType,
- TypeBinding requiredType)
+ TypeBinding requiredType, AstGenerator gen)
{
- return Lifting.liftCall(this._scope, this._teamExpr, rhs, providedType, requiredType, false);
+ return Lifting.liftCall(this._scope, gen.thisReference(), rhs, providedType, requiredType, false);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLowering.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLowering.java
index 6af5828a5..21a7bb54f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLowering.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayLowering.java
@@ -58,7 +58,7 @@ public class ArrayLowering extends ArrayTranslations {
}
/* implement hook. */
- Expression translation(Expression rhs, TypeBinding providedType, TypeBinding requiredType) {
+ Expression translation(Expression rhs, TypeBinding providedType, TypeBinding requiredType, AstGenerator gen) {
return new Lowering().lowerExpression(this._scope, rhs, providedType, requiredType, this._teamExpr, false);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayTranslations.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayTranslations.java
index 5d4966ae4..4718fd903 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayTranslations.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/ArrayTranslations.java
@@ -101,8 +101,8 @@ public abstract class ArrayTranslations {
scope, this._teamExpr, providedType, requiredType, isLifting);
// if expression is resolved but teamExpression is unresolved schedule special resolving:
- IRunInScope hook = new IRunInScope() { public void run(BlockScope blockScope) { /*nop*/ } };
- if (deferredResolve && expression.resolvedType != null && this._teamExpr.resolvedType == null) {
+ IRunInScope hook = null;
+ if (!isLifting && deferredResolve && expression.resolvedType != null && this._teamExpr.resolvedType == null) {
hook = new IRunInScope() { public void run(BlockScope blockScope) {
// resolving this expression was deferred:
ArrayTranslations.this._teamExpr.resolve(blockScope);
@@ -110,11 +110,16 @@ public abstract class ArrayTranslations {
}
AstGenerator gen = new AstGenerator(expression.sourceStart, expression.sourceEnd);
- MessageSend send = gen.messageSendWithResolveHook(
+ MessageSend send = (hook != null)
+ ? gen.messageSendWithResolveHook(
this._teamExpr,
methodBinding.selector,
new Expression[] {expression},
- hook);
+ hook)
+ : gen.messageSend(
+ this._teamExpr,
+ methodBinding.selector,
+ new Expression[] {expression});
// manual resolving since expression is already resolved:
send.binding = methodBinding;
@@ -371,7 +376,7 @@ public abstract class ArrayTranslations {
{
return new Assignment(
lhsReference,
- translation(rhsReference, this._providedType.leafComponentType(), this._requiredType.leafComponentType()),
+ translation(rhsReference, this._providedType.leafComponentType(), this._requiredType.leafComponentType(), gen),
0);
}
else
@@ -399,9 +404,10 @@ public abstract class ArrayTranslations {
* @param rhs
* @param providedType
* @param requiredType
+ * @param gen generator for creating new AST nodes
* @return expression translating a single object
*/
- abstract Expression translation(Expression rhs, TypeBinding providedType, TypeBinding requiredType);
+ abstract Expression translation(Expression rhs, TypeBinding providedType, TypeBinding requiredType, AstGenerator gen);
private MethodDeclaration generateTransformArrayMethod(
TypeDeclaration teamType,
char[] transformMethodName,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java
index 1dd7b4b1c..5b034fdda 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java
@@ -872,8 +872,12 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
// lifting:
TypeBinding[]/*role,base*/ returnTypes = getReturnTypes(mapping, 0);
// who is responsible for lifting: the team or the current role?
- Expression liftReceiver = (isRoleOfCurrentRole(mapping.scope.enclosingReceiverType(), returnTypes[0]))
- ? Lifting.liftCall(mapping.scope, gen.thisReference(), gen.singleNameReference(IOTConstants.BASE), returnTypes[1], returnTypes[0], false)
+ ReferenceBinding currentRole = mapping.scope.enclosingReceiverType();
+ Expression liftReceiver = (isRoleOfCurrentRole(currentRole, returnTypes[0]))
+ ? Lifting.liftCall(mapping.scope,
+ gen.thisReference(),
+ gen.castExpression(gen.singleNameReference(IOTConstants.BASE), gen.typeReference(currentRole.baseclass()), CastExpression.RAW),
+ currentRole.baseclass(), currentRole, false)
// TODO: might want to extend the signature of callNext to pass the current role to avoid this lifting?
: gen.thisReference();
result = Lifting.liftCall(mapping.scope,

Back to the top