Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-10-30 11:20:32 +0000
committerEd Willink2016-10-30 11:41:06 +0000
commitad9e674cf3fa3a48aedbd37174de47a2bdc44f90 (patch)
treeff7ee08531147dc8839c6f03f1f5e1a445e2456f /plugins
parent7e9cc8f7c8293b8a8b57df4d109c8017c8c3be0c (diff)
downloadorg.eclipse.qvtd-ad9e674cf3fa3a48aedbd37174de47a2bdc44f90.tar.gz
org.eclipse.qvtd-ad9e674cf3fa3a48aedbd37174de47a2bdc44f90.tar.xz
org.eclipse.qvtd-ad9e674cf3fa3a48aedbd37174de47a2bdc44f90.zip
[500962] Generate and test plausible incremental code
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java118
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java279
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java13
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/BasicQVTiExecutor.java3
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java19
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractConnection.java10
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Connection.java4
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIncrementalConnectionInternal.java2
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIntervalInternal.java3
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java1
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java1
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java3
12 files changed, 341 insertions, 115 deletions
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java
index f5982afe0..f56a91307 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java
@@ -13,7 +13,11 @@ package org.eclipse.qvtd.codegen.qvti.analyzer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EClassifier;
@@ -59,12 +63,14 @@ import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.Variable;
import org.eclipse.ocl.pivot.VariableDeclaration;
import org.eclipse.ocl.pivot.VariableExp;
+import org.eclipse.ocl.pivot.ids.CollectionTypeId;
import org.eclipse.ocl.pivot.ids.TypeId;
import org.eclipse.ocl.pivot.internal.complete.StandardLibraryInternal;
import org.eclipse.ocl.pivot.library.LibraryProperty;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.ocl.pivot.utilities.NameUtil;
import org.eclipse.ocl.pivot.utilities.PivotUtil;
+import org.eclipse.ocl.pivot.utilities.TreeIterable;
import org.eclipse.qvtd.codegen.qvti.java.QVTiGlobalContext;
import org.eclipse.qvtd.codegen.qvticgmodel.CGConnectionAssignment;
import org.eclipse.qvtd.codegen.qvticgmodel.CGConnectionVariable;
@@ -165,6 +171,19 @@ public class QVTiAS2CGVisitor extends AS2CGVisitor implements QVTimperativeVisit
}
}
+ public static class InlinedBodyAdapter extends AdapterImpl
+ {
+ protected final @NonNull OperationCallExp operationCallExp;
+
+ public InlinedBodyAdapter(@NonNull OperationCallExp operationCallExp) {
+ this.operationCallExp = operationCallExp;
+ }
+
+ public @NonNull OperationCallExp getOperationCallExp() {
+ return operationCallExp;
+ }
+ }
+
/**
* PredicateTreeBuilder supports building a CGMapping.body as a nest of if/let expressions top-down,
* continually appending to the 'leaf' which is the then-expression of an if, or the in-expression of a let.
@@ -361,6 +380,80 @@ public class QVTiAS2CGVisitor extends AS2CGVisitor implements QVTimperativeVisit
this.standardLibrary = environmentFactory.getStandardLibrary();
}
+ private @NonNull Set<@NonNull Mapping> computeUseClases(@NonNull ImperativeTransformation asTransformation) {
+ //
+ // Compute the intervalIndex of each Mapping.
+ //
+ Map<@NonNull Mapping, @NonNull Integer> mapping2intervalIndex = new HashMap<>();
+ {
+ int intervalIndex = 0;
+ for (@NonNull Mapping asMapping : QVTimperativeUtil.getOwnedMappings(asTransformation)) {
+ mapping2intervalIndex.put(asMapping, intervalIndex++);
+ }
+ }
+ //
+ // Compute the latestIntervalIndex of each ConnectionVariable.
+ //
+ Map<@NonNull ConnectionVariable, @NonNull Integer> connectionValue2latestIntervalIndex = new HashMap<>();
+ for (@NonNull Mapping asMapping : QVTimperativeUtil.getOwnedMappings(asTransformation)) {
+ for (@NonNull EObject eObject : new TreeIterable(asMapping, false)) {
+ if (eObject instanceof AppendParameterBinding) {
+ AppendParameterBinding appendParameterBinding = (AppendParameterBinding)eObject;
+ MappingCall mappingCall = appendParameterBinding.getMappingCall();
+ Mapping referredMapping = mappingCall.getReferredMapping();
+ Integer appendingIntervalIndex = mapping2intervalIndex.get(referredMapping);
+ assert appendingIntervalIndex != null;
+ ConnectionVariable connectionValue = appendParameterBinding.getValue();
+ assert connectionValue != null;
+ Integer latestIntervalIndex = connectionValue2latestIntervalIndex.get(connectionValue);
+ if ((latestIntervalIndex == null) || (latestIntervalIndex < appendingIntervalIndex)) {
+ connectionValue2latestIntervalIndex.put(connectionValue, appendingIntervalIndex);
+ }
+ }
+ }
+ }
+ //
+ // Set Mapping isRecursive if consume may preceded append.
+ //
+ Set<@NonNull Mapping> useClassMappings = new HashSet<>();
+ for (@NonNull Mapping asMapping : QVTimperativeUtil.getOwnedMappings(asTransformation)) {
+ for (@NonNull EObject eObject : new TreeIterable(asMapping, false)) {
+ if (eObject instanceof GuardParameterBinding) {
+ GuardParameterBinding guardParameterBinding = (GuardParameterBinding)eObject;
+ MappingCall mappingCall = guardParameterBinding.getMappingCall();
+ Mapping referredMapping = mappingCall.getReferredMapping();
+ assert referredMapping != null;
+ Integer consumingIntervalIndex = mapping2intervalIndex.get(referredMapping);
+ assert consumingIntervalIndex != null;
+ ConnectionVariable connectionValue = guardParameterBinding.getValue();
+ assert connectionValue != null;
+ Integer latestIntervalIndex = connectionValue2latestIntervalIndex.get(connectionValue);
+ if (latestIntervalIndex == null) {
+ latestIntervalIndex = 0; // root connections are not 'appended'
+ }
+ if (latestIntervalIndex >= consumingIntervalIndex) {
+ useClassMappings.add(referredMapping);
+ }
+ }
+ }
+ }
+ //
+ //
+ //
+ for (@NonNull Mapping asMapping : QVTimperativeUtil.getOwnedMappings(asTransformation)) {
+ if (asMapping.isIsStrict()) {
+ useClassMappings.add(asMapping);
+ }
+ else if (QVTimperativeUtil.isObserver(asMapping)) {
+ useClassMappings.add(asMapping);
+ }
+ }
+ if (useClassMappings.size() > 0) {
+ useClassMappings.add(QVTimperativeUtil.getRootMapping(asTransformation));
+ }
+ return useClassMappings;
+ }
+
@Override
protected <T extends EObject> @NonNull T createCopy(@NonNull T aPrototype) {
Copier copier = new EcoreUtil.Copier();
@@ -545,19 +638,6 @@ public class QVTiAS2CGVisitor extends AS2CGVisitor implements QVTimperativeVisit
return cgInlineOperationCall;
}
- public static class InlinedBodyAdapter extends AdapterImpl
- {
- protected final @NonNull OperationCallExp operationCallExp;
-
- public InlinedBodyAdapter(@NonNull OperationCallExp operationCallExp) {
- this.operationCallExp = operationCallExp;
- }
-
- public @NonNull OperationCallExp getOperationCallExp() {
- return operationCallExp;
- }
- }
-
@Override
public @Nullable CGNamedElement visitAddStatement(@NonNull AddStatement asAddStatement) {
ConnectionVariable asVariable = asAddStatement.getTargetVariable();
@@ -617,12 +697,16 @@ public class QVTiAS2CGVisitor extends AS2CGVisitor implements QVTimperativeVisit
cgVariable.setRequired(initValue.isRequired());
return cgVariable; */
OCLExpression asInit = asVariable.getOwnedExpression();
- CGAccumulator cgAccumulator = CGModelFactory.eINSTANCE.createCGAccumulator();
+ CGAccumulator cgAccumulator = CGModelFactory.eINSTANCE.createCGAccumulator(); // ?? FIXME Use ConnectionVariable
cgAccumulator.setAst(asVariable);
cgAccumulator.setName(asVariable.getName());
if (asInit != null) {
CGValuedElement cgInit = doVisit(CGValuedElement.class, asInit);
- cgAccumulator.setTypeId(cgInit.getTypeId());
+ TypeId typeId = asInit.getTypeId();
+ if (typeId instanceof CollectionTypeId) {
+ typeId = ((CollectionTypeId)typeId).getElementTypeId();
+ }
+ cgAccumulator.setTypeId(analyzer.getTypeId(typeId));
cgAccumulator.setInit(cgInit);
// cgAccumulator.setRequired(true);
}
@@ -838,9 +922,13 @@ public class QVTiAS2CGVisitor extends AS2CGVisitor implements QVTimperativeVisit
cgTypedModel.setModelIndex(cgTypedModels.size());
cgTypedModels.add(cgTypedModel);
}
+ Set<@NonNull Mapping> useClasses = computeUseClases(asTransformation);
for (@NonNull Mapping asMapping : QVTimperativeUtil.getOwnedMappings(asTransformation)) {
CGMapping cgMapping = doVisit(CGMapping.class, asMapping);
cgTransformation.getMappings().add(cgMapping);
+ if (useClasses.contains(asMapping)) {
+ cgMapping.setUseClass(true);
+ }
}
for (Operation asOperation : asTransformation.getOwnedOperations()) {
CGOperation cgOperation = doVisit(CGOperation.class, asOperation);
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 7c95484c3..fe367793a 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
@@ -98,17 +98,15 @@ import org.eclipse.qvtd.codegen.qvticgmodel.CGTransformation;
import org.eclipse.qvtd.codegen.qvticgmodel.CGTypedModel;
import org.eclipse.qvtd.codegen.qvticgmodel.util.QVTiCGModelVisitor;
import org.eclipse.qvtd.codegen.utilities.QVTiCGUtil;
-import org.eclipse.qvtd.pivot.qvtimperative.AppendParameter;
import org.eclipse.qvtd.pivot.qvtimperative.AppendParameterBinding;
import org.eclipse.qvtd.pivot.qvtimperative.BufferStatement;
import org.eclipse.qvtd.pivot.qvtimperative.ConnectionVariable;
-import org.eclipse.qvtd.pivot.qvtimperative.GuardParameter;
+import org.eclipse.qvtd.pivot.qvtimperative.GuardParameterBinding;
import org.eclipse.qvtd.pivot.qvtimperative.ImperativeTransformation;
import org.eclipse.qvtd.pivot.qvtimperative.ImperativeTypedModel;
import org.eclipse.qvtd.pivot.qvtimperative.LoopParameterBinding;
import org.eclipse.qvtd.pivot.qvtimperative.Mapping;
import org.eclipse.qvtd.pivot.qvtimperative.MappingCall;
-import org.eclipse.qvtd.pivot.qvtimperative.MappingParameter;
import org.eclipse.qvtd.pivot.qvtimperative.MappingParameterBinding;
import org.eclipse.qvtd.pivot.qvtimperative.ObservableStatement;
import org.eclipse.qvtd.pivot.qvtimperative.SetStatement;
@@ -849,6 +847,7 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
}
protected void doFunctionIsEqual(@NonNull CGShadowExp cgShadowExp, @NonNull String instanceName) {
+ js.append("@Override\n");
js.append("public boolean isEqual(");
js.appendIsRequired(true);
js.append(" ");
@@ -992,6 +991,189 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
js.append("}\n");
}
+ public @NonNull Boolean doMappingCall_Class(@NonNull CGMappingCall cgMappingCall) {
+ js.append("invocationManager.flush();\n");
+ MappingCall pMappingCall = (MappingCall) cgMappingCall.getAst();
+ Mapping pReferredMapping = pMappingCall.getReferredMapping();
+ assert pReferredMapping != null;
+ CGMapping cgReferredMapping = analyzer.getMapping(pReferredMapping);
+ assert cgReferredMapping != null;
+ List<CGMappingCallBinding> cgMappingCallBindings = cgMappingCall.getMappingCallBindings();
+ //
+ // Set loopVariable non-null if it needs to be type-checked and cast to a narrower type.
+ //
+ for (@SuppressWarnings("null")@NonNull CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
+ TypeDescriptor checkedType = needsTypeCheck(cgMappingCallBinding);
+ if (checkedType != null) {
+ js.append("if (");
+ js.appendValueName(cgMappingCallBinding.getValue());
+ js.append(" instanceof ");
+ js.appendClassReference(checkedType);
+ js.append(") {\n");
+ js.pushIndentation(null);
+ }
+ else if (!cgMappingCallBinding.isNonNull()) {
+ Element asMappingParameterBinding = cgMappingCallBinding.getAst();
+ if (!(asMappingParameterBinding instanceof GuardParameterBinding)) { // FIXME this should be part of isNonNull
+ js.append("if (");
+ js.appendValueName(cgMappingCallBinding.getValue());
+ js.append(" != null) {\n");
+ js.pushIndentation(null);
+ }
+ }
+ }
+ //
+ // Emit the mapping call.
+ //
+ Iterable<@NonNull CGMappingCallBinding> iterateBindings = getIterateBindings(cgMappingCallBindings);
+ String mappingCtorName = getMappingCtorName(cgReferredMapping);
+ if (iterateBindings == null) {
+ for (CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
+ Element ast = cgMappingCallBinding.getAst();
+ js.append(mappingCtorName);
+ js.append(".");
+ js.append(ast instanceof AppendParameterBinding ? "addAppendedConnection" : "addConsumedConnection");
+ js.append("(");
+ appendConnectionBinding(cgMappingCallBinding);
+ js.append(");\n");
+ }
+ }
+ else {
+ js.append(mappingCtorName);
+ js.append(".invoke(");
+ boolean isFirst = true;
+ for (@SuppressWarnings("null")@NonNull CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
+ if (!isFirst) {
+ js.append(", ");
+ }
+ TypeDescriptor checkedType = needsTypeCheck(cgMappingCallBinding);
+ if (checkedType != null) {
+ js.append("(");
+ js.appendClassReference(checkedType);
+ js.append(")");
+ }
+ js.appendValueName(cgMappingCallBinding.getValue());
+ isFirst = false;
+ }
+ js.append(");\n");
+ }
+ //
+ // End the type check.
+ //
+ for (@SuppressWarnings("null")@NonNull CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
+ TypeDescriptor checkedType = needsTypeCheck(cgMappingCallBinding);
+ if (checkedType != null) {
+ js.popIndentation();
+ js.append("}\n");
+ }
+ else if (!cgMappingCallBinding.isNonNull()) {
+ Element asMappingParameterBinding = cgMappingCallBinding.getAst();
+ if (!(asMappingParameterBinding instanceof GuardParameterBinding)) { // FIXME this should be part of isNonNull
+ js.popIndentation();
+ js.append("}\n");
+ }
+ }
+ }
+ js.append("invocationManager.flush();\n");
+ return true;
+ }
+
+ public @NonNull Boolean doMappingCall_Function(@NonNull CGMappingCall cgMappingCall) {
+ MappingCall pMappingCall = (MappingCall) cgMappingCall.getAst();
+ Mapping pReferredMapping = pMappingCall.getReferredMapping();
+ assert pReferredMapping != null;
+ CGMapping cgReferredMapping = analyzer.getMapping(pReferredMapping);
+ assert cgReferredMapping != null;
+ List<CGMappingCallBinding> cgMappingCallBindings = cgMappingCall.getMappingCallBindings();
+ //
+ // Set loopVariable non-null if it needs to be type-checked and cast to a narrower type.
+ //
+ for (@SuppressWarnings("null")@NonNull CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
+ MappingParameterBinding asMappingParameterBinding = (MappingParameterBinding)cgMappingCallBinding.getAst();
+ if (asMappingParameterBinding instanceof AppendParameterBinding) {
+ }
+ else if (asMappingParameterBinding instanceof GuardParameterBinding) {
+ js.append("for (");
+ js.appendClassReference(Boolean.TRUE, cgMappingCallBinding);
+ js.append(" ");
+ js.appendValueName(cgMappingCallBinding);
+ js.append(" : ");
+ js.appendValueName(cgMappingCallBinding.getValue());
+ js.append(".typedIterable(");
+ js.appendClassReference(null, cgMappingCallBinding);
+ js.append(".class)");
+ js.append(") {\n");
+ js.pushIndentation(null);
+ // FIXME typeCheck
+ }
+ else {
+ TypeDescriptor checkedType = needsTypeCheck(cgMappingCallBinding);
+ if (checkedType != null) {
+ js.append("if (");
+ js.appendValueName(cgMappingCallBinding.getValue());
+ js.append(" instanceof ");
+ js.appendClassReference(checkedType);
+ js.append(") {\n");
+ js.pushIndentation(null);
+ }
+ else if (!cgMappingCallBinding.isNonNull()) {
+ js.append("if (");
+ js.appendValueName(cgMappingCallBinding.getValue());
+ js.append(" != null) {\n");
+ js.pushIndentation(null);
+ }
+ }
+ }
+ //
+ // Emit the mapping call.
+ //
+ js.append(getMappingName(cgReferredMapping) + "(");
+ boolean isFirst = true;
+ for (@SuppressWarnings("null")@NonNull CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
+ if (!isFirst) {
+ js.append(", ");
+ }
+ TypeDescriptor checkedType = needsTypeCheck(cgMappingCallBinding);
+ if (checkedType != null) {
+ js.append("(");
+ js.appendClassReference(checkedType);
+ js.append(")");
+ }
+ MappingParameterBinding asMappingParameterBinding = (MappingParameterBinding)cgMappingCallBinding.getAst();
+ if (asMappingParameterBinding instanceof GuardParameterBinding) {
+ js.appendValueName(cgMappingCallBinding);
+ }
+ else {
+ js.appendValueName(cgMappingCallBinding.getValue());
+ }
+ isFirst = false;
+ }
+ js.append(");\n");
+ //
+ // End the type check.
+ //
+ for (@SuppressWarnings("null")@NonNull CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
+ MappingParameterBinding asMappingParameterBinding = (MappingParameterBinding)cgMappingCallBinding.getAst();
+ if (asMappingParameterBinding instanceof AppendParameterBinding) {
+ }
+ else if (asMappingParameterBinding instanceof GuardParameterBinding) {
+ js.popIndentation();
+ js.append("}\n");
+ }
+ else {TypeDescriptor checkedType = needsTypeCheck(cgMappingCallBinding);
+ if (checkedType != null) {
+ js.popIndentation();
+ js.append("}\n");
+ }
+ else if (!cgMappingCallBinding.isNonNull()) {
+ js.popIndentation();
+ js.append("}\n");
+ }
+ }
+ }
+ return true;
+ }
+
protected void doMappingConnectionVariable(@NonNull CGGuardVariable cgFreeVariable) {
if (cgFreeVariable instanceof CGConnectionVariable) {
js.append("final ");
@@ -1051,7 +1233,7 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
protected void doMappingConstructorConstants(/*@NonNull*/ List<@NonNull CGMapping> cgMappings) {
for (@NonNull CGMapping cgMapping : cgMappings) {
- if (useClass(cgMapping) && (isIncremental || (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.appendClassReference(true, constructorClass);
@@ -1186,7 +1368,7 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
js.append("@Override\n");
js.append("public boolean run() {\n");
js.pushIndentation(null);
- if (isIncremental) {
+ if (isIncremental || useClass(cgRootMapping)) {
js.append(getMappingCtorName(cgRootMapping) + ".invoke();\n");
js.append("return invocationManager.flush();\n");
}
@@ -1357,17 +1539,11 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
if (alwaysUseClasses) {
return true;
}
- Mapping asMapping = ClassUtil.nonNullState((Mapping) cgMapping.getAst());
- if (QVTimperativeUtil.isObserver(asMapping)) {
+ if (isIncremental) {
return true;
}
- for (MappingParameter asParameter : asMapping.getOwnedParameters()) {
- if (asParameter instanceof AppendParameter) {
- return true;
- }
- if (asParameter instanceof GuardParameter) { // FIXME only if 'consumes'
- return true;
- }
+ if (cgMapping.isUseClass()) {
+ return true;
}
return false;
}
@@ -1795,81 +1971,12 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
}
}
}
- //
- // Set loopVariable non-null if it needs to be type-checked and cast to a narrower type.
- //
- for (@SuppressWarnings("null")@NonNull CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
- TypeDescriptor checkedType = needsTypeCheck(cgMappingCallBinding);
- if (checkedType != null) {
- js.append("if (");
- js.appendValueName(cgMappingCallBinding.getValue());
- js.append(" instanceof ");
- js.appendClassReference(checkedType);
- js.append(") {\n");
- js.pushIndentation(null);
- }
- else if (!cgMappingCallBinding.isNonNull()) {
- js.append("if (");
- js.appendValueName(cgMappingCallBinding.getValue());
- js.append(" != null) {\n");
- js.pushIndentation(null);
- }
- }
- //
- // Emit the mapping call.
- //
- Iterable<@NonNull CGMappingCallBinding> iterateBindings = getIterateBindings(cgMappingCallBindings);
- String mappingCtorName = getMappingCtorName(cgReferredMapping);
- if (useClass(cgReferredMapping) && (iterateBindings == null)) {
- for (CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
- Element ast = cgMappingCallBinding.getAst();
- js.append(mappingCtorName);
- js.append(".");
- js.append(ast instanceof AppendParameterBinding ? "addAppendedConnection" : "addConsumedConnection");
- js.append("(");
- appendConnectionBinding(cgMappingCallBinding);
- js.append(");\n");
- }
+ if (useClass(cgReferredMapping)) {
+ return doMappingCall_Class(cgMappingCall);
}
else {
- if (useClass(cgReferredMapping)) {
- js.append(mappingCtorName);
- js.append(".invoke(");
- }
- else {
- js.append(getMappingName(cgReferredMapping) + "(");
- }
- boolean isFirst = true;
- for (@SuppressWarnings("null")@NonNull CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
- if (!isFirst) {
- js.append(", ");
- }
- TypeDescriptor checkedType = needsTypeCheck(cgMappingCallBinding);
- if (checkedType != null) {
- js.append("(");
- js.appendClassReference(checkedType);
- js.append(")");
- }
- js.appendValueName(cgMappingCallBinding.getValue());
- isFirst = false;
- }
- js.append(");\n");
- }
- //
- // End the type check.
- //
- for (@SuppressWarnings("null")@NonNull CGMappingCallBinding cgMappingCallBinding : cgMappingCallBindings) {
- TypeDescriptor checkedType = needsTypeCheck(cgMappingCallBinding);
- if (checkedType != null) {
- js.popIndentation();
- js.append("}\n");
- }
- else if (!cgMappingCallBinding.isNonNull()) {
- js.popIndentation();
- js.append("}\n");
- }
+ return doMappingCall_Function(cgMappingCall);
}
- return true;
}
@Override
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java
index df5428f32..d8e6965d6 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java
@@ -162,9 +162,7 @@ public abstract class AbstractCompilerChain extends CompilerUtil implements Comp
options.setPackagePrefix(javaExtraPrefix);
}
Boolean javaIsIncremental = compilerChain.getOption(JAVA_STEP, JAVA_INCREMENTAL_KEY);
- if (javaIsIncremental != null) {
- options.setIsIncremental(true);
- }
+ options.setIsIncremental(javaIsIncremental == Boolean.TRUE);
String javaCodeSource;
try {
javaCodeSource = cg.generateClassFile();
@@ -417,9 +415,7 @@ public abstract class AbstractCompilerChain extends CompilerUtil implements Comp
@Override
public @NonNull Class<? extends Transformer> build(@NonNull String enforcedOutputName, @NonNull String ... genModelFiles) throws Exception {
ImperativeTransformation asTransformation = compile(enforcedOutputName);
- JavaResult javaResult = qvti2java(asTransformation, genModelFiles);
- Class<? extends Transformer> txClass = java2class(javaResult);
- return txClass;
+ return generate(asTransformation, genModelFiles);
}
@Override
@@ -499,6 +495,11 @@ public abstract class AbstractCompilerChain extends CompilerUtil implements Comp
@Override
public void dispose() {}
+ public @NonNull Class<? extends Transformer> generate(@NonNull ImperativeTransformation asTransformation, @NonNull String... genModelFiles) throws Exception {
+ JavaResult javaResult = qvti2java(asTransformation, genModelFiles);
+ return java2class(javaResult);
+ }
+
@Override
public @NonNull QVTiEnvironmentFactory getEnvironmentFactory() {
return environmentFactory;
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/BasicQVTiExecutor.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/BasicQVTiExecutor.java
index f3dd6689a..dd7514403 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/BasicQVTiExecutor.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/BasicQVTiExecutor.java
@@ -365,8 +365,7 @@ public abstract class BasicQVTiExecutor extends AbstractExecutor implements QVTi
@Override
public @Nullable Object internalExecuteTransformation(@NonNull ImperativeTransformation transformation, @NonNull EvaluationVisitor undecoratedVisitor) {
- Mapping rule = QVTimperativeUtil.getOwnedMapping(transformation, QVTimperativeUtil.ROOT_MAPPING_NAME);
- // assert rule == transformation.getRule().get(0);
+ Mapping rule = QVTimperativeUtil.getRootMapping(transformation);
CallExp callExp = PivotFactory.eINSTANCE.createOperationCallExp(); // FIXME TransformationCallExp
pushEvaluationEnvironment(rule, (TypedElement)callExp);
try {
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java
index 41ef7cea6..b5614c2c5 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java
@@ -48,6 +48,7 @@ import org.eclipse.qvtd.pivot.qvtimperative.LoopVariable;
import org.eclipse.qvtd.pivot.qvtimperative.Mapping;
import org.eclipse.qvtd.pivot.qvtimperative.MappingCall;
import org.eclipse.qvtd.pivot.qvtimperative.MappingLoop;
+import org.eclipse.qvtd.pivot.qvtimperative.MappingParameter;
import org.eclipse.qvtd.pivot.qvtimperative.MappingParameterBinding;
import org.eclipse.qvtd.pivot.qvtimperative.MappingStatement;
import org.eclipse.qvtd.pivot.qvtimperative.NewStatement;
@@ -265,8 +266,15 @@ public class QVTimperativeUtil extends QVTbaseUtil
}
@SuppressWarnings("unchecked")
+ public static @NonNull Iterable<@NonNull MappingParameter> getOwnedMappingParameters(@NonNull Mapping mapping) {
+ Object ownedParameters = mapping.getOwnedParameters();
+ return (@NonNull Iterable<@NonNull MappingParameter>)ownedParameters;
+ }
+
+ @SuppressWarnings("unchecked")
public static @NonNull Iterable<@NonNull Mapping> getOwnedMappings(@NonNull ImperativeTransformation transformation) {
- return (@NonNull Iterable<@NonNull Mapping>)(Object)transformation.getRule();
+ Object rule = transformation.getRule();
+ return (@NonNull Iterable<@NonNull Mapping>)rule;
}
public static @NonNull ImperativeTypedModel getOwnedTypedModel(@NonNull ImperativeTransformation transformation, @Nullable String name) {
@@ -275,7 +283,14 @@ public class QVTimperativeUtil extends QVTbaseUtil
@SuppressWarnings("unchecked")
public static @NonNull Iterable<@NonNull ImperativeTypedModel> getOwnedTypedModels(@NonNull ImperativeTransformation transformation) {
- return (@NonNull Iterable<@NonNull ImperativeTypedModel>)(Object)transformation.getModelParameter();
+ Object modelParameter = transformation.getModelParameter();
+ return (@NonNull Iterable<@NonNull ImperativeTypedModel>)modelParameter;
+ }
+
+ public static @NonNull Mapping getRootMapping(@NonNull ImperativeTransformation transformation) {
+ Mapping mapping = getOwnedMapping(transformation, QVTimperativeUtil.ROOT_MAPPING_NAME);
+ // assert mapping == transformation.getRule().get(0);
+ return mapping;
}
public static @NonNull Property getTargetProperty(@NonNull SetStatement asSetStatement) {
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractConnection.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractConnection.java
index cd190bc70..549c71249 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractConnection.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractConnection.java
@@ -74,6 +74,11 @@ public abstract class AbstractConnection implements Connection
return nextConnection;
}
+ // @Override
+ public boolean isQueued() {
+ return isQueued;
+ }
+
@Override
public void propagate() {
for (@NonNull InvocationConstructor consumer : consumers) {
@@ -81,7 +86,8 @@ public abstract class AbstractConnection implements Connection
}
}
- protected final void queue() {
+ @Override
+ public final void queue() {
if (!isQueued) {
isQueued = true;
interval.queue(this);
@@ -95,7 +101,7 @@ public abstract class AbstractConnection implements Connection
public void setNextConnection(@NonNull AbstractConnection nextConnection) {
assert nextConnection != this;
- assert isQueued;
+ // assert isQueued;
this.nextConnection = nextConnection;
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Connection.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Connection.java
index 0d99d4b53..ba36c8104 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Connection.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Connection.java
@@ -82,7 +82,11 @@ public interface Connection extends ExecutionVisitable, Nameable
int getValues();
+ // boolean isQueued();
+
void propagate();
+ void queue();
+
<@NonNull T> @NonNull Iterable<T> typedIterable(Class<T> elementClass);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIncrementalConnectionInternal.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIncrementalConnectionInternal.java
index f034b519b..6b8c13363 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIncrementalConnectionInternal.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIncrementalConnectionInternal.java
@@ -138,7 +138,7 @@ public abstract class AbstractIncrementalConnectionInternal extends AbstractConn
public void consume(int elementIndex, @NonNull Invocation invocation) {
List<@NonNull Object> valueAndConsumingInvocations = listOfValueAndConsumingInvocations.get(elementIndex);
assert valueAndConsumingInvocations != null;
- assert !valueAndConsumingInvocations.contains(invocation); // Earlier indexes cannot be the invocation, so no need for a sub-list
+ // assert !valueAndConsumingInvocations.contains(invocation); // Earlier indexes cannot be the invocation, so no need for a sub-list
valueAndConsumingInvocations.add(invocation);
// FIXME empty status if all consumers at final index
// invocationManager.dequeue(this);
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIntervalInternal.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIntervalInternal.java
index b5d3fa760..b87f37981 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIntervalInternal.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIntervalInternal.java
@@ -235,6 +235,9 @@ public abstract class AbstractIntervalInternal implements Interval
}
else { // New element
assert headConnection != null;
+ if (connection2.getNextConnection() != null) {
+ return;
+ }
tailConnection2.setNextConnection(connection2);
}
tailConnection = connection2;
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 9a490c431..56b41639a 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
@@ -321,6 +321,7 @@ public abstract class AbstractInvocationConstructor implements InvocationConstru
else {
firstConsumer = new Consumer(this, valuesCount, 0, connection);
}
+ connection.queue();
valuesCount++;
}
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 775347860..cf81a3f2d 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
@@ -546,6 +546,7 @@ public abstract class AbstractTransformerInternal extends AbstractModelManager i
return new LazyInvocationManager(executor);
}
+ @Deprecated // Use createConnection
protected SetValue.@NonNull Accumulator createUnenforcedSetAccumulatorValue(@NonNull CollectionTypeId typeId) {
return new UnenforcedSetAccumulator(typeId);
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java
index 8fce944fa..0f0a35f7d 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java
@@ -333,12 +333,13 @@ public class IncrementalObjectManager extends AbstractObjectManager
{
public ManyToManySlotState(@NonNull Object eObject, @NonNull EStructuralFeature eFeature) {
super(eObject, eFeature);
- throw new UnsupportedOperationException();
+ // throw new UnsupportedOperationException();
}
@Override
public synchronized void assigned(@NonNull Object eObject, @NonNull EStructuralFeature eFeature, @Nullable Object ecoreValue) {
throw new UnsupportedOperationException();
+ // ?? identify the mesh of M:N objects and set all of them assigned
}
}

Back to the top