Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-05-09 17:29:39 -0400
committerEd Willink2016-05-18 09:17:46 -0400
commit94c097d079762aa61913f23d5a2e4f885c4ace32 (patch)
tree0357c21a7e1392c6d48af04828a8cd6fbd37f6fa
parentd502fb47d034b908725565ab50f7300d952bd570 (diff)
downloadorg.eclipse.qvtd-94c097d079762aa61913f23d5a2e4f885c4ace32.tar.gz
org.eclipse.qvtd-94c097d079762aa61913f23d5a2e4f885c4ace32.tar.xz
org.eclipse.qvtd-94c097d079762aa61913f23d5a2e4f885c4ace32.zip
[486722] Introduce Occurrence to generalize unique
execution/instance/value
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java4
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractExecutionVisitor.java63
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractIdentification.java25
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java5
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocationManager.java3
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java3
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractOccurrence.java19
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractSlotState.java3
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractTransformer.java2
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitable.java3
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java14
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Identification.java31
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java10
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Occurrence.java32
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Transformer.java2
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java92
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/rel2core/PivotNormalizer.java1
17 files changed, 241 insertions, 71 deletions
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java
index 7ea826462..12a6ac6dc 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java
@@ -30,7 +30,7 @@ import org.eclipse.qvtd.pivot.qvtimperative.evaluationstatus.PropertyStatus;
import org.eclipse.qvtd.pivot.qvtimperative.utilities.GraphStringBuilder;
import org.eclipse.qvtd.pivot.qvtimperative.utilities.GraphStringBuilder.GraphEdge;
import org.eclipse.qvtd.pivot.qvtimperative.utilities.GraphStringBuilder.GraphNode;
-import org.eclipse.qvtd.runtime.evaluation.ExecutionVisitor;
+import org.eclipse.qvtd.runtime.evaluation.AbstractExecutionVisitor;
import org.eclipse.qvtd.runtime.evaluation.Invocation;
import org.eclipse.qvtd.runtime.evaluation.InvocationManager;
import org.eclipse.qvtd.runtime.evaluation.ObjectManager;
@@ -39,7 +39,7 @@ import org.eclipse.qvtd.runtime.evaluation.Transformer;
import com.google.common.collect.Iterables;
-public class Execution2GraphVisitor implements ExecutionVisitor<String>
+public class Execution2GraphVisitor extends AbstractExecutionVisitor<String>
{
protected static final class ExecutionEdge implements GraphEdge
{
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractExecutionVisitor.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractExecutionVisitor.java
new file mode 100644
index 000000000..b2b93130f
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractExecutionVisitor.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * E.D.Willink - Initial API and implementation
+ *
+ * This code is auto-generated
+ * from: org.eclipse.ocl.pivot/model/Pivot.genmodel
+ *
+ * Only the copyright statement is editable.
+ *******************************************************************************/
+package org.eclipse.qvtd.runtime.evaluation;
+
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * @since 1.1
+ */
+public /*abstract*/ class AbstractExecutionVisitor<R> implements ExecutionVisitor<R>
+{
+ /**
+ * Return the result of visiting a visitable for which no more specific pivot type method
+ * is available.
+ */
+ public R visiting(@NonNull ExecutionVisitable visitable) {
+ throw new UnsupportedOperationException("No " + getClass().getSimpleName() + " suupport for a " + visitable.getClass().getSimpleName());
+ }
+
+ @Override
+ public R visitIdentification(@NonNull Identification object) {
+ return visiting(object);
+ }
+
+ @Override
+ public R visitInvocation(@NonNull Invocation object) {
+ return visiting(object);
+ }
+
+ @Override
+ public R visitInvocationManager(@NonNull InvocationManager object) {
+ return visiting(object);
+ }
+
+ @Override
+ public R visitObjectManager(@NonNull ObjectManager object) {
+ return visiting(object);
+ }
+
+ @Override
+ public R visitSlotState(@NonNull SlotState object) {
+ return visiting(object);
+ }
+
+ @Override
+ public R visitTransformer(@NonNull Transformer object) {
+ return visiting(object);
+ }
+
+}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractIdentification.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractIdentification.java
new file mode 100644
index 000000000..f4a96461c
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractIdentification.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2015 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * E.D.Willink - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.qvtd.runtime.evaluation;
+
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * AbstractIdentification provides the mandatory shared functionality of the uniqiuely idenmtified object functionality.
+ * @since 1.1
+ */
+public abstract class AbstractIdentification extends AbstractOccurrence implements Identification
+{
+ @Override
+ public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
+ return visitor.visitIdentification(this);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java
index effe336f7..9479e2ac9 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java
@@ -16,14 +16,13 @@ import java.util.List;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.qvtd.runtime.internal.evaluation.AbstractInvocationInternal;
/**
* AbstractInvocation provides the mandatory shared functionality of the intrusive blocked/waiting linked list functionality.
* @since 1.1
*/
-public abstract class AbstractInvocation extends AbstractInvocationInternal
+public abstract class AbstractInvocation extends AbstractInvocationInternal implements Invocation
{
public abstract static class Incremental extends AbstractInvocation implements Invocation.Incremental
{
@@ -77,7 +76,7 @@ public abstract class AbstractInvocation extends AbstractInvocationInternal
}
@Override
- public @Nullable <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
+ public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
return visitor.visitInvocation(this);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocationManager.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocationManager.java
index 4e7cd5c39..3cafac126 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocationManager.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocationManager.java
@@ -11,7 +11,6 @@
package org.eclipse.qvtd.runtime.evaluation;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
/**
* AbstractInvocationManager provides the mandatory shared functionality for a mapping invocation manager.
@@ -21,7 +20,7 @@ public abstract class AbstractInvocationManager implements InvocationManager
{
@Override
- public @Nullable <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
+ public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
return visitor.visitInvocationManager(this);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java
index 16c735b57..39cc686f6 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java
@@ -14,7 +14,6 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
/**
* AbstractObjectManager provides the mandatory shared functionality for an object state manager.
@@ -31,7 +30,7 @@ public abstract class AbstractObjectManager implements ObjectManager
}
@Override
- public @Nullable <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
+ public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
return visitor.visitObjectManager(this);
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractOccurrence.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractOccurrence.java
new file mode 100644
index 000000000..08760896c
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractOccurrence.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * E.D.Willink - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.qvtd.runtime.evaluation;
+
+/**
+ * AbstractOccurrence provides the mandatory shared functionality of the unique occurrence functionality.
+ * @since 1.1
+ */
+public abstract class AbstractOccurrence implements Occurrence
+{
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractSlotState.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractSlotState.java
index 84305b384..caaafc2e1 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractSlotState.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractSlotState.java
@@ -16,7 +16,6 @@ import java.util.List;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
/**
* The abstract implementation of a SlotState provides the mandatory shared functionality for maintaining
@@ -63,7 +62,7 @@ public abstract class AbstractSlotState implements SlotState
}
@Override
- public @Nullable <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
+ public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
return visitor.visitSlotState(this);
}
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractTransformer.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractTransformer.java
index 51278a608..911e9d658 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractTransformer.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractTransformer.java
@@ -37,7 +37,7 @@ public abstract class AbstractTransformer extends AbstractTransformerInternal
}
@Override
- public @Nullable <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
+ public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
return visitor.visitTransformer(this);
}
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitable.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitable.java
index 562cf8281..9c6f8ffdc 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitable.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitable.java
@@ -11,7 +11,6 @@
package org.eclipse.qvtd.runtime.evaluation;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
/**
* ExecutionVisitable defines the common visitable capability of all run-time execution objects.
@@ -27,5 +26,5 @@ public interface ExecutionVisitable
* variant of visitXXX() to facilitate derived-class-specific
* processing or just visit() when no such method is available.
*/
- @Nullable <R> R accept(@NonNull ExecutionVisitor<R> visitor);
+ <R> R accept(@NonNull ExecutionVisitor<R> visitor);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java
index 9fec9d19e..eb9431500 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java
@@ -16,7 +16,6 @@
package org.eclipse.qvtd.runtime.evaluation;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
/**
* @since 1.1
@@ -27,11 +26,12 @@ public interface ExecutionVisitor<R>
* Return the result of visiting a visitable for which no more specific pivot type method
* is available.
*/
-// @Nullable R visiting(@NonNull ExecutionVisitable visitable);
+// R visiting(@NonNull ExecutionVisitable visitable);
- @Nullable R visitInvocation(@NonNull Invocation object);
- @Nullable R visitInvocationManager(@NonNull InvocationManager object);
- @Nullable R visitObjectManager(@NonNull ObjectManager object);
- @Nullable R visitSlotState(@NonNull SlotState object);
- @Nullable R visitTransformer(@NonNull Transformer object);
+ R visitIdentification(@NonNull Identification object);
+ R visitInvocation(@NonNull Invocation object);
+ R visitInvocationManager(@NonNull InvocationManager object);
+ R visitObjectManager(@NonNull ObjectManager object);
+ R visitSlotState(@NonNull SlotState object);
+ R visitTransformer(@NonNull Transformer object);
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Identification.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Identification.java
new file mode 100644
index 000000000..5f8263929
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Identification.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2015 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * E.D.Willink - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.qvtd.runtime.evaluation;
+
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * An Identification identifies a unique object with its bound values. This is used to support
+ * - a function cache which associates a result with its arguments.
+ * - an OCL shadow which identifies objects from all its properties.
+ * - a QVTr key which identifies objects from a subset of their properties.
+ *
+ * @noimplement clients should derive from AbstractIdentification
+ * @since 1.1
+ */
+public interface Identification extends Occurrence
+{
+ @NonNull Object getInstance();
+
+ public interface Incremental extends Identification, Occurrence.Incremental
+ {
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java
index a1765bb30..ace17cb0e 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java
@@ -11,7 +11,6 @@
package org.eclipse.qvtd.runtime.evaluation;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.ocl.pivot.ids.IdResolver;
/**
* An Invocation identifies a unique invocation of a Mapping and the objects/values bound to its guard variables.
@@ -19,7 +18,7 @@ import org.eclipse.ocl.pivot.ids.IdResolver;
* @noimplement clients should derive from AbstractInvocation
* @since 1.1
*/
-public interface Invocation extends ExecutionVisitable
+public interface Invocation extends Occurrence
{
/**
* Execute the mapping invocation, returning true if successfully executed, or false if some predicate failed.
@@ -32,18 +31,13 @@ public interface Invocation extends ExecutionVisitable
* Insert this Invocation following predecessor, which may be in the blocked or waiting invocations linked list.
*/
void insertAfter(@NonNull Invocation predecessor);
-
- /**
- * Return true if a mapping invocation with thoseValues would be a re-invocation of this invocation.
- */
- boolean isEqual(@NonNull IdResolver idResolver, @NonNull Object @NonNull [] thoseValues);
/**
* Remove this Invocation from the blocked or waiting invocations linked list.
*/
void remove();
- public interface Incremental extends Invocation
+ public interface Incremental extends Invocation, Occurrence.Incremental
{
void addCreatedObject(@NonNull Object createdObject);
void addReadSlot(SlotState.@NonNull Incremental readSlot);
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Occurrence.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Occurrence.java
new file mode 100644
index 000000000..e6f906360
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Occurrence.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * E.D.Willink - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.qvtd.runtime.evaluation;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.ocl.pivot.ids.IdResolver;
+
+/**
+ * An Occurrence identifies an object creation or execution that must only happen once.
+ *
+ * @noimplement clients should derive from AbstractSingleton
+ * @since 1.1
+ */
+public interface Occurrence extends ExecutionVisitable
+{
+ /**
+ * Return true if an occurrence with thoseValues would be a re-occurrence.
+ */
+ boolean isEqual(@NonNull IdResolver idResolver, @NonNull Object @NonNull [] thoseValues);
+
+ public interface Incremental extends Occurrence
+ {
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Transformer.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Transformer.java
index 69e7172ae..59e9e67ef 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Transformer.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Transformer.java
@@ -23,7 +23,7 @@ import org.eclipse.ocl.pivot.evaluation.ModelManager;
* @since 1.1
* @noimplement clients should derive from AbstractTransformer
*/
-public interface Transformer extends ModelManager//, ExecutionVisitable
+public interface Transformer extends ModelManager, ExecutionVisitable
{
/**
* Clients may reference this explicitly to force a compile-time failure for a mismatch.
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java
index 727f296d0..df39af5a5 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java
@@ -44,6 +44,8 @@ import org.eclipse.ocl.pivot.values.InvalidValueException;
import org.eclipse.qvtd.runtime.evaluation.AbstractTransformer;
import org.eclipse.qvtd.runtime.evaluation.AbstractTypedModelInstance;
import org.eclipse.qvtd.runtime.evaluation.ExecutionVisitable;
+import org.eclipse.qvtd.runtime.evaluation.Identification;
+import org.eclipse.qvtd.runtime.evaluation.Occurrence;
import org.eclipse.qvtd.runtime.evaluation.Invocation;
import org.eclipse.qvtd.runtime.evaluation.InvocationFailedException;
import org.eclipse.qvtd.runtime.evaluation.InvocationManager;
@@ -331,12 +333,12 @@ public abstract class AbstractTransformerInternal extends AbstractModelManager i
private final @Nullable Map<@NonNull ClassId, @NonNull Set<@NonNull Integer>> classId2classIndexes;
/**
- * Map from invocation identity to one or more invocations with that identity. Single map entries use the
- * Invocation directly as the entry. Colliding entries use a List<Invocation> for the collisions.
+ * Map from occurrence identity to one or more occurrences with that identity. Single map entries use the
+ * Occurence directly as the entry. Colliding entries use a List<Occurence> for the collisions.
* <br>
- * This map is used to inhibit repeated invocations of the invocationId.
+ * This map is used to inhibit repeated occurrences of the occurrenceId.
*/
- private final @NonNull Map<@NonNull Integer, @NonNull Object> invocationId2invocation = new HashMap<@NonNull Integer, @NonNull Object>();
+ private final @NonNull Map<@NonNull Integer, @NonNull Object> occurrenceId2occurrence = new HashMap<@NonNull Integer, @NonNull Object>();
/**
* Manager for the blocked and unblocked invocations.
@@ -423,49 +425,50 @@ public abstract class AbstractTransformerInternal extends AbstractModelManager i
}
/**
- * Create and return the invocation for an invocationClass and boundValues.
- * Returns null if already created.
+ * Create or reuse the unique occurrence object, created by constructor and parameterized by argValues.
* @throws ReflectiveOperationException
*/
- private @Nullable Invocation createFirst(@NonNull Constructor<? extends Invocation> constructor, @NonNull Object... boundValues) throws ReflectiveOperationException {
- Class<? extends Invocation> invocationClass = constructor.getDeclaringClass();
- assert invocationClass != null;
- int hashCode = System.identityHashCode(invocationClass);
- for (@NonNull Object boundValue : boundValues) {
- hashCode = 3 * hashCode + idResolver.oclHashCode(boundValue);
+ private <T extends Occurrence> @NonNull T createFirst(@NonNull Constructor<? extends T> constructor, @NonNull Object... argValues) throws ReflectiveOperationException {
+ Class<? extends T> occurrenceClass = constructor.getDeclaringClass();
+ assert occurrenceClass != null;
+ int hashCode = System.identityHashCode(occurrenceClass);
+ for (@NonNull Object argValue : argValues) {
+ hashCode = 3 * hashCode + idResolver.oclHashCode(argValue);
}
- Object zeroOrMoreInvocations = invocationId2invocation.get(hashCode);
- Invocation oneInvocation = null;
- List<@NonNull Invocation> twoOrMoreInvocations2 = null;
- if (zeroOrMoreInvocations instanceof Invocation) {
- oneInvocation = (Invocation)zeroOrMoreInvocations;
- if ((invocationClass == oneInvocation.getClass()) && oneInvocation.isEqual(idResolver, boundValues)) {
- return oneInvocation;
+ Object zeroOrMoreOccurrences = occurrenceId2occurrence.get(hashCode);
+ Occurrence oneOccurrence = null;
+ List<@NonNull Occurrence> twoOrMoreOccurrences2 = null;
+ if (zeroOrMoreOccurrences instanceof Occurrence) {
+ oneOccurrence = (Occurrence)zeroOrMoreOccurrences;
+ if ((occurrenceClass == oneOccurrence.getClass()) && oneOccurrence.isEqual(idResolver, argValues)) {
+ @SuppressWarnings("unchecked") T castOccurrence = (T)oneOccurrence;
+ return castOccurrence;
}
}
- else if (zeroOrMoreInvocations instanceof List<?>) {
- @SuppressWarnings("unchecked")@NonNull List<@NonNull Invocation> zeroOrMoreInvocations2 = (List<@NonNull Invocation>)zeroOrMoreInvocations;
- twoOrMoreInvocations2 = zeroOrMoreInvocations2;
- for (@NonNull Invocation anInvocation : twoOrMoreInvocations2) {
- if ((invocationClass == anInvocation.getClass()) && anInvocation.isEqual(idResolver, boundValues)) {
- return anInvocation;
+ else if (zeroOrMoreOccurrences instanceof List<?>) {
+ @SuppressWarnings("unchecked")@NonNull List<@NonNull Occurrence> zeroOrMoreOccurrences2 = (List<@NonNull Occurrence>)zeroOrMoreOccurrences;
+ twoOrMoreOccurrences2 = zeroOrMoreOccurrences2;
+ for (@NonNull Occurrence anOccurrence : twoOrMoreOccurrences2) {
+ if ((occurrenceClass == anOccurrence.getClass()) && anOccurrence.isEqual(idResolver, argValues)) {
+ @SuppressWarnings("unchecked") T castOccurrence = (T)anOccurrence;
+ return castOccurrence;
}
}
}
- Invocation theInvocation = constructor.newInstance(this, boundValues);
- if (zeroOrMoreInvocations == null) {
- invocationId2invocation.put(hashCode, theInvocation);
+ T theOccurrence = constructor.newInstance(this, argValues);
+ if (zeroOrMoreOccurrences == null) {
+ occurrenceId2occurrence.put(hashCode, theOccurrence);
}
else {
- if (twoOrMoreInvocations2 == null) {
- twoOrMoreInvocations2 = new ArrayList<@NonNull Invocation>(4);
- assert oneInvocation != null;
- twoOrMoreInvocations2.add(oneInvocation);
+ if (twoOrMoreOccurrences2 == null) {
+ twoOrMoreOccurrences2 = new ArrayList<@NonNull Occurrence>(4);
+ assert oneOccurrence != null;
+ twoOrMoreOccurrences2.add(oneOccurrence);
}
- twoOrMoreInvocations2.add(theInvocation);
- invocationId2invocation.put(hashCode, twoOrMoreInvocations2);
+ twoOrMoreOccurrences2.add(theOccurrence);
+ occurrenceId2occurrence.put(hashCode, twoOrMoreOccurrences2);
}
- return theInvocation;
+ return theOccurrence;
}
/**
@@ -516,6 +519,17 @@ public abstract class AbstractTransformerInternal extends AbstractModelManager i
protected @NonNull <T extends EObject> List<T> getObjectsByType(int modelIndex, @NonNull EClass eClass) {
return models[modelIndex].getObjectsByType(eClass);
} */
+
+ /**
+ * Create or re-use the unique Identification object constructed by constructor and parameterized by partValues.
+ *
+ * @throws ReflectiveOperationException
+ */
+ public <T extends Identification> @NonNull T getIdentification(@NonNull Constructor<T> constructor, @NonNull Object... partValues) throws ReflectiveOperationException {
+ T identification = createFirst(constructor, partValues);
+ AbstractTransformer.INVOCATIONS.println("getIdentification " + identification);
+ return identification;
+ }
/**
* Return the List of all PropertyIndexes for which an EClass instance could be the unnavigable opposite.
@@ -640,10 +654,8 @@ public abstract class AbstractTransformerInternal extends AbstractModelManager i
* @throws ReflectiveOperationException
*/
public <T extends Invocation> void invokeOnce(@NonNull Constructor<T> constructor, @NonNull Object... boundValues) throws ReflectiveOperationException {
- Invocation invocation = createFirst(constructor, boundValues);
- if (invocation != null) {
- AbstractTransformer.INVOCATIONS.println("invokeOnce " + invocation);
- invocationManager.invoke(invocation, true);
- }
+ T invocation = createFirst(constructor, boundValues);
+ AbstractTransformer.INVOCATIONS.println("invokeOnce " + invocation);
+ invocationManager.invoke(invocation, true);
}
}
diff --git a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/rel2core/PivotNormalizer.java b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/rel2core/PivotNormalizer.java
index ca8e3ba96..dde0937bd 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/rel2core/PivotNormalizer.java
+++ b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/rel2core/PivotNormalizer.java
@@ -26,7 +26,6 @@ import org.eclipse.ocl.pivot.NamedElement;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.ocl.pivot.utilities.NameUtil;
import org.eclipse.ocl.pivot.utilities.Nameable;
-import org.eclipse.ocl.pivot.utilities.NameUtil.NameableComparator;
import org.eclipse.qvtd.xtext.qvtimperative.tests.ModelNormalizer;
public class PivotNormalizer implements ModelNormalizer

Back to the top