Commit 92ced2c6 authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

enhancing the SelectTerm with expressions

refs 954
parent 60fc39b3
......@@ -75,8 +75,10 @@
containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SelectTerm" eSuperTypes="platform:/plugin/org.fortiss.af3.expression/model/expression.ecore#//terms/IExpressionTerm">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="identifier" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="field" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="tuple" eType="ecore:EClass platform:/plugin/org.fortiss.af3.expression/model/expression.ecore#//terms/IExpressionTerm"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="index" eType="ecore:EClass platform:/plugin/org.fortiss.af3.expression/model/expression.ecore#//terms/IExpressionTerm"
containment="true"/>
</eClassifiers>
</eSubpackages>
</eSubpackages>
......
......@@ -76,8 +76,8 @@
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference yices.ecore#//types/constructor/MkRecord/memberExpressions"/>
</genClasses>
<genClasses ecoreClass="yices.ecore#//types/constructor/SelectTerm">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute yices.ecore#//types/constructor/SelectTerm/identifier"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute yices.ecore#//types/constructor/SelectTerm/field"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference yices.ecore#//types/constructor/SelectTerm/tuple"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference yices.ecore#//types/constructor/SelectTerm/index"/>
</genClasses>
</nestedGenPackages>
</nestedGenPackages>
......
......@@ -17,6 +17,8 @@ $Id: YicesFile.java 1270 2011-08-29 08:55:46Z ratiu $
+--------------------------------------------------------------------------*/
package org.fortiss.af3.tools.yices.model;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.rawString;
import java.util.List;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
......@@ -216,11 +218,25 @@ public class YicesModelFactory {
return dft;
}
/** Factory for {@link SelectTerm} objects. */
/**
* Factory for {@link SelectTerm} objects.
*
* @deprecated please use {@link #createSelectTerm(IExpressionTerm, IExpressionTerm)}
*/
@Deprecated
public static SelectTerm createSelectTerm(String identifier, String field) {
SelectTerm select = AF3YicesConstructorFactory.eINSTANCE.createSelectTerm();
select.setIdentifier(identifier);
select.setField(field);
select.setTuple(rawString(identifier));
select.setIndex(rawString(field));
return select;
}
/** Factory for {@link SelectTerm} objects. */
public static SelectTerm createSelectTerm(IExpressionTerm tupleExpression,
IExpressionTerm indexExpression) {
SelectTerm select = AF3YicesConstructorFactory.eINSTANCE.createSelectTerm();
select.setTuple(tupleExpression);
select.setIndex(indexExpression);
return select;
}
......
......@@ -89,8 +89,6 @@ public class YicesTextGenerator implements ITextGenerator<YicesFile> {
w.append("(check)\n");
} else if(line instanceof DefineType) {
generateText(w, (DefineType)line);
} else if(line instanceof SelectTerm) {
generateText(w, (SelectTerm)line);
}
}
}
......@@ -290,11 +288,6 @@ public class YicesTextGenerator implements ITextGenerator<YicesFile> {
w.append(")\n");
}
/** Generate text for select command. */
private void generateText(Writer w, SelectTerm st) throws IOException {
w.append("(select " + st.getIdentifier() + ") " + st.getField() + ")");
}
/** Generate text for Subrange type. */
private void generateText(Writer w, Subrange subrange) throws IOException,
UnknownLanguageFragmentException {
......@@ -338,7 +331,8 @@ public class YicesTextGenerator implements ITextGenerator<YicesFile> {
} else if(term instanceof SelectTerm) {
StringBuffer sb = new StringBuffer("(select (");
SelectTerm st = (SelectTerm)term;
sb.append(st.getIdentifier() + ") " + st.getField() + ")");
sb.append(convertExpressionToString(st.getTuple()) + ") " +
convertExpressionToString(st.getIndex()) + ")");
return sb.toString();
} else if(term instanceof MkRecord) {
......
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