Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-05-14 14:02:47 -0400
committerEd Willink2016-05-18 09:17:55 -0400
commitdb78d5ad470cc6fd6afed40e47d03d527a1eaea8 (patch)
tree0bcb2b0c5252d20bd551de7566787e7f7df14e8b
parent0189593c234fde5c39ab729154136ceeed385317 (diff)
downloadorg.eclipse.qvtd-db78d5ad470cc6fd6afed40e47d03d527a1eaea8.tar.gz
org.eclipse.qvtd-db78d5ad470cc6fd6afed40e47d03d527a1eaea8.tar.xz
org.eclipse.qvtd-db78d5ad470cc6fd6afed40e47d03d527a1eaea8.zip
[486722] Omit type-conformance casts from *.qvti
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java10
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/BasicQVTiExecutor.java22
2 files changed, 26 insertions, 6 deletions
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java
index 726252bf6..a26980bf9 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java
@@ -1372,11 +1372,11 @@ public class BasicRegion2Mapping extends AbstractRegion2Mapping
}
}
if (initExpression != null) {
- Type initType = initExpression.getType();
- assert variableType != null;
- if (!initType.conformsTo(visitor.getStandardLibrary(), variableType)) {
- initExpression = createOclAsTypeCallExp(initExpression, variableType);
- }
+// Type initType = initExpression.getType();
+// assert variableType != null;
+// if (!initType.conformsTo(visitor.getStandardLibrary(), variableType)) { // Let CG sort it out as a predicate
+// initExpression = createOclAsTypeCallExp(initExpression, variableType);
+// }
if (initExpression.isIsRequired()) {
isRequired = true;
}
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 bef509dab..c5238cdbf 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
@@ -14,6 +14,7 @@ import java.io.IOException;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.xmi.XMLResource;
@@ -25,6 +26,7 @@ import org.eclipse.ocl.pivot.OCLExpression;
import org.eclipse.ocl.pivot.PivotFactory;
import org.eclipse.ocl.pivot.Property;
import org.eclipse.ocl.pivot.Type;
+import org.eclipse.ocl.pivot.TypedElement;
import org.eclipse.ocl.pivot.Variable;
import org.eclipse.ocl.pivot.evaluation.EvaluationEnvironment;
import org.eclipse.ocl.pivot.evaluation.EvaluationVisitor;
@@ -35,6 +37,7 @@ import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.ocl.pivot.utilities.NameUtil;
import org.eclipse.ocl.pivot.utilities.ValueUtil;
import org.eclipse.ocl.pivot.values.CollectionValue;
+import org.eclipse.ocl.pivot.values.InvalidValueException;
import org.eclipse.qvtd.pivot.qvtbase.Domain;
import org.eclipse.qvtd.pivot.qvtbase.Predicate;
import org.eclipse.qvtd.pivot.qvtbase.Rule;
@@ -480,7 +483,24 @@ public class BasicQVTiExecutor extends AbstractExecutor implements QVTiExecutor
}
}
- public Resource saveModel(@NonNull String name, @NonNull URI modelURI, String contentType, @Nullable Map<?, ?> savingOptions) throws IOException {
+ @Override
+ public void replace(@NonNull TypedElement asVariable, @Nullable Object value) {
+ if (value == null) {
+ if (asVariable.isIsRequired()) {
+ throw new InvalidValueException("Attempted to assign null value to " + asVariable);
+ }
+ }
+ else if (!(value instanceof Throwable)){
+ Type valueType = getIdResolver().getDynamicTypeOf(value);
+ Type variableType = ClassUtil.nonNullState(asVariable.getType());
+ if (!valueType.conformsTo(getStandardLibrary(), variableType) && (variableType.getESObject() != EcorePackage.Literals.EOBJECT)) { // FIXME EObject fudge for Adolfo's test models
+ throw new InvalidValueException("Attempted to assign incompatible value to " + asVariable);
+ }
+ }
+ super.replace(asVariable, value);
+ }
+
+ public Resource saveModel(@NonNull String name, @NonNull URI modelURI, String contentType, @Nullable Map<?, ?> savingOptions) throws IOException {
TypedModel typedModel = NameUtil.getNameable(transformation.getModelParameter(), name);
if (typedModel == null) {
throw new IllegalStateException("Unknown TypedModel '" + name + "'");

Back to the top