Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[qvtd-dev] QVTc MappingCall support

Ho Horacio

I've just pushed the QVTc editor support for MappingCall's to master. The ICMT paper examples are now JUnit tests (there was a missing "|" in one of the guard patterns.)

A built distribution is available at https://hudson.eclipse.org/hudson/job/buckminster-mmt-qvtd-kepler/lastSuccessfulBuild/artifact/. An N-build will be on the download page tomorrow.

With two kinds of nested mapping Mapping now extends NestedMapping, to allow an alternate MappingCall. Mapping.local is therefore a NestedMapping.

The patch below fixes up QVTcoreEvaluationVisitorImpl, leaving you with the job of implementing visitMappingCall etc.

---

You same to have made very heavy weather of the M5 merge. If there's a problem it needs sorting out, since it should be easy.

    Regards

        Ed

### Eclipse Workspace Patch 1.0
#P uk.ac.york.qvtd.pivot.qvtcore
diff --git src/org/eclipse/qvtd/pivot/qvtcore/evaluation/QVTcoreEvaluationVisitorImpl.java src/org/eclipse/qvtd/pivot/qvtcore/evaluation/QVTcoreEvaluationVisitorImpl.java
index ebf276a..e167afb 100644
--- src/org/eclipse/qvtd/pivot/qvtcore/evaluation/QVTcoreEvaluationVisitorImpl.java +++ src/org/eclipse/qvtd/pivot/qvtcore/evaluation/QVTcoreEvaluationVisitorImpl.java
@@ -46,6 +46,9 @@
 import org.eclipse.qvtd.pivot.qvtcore.EnforcementOperation;
 import org.eclipse.qvtd.pivot.qvtcore.GuardPattern;
 import org.eclipse.qvtd.pivot.qvtcore.Mapping;
+import org.eclipse.qvtd.pivot.qvtcore.MappingCall;
+import org.eclipse.qvtd.pivot.qvtcore.MappingCallBinding;
+import org.eclipse.qvtd.pivot.qvtcore.NestedMapping;
 import org.eclipse.qvtd.pivot.qvtcore.PropertyAssignment;
 import org.eclipse.qvtd.pivot.qvtcore.RealizedVariable;
 import org.eclipse.qvtd.pivot.qvtcore.VariableAssignment;
@@ -318,14 +321,14 @@
// The transformation only has one mapping, the root mapping. Call // nested mappings in correct order, i.e. call all LtoM first then
             // all MtoR
-            for (Mapping m : ((Mapping) rule).getLocal()) {
+            for (NestedMapping m : ((Mapping) rule).getLocal()) {
                 if (isLtoMMapping(m)) {
                     m.accept(this);
                 }
             }
             // Remove all bindings to evaluate MtoR
             getEvaluationEnvironment().clear();
-            for (Mapping m : ((Mapping) rule).getLocal()) {
+            for (NestedMapping m : ((Mapping) rule).getLocal()) {
                 if (isMtoRMapping(m)) {
                     m.accept(this);
                 }
@@ -405,6 +408,22 @@
         }
         return true;
     }
+
+    @Override
+    @Nullable
+    public Object visitMappingCall(@NonNull MappingCall object) {
+ // TODO Add visit function or decide if it should never be implemented
+        throw new UnsupportedOperationException(
+                "Visit method not implemented yet");
+    }
+
+    @Override
+    @Nullable
+ public Object visitMappingCallBinding(@NonNull MappingCallBinding object) { + // TODO Add visit function or decide if it should never be implemented
+        throw new UnsupportedOperationException(
+                "Visit method not implemented yet");
+    }

     /**
* Visit left to middle mapping. Mapping's domains define the loop variables
@@ -433,7 +452,7 @@
                             mapping.getBottomPattern().accept(this);
                         //}
                         // Nested mappings
-                        for (Mapping localMapping : mapping.getLocal()) {
+ for (NestedMapping localMapping : mapping.getLocal()) {
                             localMapping.accept(this);
                         }
                     }
@@ -470,7 +489,7 @@
                     for (Domain domain : mapping.getDomain()) {
                         ((CoreDomain) domain).accept(this);
                     }
-                    for (Mapping localMapping : mapping.getLocal()) {
+                    for (NestedMapping localMapping : mapping.getLocal()) {
                         localMapping.accept(this);
                     }
                 }
@@ -488,7 +507,14 @@
      * @param mapping the mapping
      * @return true, if is mto r mapping
      */
-    private boolean isMtoRMapping(Mapping mapping) {
+    private boolean isMtoRMapping(NestedMapping nestedMapping) {
+        Mapping mapping;
+        if (nestedMapping instanceof MappingCall) {
+            mapping = ((MappingCall)nestedMapping).getReferredMapping();
+        }
+        else {
+            mapping = (Mapping)nestedMapping;
+        }
         if (mapping.getDomain().size() == 0) {
             return false;
         }
@@ -507,7 +533,14 @@
      * @param mapping the mapping
      * @return true, if is lto m mapping
      */
-    private boolean isLtoMMapping(Mapping mapping) {
+    private boolean isLtoMMapping(NestedMapping nestedMapping) {
+        Mapping mapping;
+        if (nestedMapping instanceof MappingCall) {
+            mapping = ((MappingCall)nestedMapping).getReferredMapping();
+        }
+        else {
+            mapping = (Mapping)nestedMapping;
+        }
         if (mapping.getDomain().size() == 0) {
             return false;
         }



Back to the top