Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java35
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java12
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java18
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java9
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java14
5 files changed, 68 insertions, 20 deletions
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
index d39a865d5..312ba759c 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
@@ -110,6 +110,7 @@ import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperativeUtil;
import org.eclipse.qvtd.runtime.evaluation.AbstractInvocation;
import org.eclipse.qvtd.runtime.evaluation.AbstractTransformer;
import org.eclipse.qvtd.runtime.evaluation.AbstractValueOccurrence;
+import org.eclipse.qvtd.runtime.evaluation.Invocation;
import org.eclipse.qvtd.runtime.evaluation.InvocationManager;
import org.eclipse.qvtd.runtime.evaluation.ObjectManager;
import org.eclipse.qvtd.runtime.evaluation.TransformationExecutor;
@@ -958,11 +959,18 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
js.append("public ");
js.append(getMappingName(cgMapping));
js.append("(");
+ if (isIncremental) {
+ js.appendClassReference(true, isIncremental ? Invocation.Constructor.Incremental.class : Invocation.Constructor.class);
+ js.append(" constructor, ");
+ }
js.appendIsRequired(true);
js.append(" Object ");
js.appendIsRequired(true);
js.append(" [] boundValues) {\n");
js.pushIndentation(null);
+ if (isIncremental) {
+ js.append("super(constructor);\n");
+ }
int i = 0;
for (@NonNull CGGuardVariable cgFreeVariable : cgFreeVariables) {
String valueName = getValueName(cgFreeVariable);
@@ -986,13 +994,12 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
protected void doMappingConstructorConstants(/*@NonNull*/ List<@NonNull CGMapping> cgMappings) {
for (@NonNull CGMapping cgMapping : cgMappings) {
- if (useClass(cgMapping) && (cgMapping.getFreeVariables().size() > 0)) {
+ if (useClass(cgMapping) && (isIncremental || (cgMapping.getFreeVariables().size() > 0))) {
+ Class<?> constructorClass = isIncremental ? AbstractInvocationConstructor.Incremental.class : AbstractInvocationConstructor.class;
js.append("protected final ");
- js.appendIsRequired(true);
- js.append(" ");
- js.appendClassReference(AbstractInvocationConstructor.class);
+ js.appendClassReference(true, constructorClass);
js.append(" " + getMappingCtorName(cgMapping) + " = new ");
- js.appendClassReference(AbstractInvocationConstructor.class);
+ js.appendClassReference(constructorClass);
js.append("(idResolver, ");
js.appendString(QVTiCGUtil.getName(cgMapping));
js.append(")\n");
@@ -1009,7 +1016,11 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
js.appendIsRequired(true);
js.append(" [] values) {\n");
js.pushIndentation(null);
- js.append("return new " + getMappingName(cgMapping) + "(values);\n");
+ js.append("return new " + getMappingName(cgMapping) + "(");
+ if (isIncremental) {
+ js.append("this, ");
+ }
+ js.append("values);\n");
js.popIndentation();
js.append("}\n");
js.popIndentation();
@@ -1116,19 +1127,17 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
js.append("@Override\n");
js.append("public boolean run() {\n");
js.pushIndentation(null);
- js.append("return ");
if (isIncremental) {
- js.append("new ");
- js.append(getMappingName(cgRootMapping));
- js.append("(new ");
- js.appendIsRequired(true);
- js.append(" Object[0]).execute()");
+ js.appendClassReference(Invocation.class);
+ js.append(" rootInvocation = " + getMappingCtorName(cgRootMapping) + ".newInstance(new @NonNull Object[0]);\n");
+ js.append("return rootInvocation.execute() && invocationManager.flush();\n");
}
else {
+ js.append("return ");
js.append(getMappingName(cgRootMapping));
js.append("()");
+ js.append(" && invocationManager.flush();\n");
}
- js.append(" && invocationManager.flush();\n");
js.popIndentation();
js.append("}\n");
}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java
index de0b4e6c9..9effec8a8 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java
@@ -163,11 +163,11 @@ public class QVTiIncrementalExecutor extends BasicQVTiExecutor
}
Invocation.Constructor invocationConstructor = mapping2invocationConstructor2.get(asMapping);
if (invocationConstructor == null) {
- invocationConstructor = new AbstractInvocationConstructor(idResolver, QVTimperativeUtil.getName(asMapping))
+ invocationConstructor = new AbstractInvocationConstructor.Incremental(idResolver, QVTimperativeUtil.getName(asMapping))
{
@Override
public @NonNull Invocation newInstance(@NonNull Object @NonNull [] theseValues) {
- Invocation.Incremental invocation = new AbstractInvocation.Incremental()
+ Invocation.Incremental invocation = new AbstractInvocation.Incremental(this)
{
protected Object returnStatus;
@@ -197,10 +197,10 @@ public class QVTiIncrementalExecutor extends BasicQVTiExecutor
return true;
}
- @Override
- public String toString() {
- return mappingCall.getReferredMapping().getName();// + "@" + Integer.toHexString(System.identityHashCode(this));
- }
+ // @Override
+ // public @NonNull String toString() {
+ // return mappingCall.getReferredMapping().getName();// + "@" + Integer.toHexString(System.identityHashCode(this));
+ // }
};
return invocation;
}
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 f462368ab..197652e0b 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
@@ -28,10 +28,18 @@ public abstract class AbstractInvocation extends AbstractInvocationInternal
public static final @NonNull List<@NonNull Object> EMPTY_OBJECT_LIST = Collections.emptyList();
public static final @NonNull List<SlotState.@NonNull Incremental> EMPTY_SLOT_LIST = Collections.emptyList();
+ protected final Invocation.@NonNull Constructor constructor;
+ protected final int sequence;
+
private Set<@NonNull Object> createdObjects = null;
private Set<SlotState.@NonNull Incremental> readSlots = null;
private Set<SlotState.@NonNull Incremental> writeSlots = null;
+ protected Incremental(Invocation.Constructor.@NonNull Incremental constructor) {
+ this.constructor = constructor;
+ this.sequence = constructor.nextSequence();
+ }
+
@Override
public void addCreatedObject(@NonNull Object createdObject) {
if (createdObjects == null) {
@@ -64,6 +72,11 @@ public abstract class AbstractInvocation extends AbstractInvocationInternal
}
@Override
+ public @NonNull String getName() {
+ return constructor.getName() + "-" + sequence;
+ }
+
+ @Override
public @NonNull Iterable<SlotState.@NonNull Incremental> getReadSlots() {
return readSlots != null ? readSlots : EMPTY_SLOT_LIST;
}
@@ -72,6 +85,11 @@ public abstract class AbstractInvocation extends AbstractInvocationInternal
public @NonNull Iterable<SlotState.@NonNull Incremental> getWriteSlots() {
return writeSlots != null ? writeSlots : EMPTY_SLOT_LIST;
}
+
+ @Override
+ public @NonNull String toString() {
+ return getName();
+ }
}
@Override
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 6f0a46735..919d74dde 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
@@ -46,6 +46,11 @@ public interface Invocation extends ExecutionVisitable
public interface Constructor extends Nameable
{
+ public interface Incremental extends Constructor
+ {
+ int nextSequence();
+ }
+
/**
* Return the first invocation of this constructor with argValues, using newInstance(argValues) to
* create a new invocation instance if necessary. Returns null if an instance already created.
@@ -61,12 +66,14 @@ public interface Invocation extends ExecutionVisitable
@NonNull Invocation newInstance(@NonNull Object @NonNull [] values);
}
- public interface Incremental extends Invocation
+ public interface Incremental extends Invocation, Nameable
{
void addCreatedObject(@NonNull Object createdObject);
void addReadSlot(SlotState.@NonNull Incremental readSlot);
void addWriteSlot(SlotState.@NonNull Incremental writeSlot);
@NonNull Iterable<@NonNull Object> getCreatedObjects();
+ @Override
+ @NonNull String getName();
@NonNull Iterable<SlotState.@NonNull Incremental> getReadSlots();
@NonNull Iterable<SlotState.@NonNull Incremental> getWriteSlots();
// void invalidate();
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java
index aebb0951f..b28271192 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java
@@ -22,6 +22,20 @@ import org.eclipse.qvtd.runtime.evaluation.Invocation;
public abstract class AbstractInvocationConstructor implements Invocation.Constructor
{
+ public static abstract class Incremental extends AbstractInvocationConstructor implements Invocation.Constructor.Incremental
+ {
+ protected int sequence = 0;
+
+ public Incremental(@NonNull IdResolver idResolver, @NonNull String name) {
+ super(idResolver, name);
+ }
+
+ @Override
+ public int nextSequence() {
+ return sequence++;
+ }
+ }
+
protected final IdResolver.@NonNull IdResolverExtension idResolver;
protected final @NonNull String name;

Back to the top