Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-12-31 18:22:35 +0000
committerStephan Herrmann2013-01-22 20:46:00 +0000
commit00eccfa97885d2dda1f022d99d936f182f89b2b4 (patch)
treeba7e8f76f04677c8b9c37b251d8da4b47e3d47f5
parent4a483ebef7845318fc0052989aa6f1b1decbf9ce (diff)
downloadorg.eclipse.objectteams-00eccfa97885d2dda1f022d99d936f182f89b2b4.tar.gz
org.eclipse.objectteams-00eccfa97885d2dda1f022d99d936f182f89b2b4.tar.xz
org.eclipse.objectteams-00eccfa97885d2dda1f022d99d936f182f89b2b4.zip
Bug 397192 - Prepare OTDT for new (dynamic) weaver:
Fixed test4310_maximumParameterTweeking1 - base method spec may need to reflect synth args of a static role method - CallinImplementorDyn must respect some argument offsets during re-packing in callNext and callReplace et al. SomeTests: 683/0/48
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java15
2 files changed, 19 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java
index 1fd5d3596..4f2e1054f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java
@@ -658,7 +658,13 @@ public class MethodSpec extends ASTNode implements InvocationSite
StringBuffer buffer = new StringBuffer();
buffer.append('(');
- // manual retrenching:
+ // synthetic args for static role method?
+ MethodBinding orig = method.copyInheritanceSrc != null ? method.copyInheritanceSrc : method; // normalize to copyInhSrc so reading a callin-attr. from bytes can more easily find the method
+ if (CallinImplementorDyn.DYNAMIC_WEAVING && orig.declaringClass.isRole() && orig.isStatic()) {
+ buffer.append('I');
+ buffer.append(String.valueOf(orig.declaringClass.enclosingType().signature()));
+ }
+ // manual retrenching?
boolean shouldRetrench = !CallinImplementorDyn.DYNAMIC_WEAVING && method.isCallin();
int offset = shouldRetrench ? MethodSignatureEnhancer.ENHANCING_ARG_LEN : 0;
int paramLen = method.parameters.length;
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 223eea85d..e03b6dd1b 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
@@ -452,13 +452,16 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
receiver = gen.singleNameReference(callinDecl.getRoleMethod().declaringClass.sourceName());
}
+ int baseArgOffset = 0;
+ if (baseSpec.isCallin()) baseArgOffset+=MethodSignatureEnhancer.ENHANCING_ARG_LEN;
+ if (baseSpec.isStatic() && baseSpec.getDeclaringClass().isRole()) baseArgOffset+=2;
// unpack arguments to be used by parameter mappings and base predicate:
// ArgTypeN argn = args[n]
if (callinDecl.mappings != null || (hasBasePredicate && baseSpec.arguments != null)) {
TypeBinding[] baseParams = baseSpec.resolvedParameters();
for (int i=0; i<baseSpec.arguments.length; i++) {
Argument baseArg = baseSpec.arguments[i];
- Expression rawArg = gen.arrayReference(gen.singleNameReference(ARGUMENTS), i);
+ Expression rawArg = gen.arrayReference(gen.singleNameReference(ARGUMENTS), i+baseArgOffset);
Expression init = rawArg;
if (!baseParams[i].isTypeVariable())
init = gen.createCastOrUnboxing(rawArg, baseParams[i], callinDecl.scope);
@@ -505,7 +508,7 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
}
}
if (callinDecl.mappings == null) {
- arg = gen.arrayReference(gen.singleNameReference(ARGUMENTS), i); // prepare: somePreparation(arguments[i])
+ arg = gen.arrayReference(gen.singleNameReference(ARGUMENTS), i+baseArgOffset); // prepare: somePreparation(arguments[i])
TypeBinding baseArgType = baseSpec.resolvedParameters()[i];
if (roleParam.isBaseType()) {
// this includes intermediate cast to boxed type:
@@ -808,6 +811,12 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
if (mapping.positions != null) {
int[] poss = mapping.positions;
nLabels = caseBlockStats.size();
+ int argOffset = 0; // some methods have their real arguments at an offset
+ MethodSpec baseSpec = mapping.baseMethodSpecs[0]; // TODO(SH): check all base methods??
+ if (baseSpec.isCallin())
+ argOffset += 6;
+ if (baseSpec.isStatic() && baseSpec.getDeclaringClass().isRole())
+ argOffset += 2;
for (int i=0; i<poss.length; i++)
// arguments[basepos] = baseCallArguments[i]
if (poss[i] > 0) {
@@ -823,7 +832,7 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
&& ((ReferenceBinding)roleSideParameter).baseclass().isCompatibleWith(baseSideParameter))
roleSideArgument = new PotentialLowerExpression(roleSideArgument, baseSideParameter, gen.thisReference());
repackingStats.add(gen.assignment(gen.arrayReference(gen.singleNameReference(ARGUMENTS), // arguments[p] = baseCallArguments[i];
- poss[i]-1), // 0 represents result
+ poss[i]-1+argOffset), // 0 represents result
roleSideArgument));
}
} else if (nRoleArgs > 0) {

Back to the top