Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementor.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java31
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java10
3 files changed, 32 insertions, 13 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementor.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementor.java
index 4aff36ec9..295f79f8c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementor.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
*
- * Copyright 2003, 2013 Fraunhofer Gesellschaft, Munich, Germany,
+ * Copyright 2003, 2018 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute for Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
@@ -112,7 +112,7 @@ public class CallinImplementor extends MethodMappingImplementor
public static final String OT_LOCAL = "_OT$local$"; //$NON-NLS-1$
//_OT$role
static final char[] ROLE_VAR_NAME = CharOperation.concat(IOTConstants.OT_DOLLAR_NAME, IOTConstants.ROLE);
- private static final char[] OLD_IS_EXECUTING = "_OT$oldIsExecuting".toCharArray(); //$NON-NLS-1$
+ static final char[] OLD_IS_EXECUTING = "_OT$oldIsExecuting".toCharArray(); //$NON-NLS-1$
private ClassScope _roleScope;
/**
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 105293f77..f7288c8e4 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
@@ -460,8 +460,12 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
hasBasePredicate = true;
}
}
- Expression resetFlag =
- CallinImplementor.setExecutingCallin(roleType.roleModel, blockStatements); // boolean _OT$oldIsExecutingCallin = _OT$setExecutingCallin(true);
+ // below this line we are "inside" the callin execution:
+ blockStatements.add(gen.assignment(gen.singleNameReference(CallinImplementor.OLD_IS_EXECUTING), // _OT$oldIsExecutingCallin = _OT$setExecutingCallin(true); // local declared at top level
+ gen.messageSend(
+ gen.thisReference(),
+ IOTConstants.SET_EXECUTING_CALLIN,
+ new Expression[]{ gen.booleanLiteral(true) })));
// ----------- receiver for role method call: -----------
Expression receiver;
@@ -705,7 +709,7 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
// try { roleMessageSend(); }
// catch(Exception _OT$caughtException) { throw new SneakyException(_OT$caughtException); }
// finally { _OT$setExecutingCallin(_OT$oldIsExecutingCallin); }
- blockStatements.add(protectRoleMethodCall(messageSendStatements, roleMethodBinding, resetFlag, gen));
+ blockStatements.add(protectRoleMethodCall(messageSendStatements, roleMethodBinding, gen));
statements.add(gen.block(blockStatements.toArray(new Statement[blockStatements.size()])));
// collectively report the problem(s)
if (canLiftingFail && callinDecl.rolesWithLiftingProblem != null)
@@ -807,12 +811,22 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
exceptionStatementss = new Statement[][]{{catchStatement1}};
}
tryStats.add(switchStat);
+
+ LocalDeclaration flagVariable = gen.localVariable(CallinImplementor.OLD_IS_EXECUTING,
+ gen.qualifiedTypeReference(TypeConstants.JAVA_LANG_BOOLEAN),
+ gen.nullLiteral());
+ Statement resetFlag = gen.ifStatement(gen.nonNullCheck(gen.singleNameReference(CallinImplementor.OLD_IS_EXECUTING)),
+ gen.messageSend(gen.thisReference(),
+ IOTConstants.SET_EXECUTING_CALLIN,
+ new Expression[]{ gen.singleNameReference(CallinImplementor.OLD_IS_EXECUTING) }));
methodDecl.statements = new Statement[] {
- gen.tryCatch(
+ flagVariable,
+ gen.tryStatement(
tryStats.toArray(new Statement[tryStats.size()]),
// expected exception is ignored, do nothing (before/after) or proceed to callNext (replace)
exceptionArguments,
- exceptionStatementss)
+ exceptionStatementss,
+ new Statement[] {resetFlag})
};
methodDecl.hasParsedStatements = true;
return true;
@@ -1009,7 +1023,7 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
}
/** Convert custom exceptions into SneakyException as to bypass checking by the compiler. */
- TryStatement protectRoleMethodCall(Statement[] statements, MethodBinding roleMethod, Statement finallyStat, AstGenerator gen) {
+ TryStatement protectRoleMethodCall(Statement[] statements, MethodBinding roleMethod, AstGenerator gen) {
Argument catch1Arg = gen.argument(CATCH_ARG, gen.qualifiedTypeReference(TypeConstants.JAVA_LANG_RUNTIMEEXCEPTION)); // incl. LiftingVetoException
Statement[] catch1Stat = new Statement[] {
gen.throwStatement(gen.singleNameReference(CATCH_ARG)) // rethrow as-is
@@ -1021,11 +1035,10 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
new Expression[] { gen.singleNameReference(CATCH_ARG) }
))
};
- return gen.tryStatement(
+ return gen.tryCatch(
statements,
new Argument[] {catch1Arg, catch2Arg},
- new Statement[][] {catch1Stat, catch2Stat},
- new Statement[] {finallyStat});
+ new Statement[][] {catch1Stat, catch2Stat});
}
private void generateCallOrigStatic(List<CallinMappingDeclaration> callinDecls, TeamModel aTeam) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java
index ff2b00c26..0ee91cdd5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
*
- * Copyright 2004, 2016 Fraunhofer Gesellschaft, Munich, Germany,
+ * Copyright 2004, 2018 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute for Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
@@ -305,10 +305,16 @@ public class AstGenerator extends AstFactory {
return result;
}
public Expression nullCheck(Expression value) {
+ return internalNullCheck(value, OperatorIds.EQUAL_EQUAL);
+ }
+ public Expression nonNullCheck(Expression value) {
+ return internalNullCheck(value, OperatorIds.NOT_EQUAL);
+ }
+ Expression internalNullCheck(Expression value, int operator) {
EqualExpression result = new EqualExpression(
value,
nullLiteral(),
- OperatorIds.EQUAL_EQUAL) {
+ operator) {
protected void checkVariableComparison(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo, FlowInfo initsWhenTrue, FlowInfo initsWhenFalse, LocalVariableBinding local, int nullStatus, Expression reference) {
// similar to super version: do mark flowInfo but avoid reporting any problems
switch (nullStatus) {

Back to the top