Commit 90e8f27e authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

makes analysis a function scope

refs 2890
parent fb45cf4f
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model" nsURI="http://www.fortiss.org/af3/mira" nsPrefix="org-fortiss-af3-mira">
<eClassifiers xsi:type="ecore:EClass" name="Analysis" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedCommentedElement platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//IProjectRootElement platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHierarchicElement platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//constraints/IConstrained">
<eClassifiers xsi:type="ecore:EClass" name="Analysis" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedCommentedElement platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//IProjectRootElement platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHierarchicElement platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//constraints/IConstrained platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionScope">
<eOperations name="getRequirementsList">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return AnalysisStaticImpl.getRequirementsList(this);"/>
......@@ -57,6 +57,17 @@
<details key="body" value="AnalysisStaticImpl.initializeRequirementRelationStatus(this);"/>
</eAnnotations>
</eOperations>
<eOperations name="getDefinitionElement" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return AnalysisStaticImpl.getDefinitionElement(this,call);"/>
</eAnnotations>
<eParameters name="call" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/FunctionCallBase"/>
</eOperations>
<eOperations name="getIFunctionDefinitions" upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return AnalysisStaticImpl.getIFunctionDefinitions(this);"/>
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="requirementRelation" upperBound="-1"
eType="#//RequirementRelation" containment="true" eOpposite="#//RequirementRelation/analysis"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="requirementRelationStatus"
......
......@@ -59,6 +59,10 @@
<genOperations ecoreOperation="mira.ecore#//Analysis/getAssociatedComponentArchitectures"/>
<genOperations ecoreOperation="mira.ecore#//Analysis/computeReqID"/>
<genOperations ecoreOperation="mira.ecore#//Analysis/initializeRequirementRelationStatus"/>
<genOperations ecoreOperation="mira.ecore#//Analysis/getDefinitionElement">
<genParameters ecoreParameter="mira.ecore#//Analysis/getDefinitionElement/call"/>
</genOperations>
<genOperations ecoreOperation="mira.ecore#//Analysis/getIFunctionDefinitions"/>
</genClasses>
<genClasses ecoreClass="mira.ecore#//Requirement">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute mira.ecore#//Requirement/description"/>
......
......@@ -17,6 +17,8 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.model.impl;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createUserDefinedFunctionDefinition;
import static org.fortiss.af3.mira.utils.ParameterUtils.getAllParameterDefinitions;
import static org.fortiss.tooling.kernel.utils.EMFResourceUtils.loadModelFromFile;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
......@@ -24,19 +26,36 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import java.util.ArrayList;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.expression.model.definitions.FunctionDefinition;
import org.fortiss.af3.expression.model.terms.Const;
import org.fortiss.af3.expression.model.terms.UserdefinedFunction;
import org.fortiss.af3.expression.model.terms.imperative.Return;
import org.fortiss.af3.expression.model.terms.imperative.impl.ReturnStaticImpl;
import org.fortiss.af3.expression.model.terms.imperative.impl.StatementSequenceStaticImpl;
import org.fortiss.af3.expression.model.terms.impl.BoolConstStaticImpl;
import org.fortiss.af3.expression.model.terms.impl.DoubleConstStaticImpl;
import org.fortiss.af3.expression.model.terms.impl.IntConstStaticImpl;
import org.fortiss.af3.expression.model.types.TBool;
import org.fortiss.af3.expression.model.types.TDouble;
import org.fortiss.af3.expression.model.types.TInt;
import org.fortiss.af3.mira.AF3MiraActivator;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.ExternalRelation;
import org.fortiss.af3.mira.model.ParameterDefinition;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.RequirementsContainer;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.model.relations.RequirementRelationStatus;
import org.fortiss.af3.mira.model.requirementSource.RequirementSource;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.project.model.typesystem.FunctionCallBase;
import org.fortiss.af3.project.model.typesystem.IFunction;
import org.fortiss.af3.project.model.typesystem.IFunctionDefinition;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.utils.KernelModelElementUtils;
......@@ -46,7 +65,7 @@ import org.fortiss.tooling.kernel.utils.KernelModelElementUtils;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 9D0C76C8B66270E1196D8ED2A0FFEAE9
* @ConQAT.Rating YELLOW Hash: B5CDEAD5B5A035829BE0F8959FE32277
*/
class AnalysisStaticImpl {
......@@ -148,4 +167,50 @@ class AnalysisStaticImpl {
return statusList;
}
/** Returns the {@link IFunctionDefinition} corresponding to a signal in the requirements. */
public static IFunctionDefinition getDefinitionElement(Analysis a, FunctionCallBase call) {
for(ParameterDefinition pd : getAllParameterDefinitions(a)) {
IFunction f = call.getFunction();
if(f instanceof UserdefinedFunction) {
if(((UserdefinedFunction)f).getName().equals(pd.getName())) {
return functionDefinitionOfParameter(pd);
}
}
}
return null;
}
/** Returns the list of signals in <code>a</code> as a list of function definitions. */
public static EList<IFunctionDefinition> getIFunctionDefinitions(Analysis a) {
BasicEList<IFunctionDefinition> res = new BasicEList<>();
for(ParameterDefinition pd : getAllParameterDefinitions(a)) {
FunctionDefinition uf = functionDefinitionOfParameter(pd);
res.add(uf);
}
return res;
}
/** Creates a {@link FunctionDefinition} out of a {@link ParameterDefinition}. */
private static FunctionDefinition functionDefinitionOfParameter(ParameterDefinition pd) {
FunctionDefinition uf =
createUserDefinedFunctionDefinition(pd.getName(), copy(pd.getType()));
try {
if(pd.getValue() != null && pd.getType() != null) {
Const value = null;
if(pd.getType() instanceof TInt) {
value = IntConstStaticImpl.create(Integer.parseInt(pd.getValue()));
} else if(pd.getType() instanceof TDouble) {
value = DoubleConstStaticImpl.create(Float.parseFloat(pd.getValue()));
} else if(pd.getType() instanceof TBool) {
value = BoolConstStaticImpl.create(Boolean.parseBoolean(pd.getValue()));
}
Return ret = ReturnStaticImpl.create(value);
uf.setDefinition(StatementSequenceStaticImpl.create(ret));
}
} catch(NumberFormatException e) {
return uf;
}
return uf;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment