Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-09-21 08:54:58 +0000
committerEd Willink2016-09-21 08:54:58 +0000
commitd3b004ded878d2e13654268b82f5b9a0f9314161 (patch)
treec68e49c8f0eb7dcfd5383eabb69f86440bd53b10 /plugins
parentf0ef5c5f0322caac2cc2716dfb96021e420c7b99 (diff)
downloadorg.eclipse.qvtd-d3b004ded878d2e13654268b82f5b9a0f9314161.tar.gz
org.eclipse.qvtd-d3b004ded878d2e13654268b82f5b9a0f9314161.tar.xz
org.eclipse.qvtd-d3b004ded878d2e13654268b82f5b9a0f9314161.zip
[500369] Eliminate DomainAnalysis from QVTi
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java20
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java64
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCodeGenerator.java4
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/AbstractDomainUsageAnalysis.java899
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/QVTimperativeDomainUsageAnalysis.java161
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/RootDomainUsageAnalysis.java704
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/BasicQVTiExecutor.java4
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEnvironmentFactory.java19
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java11
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java50
11 files changed, 75 insertions, 1862 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 e5aa1425c..7c98b54ab 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
@@ -65,7 +65,6 @@ 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.qvtd.codegen.qvti.java.QVTiCodeGenerator;
import org.eclipse.qvtd.codegen.qvti.java.QVTiGlobalContext;
import org.eclipse.qvtd.codegen.qvticgmodel.CGConnectionAssignment;
import org.eclipse.qvtd.codegen.qvticgmodel.CGConnectionVariable;
@@ -98,7 +97,6 @@ import org.eclipse.qvtd.pivot.qvtbase.Predicate;
import org.eclipse.qvtd.pivot.qvtbase.Rule;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
-import org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage;
import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
import org.eclipse.qvtd.pivot.qvtimperative.AddStatement;
import org.eclipse.qvtd.pivot.qvtimperative.AppendParameter;
@@ -126,7 +124,6 @@ import org.eclipse.qvtd.pivot.qvtimperative.SimpleParameter;
import org.eclipse.qvtd.pivot.qvtimperative.SimpleParameterBinding;
import org.eclipse.qvtd.pivot.qvtimperative.Statement;
import org.eclipse.qvtd.pivot.qvtimperative.VariableStatement;
-import org.eclipse.qvtd.pivot.qvtimperative.analysis.QVTimperativeDomainUsageAnalysis;
import org.eclipse.qvtd.pivot.qvtimperative.evaluation.QVTiTransformationAnalysis;
import org.eclipse.qvtd.pivot.qvtimperative.util.QVTimperativeVisitor;
import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperativeUtil;
@@ -369,23 +366,6 @@ public class QVTiAS2CGVisitor extends AS2CGVisitor implements QVTimperativeVisit
EObject aCopy = copier.copy(aPrototype);
assert aCopy != null;
copier.copyReferences();
- Transformation asTransformation = QVTbaseUtil.getContainingTransformation(aPrototype);
- if (asTransformation != null) {
- // System.out.println("Copying " + aPrototype);
- QVTiCodeGenerator codeGenerator = analyzer.getCodeGenerator();
- QVTiTransformationAnalysis transformationAnalysis = codeGenerator.getTransformationAnalysis(asTransformation);
- QVTimperativeDomainUsageAnalysis domainUsageAnalysis = transformationAnalysis.getDomainUsageAnalysis();
- for (EObject prototypeEObject : copier.keySet()) {
- EObject clonedEObject = copier.get(prototypeEObject);
- assert clonedEObject != null;
- DomainUsage usage = domainUsageAnalysis.basicGetUsage((Element)prototypeEObject);
- // System.out.println(" " + prototypeEObject.eClass().getName() + "@" + Integer.toHexString(System.identityHashCode(prototypeEObject)) + " => " + usage + " : " + prototypeEObject);
- if (usage != null) {
- // System.out.println(" " + clonedEObject.eClass().getName() + "@" + Integer.toHexString(System.identityHashCode(clonedEObject)) + " <= " + usage + " : " + clonedEObject);
- domainUsageAnalysis.setUsage((Element) clonedEObject, usage);
- }
- }
- }
@SuppressWarnings("unchecked") T castCopy = (T) aCopy;
return castCopy;
}
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 ab2ebd760..71681d164 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
@@ -56,7 +56,6 @@ import org.eclipse.ocl.pivot.Operation;
import org.eclipse.ocl.pivot.Parameter;
import org.eclipse.ocl.pivot.Property;
import org.eclipse.ocl.pivot.SetType;
-import org.eclipse.ocl.pivot.ShadowExp;
import org.eclipse.ocl.pivot.ShadowPart;
import org.eclipse.ocl.pivot.VariableDeclaration;
import org.eclipse.ocl.pivot.evaluation.Executor;
@@ -100,8 +99,8 @@ import org.eclipse.qvtd.codegen.qvticgmodel.util.QVTiCGModelVisitor;
import org.eclipse.qvtd.codegen.utilities.QVTiCGUtil;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
-import org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage;
import org.eclipse.qvtd.pivot.qvtimperative.ConnectionVariable;
+import org.eclipse.qvtd.pivot.qvtimperative.ImperativeTypedModel;
import org.eclipse.qvtd.pivot.qvtimperative.Mapping;
import org.eclipse.qvtd.pivot.qvtimperative.MappingCall;
import org.eclipse.qvtd.pivot.qvtimperative.MappingParameterBinding;
@@ -541,7 +540,8 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
protected boolean doFunctionBody2(@NonNull CGFunction cgFunction, @NonNull CGShadowExp cgShadowExp, @NonNull String instanceName) {
js.append(" {\n");
js.pushIndentation(null);
- doEcoreCreate(cgShadowExp, ClassUtil.nonNullState(cgShadowExp.getEcoreClassifier()));
+ EClassifier eClassifier = ClassUtil.nonNullState(cgShadowExp.getEcoreClassifier());
+ doEcoreCreate(cgShadowExp, eClassifier);
int index = 0;
for (@NonNull CGShadowPart cgShadowPart : ClassUtil.nullFree(cgShadowExp.getParts())) {
Property asProperty = ClassUtil.nonNullState(((ShadowPart)cgShadowPart.getAst()).getReferredProperty());
@@ -570,17 +570,51 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
js.appendValueName(cgShadowExp);
js.append(";\n");
//
- ShadowExp asShadowExp = (ShadowExp)ClassUtil.nonNullState(cgShadowExp.getAst());
- DomainUsage usage = transformationAnalysis.getDomainUsageAnalysis().getUsage(asShadowExp);
- TypedModel asTypedModel = ClassUtil.nonNullState(usage.getTypedModel(asShadowExp));
- CGTypedModel cgTypedModel = context.getAnalyzer().getTypedModel(asTypedModel);
+ EPackage ePackage = eClassifier.getEPackage();
+ ImperativeTypedModel bestOutputTypedModel = null;
+ ImperativeTypedModel bestMiddleTypedModel = null;
+ ImperativeTypedModel bestInputTypedModel = null;
+ for (TypedModel typedModel : transformationAnalysis.getTransformation().getModelParameter()) {
+ ImperativeTypedModel imperativeTypedModel = null;
+ if (typedModel instanceof ImperativeTypedModel) {
+ for (org.eclipse.ocl.pivot.Package usedPackage : typedModel.getUsedPackage()) {
+ if (usedPackage.getESObject() == ePackage) {
+ imperativeTypedModel = (ImperativeTypedModel) typedModel;
+ }
+ }
+ if (imperativeTypedModel != null) {
+ if (imperativeTypedModel.isIsEnforced()) {
+ bestOutputTypedModel = imperativeTypedModel;
+ }
+ else if (!imperativeTypedModel.isIsChecked()) {
+ bestMiddleTypedModel = imperativeTypedModel;
+ }
+ else {
+ bestInputTypedModel = imperativeTypedModel;
+ }
+ }
+ }
+ }
+ ImperativeTypedModel asTypedModel = null;
+ if (bestOutputTypedModel != null) {
+ asTypedModel = bestOutputTypedModel;
+ }
+ else if (bestMiddleTypedModel != null) {
+ asTypedModel = bestMiddleTypedModel;
+ }
+ else if (bestInputTypedModel != null) {
+ asTypedModel = bestInputTypedModel;
+ }
+ if (asTypedModel != null) { // FIXME Why are shadow objects put in a model at all -- testQVTrCompiler_SeqToStm_CG requires it
+ CGTypedModel cgTypedModel = context.getAnalyzer().getTypedModel(asTypedModel);
+ js.append(QVTiGlobalContext.MODELS_NAME);
+ js.append("[");
+ appendModelIndex(cgTypedModel);
+ js.append("].add(");
+ js.appendValueName(cgShadowExp);
+ js.append(");\n");
+ }
//
- js.append(QVTiGlobalContext.MODELS_NAME);
- js.append("[");
- appendModelIndex(cgTypedModel);
- js.append("].add(");
- js.appendValueName(cgShadowExp);
- js.append(");\n");
js.popIndentation();
js.append("}\n");
return true;
@@ -1964,7 +1998,7 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
return true;
}
- @Override
+ /* @Override
public @NonNull Boolean visitCGShadowExp(@NonNull CGShadowExp cgShadowExp) {
super.visitCGShadowExp(cgShadowExp);
ShadowExp asShadowExp = (ShadowExp)ClassUtil.nonNullState(cgShadowExp.getAst());
@@ -1978,7 +2012,7 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
js.appendValueName(cgShadowExp);
js.append(");\n");
return true;
- }
+ } */
@Override
public @NonNull Boolean visitCGTransformation(@NonNull CGTransformation cgTransformation) {
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCodeGenerator.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCodeGenerator.java
index d334f624a..466b4ab8b 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCodeGenerator.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCodeGenerator.java
@@ -247,8 +247,8 @@ public class QVTiCodeGenerator extends JavaCodeGenerator
// Map<Transformation, QVTiTransformationAnalysis> transformation2analysis = new HashMap<Transformation, QVTiTransformationAnalysis>();
QVTiTransformationAnalysis transformationAnalysis = transformation2analysis.get(transformation);
if (transformationAnalysis == null) {
- transformationAnalysis = new QVTiTransformationAnalysis(getEnvironmentFactory());
- transformationAnalysis.analyzeTransformation(transformation);
+ transformationAnalysis = new QVTiTransformationAnalysis(getEnvironmentFactory(), transformation);
+ transformationAnalysis.analyzeTransformation();
transformation2analysis.put(transformation, transformationAnalysis);
}
return transformationAnalysis;
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/META-INF/MANIFEST.MF b/plugins/org.eclipse.qvtd.pivot.qvtimperative/META-INF/MANIFEST.MF
index 2f67c20be..f34bd3933 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/META-INF/MANIFEST.MF
@@ -8,7 +8,6 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.qvtd.pivot.qvtimperative,
- org.eclipse.qvtd.pivot.qvtimperative.analysis,
org.eclipse.qvtd.pivot.qvtimperative.attributes,
org.eclipse.qvtd.pivot.qvtimperative.evaluation,
org.eclipse.qvtd.pivot.qvtimperative.evaluationstatus,
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/AbstractDomainUsageAnalysis.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/AbstractDomainUsageAnalysis.java
deleted file mode 100644
index b62e0de91..000000000
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/AbstractDomainUsageAnalysis.java
+++ /dev/null
@@ -1,899 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 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.pivot.qvtimperative.analysis;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.ocl.pivot.CollectionItem;
-import org.eclipse.ocl.pivot.CollectionLiteralExp;
-import org.eclipse.ocl.pivot.CollectionLiteralPart;
-import org.eclipse.ocl.pivot.CollectionRange;
-import org.eclipse.ocl.pivot.CollectionType;
-import org.eclipse.ocl.pivot.Element;
-import org.eclipse.ocl.pivot.ExpressionInOCL;
-import org.eclipse.ocl.pivot.IfExp;
-import org.eclipse.ocl.pivot.IterateExp;
-import org.eclipse.ocl.pivot.Iteration;
-import org.eclipse.ocl.pivot.IteratorExp;
-import org.eclipse.ocl.pivot.LanguageExpression;
-import org.eclipse.ocl.pivot.LetExp;
-import org.eclipse.ocl.pivot.LiteralExp;
-import org.eclipse.ocl.pivot.MapLiteralExp;
-import org.eclipse.ocl.pivot.MapLiteralPart;
-import org.eclipse.ocl.pivot.NavigationCallExp;
-import org.eclipse.ocl.pivot.NullLiteralExp;
-import org.eclipse.ocl.pivot.OCLExpression;
-import org.eclipse.ocl.pivot.Operation;
-import org.eclipse.ocl.pivot.OperationCallExp;
-import org.eclipse.ocl.pivot.OppositePropertyCallExp;
-import org.eclipse.ocl.pivot.Parameter;
-import org.eclipse.ocl.pivot.PrimitiveType;
-import org.eclipse.ocl.pivot.Property;
-import org.eclipse.ocl.pivot.PropertyCallExp;
-import org.eclipse.ocl.pivot.SelfType;
-import org.eclipse.ocl.pivot.ShadowExp;
-import org.eclipse.ocl.pivot.ShadowPart;
-import org.eclipse.ocl.pivot.TemplateParameter;
-import org.eclipse.ocl.pivot.TemplateSignature;
-import org.eclipse.ocl.pivot.TemplateableElement;
-import org.eclipse.ocl.pivot.TupleLiteralExp;
-import org.eclipse.ocl.pivot.TupleLiteralPart;
-import org.eclipse.ocl.pivot.TupleType;
-import org.eclipse.ocl.pivot.Type;
-import org.eclipse.ocl.pivot.TypeExp;
-import org.eclipse.ocl.pivot.TypedElement;
-import org.eclipse.ocl.pivot.Variable;
-import org.eclipse.ocl.pivot.VariableDeclaration;
-import org.eclipse.ocl.pivot.VariableExp;
-import org.eclipse.ocl.pivot.ids.OperationId;
-import org.eclipse.ocl.pivot.internal.manager.TemplateParameterSubstitutionVisitor;
-import org.eclipse.ocl.pivot.internal.utilities.EnvironmentFactoryInternal;
-import org.eclipse.ocl.pivot.util.Visitable;
-import org.eclipse.ocl.pivot.utilities.ClassUtil;
-import org.eclipse.ocl.pivot.utilities.EnvironmentFactory;
-import org.eclipse.ocl.pivot.utilities.MetamodelManager;
-import org.eclipse.ocl.pivot.utilities.ParserException;
-import org.eclipse.qvtd.pivot.qvtbase.Domain;
-import org.eclipse.qvtd.pivot.qvtbase.Function;
-import org.eclipse.qvtd.pivot.qvtbase.Predicate;
-import org.eclipse.qvtd.pivot.qvtbase.Rule;
-import org.eclipse.qvtd.pivot.qvtbase.Transformation;
-import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
-import org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage;
-import org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsageAnalysis;
-import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
-import org.eclipse.qvtd.pivot.qvtimperative.CheckStatement;
-import org.eclipse.qvtd.pivot.qvtimperative.DeclareStatement;
-import org.eclipse.qvtd.pivot.qvtimperative.GuardParameter;
-import org.eclipse.qvtd.pivot.qvtimperative.Mapping;
-import org.eclipse.qvtd.pivot.qvtimperative.MappingParameter;
-import org.eclipse.qvtd.pivot.qvtimperative.NewStatement;
-import org.eclipse.qvtd.pivot.qvtimperative.SetStatement;
-import org.eclipse.qvtd.pivot.qvtimperative.SimpleParameter;
-import org.eclipse.qvtd.pivot.qvtimperative.Statement;
-import org.eclipse.qvtd.pivot.qvtimperative.util.AbstractExtendingQVTimperativeVisitor;
-import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperativeUtil;
-
-/**
- * AbstractDomainUsageAnalysis provides shared functionality for the overall analysis and for nested operational analyses.
- */
-public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTimperativeVisitor<org.eclipse.qvtd.pivot.qvtbase.analysis.@NonNull DomainUsage, @NonNull EnvironmentFactory> implements DomainUsageAnalysis.Internal
-{
- private DomainUsage selfUsage = null;
- protected final @NonNull Map<@NonNull Element, org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage> element2usage = new HashMap<@NonNull Element, org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage>();
-
- protected AbstractDomainUsageAnalysis(@NonNull EnvironmentFactory environmentFactory) {
- super(environmentFactory);
- }
-
- @Override
- public @Nullable DomainUsage basicGetUsage(@Nullable Element element) {
- return element2usage.get(element);
- }
-
- protected @NonNull DomainUsage doNavigationCallExp(@NonNull Property property, @NonNull NavigationCallExp object) {
- DomainUsage actualSourceUsage = visit(object.getOwnedSource());
- DomainUsage knownPropertyUsage = visit(property);
- DomainUsage usage = knownPropertyUsage;
- RootDomainUsageAnalysis rootAnalysis = getRootAnalysis();
- Property oppositeProperty = property.getOpposite();
- if (property.isIsComposite() // Composite properties have both ends in the sme domain
- || ((oppositeProperty != null) && oppositeProperty.isIsComposite())
- || (property == rootAnalysis.getOclContainerProperty()) // FIXME ensure these are isComposite
- || (property == rootAnalysis.getOclContentsProperty())) {
- usage = intersection(usage, actualSourceUsage);
- }
- else if (!property.isIsImplicit() /*&& !rootAnalysis.isDirty(property)*/ // Simple input domain nodes cannot reference middle or output domains
- && (usage.isMiddle() || usage.isOutput())
- && actualSourceUsage.isInput() && !actualSourceUsage.isMiddle() && !actualSourceUsage.isOutput()) {
- usage = intersection(usage, actualSourceUsage);
- }
- return usage;
- }
-
- protected @NonNull DomainUsage doSetStatement(@NonNull Property property, @NonNull SetStatement object) {
- DomainUsage slotUsage = visit(object.getTargetVariable());
- DomainUsage valueUsage = visit(object.getOwnedExpression());
- DomainUsage knownSourceUsage = getRootAnalysis().property2containingClassUsage.get(property);
- if (knownSourceUsage != null) {
- DomainUsage knownTargetUsage = getRootAnalysis().getUsage(property);
- assert knownTargetUsage != null;
- intersection(knownSourceUsage, slotUsage);
- intersection(knownTargetUsage, valueUsage);
- return knownSourceUsage; //intersection(knownTargetUsage, valueUsage);
- }
- else {
- return slotUsage; //intersection(slotUsage, valueUsage);
- }
- }
-
- protected @NonNull DomainUsage getAllInstancesUsage(@NonNull OperationCallExp object, @NonNull DomainUsage sourceUsage) {
- return sourceUsage;
- }
-
- protected @NonNull DomainUsage getDomainUsage(@Nullable EObject object) {
- Domain domain = QVTimperativeUtil.getContainingDomain(object);
- if (domain != null) {
- return visit(domain.getTypedModel());
- }
- else {
- return getRootAnalysis().getMiddleUsage();
- }
- }
-
- public @NonNull Map<@NonNull Element, org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage> getElements2Usage() {
- return element2usage;
- }
-
- public @NonNull EnvironmentFactory getEnvironmentFactory() {
- return context;
- }
-
- protected abstract @NonNull RootDomainUsageAnalysis getRootAnalysis();
-
- @Override
- public @NonNull DomainUsage getUsage(@NonNull Element element) {
- DomainUsage usage = element2usage.get(element);
- if (usage == null) {
- usage = element.accept(this);
- // if ((usage == null) || usage.isNone()) { // FIXME debugging
- // usage = element.accept(this);
- // }
- assert usage != null : "null usage for " + element.eClass().getName() + " " + element;
- setUsage(element, usage);
- }
- return usage;
- }
-
- public @NonNull DomainUsage intersection(@NonNull DomainUsage firstUsage, @NonNull DomainUsage secondUsage) {
- int firstMask = ((DomainUsage.Internal)firstUsage).getMask();
- int secondMask = ((DomainUsage.Internal)secondUsage).getMask();
- if (firstMask == secondMask) {
- if (firstUsage != secondUsage) {
- if (!firstUsage.isConstant()) {
- replace((DomainUsage.Internal) firstUsage, secondUsage);
- return secondUsage;
- }
- else if (!secondUsage.isConstant()) {
- replace((DomainUsage.Internal) secondUsage, firstUsage);
- return firstUsage;
- }
- }
- return firstUsage;
- }
- else {
- int intersectionMask = firstMask & secondMask;
- DomainUsage usage = getRootAnalysis().getValidUsage(intersectionMask);
- if (usage != null) {
- if ((usage != firstUsage) && !firstUsage.isConstant()) {
- replace((DomainUsage.Internal) firstUsage, usage);
- }
- if ((usage != secondUsage) && !secondUsage.isConstant()) {
- replace((DomainUsage.Internal) secondUsage, usage);
- }
- return usage;
- }
- else {
- usage = getRootAnalysis().createVariableUsage(intersectionMask);
- if (!firstUsage.isConstant()) {
- replace((DomainUsage.Internal) firstUsage, usage);
- }
- if (!secondUsage.isConstant()) {
- replace((DomainUsage.Internal) secondUsage, usage);
- }
- return usage;
- }
- }
- }
-
- protected void popSelfUsage(@Nullable DomainUsage savedUsage) {
- selfUsage = savedUsage;
- }
-
- protected DomainUsage pushSelfUsage(@NonNull DomainUsage usage) {
- DomainUsage oldUsage = selfUsage;
- int usageMask = ((DomainUsage.Internal)usage).getMask();
- DomainUsage constantUsage = getRootAnalysis().getValidUsage(usageMask);
- if (constantUsage == null) {
- usage = getRootAnalysis().createVariableUsage(usageMask);
- }
- selfUsage = usage;
- return oldUsage;
- }
-
- protected void replace(DomainUsage.@NonNull Internal oldUsage, @NonNull DomainUsage newUsage) {
- Iterable<Element> elements = oldUsage.getElements();
- if (elements != null) {
- for (@SuppressWarnings("null")@NonNull Element element : elements) {
- setUsage(element, newUsage);
- }
- }
- }
-
- protected void setBoundVariablesUsages(@NonNull Rule rule) {
- /* DomainUsage primitiveUsage = getRootAnalysis().getPrimitiveUsage();
- for (Domain domain : rule.getDomain()) {
- if (domain instanceof ImperativeDomain) {
- DomainUsage usage = visit(domain.getTypedModel());
- for (GuardParameter variable : ((ImperativeDomain)domain).getOwnedGuardVariables()) {
- if (variable != null) {
- DomainUsage variableUsage = visit(variable.getType());
- if (variableUsage != primitiveUsage) {
- variableUsage = usage;
- }
- assert variableUsage != null;
- setUsage(variable, variableUsage);
- }
- }
- }
- } */
- if (rule instanceof Mapping) {
- DomainUsage middleUsage = getRootAnalysis().getMiddleUsage();
- for (MappingParameter variable : ((Mapping)rule).getOwnedParameters()) {
- if (variable != null) {
- DomainUsage variableUsage = visit(variable.getType());
- // if (variableUsage != primitiveUsage) {
- if (!variableUsage.isInput() && !variableUsage.isOutput() && !variableUsage.isPrimitive()) {
- variableUsage = middleUsage;
- }
- assert variableUsage != null;
- setUsage(variable, variableUsage);
- }
- }
- }
- }
-
- protected void setUsage(@NonNull Element element, @NonNull DomainUsage newUsage) {
- // if (newUsage.isNone()) {
- // element.toString();
- // }
- // if ("s".equals(element.toString())) {
- // element.toString();
- // }
- element2usage.put(element, newUsage);
- ((DomainUsage.Internal)newUsage).addUsedBy(element);
- // System.out.println(" setUsage " + getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(this))
- // + " : " + element.eClass().getName() + "@" + Integer.toHexString(System.identityHashCode(element))
- // + " <= " + newUsage
- // );
- }
-
- @Override
- public String toString() {
- Map<@NonNull String, org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage> map = new HashMap<@NonNull String, org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage>(element2usage.size());
- List<@NonNull String> keys = new ArrayList<@NonNull String>(element2usage.size());
- for (Map.Entry<@NonNull Element, org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage> entry : element2usage.entrySet()) {
- Element element = entry.getKey();
- String key = element.eClass().getName() + " : " + element;
- map.put(key, entry.getValue());
- keys.add(key);
- }
- Collections.sort(keys);
- StringBuilder s = new StringBuilder();
- for (@NonNull String key : keys) {
- DomainUsage usage = map.get(key);
- if (s.length() > 0) {
- s.append("\n");
- }
- s.append(key);
- s.append(" => ");
- s.append(usage);
- }
- return s.toString();
- }
-
- public @NonNull DomainUsage union(@NonNull DomainUsage firstUsage, @NonNull DomainUsage secondUsage) {
- int firstMask = ((DomainUsage.Internal)firstUsage).getMask();
- int secondMask = ((DomainUsage.Internal)secondUsage).getMask();
- int unionMask = firstMask | secondMask;
- if ((unionMask == firstMask) && firstUsage.isConstant()) {
- return firstUsage;
- }
- else if ((unionMask == secondMask) && secondUsage.isConstant()) {
- return secondUsage;
- }
- else if (firstUsage.isConstant() && secondUsage.isConstant()) {
- return getRootAnalysis().getConstantUsage(unionMask);
- }
- else {
- return getRootAnalysis().createVariableUsage(unionMask);
- }
- }
-
- @Override
- public @NonNull DomainUsage visit(@Nullable Element element) {
- if (element == null) {
- return getRootAnalysis().getAnyUsage();
- }
- DomainUsage usage = element2usage.get(element);
- if (usage == null) {
- // if ("s : StmcMM::StateMachine[1]".equals(element.toString())) {
- // element.toString();
- // }
- usage = element.accept(this);
- // if (usage == null) { // FIXME debugging
- // usage = element.accept(this);
- // }
- assert usage != null : "null usage for " + element.eClass().getName() + " " + element;
- setUsage(element, usage);
- }
- return usage;
- }
-
- @Override
- public @NonNull DomainUsage visiting(@NonNull Visitable visitable) {
- throw new UnsupportedOperationException("Unsupported " + visitable.eClass().getName() + " for " + getClass().getSimpleName());
- }
-
- @Override
- public @NonNull DomainUsage visitCheckStatement(@NonNull CheckStatement object) {
- return visit(object.getOwnedExpression());
- }
-
- @Override
- public @NonNull DomainUsage visitClass(org.eclipse.ocl.pivot.@NonNull Class object) {
- DomainUsage usage = getRootAnalysis().class2usage.get(object);
- if (usage != null) {
- return usage;
- }
- else {
- return getRootAnalysis().getPrimitiveUsage();
- }
- }
-
- @Override
- public @NonNull DomainUsage visitCollectionItem(@NonNull CollectionItem object) {
- return visit(object.getOwnedItem());
- }
-
- @Override
- public @NonNull DomainUsage visitCollectionLiteralExp(@NonNull CollectionLiteralExp object) {
- DomainUsage usage = visit(((CollectionType)object.getType()).getElementType());
- // DomainUsage usage = getRootAnalysis().getAnyUsage();
- for (@SuppressWarnings("null")@NonNull CollectionLiteralPart part : object.getOwnedParts()) {
- usage = intersection(usage, visit(part));
- }
- return usage;
- }
-
- @Override
- public @NonNull DomainUsage visitCollectionRange(@NonNull CollectionRange object) {
- DomainUsage firstUsage = visit(object.getOwnedFirst());
- DomainUsage lastUsage = visit(object.getOwnedLast());
- return intersection(firstUsage, lastUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitCollectionType(@NonNull CollectionType object) {
- return visit(object.getElementType());
- }
-
- @Override
- public @NonNull DomainUsage visitDeclareStatement(@NonNull DeclareStatement object) {
- OCLExpression ownedExpression = object.getOwnedExpression();
- if (ownedExpression != null) {
- return visit(ownedExpression);
- }
- return visit(object.getType());
- }
-
- @Override
- public @NonNull DomainUsage visitExpressionInOCL(@NonNull ExpressionInOCL object) {
- OCLExpression ownedBody = object.getOwnedBody();
- if ((ownedBody == null) && (object.getBody() != null)) {
- try {
- ownedBody = context.getMetamodelManager().parseSpecification(object).getOwnedBody(); // FIXME why is this necessary
- } catch (ParserException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- Variable ownedContext = object.getOwnedContext();
- if ((ownedContext != null) && (selfUsage != null)) {
- setUsage(ownedContext, selfUsage);
- }
- else {
- visit(ownedContext);
- }
- for (Variable parameter : object.getOwnedParameters()) {
- visit(parameter);
- }
- visit(object.getOwnedResult());
- return visit(ownedBody);
- }
-
- @Override
- public @NonNull DomainUsage visitFunction(@NonNull Function object) {
- for (@SuppressWarnings("null")@NonNull Parameter parameter : object.getOwnedParameters()) {
- visit(parameter);
- }
- OCLExpression queryExpression = object.getQueryExpression();
- if (queryExpression != null) {
- return visit(queryExpression);
- }
- else {
- return visit(object.getType());
- }
- }
-
- @Override
- public @NonNull DomainUsage visitGuardParameter(@NonNull GuardParameter object) {
- return visit(object.getReferredTypedModel());
- }
-
- @Override
- public @NonNull DomainUsage visitIfExp(@NonNull IfExp object) {
- @SuppressWarnings("unused") DomainUsage conditionUsage = visit(object.getOwnedCondition());
- DomainUsage thenUsage = visit(object.getOwnedThen());
- DomainUsage elseUsage = visit(object.getOwnedElse());
- return intersection(thenUsage, elseUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitIterateExp(@NonNull IterateExp object) {
- DomainUsage sourceUsage = visit(object.getOwnedSource());
- for (Variable iterator : object.getOwnedIterators()) {
- if (iterator != null) {
- setUsage(iterator, sourceUsage);
- }
- }
- visit(object.getOwnedResult());
- @SuppressWarnings("unused") DomainUsage bodyUsage = visit(object.getOwnedBody());
- TemplateParameterSubstitutionVisitor visitor = new TemplateParameterSubstitutionVisitor((@NonNull EnvironmentFactoryInternal) context, object.getOwnedSource().getType(), null);
- object.accept(visitor);
- Iteration iteration = object.getReferredIteration();
- for (EObject eObject = iteration; eObject != null; eObject = eObject.eContainer()) {
- if (eObject instanceof TemplateableElement) {
- TemplateSignature ownedSignature = ((TemplateableElement)eObject).getOwnedSignature();
- if (ownedSignature != null) {
- for (TemplateParameter templateParameter : ownedSignature.getOwnedParameters()) {
- if (templateParameter != null) {
- Type templateParameterType = visitor.get(templateParameter);
- DomainUsage templateParameterUsage = visit(templateParameterType);
- setUsage(templateParameter, templateParameterUsage);
- }
- }
- }
- }
- }
- return visit(iteration.getType());
- }
-
- @Override
- public @NonNull DomainUsage visitIteratorExp(@NonNull IteratorExp object) {
- DomainUsage sourceUsage = visit(object.getOwnedSource());
- for (Variable iterator : object.getOwnedIterators()) {
- if (iterator != null) {
- setUsage(iterator, sourceUsage);
- }
- }
- @SuppressWarnings("unused") DomainUsage bodyUsage = visit(object.getOwnedBody());
- TemplateParameterSubstitutionVisitor visitor = new TemplateParameterSubstitutionVisitor((@NonNull EnvironmentFactoryInternal) context, object.getOwnedSource().getType(), null);
- object.accept(visitor);
- Iteration iteration = object.getReferredIteration();
- for (EObject eObject = iteration; eObject != null; eObject = eObject.eContainer()) {
- if (eObject instanceof TemplateableElement) {
- TemplateSignature ownedSignature = ((TemplateableElement)eObject).getOwnedSignature();
- if (ownedSignature != null) {
- for (TemplateParameter templateParameter : ownedSignature.getOwnedParameters()) {
- if (templateParameter != null) {
- Type templateParameterType = visitor.get(templateParameter);
- DomainUsage templateParameterUsage = visit(templateParameterType);
- setUsage(templateParameter, templateParameterUsage);
- }
- }
- }
- }
- }
- return visit(iteration.getType());
- }
-
- @Override
- public @NonNull DomainUsage visitLetExp(@NonNull LetExp object) {
- visit(object.getOwnedVariable());
- return visit(object.getOwnedIn());
- }
-
- @Override
- public @NonNull DomainUsage visitLiteralExp(@NonNull LiteralExp object) {
- return getRootAnalysis().getPrimitiveUsage();
- }
-
- @Override
- public @NonNull DomainUsage visitMapLiteralExp(@NonNull MapLiteralExp object) {
- DomainUsage usage = getRootAnalysis().getAnyUsage();
- for (@SuppressWarnings("null")@NonNull MapLiteralPart part : object.getOwnedParts()) {
- usage = intersection(usage, visit(part));
- }
- return usage;
- }
-
- @Override
- public @NonNull DomainUsage visitMapLiteralPart(@NonNull MapLiteralPart object) {
- DomainUsage keyUsage = visit(object.getOwnedKey());
- DomainUsage valueUsage = visit(object.getOwnedValue());
- return intersection(keyUsage, valueUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitMapping(@NonNull Mapping object) {
- for (Domain domain : object.getDomain()) {
- visit(domain);
- }
- for (Statement predicate : object.getOwnedStatements()) {
- visit(predicate);
- }
- return getRootAnalysis().getNoneUsage();
- }
-
- @Override
- public @NonNull DomainUsage visitNewStatement(@NonNull NewStatement object) {
- return visit(object.getReferredTypedModel());
- }
-
- @Override
- public @NonNull DomainUsage visitNullLiteralExp(@NonNull NullLiteralExp object) {
- return getRootAnalysis().createVariableUsage(getRootAnalysis().getAnyMask());
- }
-
- @Override
- public @NonNull DomainUsage visitOperation(@NonNull Operation object) {
- // System.out.println(" " + getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(this)) + " : " + object);
- DomainUsage savedUsage = pushSelfUsage(visit(object.getOwningClass()));
- try {
- for (@SuppressWarnings("null")@NonNull Parameter parameter : object.getOwnedParameters()) {
- visit(parameter);
- }
- LanguageExpression bodyExpression = object.getBodyExpression();
- if (bodyExpression == null) {
- return visit(object.getType());
- }
- MetamodelManager metamodelManager = context.getMetamodelManager();
- try {
- ExpressionInOCL parseSpecification = metamodelManager.parseSpecification(bodyExpression);
- return visit(parseSpecification);
- } catch (ParserException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return visit(object.getType());
- }
- // ownedBody = parseSpecification.getOwnedBody(); // FIXME why is this necessary
- // LanguageExpression bodyExpression = object.getBodyExpression();
- }
- finally {
- popSelfUsage(savedUsage);
- }
- }
-
- @Override
- public @NonNull DomainUsage visitOperationCallExp(@NonNull OperationCallExp object) {
- DomainUsage sourceUsage = visit(object.getOwnedSource());
- DomainUsage savedUsage = pushSelfUsage(sourceUsage);
- try {
- Operation operation = ClassUtil.nonNullState(object.getReferredOperation());
- RootDomainUsageAnalysis rootAnalysis = getRootAnalysis();
- OperationId operationId = operation.getOperationId();
- //
- // Special case: usage of oclContainer()/oclContents() is unchanged from the usage of the source.
- //
- if ((operationId == rootAnalysis.getOclContainerId())
- || (operationId == rootAnalysis.getOclContentsId())) {
- return sourceUsage;
- }
- String operationName = object.getReferredOperation().getName();
- if ("allInstances".equals(operationName)) { // FIXME BUG 487257 Revise this
- return /*getAllInstancesUsage(object,*/ sourceUsage;//);
- }
- //
- // Special case: left/right of "="/"<>" have same usage. Result is primitive.
- //
- // if ((operationId == getRootAnalysis().getOclAnyEqualsOperationId())
- // || (operationId == getRootAnalysis().getOclAnyNotEqualsOperationId())) {
- if ("=".equals(operationName) // FIXME BUG 487252 rationalize the derived operationIds
- || "<>".equals(operationName)) {
- DomainUsage rightUsage = visit(object.getOwnedArguments().get(0));
- intersection(sourceUsage, rightUsage);
- return getRootAnalysis().getPrimitiveUsage();
- }
- if ("oclAsType".equals(operationName) && !sourceUsage.isPrimitive()) { // FIXME fudge for Adolfo's suspect EObjects
- TemplateParameter templateParameter = operation.getType().isTemplateParameter();
- if (templateParameter != null) {
- List<Parameter> ownedParameters = operation.getOwnedParameters();
- int iMax = Math.min(ownedParameters.size(), object.getOwnedArguments().size());
- for (int i = 0; i < iMax; i++) {
- Parameter parameter = ownedParameters.get(i);
- if (parameter.isIsTypeof() && (parameter.getType() == templateParameter)) {
- OCLExpression argument = object.getOwnedArguments().get(i);
- DomainUsage argumentUsage = visit(argument);
- intersection(sourceUsage, argumentUsage);
- }
- }
- }
- return sourceUsage;
- }
- TemplateParameter templateParameter = operation.getType().isTemplateParameter();
- if (templateParameter != null) { // Handle e.g oclAsType()
- List<Parameter> ownedParameters = operation.getOwnedParameters();
- int iMax = Math.min(ownedParameters.size(), object.getOwnedArguments().size());
- for (int i = 0; i < iMax; i++) {
- Parameter parameter = ownedParameters.get(i);
- if (parameter.isIsTypeof() && (parameter.getType() == templateParameter)) {
- OCLExpression argument = object.getOwnedArguments().get(i);
- DomainUsage argumentUsage = visit(argument);
- return argumentUsage;
- }
- }
- }
- DomainUsageAnalysis analysis = rootAnalysis.getAnalysis(operation);
- Map<DomainUsage, DomainUsage> referred2specialized = new HashMap<DomainUsage, DomainUsage>();
- List<@NonNull Parameter> ownedParameters = ClassUtil.nullFree(operation.getOwnedParameters());
- int iMax = Math.min(ownedParameters.size(), object.getOwnedArguments().size());
- for (int i = 0; i < iMax; i++) {
- Parameter parameter = ownedParameters.get(i);
- OCLExpression argument = object.getOwnedArguments().get(i);
- DomainUsage referredParameterUsage = analysis.getUsage(parameter);
- DomainUsage specializedParameterUsage;
- if (referredParameterUsage.isConstant()) {
- specializedParameterUsage = referredParameterUsage;
- }
- else {
- specializedParameterUsage = referred2specialized.get(referredParameterUsage);
- if (specializedParameterUsage == null) {
- // specializedParameterUsage = new DomainUsageVariable(getRootAnalysis(), ((DomainUsage.Internal)referredParameterUsage).getMask());
- specializedParameterUsage = ((DomainUsage.Internal)referredParameterUsage).cloneVariable();
- referred2specialized.put(referredParameterUsage, specializedParameterUsage);
- }
- }
- DomainUsage argumentUsage = visit(argument);
- intersection(argumentUsage, specializedParameterUsage);
- }
- DomainUsage operationUsage = analysis.basicGetUsage(operation);
- if ((operationUsage != null) && !operationUsage.isConstant()) {
- // operationUsage = new DomainUsageVariable(getRootAnalysis(), ((DomainUsage.Internal)operationUsage).getMask());
- operationUsage = ((DomainUsage.Internal)operationUsage).cloneVariable();
- }
- DomainUsage operationCallUsage = visit(object.getType());
- return /*operationUsage != null ? intersection(operationUsage, operationCallUsage) :*/ operationCallUsage;
- }
- finally {
- popSelfUsage(savedUsage);
- }
- }
-
- @Override
- public @NonNull DomainUsage visitOppositePropertyCallExp(@NonNull OppositePropertyCallExp object) {
- Property property = ClassUtil.nonNullState(object.getReferredProperty());
- Property oppositeProperty = ClassUtil.nonNullState(property.getOpposite());
- return doNavigationCallExp(oppositeProperty, object);
- }
-
- @Override
- public @NonNull DomainUsage visitParameter(@NonNull Parameter object) {
- // Operation operation = object.getOwningOperation();
- // Map<Element, DomainUsage> map = analyzeOperation(operation);
- // return map.get(object);
- DomainUsage usage = visit(object.getType());
- return getRootAnalysis().getValidOrVariableUsage(usage);
- }
-
- @Override
- public @NonNull DomainUsage visitPredicate(@NonNull Predicate object) {
- return visit(object.getConditionExpression());
- }
-
- @Override
- public @NonNull DomainUsage visitPrimitiveType(@NonNull PrimitiveType object) {
- return getRootAnalysis().getPrimitiveUsage();
- }
-
- @Override
- public @NonNull DomainUsage visitProperty(@NonNull Property property) {
- DomainUsage annotatedUsage = getRootAnalysis().getAnnotatedUsage(property);
- DomainUsage superUsage = super.visitProperty(property);
- if (annotatedUsage != null) {
- return intersection(annotatedUsage, superUsage);
- }
- else {
- return superUsage;
- }
- }
-
- @Override
- public @NonNull DomainUsage visitPropertyCallExp(@NonNull PropertyCallExp object) {
- Property property = ClassUtil.nonNullState(object.getReferredProperty());
- return doNavigationCallExp(property, object);
- }
-
- @Override
- public @NonNull DomainUsage visitSelfType(@NonNull SelfType object) {
- return ClassUtil.nonNullState(selfUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitSetStatement(@NonNull SetStatement object) {
- Property property = QVTimperativeUtil.getTargetProperty(object);
- // if ("middleRoot.name := hsvRoot.name".equals(object.toString())) {
- // property = object.getTargetProperty();
- // }
- return doSetStatement(property, object);
- }
-
- @Override
- public @NonNull DomainUsage visitShadowExp(@NonNull ShadowExp object) {
- DomainUsage usage = visit(object.getType());
- for (@SuppressWarnings("null")@NonNull ShadowPart part : object.getOwnedParts()) {
- /*usage = intersection(usage,*/ visit(part); //);
- }
- return usage;
- }
-
- @Override
- public @NonNull DomainUsage visitShadowPart(@NonNull ShadowPart object) {
- visit(object.getOwnedInit());
- return visit(object.getType());
- }
-
- @Override
- public @NonNull DomainUsage visitSimpleParameter(@NonNull SimpleParameter object) {
- return visit(object.getReferredTypedModel());
- }
-
- @Override
- public @NonNull DomainUsage visitTemplateParameter(@NonNull TemplateParameter object) {
- RootDomainUsageAnalysis rootAnalysis = getRootAnalysis();
- int anyMask = rootAnalysis.getAnyMask();
- DomainUsage usage = rootAnalysis.getValidUsage(anyMask);
- if (usage == null) {
- usage = rootAnalysis.createVariableUsage(anyMask);
- }
- return usage;
- }
-
- @Override
- public @NonNull DomainUsage visitTransformation(@NonNull Transformation object) {
- RootDomainUsageAnalysis rootAnalysis = getRootAnalysis();
- if (rootAnalysis != this) {
- return rootAnalysis.getNoneUsage();
- }
- // for (TypedModel typedModel : object.getModelParameter()) { -- done in analyzeTransformation
- // visit(typedModel);
- // }
- // System.out.println(" " + getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(this)) + " : " + object);
- Variable ownedContext = QVTbaseUtil.getContextVariable(getEnvironmentFactory().getStandardLibrary(), object);
- setUsage(ownedContext, getRootAnalysis().getNoneUsage());
- //
- // Ensure all operations are analyzed even if not used.
- //
- for (Operation operation : object.getOwnedOperations()) {
- if (operation != null) {
- getRootAnalysis().analyzeOperation(operation);
- }
- }
- //
- // Define all bound variables so that they back propgate to resolve domain usage variables.
- //
- for (Rule rule : object.getRule()) {
- if (rule != null) {
- setBoundVariablesUsages(rule);
- }
- }
- //
- // Analyze the rest of the tree.
- //
- for (Rule rule : object.getRule()) {
- visit(rule);
- }
- return getRootAnalysis().getNoneUsage();
- }
-
- @Override
- public @NonNull DomainUsage visitTupleLiteralExp(@NonNull TupleLiteralExp object) {
- DomainUsage usage = getRootAnalysis().getAnyUsage();
- for (@SuppressWarnings("null")@NonNull TupleLiteralPart part : object.getOwnedParts()) {
- usage = intersection(usage, visit(part)); // FIXME need HYBRID
- }
- return usage;
- }
-
- @Override
- public @NonNull DomainUsage visitTupleLiteralPart(@NonNull TupleLiteralPart object) {
- return visit(object.getType());
- }
-
- @Override
- public @NonNull DomainUsage visitTupleType(@NonNull TupleType object) {
- DomainUsage usage = getRootAnalysis().getAnyUsage();
- for (@SuppressWarnings("null")@NonNull Property part : object.getOwnedProperties()) {
- usage = intersection(usage, visit(part.getType()));
- }
- return usage;
- }
-
- @Override
- public @NonNull DomainUsage visitType(@NonNull Type object) {
- return getRootAnalysis().getPrimitiveUsage();
- }
-
- @Override
- public @NonNull DomainUsage visitTypeExp(@NonNull TypeExp object) {
- DomainUsage usage = visit(object.getReferredType());
- return getRootAnalysis().getValidOrVariableUsage(usage);
- }
-
- @Override
- public @NonNull DomainUsage visitTypedElement(@NonNull TypedElement object) {
- return visit(object.getType());
- }
-
- @Override
- public @NonNull DomainUsage visitTypedModel(@NonNull TypedModel object) {
- RootDomainUsageAnalysis rootAnalysis = getRootAnalysis();
- if (rootAnalysis != this) {
- return ClassUtil.nonNullState(rootAnalysis.basicGetUsage(object));
- }
- return ClassUtil.nonNullState(element2usage.get(object));
- }
-
- @Override
- public @NonNull DomainUsage visitVariable(@NonNull Variable object) {
- OCLExpression ownedInit = object.getOwnedInit();
- if (ownedInit != null) {
- return visit(ownedInit);
- }
- Domain domain = QVTimperativeUtil.getContainingDomain(object);
- if (domain != null) {
- return visit(domain);
- }
- else {
- return visit(object.getType());
- }
- }
-
- @Override
- public @NonNull DomainUsage visitVariableDeclaration(@NonNull VariableDeclaration object) {
- return visit(object.getType());
- }
-
- @Override
- public @NonNull DomainUsage visitVariableExp(@NonNull VariableExp object) {
- VariableDeclaration referredVariable = object.getReferredVariable();
- DomainUsage usage = visit(referredVariable);
- assert usage != null : referredVariable + " usage not defined";
- return usage;
- }
-}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/QVTimperativeDomainUsageAnalysis.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/QVTimperativeDomainUsageAnalysis.java
deleted file mode 100644
index 6bf43fdd1..000000000
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/QVTimperativeDomainUsageAnalysis.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 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.pivot.qvtimperative.analysis;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.ocl.pivot.Element;
-import org.eclipse.ocl.pivot.OCLExpression;
-import org.eclipse.ocl.pivot.OperationCallExp;
-import org.eclipse.ocl.pivot.Type;
-import org.eclipse.ocl.pivot.VariableExp;
-import org.eclipse.ocl.pivot.internal.complete.StandardLibraryInternal;
-import org.eclipse.ocl.pivot.utilities.EnvironmentFactory;
-import org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage;
-import org.eclipse.qvtd.pivot.qvtimperative.AddStatement;
-import org.eclipse.qvtd.pivot.qvtimperative.AppendParameterBinding;
-import org.eclipse.qvtd.pivot.qvtimperative.ConnectionVariable;
-import org.eclipse.qvtd.pivot.qvtimperative.GuardParameterBinding;
-import org.eclipse.qvtd.pivot.qvtimperative.ImperativeModel;
-import org.eclipse.qvtd.pivot.qvtimperative.LoopParameterBinding;
-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.MappingParameterBinding;
-import org.eclipse.qvtd.pivot.qvtimperative.MappingStatement;
-import org.eclipse.qvtd.pivot.qvtimperative.SimpleParameterBinding;
-import org.eclipse.qvtd.pivot.qvtimperative.Statement;
-import org.eclipse.qvtd.pivot.qvtimperative.util.QVTimperativeVisitor;
-
-/**
- * A QVTimperativeDomainUsageAnalysis identifies a constrained domain result from the DomainUsageAnalysis of an OCL AST node.
- */
-public class QVTimperativeDomainUsageAnalysis extends RootDomainUsageAnalysis implements QVTimperativeVisitor<org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage>
-{
- public QVTimperativeDomainUsageAnalysis(@NonNull EnvironmentFactory environmentFactory) {
- super(environmentFactory);
- }
-
- @Override
- public void setUsage(@NonNull Element element, @NonNull DomainUsage newUsage) {
- super.setUsage(element, newUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitAddStatement(@NonNull AddStatement object) {
- DomainUsage valueUsage = visit(object.getOwnedExpression());
- DomainUsage variableUsage = visit(object.getTargetVariable());
- return intersection(variableUsage, valueUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitAppendParameterBinding(@NonNull AppendParameterBinding object) {
- DomainUsage valueUsage = visit(object.getValue());
- DomainUsage variableUsage = visit(object.getBoundVariable());
- return intersection(valueUsage, variableUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitConnectionVariable(@NonNull ConnectionVariable object) {
- return visitVariableDeclaration(object);
- }
-
- @Override
- public @NonNull DomainUsage visitGuardParameterBinding(@NonNull GuardParameterBinding object) {
- DomainUsage valueUsage = visit(object.getValue());
- DomainUsage variableUsage = visit(object.getBoundVariable());
- return intersection(valueUsage, variableUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitImperativeModel(@NonNull ImperativeModel object) {
- return visitBaseModel(object);
- }
-
- @Override
- public @NonNull DomainUsage visitLoopParameterBinding(@NonNull LoopParameterBinding object) {
- DomainUsage valueUsage = visit(object.getValue());
- DomainUsage variableUsage = visit(object.getBoundVariable());
- return intersection(valueUsage, variableUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitMapping(@NonNull Mapping object) {
- DomainUsage usage = getNoneUsage();
- setUsage(object, usage);
- super.visitMapping(object);
- for (Statement mappingStatement : object.getOwnedStatements()) {
- visit(mappingStatement);
- }
- return usage;
- }
-
- @Override
- public @NonNull DomainUsage visitMappingCall(@NonNull MappingCall object) {
- for (MappingParameterBinding mappingParameterBinding : object.getBinding()) {
- visit(mappingParameterBinding);
- }
- return getNoneUsage();
- }
-
- @Override
- public @NonNull DomainUsage visitMappingLoop(@NonNull MappingLoop object) {
- DomainUsage sourceUsage = visit(object.getOwnedExpression());
- for (LoopVariable iterator : object.getOwnedIterators()) {
- if (iterator != null) {
- setUsage(iterator, sourceUsage);
- }
- }
- for (MappingStatement mappingStatement : object.getOwnedMappingStatements()) {
- visit(mappingStatement);
- }
- return getNoneUsage();
- }
-
- @Override
- public @NonNull DomainUsage visitMappingStatement(@NonNull MappingStatement object) {
- return visitStatement(object);
- }
-
- @Override
- public @NonNull DomainUsage visitOperationCallExp(@NonNull OperationCallExp object) {
- String operationName = object.getReferredOperation().getName();
- if ("objectsOfKind".equals(operationName) || "objectsOfType".equals(operationName)) { // FIXME stronger test
- for (OCLExpression argument : object.getOwnedArguments()) {
- visit(argument);
- }
- return visit(object.getOwnedSource());
- }
- return super.visitOperationCallExp(object);
- }
-
- @Override
- public @NonNull DomainUsage visitSimpleParameterBinding(@NonNull SimpleParameterBinding object) {
- DomainUsage valueUsage = visit(object.getValue());
- DomainUsage variableUsage = visit(object.getBoundVariable());
- return intersection(valueUsage, variableUsage);
- }
-
- @Override
- public @NonNull DomainUsage visitStatement(@NonNull Statement object) {
- return visiting(object);
- }
-
- @Override
- public @NonNull DomainUsage visitVariableExp(@NonNull VariableExp object) {
- StandardLibraryInternal standardLibrary = (StandardLibraryInternal) context.getStandardLibrary();
- Type transformationType = standardLibrary.getLibraryType("Transformation");
- if ((transformationType != null) && object.getType().conformsTo(standardLibrary, transformationType)) {
- return getNoneUsage();
- }
- return super.visitVariableExp(object);
- }
-}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/RootDomainUsageAnalysis.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/RootDomainUsageAnalysis.java
deleted file mode 100644
index 0fc4ce093..000000000
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/analysis/RootDomainUsageAnalysis.java
+++ /dev/null
@@ -1,704 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 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.pivot.qvtimperative.analysis;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.ocl.pivot.Annotation;
-import org.eclipse.ocl.pivot.CollectionType;
-import org.eclipse.ocl.pivot.CompleteClass;
-import org.eclipse.ocl.pivot.CompleteModel;
-import org.eclipse.ocl.pivot.CompletePackage;
-import org.eclipse.ocl.pivot.DataType;
-import org.eclipse.ocl.pivot.Detail;
-import org.eclipse.ocl.pivot.Element;
-import org.eclipse.ocl.pivot.NullLiteralExp;
-import org.eclipse.ocl.pivot.Operation;
-import org.eclipse.ocl.pivot.Property;
-import org.eclipse.ocl.pivot.StandardLibrary;
-import org.eclipse.ocl.pivot.Variable;
-import org.eclipse.ocl.pivot.ids.OperationId;
-import org.eclipse.ocl.pivot.internal.complete.StandardLibraryInternal;
-import org.eclipse.ocl.pivot.utilities.ClassUtil;
-import org.eclipse.ocl.pivot.utilities.EnvironmentFactory;
-import org.eclipse.ocl.pivot.utilities.LabelUtil;
-import org.eclipse.ocl.pivot.utilities.NameUtil;
-import org.eclipse.ocl.pivot.utilities.PivotUtil;
-import org.eclipse.qvtd.pivot.qvtbase.QVTbaseFactory;
-import org.eclipse.qvtd.pivot.qvtbase.Transformation;
-import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
-import org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage;
-import org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsageAnalysis;
-import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
-import org.eclipse.qvtd.pivot.qvtimperative.ImperativeTypedModel;
-import org.eclipse.qvtd.pivot.qvtimperative.util.QVTimperativeVisitor;
-
-public class RootDomainUsageAnalysis extends AbstractDomainUsageAnalysis implements QVTimperativeVisitor<org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage>, DomainUsageAnalysis.Root
-{
- protected abstract class AbstractDomainUsage implements DomainUsage.Internal
- {
- protected final int bitMask;
-
- protected AbstractDomainUsage(int bitMask) {
- this.bitMask = bitMask;
- }
-
- @Override
- public int compareTo(DomainUsage.Internal o) {
- return getMask() - o.getMask();
- }
-
- @Override
- public int getMask() {
- return bitMask;
- }
-
- @Override
- public @Nullable TypedModel getTypedModel() throws IllegalStateException {
- return getTypedModel(null);
- }
-
- @Override
- public @Nullable TypedModel getTypedModel(@Nullable Element context) throws IllegalStateException {
- int residue = bitMask;
- for (int i = 0; residue != 0; i++) {
- int bit = 1 << i;
- if ((residue & bit) != 0) {
- residue &= ~bit;
- if (residue == 0) {
- return RootDomainUsageAnalysis.this.getTypedModel(i);
- }
- if (!(context instanceof NullLiteralExp)) {
- System.err.println("Ambiguous TypedModel: " + this + " for " + LabelUtil.getLabel(context));
- }
- // throw new IllegalStateException("Ambiguous TypedModel: " + this);
- return RootDomainUsageAnalysis.this.getTypedModel(i);
- }
- }
- return null;
- }
-
- @Override
- public @NonNull Iterable<@NonNull TypedModel> getTypedModels() {
- List<@NonNull TypedModel> typedModels = new ArrayList<>();
- int residue = bitMask;
- for (int i = 0; residue != 0; i++) {
- int bit = 1 << i;
- if ((residue & bit) != 0) {
- residue &= ~bit;
- typedModels.add(RootDomainUsageAnalysis.this.getTypedModel(i));
- }
- }
- return typedModels;
- }
-
- @Override
- public boolean isCheckable() {
- return isInput();
- }
-
- @Override
- public boolean isEnforceable() {
- return isOutput();
- }
-
- @Override
- public boolean isInput() {
- return (bitMask & inputUsage.bitMask) != 0;
- }
-
- @Override
- public boolean isMiddle() {
- return (bitMask & middleUsage.bitMask) != 0;
- }
-
- @Override
- public boolean isNone() {
- return bitMask == 0;
- }
-
- @Override
- public boolean isOutput() {
- return (bitMask & outputUsage.bitMask) != 0;
- }
-
- @Override
- public boolean isPrimitive() {
- return (bitMask & PRIMITIVE_USAGE_BIT_MASK) != 0;
- }
-
- protected String toString(@NonNull String prefix) {
- StringBuilder s = new StringBuilder();
- s.append(prefix);
- boolean first = true;
- for (int i = 0; i < bit2typedModel.size(); i++) {
- int iMask = 1 << i;
- if ((bitMask & iMask) != 0) {
- if (!first) {
- s.append("|");
- }
- String name = bit2typedModel.get(i).getName();
- s.append(name != null ? name : "$middle$");
- first = false;
- }
- }
- if (first) {
- s.append("$none$");
- }
- return s.toString();
- }
- }
-
- /**
- * A DomainUsageConstant identifies a specific domain result from the DomainUsageAnalysis of an OCL AST node.
- */
- protected class DomainUsageConstant extends AbstractDomainUsage
- {
- protected DomainUsageConstant(int bitMask) {
- super(bitMask);
- }
-
- @Override
- public void addUsedBy(@NonNull Element element) {}
-
- @Override
- public @NonNull DomainUsage cloneVariable() {
- return this;
- }
-
- @Override
- public @Nullable Iterable<Element> getElements() {
- return null;
- }
-
- @Override
- public boolean isConstant() {
- return true;
- }
-
- @Override
- public String toString() {
- return toString("«constant»");
- }
-
- public @NonNull DomainUsageConstant union(@NonNull DomainUsageConstant usage) {
- return RootDomainUsageAnalysis.this.getConstantUsage(bitMask | usage.bitMask);
- }
- }
-
- /**
- * A DomainUsageVariable identifies a constrained domain result from the DomainUsageAnalysis of an OCL AST node.
- */
- protected class DomainUsageVariable extends AbstractDomainUsage
- {
- protected final @NonNull List<Element> usedBy = new ArrayList<>();
-
- protected DomainUsageVariable(int bitMask) {
- super(bitMask);
- assert bitMask != 0;
- }
-
- @Override
- public void addUsedBy(@NonNull Element element) {
- usedBy.add(element);
- }
-
- @Override
- public @NonNull DomainUsage cloneVariable() {
- return new DomainUsageVariable(bitMask);
- }
-
- @Override
- public @Nullable Iterable<Element> getElements() {
- return usedBy;
- }
-
- @Override
- public boolean isConstant() {
- return false;
- }
-
- @Override
- public String toString() {
- return toString("«variable»");
- }
- }
-
- /**
- * A Nested DomainUsageAnalysis is used for a nested context such as an operation which is analyzed without
- * regard to its invocation parameters. The invoking context is responsible for 'specializing' the generic
- * domain analysis to suit the invocations.
- */
- protected class Nested extends AbstractDomainUsageAnalysis
- {
- protected Nested() {
- super(RootDomainUsageAnalysis.this.getEnvironmentFactory());
- }
-
- @Override
- protected @NonNull RootDomainUsageAnalysis getRootAnalysis() {
- return RootDomainUsageAnalysis.this;
- }
- }
-
- /**
- * No TypedModels is used by control infrastructure such as MappingLoops.
- */
- private static final @NonNull Integer NONE_USAGE_BIT_MASK = 0;
-
- /**
- * The first bit is reserved for the primitive TypedModel that is used by DataTypes.
- */
- private static final @NonNull Integer PRIMITIVE_USAGE_BIT_MASK = 1;
-
- protected final @NonNull StandardLibrary standardLibrary;
-
- /**
- * The model name to typed model bit mapping.
- */
- protected final @NonNull Map<@Nullable String, @NonNull Integer> name2bit = new HashMap<>();
-
- /**
- * The bit number to typed model 'mapping'.
- */
- protected final @NonNull List<@NonNull TypedModel> bit2typedModel = new ArrayList<>();
-
- /**
- * Map from Integer to all in-use Constant Usages
- */
- private final @NonNull Map<@NonNull Integer, @NonNull DomainUsageConstant> constantUsages = new HashMap<>();
-
- /**
- * Map from Integer to all single TypedModel Constant Usages
- */
- private final @NonNull Map<@NonNull Integer, @NonNull DomainUsageConstant> validUsages = new HashMap<>();
-
- /**
- * The TypedModels that are not primitive and not checkable and not enforceable.
- */
- private DomainUsageConstant middleUsage = null;
-
- /**
- * The TypedModels that are not enforceable.
- */
- private DomainUsageConstant inputUsage = null;
-
- /**
- * The TypedModels that are enforceable.
- */
- private DomainUsageConstant outputUsage = null;
-
- /**
- * The domains in which each class may be used.
- */
- protected final @NonNull Map<org.eclipse.ocl.pivot.@NonNull Class, @NonNull DomainUsageConstant> class2usage = new HashMap<>();
-
- /**
- * The domains in which the containing class of a property may be used.
- */
- protected final @NonNull Map<@NonNull Property, org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage> property2containingClassUsage = new HashMap<>();
-
- /**
- * The nested analyses for declared operations.
- */
- protected final @NonNull Map<@NonNull Operation, DomainUsageAnalysis.@NonNull Internal> operation2analysis = new HashMap<>();
-
- private final @NonNull TypedModel primitiveTypeModel = QVTbaseFactory.eINSTANCE.createTypedModel();
-
- private /*@LazyNonNull*/ OperationId oclAnyEqualsOperationId;
- private /*@LazyNonNull*/ OperationId oclAnyNotEqualsOperationId;
- private /*@LazyNonNull*/ OperationId oclElementOclContainerId;
- private /*@LazyNonNull*/ OperationId oclElementOclContentsId;
- private /*@LazyNonNull*/ Property oclElementOclContainerProperty;
- private /*@LazyNonNull*/ Property oclElementOclContentsProperty;
-
- protected RootDomainUsageAnalysis(@NonNull EnvironmentFactory environmentFactory) {
- super(environmentFactory);
- this.standardLibrary = context.getStandardLibrary();
- primitiveTypeModel.setName("$primitive$");
- add(primitiveTypeModel);
- validUsages.put(NONE_USAGE_BIT_MASK, getConstantUsage(NONE_USAGE_BIT_MASK));
- validUsages.put(PRIMITIVE_USAGE_BIT_MASK, getConstantUsage(PRIMITIVE_USAGE_BIT_MASK));
- setUsage(primitiveTypeModel, getPrimitiveUsage());
- }
-
- protected int add(@NonNull TypedModel typedModel) {
- int nextBit = bit2typedModel.size();
- bit2typedModel.add(typedModel);
- name2bit.put(typedModel.getName(), nextBit);
- return nextBit;
- }
-
- public @NonNull DomainUsageAnalysis analyzeOperation(@NonNull Operation object) {
- DomainUsageAnalysis.Internal analysis = operation2analysis.get(object);
- if (analysis == null) {
- analysis = createNestedAnalysis();
- operation2analysis.put(object, analysis);
- DomainUsage usage = analysis.visit(object);
- setUsage(object, usage);
- }
- return analysis;
- }
-
- public @NonNull Map<Element, DomainUsage> analyzeTransformation(@NonNull Transformation transformation) {
- int unenforceableMask = 0;
- int enforceableMask = 0;
- CompleteModel completeModel = context.getCompleteModel();
- for (@NonNull TypedModel typedModel : ClassUtil.nullFree(transformation.getModelParameter())) {
- int nextBit = add(typedModel);
- int bitMask = 1 << nextBit;
- @NonNull DomainUsageConstant typedModelUsage = getConstantUsage(bitMask);
- validUsages.put(bitMask, typedModelUsage);
- boolean isEnforceable = ((ImperativeTypedModel)typedModel).isIsEnforced();
- boolean isUnenforceable = !isEnforceable;//((ImperativeTypedModel)typedModel).isIsChecked();
- if (isEnforceable) {
- enforceableMask |= bitMask;
- }
- if (isUnenforceable) {
- unenforceableMask |= bitMask;
- }
- setUsage(typedModel, typedModelUsage);
- Variable ownedContext = typedModel.getOwnedContext();
- if (ownedContext != null) {
- setUsage(ownedContext, typedModelUsage);
- }
- Set<@NonNull CompleteClass> completeClasses = new HashSet<>();
- // TODO There is an issue with extending transformations, because just classes extended by the
- // the extending metamodel are tracked. Following code tries to workaround this issue. Also take into account
- // that pivot/ocl are filtered. This might be an issue, when the transformations involve the own pivot metamodel
- // (e.g. the CS2AS transformation for QVTo, Pivot-based QVTo AS extends Pivot metamodel).
- // Set<Package> allPackages = QVTbaseUtil.getAllUsedPackages(typedModel);
- // Deque<Package> pckQueue = new LinkedList<Package>(); // To track new discovered packages
- // pckQueue.addAll(allPackages);
- // while (!pckQueue.isEmpty()) {
- // Package asPackage = pckQueue.pop();
- for (org.eclipse.ocl.pivot.@NonNull Package asPackage : QVTbaseUtil.getAllUsedPackages(typedModel)) {
- CompletePackage completePackage = completeModel.getCompletePackage(asPackage);
- for (@NonNull CompleteClass completeClass : ClassUtil.nullFree(completePackage.getOwnedCompleteClasses())) {
- for (@NonNull CompleteClass superCompleteClass : completeClass.getSuperCompleteClasses()) {
- completeClasses.add(superCompleteClass);
- }
- }
- }
- for (@NonNull CompleteClass completeClass : completeClasses) {
- for (org.eclipse.ocl.pivot.@NonNull Class asClass : ClassUtil.nullFree(completeClass.getPartialClasses())) {
- DomainUsageConstant oldUsage = class2usage.get(asClass);
- DomainUsageConstant classUsage = typedModelUsage;
- if ((asClass instanceof DataType) && !(asClass instanceof CollectionType)) { // FIXME use a visitor ? perhaps CollectionTypes are not evidence of usage
- classUsage = getPrimitiveUsage();
- }
- DomainUsageConstant newUsage = oldUsage != null ? classUsage.union(oldUsage) : classUsage;
- class2usage.put(asClass, newUsage);
- }
- }
- }
- for (org.eclipse.ocl.pivot.@NonNull Class asClass : class2usage.keySet()) {
- DomainUsage newUsage = class2usage.get(asClass);
- assert newUsage != null;
- for (@NonNull Property property : ClassUtil.nullFree(asClass.getOwnedProperties())) {
- property2containingClassUsage.put(property, newUsage);
- DomainUsage referredTypeUsage = getAnnotatedUsage(property);
- if (referredTypeUsage == null) {
- referredTypeUsage = visit(property.getType());
- }
- // System.out.println(property + " => " + referredTypeUsage);
- // property2referredTypeUsage.put(property, referredTypeUsage);
- }
- }
- class2usage.put(((StandardLibraryInternal)standardLibrary).getOclTypeType(), getAnyUsage()); // Needed by oclIsKindOf() etc
- inputUsage = getConstantUsage(getAnyMask() & unenforceableMask);
- outputUsage = getConstantUsage(getAnyMask() & enforceableMask);
- middleUsage = getConstantUsage(getAnyMask() & ~unenforceableMask & ~enforceableMask & ~PRIMITIVE_USAGE_BIT_MASK);
- Variable ownedContext = transformation.getOwnedContext();
- if (ownedContext != null) {
- setUsage(ownedContext, getAnyUsage());
- }
- visit(transformation);
- return element2usage;
- }
-
- @Override
- public @Nullable DomainUsage basicGetUsage(@Nullable Element element) {
- DomainUsage usage = super.basicGetUsage(element);
- if (usage != null) {
- return usage;
- }
- Operation operation = PivotUtil.getContainingOperation(element);
- if (operation == null) {
- return null;
- }
- DomainUsageAnalysis analyzeOperation = analyzeOperation(operation);
- usage = analyzeOperation.basicGetUsage(element);
- return usage;
- }
-
- protected @NonNull Nested createNestedAnalysis() {
- return new Nested();
- }
-
- public @NonNull DomainUsage createVariableUsage(int intersectionMask) {
- return new DomainUsageVariable(intersectionMask);
- }
-
- /* @Override // FIXME BUG 487257 Revise this
- protected @NonNull DomainUsage getAllInstancesUsage(@NonNull OperationCallExp asCallExp, @NonNull DomainUsage sourceUsage) {
- if (asCallExp.getOwnedSource().getTypeValue() instanceof DataType) {
- return getPrimitiveUsage();
- }
- Domain aDomain = QVTimperativeUtil.getContainingDomain(asCallExp);
- if (aDomain instanceof ImperativeDomain) {
- DomainUsage areaUsage = getUsage(aDomain);
- return intersection(sourceUsage, areaUsage);
- }
- Mapping mapping = QVTimperativeUtil.getContainingMapping(asCallExp);
- assert mapping != null;
- DomainUsage inputUsage = getNoneUsage();
- for (Domain domain : mapping.getDomain()) {
- if (!domain.isIsEnforceable()) {
- inputUsage = union(inputUsage, getUsage(domain));
- }
- }
- if (inputUsage != getNoneUsage()) {
- return intersection(sourceUsage, inputUsage);
- }
- else { // Att root so no domains, use input
- return intersection(sourceUsage, getInputUsage());
- }
- } */
-
- public @NonNull DomainUsageAnalysis getAnalysis(@NonNull Operation operation) {
- DomainUsageAnalysis analysis = operation2analysis.get(operation);
- if (analysis == null) {
- analysis = analyzeOperation(operation);
- }
- return analysis;
- }
-
- protected @Nullable DomainUsage getAnnotatedUsage(@NonNull Property property) {
- DomainUsage referredTypeUsage = null;
- for (Element annotation : property.getOwnedAnnotations()) {
- if (annotation instanceof Annotation) {
- Annotation annotation2 = (Annotation)annotation;
- if (DomainUsage.QVT_DOMAINS_ANNOTATION_SOURCE.equals(annotation2.getName())) {
- for (Detail detail : annotation2.getOwnedDetails()) {
- if (DomainUsage.QVT_DOMAINS_ANNOTATION_REFERRED_DOMAIN.equals(detail.getName())) {
- int mask = 0;
- for (String value : detail.getValues()) {
- Integer bit = name2bit.get(value.trim());
- if (bit != null) {
- mask |= 1 << bit;
- }
- }
- referredTypeUsage = getValidUsage(mask);
- }
- }
- }
-
- }
- }
- return referredTypeUsage;
- }
-
- protected int getAnyMask() {
- return (1 << bit2typedModel.size()) - 1;
- }
-
- public @NonNull DomainUsageConstant getAnyUsage() {
- return getConstantUsage(getAnyMask());
- }
-
- /**
- * @deprecated use getInputUsage();
- */
- @Deprecated
- public @NonNull DomainUsage getCheckableUsage() {
- return getInputUsage();
- }
-
- @Override
- public @NonNull DomainUsageConstant getConstantUsage(int bitMask) {
- DomainUsageConstant usage = constantUsages.get(bitMask);
- if (usage == null) {
- usage = new DomainUsageConstant(bitMask);
- constantUsages.put(bitMask, usage);
- }
- return usage;
- }
-
- /**
- * @deprecated use getOutputUsage();
- */
- @Deprecated
- public @NonNull DomainUsage getEnforceableUsage() {
- return getOutputUsage();
- }
-
- public @NonNull DomainUsage getInputUsage() {
- return ClassUtil.nonNullState(inputUsage);
- }
-
- public @NonNull DomainUsage getMiddleUsage() {
- return ClassUtil.nonNullState(middleUsage);
- }
-
- public @NonNull DomainUsage getNoneUsage() {
- DomainUsageConstant noneUsage = constantUsages.get(NONE_USAGE_BIT_MASK);
- assert noneUsage != null;
- return noneUsage;
- }
-
- public @NonNull DomainUsage getOutputUsage() {
- return ClassUtil.nonNullState(outputUsage);
- }
-
- // public @NonNull TypedModel getPrimitiveTypeModel() {
- // return primitiveTypeModel;
- // }
-
- public @NonNull OperationId getOclContainerId() {
- OperationId oclElementOclContainerId2 = oclElementOclContainerId;
- if (oclElementOclContainerId2 == null) {
- org.eclipse.ocl.pivot.Class oclElementType = standardLibrary.getOclElementType();
- Operation operation = NameUtil.getNameable(oclElementType.getOwnedOperations(), "oclContainer");
- assert operation != null;
- oclElementOclContainerId = oclElementOclContainerId2 = operation.getOperationId();
- }
- return oclElementOclContainerId2;
- }
-
- public @NonNull Property getOclContainerProperty() {
- Property oclElementOclContainerProperty2 = oclElementOclContainerProperty;
- if (oclElementOclContainerProperty2 == null) {
- org.eclipse.ocl.pivot.Class oclElementType = standardLibrary.getOclElementType();
- oclElementOclContainerProperty2 = NameUtil.getNameable(oclElementType.getOwnedProperties(), "oclContainer");
- assert oclElementOclContainerProperty2 != null;
- oclElementOclContainerProperty = oclElementOclContainerProperty2;
- }
- return oclElementOclContainerProperty2;
- }
-
- public @NonNull OperationId getOclContentsId() {
- OperationId oclElementOclContentsId2 = oclElementOclContentsId;
- if (oclElementOclContentsId2 == null) {
- org.eclipse.ocl.pivot.Class oclElementType = standardLibrary.getOclElementType();
- Operation operation = NameUtil.getNameable(oclElementType.getOwnedOperations(), "oclContents");
- assert operation != null;
- oclElementOclContentsId = oclElementOclContentsId2 = operation.getOperationId();
- }
- return oclElementOclContentsId2;
- }
-
- public @NonNull Property getOclContentsProperty() {
- Property oclElementOclContentsProperty2 = oclElementOclContentsProperty;
- if (oclElementOclContentsProperty2 == null) {
- org.eclipse.ocl.pivot.Class oclElementType = standardLibrary.getOclElementType();
- oclElementOclContentsProperty2 = NameUtil.getNameable(oclElementType.getOwnedProperties(), "oclContents");
- assert oclElementOclContentsProperty2 != null;
- oclElementOclContentsProperty = oclElementOclContentsProperty2;
- }
- return oclElementOclContentsProperty2;
- }
-
- public @NonNull OperationId getOclAnyEqualsOperationId() {
- OperationId oclAnyEqualsOperationId2 = oclAnyEqualsOperationId;
- if (oclAnyEqualsOperationId2 == null) {
- org.eclipse.ocl.pivot.Class oclAnyType = standardLibrary.getOclAnyType();
- Operation operation = NameUtil.getNameable(oclAnyType.getOwnedOperations(), "=");
- assert operation != null;
- oclAnyEqualsOperationId = oclAnyEqualsOperationId2 = operation.getOperationId();
- }
- return oclAnyEqualsOperationId2;
- }
-
- public @NonNull OperationId getOclAnyNotEqualsOperationId() {
- OperationId oclAnyNotEqualsOperationId2 = oclAnyNotEqualsOperationId;
- if (oclAnyNotEqualsOperationId2 == null) {
- org.eclipse.ocl.pivot.Class oclAnyType = standardLibrary.getOclAnyType();
- Operation operation = NameUtil.getNameable(oclAnyType.getOwnedOperations(), "<>");
- assert operation != null;
- oclAnyNotEqualsOperationId = oclAnyNotEqualsOperationId2 = operation.getOperationId();
- }
- return oclAnyNotEqualsOperationId2;
- }
-
- public @NonNull TypedModel getPrimitiveTypeModel() {
- return primitiveTypeModel;
- }
-
- public @NonNull DomainUsageConstant getPrimitiveUsage() {
- DomainUsageConstant primitiveUsage = constantUsages.get(PRIMITIVE_USAGE_BIT_MASK);
- assert primitiveUsage != null;
- return primitiveUsage;
- }
-
- @Override
- protected @NonNull RootDomainUsageAnalysis getRootAnalysis() {
- return this;
- }
-
- public @NonNull TypedModel getTypedModel(int i) {
- return bit2typedModel.get(i);
- }
-
- /* @Override
- public @Nullable DomainUsage getUsage(@Nullable EObject element) {
- DomainUsage domainUsage = super.getUsage(element);
- if ((domainUsage == null) && (element instanceof Property)) {
- domainUsage = property2referredTypeUsage.get(element);
- }
- return domainUsage;
- } */
-
- @Override
- public @NonNull DomainUsage getUsage(@NonNull Element element) {
- Operation operation = PivotUtil.getContainingOperation(element);
- if (operation != null) {
- DomainUsageAnalysis analyzeOperation = analyzeOperation(operation);
- return ClassUtil.nonNullState(analyzeOperation.getUsage(element));
- }
- else {
- return super.getUsage(element);
- }
- }
-
- /**
- * Return a corresponding non-null usage if bitMask identifies a single domain.
- */
- public @Nullable DomainUsageConstant getValidUsage(int bitMask) {
- return validUsages.get(bitMask);
- }
-
- /**
- * Return either a constant usage if usage is for a single domain,
- * else re-use a variable usgae else or create
- * a variable usage for the multiple domains.
- */
- public @NonNull DomainUsage getValidOrVariableUsage(@NonNull DomainUsage usage) {
- int bitMask = ((DomainUsage.Internal)usage).getMask();
- DomainUsage validUsage = getValidUsage(bitMask);
- if (validUsage != null) {
- return validUsage;
- }
- else if (!usage.isConstant()) {
- return usage;
- }
- else {
- return createVariableUsage(bitMask);
- }
- }
-}
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 e45eb6b71..eb33eff66 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
@@ -195,8 +195,8 @@ public class BasicQVTiExecutor extends AbstractExecutor implements QVTiExecutor
public @NonNull QVTiTransformationAnalysis getTransformationAnalysis() {
QVTiTransformationAnalysis transformationAnalysis2 = transformationAnalysis;
if (transformationAnalysis2 == null) {
- transformationAnalysis = transformationAnalysis2 = getEnvironmentFactory().createTransformationAnalysis();
- transformationAnalysis2.analyzeTransformation(transformation);
+ transformationAnalysis = transformationAnalysis2 = getEnvironmentFactory().createTransformationAnalysis(transformation);
+ transformationAnalysis2.analyzeTransformation();
}
return transformationAnalysis2;
}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEnvironmentFactory.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEnvironmentFactory.java
index 043f4b651..b60837eb4 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEnvironmentFactory.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEnvironmentFactory.java
@@ -4,7 +4,7 @@
* 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
******************************************************************************/
@@ -16,6 +16,7 @@ import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.internal.manager.TemplateParameterSubstitutionVisitor;
import org.eclipse.ocl.pivot.resource.ProjectManager;
+import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseEnvironmentFactory;
import org.eclipse.qvtd.pivot.qvtimperative.model.QVTimperativeLibrary;
import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperativeTemplateParameterSubstitutionVisitor;
@@ -30,25 +31,25 @@ public class QVTiEnvironmentFactory extends QVTbaseEnvironmentFactory
return new QVTimperativeTemplateParameterSubstitutionVisitor(environmentFactory, selfType, selfTypeValue);
}
}
-
+
public static final @NonNull CreateStrategy CREATE_STRATEGY = new QVTiCreateStrategy();
-
+
public QVTiEnvironmentFactory(@NonNull ProjectManager projectMap, @Nullable ResourceSet externalResourceSet) {
super(projectMap, externalResourceSet, CREATE_STRATEGY);
getStandardLibrary().setDefaultStandardLibraryURI(QVTimperativeLibrary.STDLIB_URI);
}
-// @Override
-// public @NonNull BasicOCLExecutor createExecutor( @NonNull ModelManager modelManager) {
-// return new BasicOCLExecutor(this, modelManager); // Inherited functionality used for validation
-// }
+ // @Override
+ // public @NonNull BasicOCLExecutor createExecutor( @NonNull ModelManager modelManager) {
+ // return new BasicOCLExecutor(this, modelManager); // Inherited functionality used for validation
+ // }
public @NonNull QVTiModelManager createModelManager(@NonNull QVTiTransformationAnalysis transformationAnalysis) {
return new QVTiModelManager(transformationAnalysis);
}
- public @NonNull QVTiTransformationAnalysis createTransformationAnalysis() {
- return new QVTiTransformationAnalysis(this);
+ public @NonNull QVTiTransformationAnalysis createTransformationAnalysis(@NonNull Transformation transformation) {
+ return new QVTiTransformationAnalysis(this, transformation);
}
public boolean keepDebug() {
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java
index ac4e8d059..45bd06c63 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java
@@ -38,7 +38,7 @@ import org.eclipse.ocl.pivot.utilities.ParserException;
import org.eclipse.ocl.pivot.utilities.XMIUtil;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
-import org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage;
+import org.eclipse.qvtd.pivot.qvtimperative.ImperativeTypedModel;
import org.eclipse.qvtd.runtime.evaluation.AbstractTransformationInstance;
import org.eclipse.qvtd.runtime.evaluation.AbstractTypedModelInstance;
import org.eclipse.qvtd.runtime.evaluation.TransformationInstance;
@@ -154,10 +154,11 @@ public class QVTiModelManager extends AbstractModelManager
@Override
public @NonNull Set<@NonNull Object> get(org.eclipse.ocl.pivot.@NonNull Class type) {
Set<@NonNull Object> elements = new HashSet<>();
- DomainUsage inputUsage = transformationAnalysis.getDomainUsageAnalysis().getInputUsage();
- for (@NonNull TypedModel typedModel : inputUsage.getTypedModels()) {
- TypedModelInstance typedModelInstance = getTypedModelInstance(typedModel);
- elements.addAll(typedModelInstance.getObjectsOfKind(type));
+ for (@NonNull TypedModel typedModel : ClassUtil.nullFree(transformationAnalysis.getTransformation().getModelParameter())) {
+ if (((ImperativeTypedModel)typedModel).isIsChecked()) {
+ TypedModelInstance typedModelInstance = getTypedModelInstance(typedModel);
+ elements.addAll(typedModelInstance.getObjectsOfKind(type));
+ }
}
return elements;
}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java
index 45bab5377..6801be0f0 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java
@@ -40,10 +40,8 @@ import org.eclipse.ocl.pivot.internal.utilities.EnvironmentFactoryInternal;
import org.eclipse.ocl.pivot.library.LibraryFeature;
import org.eclipse.ocl.pivot.library.oclany.OclElementOclContainerProperty;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
-import org.eclipse.qvtd.pivot.qvtbase.analysis.DomainUsage;
import org.eclipse.qvtd.pivot.qvtimperative.Mapping;
import org.eclipse.qvtd.pivot.qvtimperative.SetStatement;
-import org.eclipse.qvtd.pivot.qvtimperative.analysis.QVTimperativeDomainUsageAnalysis;
import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperativeUtil;
/**
@@ -60,10 +58,7 @@ public class QVTiTransformationAnalysis
{
protected final @NonNull EnvironmentFactoryInternal environmentFactory;
- /**
- * Analysis of domains applicable to each transformation element.
- */
- private final @NonNull QVTimperativeDomainUsageAnalysis domainAnalysis;
+ protected final @NonNull Transformation transformation;
/**
* Set of all types for which allInstances() is invoked.
@@ -76,11 +71,6 @@ public class QVTiTransformationAnalysis
private final @NonNull Map<@NonNull Property, @NonNull Integer> property2cacheIndex = new HashMap<>();
/**
- * Map from navigable property to sequential index in a checkable TypedModel.
- */
- private final @NonNull Map<@NonNull Property, @NonNull Integer> sourceProperty2cacheIndex = new HashMap<>();
-
- /**
* Map from propertyAssignment to the cache index of an un-navigable lookup cache to be updated by the assignment.
*/
private final @NonNull Map<@NonNull SetStatement, @NonNull Integer> setStatement2cacheIndex = new HashMap<>();
@@ -120,9 +110,9 @@ public class QVTiTransformationAnalysis
*/
private final @NonNull Map<@NonNull Type, @NonNull List<@NonNull Type>> parentClass2childClasses = new HashMap<>();
- public QVTiTransformationAnalysis(@NonNull EnvironmentFactoryInternal environmentFactory) {
+ public QVTiTransformationAnalysis(@NonNull EnvironmentFactoryInternal environmentFactory, @NonNull Transformation transformation) {
this.environmentFactory = environmentFactory;
- this.domainAnalysis = new QVTimperativeDomainUsageAnalysis(environmentFactory);
+ this.transformation = transformation;
}
private void addAllInstancesClass(@NonNull OCLExpression asExpression) {
@@ -142,12 +132,6 @@ public class QVTiTransformationAnalysis
if (cacheIndex == null) {
Integer size = property2cacheIndex.size();
property2cacheIndex.put(navigableProperty, size);
- if (sourceExpression != null) {
- DomainUsage sourceUsage = domainAnalysis.basicGetUsage(sourceExpression);
- if ((sourceUsage != null) && sourceUsage.isInput()) {
- sourceProperty2cacheIndex.put(navigableProperty, size);
- }
- }
cacheIndex = size;
}
return cacheIndex;
@@ -251,8 +235,7 @@ public class QVTiTransformationAnalysis
}
}
- public void analyzeTransformation(@NonNull Transformation transformation) {
- domainAnalysis.analyzeTransformation(transformation);
+ public void analyzeTransformation() {
//
// First pass
// - identify all allInstances() source types
@@ -350,10 +333,6 @@ public class QVTiTransformationAnalysis
return property2cacheIndex;
}
- public @NonNull QVTimperativeDomainUsageAnalysis getDomainUsageAnalysis() {
- return domainAnalysis;
- }
-
public @NonNull Set<@NonNull Mapping> getHazardousMappings() {
return hazardousMappings;
}
@@ -395,25 +374,8 @@ public class QVTiTransformationAnalysis
return environmentFactory.getMetamodelManager();
}
- /* protected int getOppositeCacheIndex(@NonNull Property oppositeProperty) {
- Integer cacheIndex = opposite2cacheIndex.get(oppositeProperty);
- if (cacheIndex == null) {
- cacheIndex = opposite2cacheIndex.size();
- opposite2cacheIndex.put(oppositeProperty, cacheIndex);
- }
- return cacheIndex;
- }
-
- public int getOppositeCacheIndexes() {
- return opposite2cacheIndex.size();
- }
-
- public @NonNull Map<Property, Integer> getOpposites() {
- return opposite2cacheIndex;
- } */
-
- public @NonNull Map<@NonNull Property, @NonNull Integer> getSourceCaches() {
- return sourceProperty2cacheIndex;
+ public @NonNull Transformation getTransformation() {
+ return transformation;
}
public boolean isHazardous(@NonNull Mapping mapping) {

Back to the top