use of com.rockwellcollins.atc.agree.agree.AgreeContractSubclause in project VERDICT by ge-high-assurance.
the class Agree2Vdm method translateAgreeAnnex.
private Model translateAgreeAnnex(List<SystemType> systemTypes, List<SystemImplementation> systemImpls, Model model, HashSet<String> dataTypeDecl, HashSet<String> nodeDecl) {
LustreProgram lustreProgram = new LustreProgram();
// Initializing the lustre program in the VDM
model.setDataflowCode(lustreProgram);
// System.out.println("Processing "+systemTypes.size()+" SystemTypes for agree annexes");
for (SystemType sysType : systemTypes) {
// unpacking sysType
for (AnnexSubclause annex : sysType.getOwnedAnnexSubclauses()) {
if (annex.getName().equalsIgnoreCase("agree")) {
// annex is of type DefaultAnnexSubclause
DefaultAnnexSubclause ddASC = (DefaultAnnexSubclause) annex;
// AnnexSubclause aSC = ddASC.getParsedAnnexSubclause();
AgreeContractSubclause agreeAnnex = (AgreeContractSubclause) ddASC.getParsedAnnexSubclause();
// populating agree contracts in the vdm component type -- SHOULD ADD THIS CODE TO AADL2VDM
verdict.vdm.vdm_lustre.ContractSpec contractSpec = new verdict.vdm.vdm_lustre.ContractSpec();
EList<EObject> annexContents = agreeAnnex.eContents();
if (annexContents.isEmpty()) {
System.out.println("Empty Agree Annex.");
}
for (EObject clause : annexContents) {
// mapping to AgreeContractclause
AgreeContract agreeContract = (AgreeContract) clause;
// getting specStatements
EList<SpecStatement> specStatements = agreeContract.getSpecs();
for (SpecStatement specStatement : specStatements) {
if (specStatement instanceof EqStatement) {
EqStatement eqStmt = (EqStatement) specStatement;
// translate EqStatement in Agree to SymbolDefinition in vdm
SymbolDefinition symbDef = translateEqStatement(eqStmt, model, dataTypeDecl, nodeDecl);
// Add agree variable/symbol definition to the contractSpec in vdm
contractSpec.getSymbol().add(symbDef);
} else if (specStatement instanceof GuaranteeStatement) {
GuaranteeStatement guaranteeStmt = (GuaranteeStatement) specStatement;
ContractItem contractItem = translateGuaranteeStatement(guaranteeStmt, dataTypeDecl, nodeDecl, model);
contractSpec.getGuarantee().add(contractItem);
} else if (specStatement instanceof AssumeStatement) {
AssumeStatement assumeStmt = (AssumeStatement) specStatement;
ContractItem contractItem = translateAssumeStatement(assumeStmt, dataTypeDecl, nodeDecl, model);
contractSpec.getAssume().add(contractItem);
} else {
if (!(specStatement instanceof ConstStatementImpl)) {
System.out.println("Element not recognizable" + clause.eContents().toString());
}
}
}
}
if (contractSpec != null) {
List<ComponentType> vdmComponentTypes = model.getComponentType();
for (ComponentType vdmComponentType : vdmComponentTypes) {
// populating agree contract details in the corresponding componentType instance in vdm
if (vdmComponentType.getName().equalsIgnoreCase(sysType.getName())) {
vdmComponentType.setContract(contractSpec);
}
}
// populating agree contract details in the componentType instance in vdm
// packComponent.setContract(contractSpec);
}
}
}
// End of unpacking sysType
}
for (SystemImplementation sysImpl : systemImpls) {
// unpacking sysType
for (AnnexSubclause annex : sysImpl.getOwnedAnnexSubclauses()) {
if (annex.getName().equalsIgnoreCase("agree")) {
// annex is of type DefaultAnnexSubclause
DefaultAnnexSubclause ddASC = (DefaultAnnexSubclause) annex;
// AnnexSubclause aSC = ddASC.getParsedAnnexSubclause();
AgreeContractSubclause agreeAnnex = (AgreeContractSubclause) ddASC.getParsedAnnexSubclause();
// populating agree contracts in the vdm node body for component implementation type
verdict.vdm.vdm_lustre.NodeBody nodeBody = new verdict.vdm.vdm_lustre.NodeBody();
;
EList<EObject> annexContents = agreeAnnex.eContents();
if (annexContents.isEmpty()) {
System.out.println("Empty Agree Annex.");
}
for (EObject clause : annexContents) {
// mapping to AgreeContractclause
AgreeContract agreeContract = (AgreeContract) clause;
// getting specStatements
EList<SpecStatement> specStatements = agreeContract.getSpecs();
for (SpecStatement specStatement : specStatements) {
if (specStatement instanceof ConstStatementImpl) {
ConstStatementImpl constStmtImpl = (ConstStatementImpl) specStatement;
ConstantDeclaration constDecl = translateConstStatementImpl(constStmtImpl, dataTypeDecl, nodeDecl, model);
nodeBody.getConstantDeclaration().add(constDecl);
} else if (specStatement instanceof EqStatementImpl) {
EqStatementImpl eqStmtImpl = (EqStatementImpl) specStatement;
nodeBody = translateEqStatementImpl(eqStmtImpl, dataTypeDecl, nodeDecl, model, nodeBody);
} else if (specStatement instanceof AssignStatementImpl) {
AssignStatementImpl assignStmtImpl = (AssignStatementImpl) specStatement;
NodeEquation nodeEquation = translateAssignStatementImpl(assignStmtImpl, dataTypeDecl, nodeDecl, model);
nodeBody.getEquation().add(nodeEquation);
} else if (specStatement instanceof AssertStatementImpl) {
AssertStatementImpl assertStmtImpl = (AssertStatementImpl) specStatement;
Expression assertion = translateAssertStatementImpl(assertStmtImpl, dataTypeDecl, nodeDecl, model);
nodeBody.getAssertion().add(assertion);
} else {
System.out.println("Element not recognizable" + clause.eContents().toString());
}
}
}
List<ComponentImpl> vdmComponentImpls = model.getComponentImpl();
for (ComponentImpl vdmComponentImpl : vdmComponentImpls) {
// populating agree contract details in the corresponding componentImplType instance in vdm
if (vdmComponentImpl.getName().equalsIgnoreCase(sysImpl.getName())) {
vdmComponentImpl.setDataflowImpl(nodeBody);
}
}
}
}
}
return model;
}
use of com.rockwellcollins.atc.agree.agree.AgreeContractSubclause in project AGREE by loonwerks.
the class AgreeASTBuilder method getAgreeNode.
private AgreeNode getAgreeNode(ComponentInstance compInst, boolean isTop) {
List<AgreeVar> inputs = new ArrayList<>();
List<AgreeVar> outputs = new ArrayList<>();
List<AgreeVar> locals = new ArrayList<>();
List<AgreeAADLConnection> aadlConnections = new ArrayList<>();
List<AgreeOverriddenConnection> userDefinedConections = new ArrayList<>();
List<AgreeConnection> connections = new ArrayList<>();
List<AgreeNode> subNodes = new ArrayList<>();
List<AgreeStatement> assertions = new ArrayList<>();
List<AgreeStatement> assumptions = new ArrayList<>();
List<AgreeStatement> guarantees = new ArrayList<>();
List<AgreeStatement> lemmas = new ArrayList<>();
List<AgreeEquation> localEquations = new ArrayList<>();
List<AgreeStatement> patternProps = Collections.emptyList();
timeOfVarMap = new HashMap<>();
timeRiseVarMap = new HashMap<>();
timeFallVarMap = new HashMap<>();
unspecifiedAadlProperties = new HashMap<>();
Expr clockConstraint = new BoolExpr(true);
Expr initialConstraint = new BoolExpr(true);
String id = compInst.getName();
AgreeVar clockVar = new AgreeVar(id + clockIDSuffix, NamedType.BOOL, compInst.getSubcomponent(), compInst, null);
EObject reference = isTop ? compInst.getComponentClassifier() : compInst.getSubcomponent();
TimingModel timing = null;
boolean foundSubNode = false;
boolean hasDirectAnnex = false;
boolean hasSubcomponents = false;
ComponentClassifier compClass = compInst.getComponentClassifier();
Set<ComponentType> effectiveTypes = new HashSet<>();
Map<String, jkind.lustre.Expr> portRewriteMap = new HashMap<>();
if (compClass instanceof ComponentImplementation) {
boolean latched = false;
ComponentImplementation cc = (ComponentImplementation) compClass;
effectiveTypes.addAll(getEffectiveComponentTypes(cc.getType()));
if (isTop || isMonolithic) {
while (cc != null) {
AgreeContractSubclause annex = getAgreeAnnex(cc);
for (ComponentInstance subInst : compInst.getComponentInstances()) {
hasSubcomponents = true;
curInst = subInst;
AgreeNode subNode = getAgreeNode(subInst, false);
if (subNode != null && subNodes.stream().noneMatch(it -> it.reference.equals(subNode.reference))) {
foundSubNode = true;
subNodes.add(subNode);
}
}
if (annex != null) {
hasDirectAnnex = true;
AgreeContract contract = (AgreeContract) annex.getContract();
curInst = compInst;
assertions.addAll(getAssertionStatements(contract.getSpecs()));
getEquationStatements(contract.getSpecs(), portRewriteMap).addAllTo(locals, assertions, guarantees);
assertions.addAll(getPropertyStatements(contract.getSpecs()));
assertions.addAll(getAssignmentStatements(contract.getSpecs()));
userDefinedConections.addAll(getConnectionStatements(contract.getSpecs()));
lemmas.addAll(getLemmaStatements(contract.getSpecs()));
lemmas.addAll(getReachableStatements(contract.getSpecs(), portRewriteMap));
addLustreNodes(contract.getSpecs());
gatherLustreTypes(contract.getSpecs());
// the clock constraints contain other nodes that we add
clockConstraint = getClockConstraint(contract.getSpecs(), subNodes);
timing = getTimingModel(contract.getSpecs());
outputs.addAll(getEquationVars(contract.getSpecs(), compInst));
for (SpecStatement spec : contract.getSpecs()) {
if (spec instanceof LatchedStatement) {
latched = true;
break;
}
}
}
// Find extended effective types
effectiveTypes.addAll(getEffectiveComponentTypes(cc.getType()));
cc = cc.getExtended();
}
EList<ConnectionInstance> connectionInstances = compInst.getAllEnclosingConnectionInstances();
List<ConnectionInstance> foo = new ArrayList<>();
compInst.getAllComponentInstances().forEach(ci -> ci.allEnclosingConnectionInstances().forEach(foo::add));
aadlConnections.addAll(getConnectionsFromInstances(connectionInstances, compInst, subNodes, latched));
connections.addAll(filterConnections(aadlConnections, userDefinedConections));
}
ComponentType compType = ((ComponentImplementation) compClass).getType();
AgreeContractSubclause compImpAnnex = getAgreeAnnex(compClass);
if (compImpAnnex != null) {
AgreeContract contract = (AgreeContract) compImpAnnex.getContract();
for (SpecStatement spec : contract.getSpecs()) {
if (spec instanceof LiftContractStatement) {
Subcomponent sub = ((ComponentImplementation) compClass).getOwnedSubcomponents().get(0);
ComponentType ct = sub.getComponentType();
for (Connection conn : ((ComponentImplementation) compClass).getAllConnections()) {
NamedElement sourceNe = conn.getSource().getConnectionEnd();
NamedElement destNe = conn.getDestination().getConnectionEnd();
String sourceStr = sourceNe.getName().replace("::", "__");
String destStr = destNe.getName().replace("::", "__");
if (ct == sourceNe.getContainingClassifier()) {
portRewriteMap.put(sourceStr, new IdExpr(destStr));
} else if (ct == destNe.getContainingClassifier()) {
portRewriteMap.put(destStr, new IdExpr(sourceStr));
}
}
effectiveTypes.addAll(getEffectiveComponentTypes(ct));
}
}
}
// make compClass the type so we can get it's other contract elements
compClass = compType;
} else if (compClass instanceof ComponentType) {
effectiveTypes.addAll(getEffectiveComponentTypes((ComponentType) compClass));
} else {
throw new AgreeException("Internal error: attempt to run AGREE analysis on instance " + compInst.getFullName() + " not instance of ComponentImplementation or ComponentType.");
}
curInst = compInst;
if (timing == null) {
timing = TimingModel.SYNC;
}
for (ComponentType compType : effectiveTypes) {
AgreeContractSubclause annex = getAgreeAnnex(compType);
if (annex != null) {
hasDirectAnnex = true;
AgreeContract contract = (AgreeContract) annex.getContract();
// this makes files for monolithic verification a bit smaller
if (!isMonolithic || isTop || !hasSubcomponents) {
assumptions.addAll(getAssumptionStatements(contract.getSpecs(), portRewriteMap));
guarantees.addAll(getGuaranteeStatements(contract.getSpecs(), portRewriteMap));
lemmas.addAll(getReachableStatements(contract.getSpecs(), portRewriteMap));
}
// Count eq statements with expressions as assertions
getEquationStatements(contract.getSpecs(), portRewriteMap).addAllTo(locals, assertions, guarantees);
assertions.addAll(getPropertyStatements(contract.getSpecs()));
outputs.addAll(getEquationVars(contract.getSpecs(), compInst));
getAgreeInputVars(contract.getSpecs(), compInst).addAllTo(inputs, assumptions, guarantees);
initialConstraint = getInitialConstraint(contract.getSpecs());
addLustreNodes(contract.getSpecs());
gatherLustreTypes(contract.getSpecs());
}
}
gatherUnspecifiedAadlProperties(unspecifiedAadlProperties, inputs, assumptions, guarantees);
if (!(foundSubNode || hasDirectAnnex)) {
return null;
}
gatherOutputsInputsAndTypes(outputs, inputs, compInst.getFeatureInstances(), assumptions, guarantees);
AgreeNodeBuilder builder = new AgreeNodeBuilder(id);
builder.addInput(inputs);
builder.addOutput(outputs);
builder.addLocal(locals);
builder.addLocalEquation(localEquations);
builder.addConnection(connections);
builder.addSubNode(subNodes);
// Clean up any vacuous true predicates
Predicate<AgreeStatement> isBoolExprAndisTrue = st -> (st.expr instanceof BoolExpr) && ((BoolExpr) st.expr).value;
assertions.removeIf(isBoolExprAndisTrue);
assumptions.removeIf(isBoolExprAndisTrue);
guarantees.removeIf(isBoolExprAndisTrue);
builder.addAssertion(assertions);
builder.addAssumption(assumptions);
builder.addGuarantee(guarantees);
builder.addLemma(lemmas);
builder.addPatternProp(patternProps);
builder.setClockConstraint(clockConstraint);
builder.setInitialConstraint(initialConstraint);
builder.setClockVar(clockVar);
builder.setReference(reference);
builder.setTiming(timing);
builder.setCompInst(compInst);
builder.addTimeOf(timeOfVarMap);
builder.addTimeRise(timeRiseVarMap);
builder.addTimeFall(timeFallVarMap);
AgreeNode result = builder.build();
renamings.put(id, compInst.getName());
refMap.put(id, compInst);
return linearizationRewriter.visit(result);
}
use of com.rockwellcollins.atc.agree.agree.AgreeContractSubclause in project AGREE by loonwerks.
the class AgreeHandlerUtil method getOrCreateAgreeContract.
public static AgreeContract getOrCreateAgreeContract(final Object element) {
// Subclauses
final AgreeContractSubclause agreeSubclause;
if (element instanceof Classifier) {
agreeSubclause = getOrCreateAgreeSubclause((Classifier) element);
} else if (element instanceof AgreeContractSubclause) {
agreeSubclause = (AgreeContractSubclause) element;
} else {
agreeSubclause = null;
}
final AgreeContract contract;
if (agreeSubclause == null) {
// Libraries
final AgreeContractLibrary agreeLibrary;
if (element instanceof AadlPackage) {
agreeLibrary = getOrCreateAgreeLibrary((AadlPackage) element);
} else if (element instanceof AgreeContractLibrary) {
agreeLibrary = (AgreeContractLibrary) element;
} else {
throw new RuntimeException("Specified business object is not a classifier or a subclause: " + element);
}
if (agreeLibrary.getContract() == null) {
agreeLibrary.setContract(AgreeFactory.eINSTANCE.createAgreeContract());
}
if (!(agreeLibrary.getContract() instanceof AgreeContract)) {
throw new RuntimeException("Contract is not an AGREE contract");
}
contract = (AgreeContract) agreeLibrary.getContract();
} else {
if (agreeSubclause.getContract() == null) {
agreeSubclause.setContract(AgreeFactory.eINSTANCE.createAgreeContract());
}
if (!(agreeSubclause.getContract() instanceof AgreeContract)) {
throw new RuntimeException("Contract is not an AGREE contract");
}
contract = (AgreeContract) agreeSubclause.getContract();
}
return contract;
}
use of com.rockwellcollins.atc.agree.agree.AgreeContractSubclause in project AGREE by loonwerks.
the class AgreeTypeSystem method typeDefFromClassifier.
public static TypeDef typeDefFromClassifier(Classifier c) {
if (c instanceof DataType || (c instanceof DataImplementation && ((DataImplementation) c).getAllSubcomponents().isEmpty() && ((DataImplementation) c).getType() != null)) {
// Includes special case for data implementations implementing extensions of primitive types
Classifier classifierType = c instanceof DataImplementation ? ((DataImplementation) c).getType() : c;
List<PropertyAssociation> pas = classifierType.getAllPropertyAssociations();
for (Classifier classType : classifierType.getSelfPlusAllExtended()) {
if (classType != null && hasIntegerDataRepresentation(classType)) {
for (PropertyAssociation choice : pas) {
Property p = choice.getProperty();
PropertyExpression v = choice.getOwnedValues().get(0).getOwnedValue();
String key = p.getQualifiedName();
if (key.equals("Data_Model::Integer_Range")) {
if (v instanceof RangeValue) {
try {
RangeValue rangeValue = (RangeValue) v;
long min = intFromPropExp(rangeValue.getMinimum()).get();
long max = intFromPropExp(rangeValue.getMaximum()).get();
return new RangeIntTypeDef(min, max);
} catch (Exception e) {
return Prim.ErrorTypeDef;
}
}
}
}
return Prim.IntTypeDef;
} else if (classType != null && hasFloatDataRepresentation(classType)) {
for (PropertyAssociation choice : pas) {
Property p = choice.getProperty();
PropertyExpression v = choice.getOwnedValues().get(0).getOwnedValue();
String key = p.getQualifiedName();
if (key.equals("Data_Model::Real_Range")) {
if (v instanceof RangeValue) {
try {
RangeValue rangeValue = (RangeValue) v;
double min = realFromPropExp(rangeValue.getMinimum()).get();
double max = realFromPropExp(rangeValue.getMaximum()).get();
return new RangeRealTypeDef(min, max);
} catch (Exception e) {
return Prim.ErrorTypeDef;
}
}
}
}
return Prim.RealTypeDef;
} else if (classType != null && hasBooleanDataRepresentation(classType)) {
return Prim.BoolTypeDef;
}
}
boolean prop_isArray = false;
int prop_arraySize = 0;
TypeDef prop_arrayBaseType = null;
boolean prop_isEnum = false;
List<String> prop_enumValues = null;
for (PropertyAssociation choice : pas) {
Property p = choice.getProperty();
PropertyExpression v = choice.getOwnedValues().get(0).getOwnedValue();
String key = p.getQualifiedName();
key = key == null ? p.getName() : key;
if (key == null) {
return Prim.ErrorTypeDef;
}
if (key.equalsIgnoreCase("Data_Model::Data_Representation")) {
if (v instanceof NamedValue) {
AbstractNamedValue anv = ((NamedValue) v).getNamedValue();
if (anv instanceof EnumerationLiteral) {
EnumerationLiteral el = (EnumerationLiteral) anv;
prop_isArray = el.getName().equals("Array");
prop_isEnum = el.getName().equals("Enum");
}
}
} else if (key.equalsIgnoreCase("Data_Model::Enumerators")) {
if (v instanceof ListValue) {
EList<PropertyExpression> peList = ((ListValue) v).getOwnedListElements();
String prefix = c.getQualifiedName() + "_";
prop_enumValues = new ArrayList<>();
for (PropertyExpression pe : peList) {
if (pe instanceof StringLiteral) {
String enumString = prefix + ((StringLiteral) pe).getValue();
prop_enumValues.add(enumString);
}
}
}
} else if (key.equalsIgnoreCase("Data_Model::Base_Type")) {
if (v instanceof ListValue) {
ListValue l = (ListValue) v;
PropertyExpression pe = l.getOwnedListElements().get(0);
if (pe instanceof ClassifierValue) {
prop_arrayBaseType = typeDefFromClassifier(((ClassifierValue) pe).getClassifier());
}
}
} else if (key.equalsIgnoreCase("Data_Model::Dimension")) {
if (v instanceof ListValue) {
ListValue l = (ListValue) v;
PropertyExpression pe = l.getOwnedListElements().get(0);
prop_arraySize = Math.toIntExact(intFromPropExp(pe).orElse((long) -1).longValue());
}
}
}
if (prop_isArray && prop_arraySize > 0 && prop_arrayBaseType != null) {
return new ArrayTypeDef(prop_arrayBaseType, prop_arraySize, Optional.of(c));
} else if (prop_isEnum && prop_enumValues != null) {
String name = c.getQualifiedName();
return new EnumTypeDef(name, prop_enumValues, c);
}
} else if (c instanceof ComponentClassifier) {
Map<String, TypeDef> fields = new HashMap<>();
Classifier currClsfr = c;
while (currClsfr != null) {
ComponentType ct = null;
if (currClsfr instanceof ComponentImplementation) {
EList<Subcomponent> subcomps = ((ComponentImplementation) currClsfr).getAllSubcomponents();
for (Subcomponent sub : subcomps) {
String fieldName = sub.getName();
if (sub.getClassifier() != null) {
boolean prop_isArray = false;
int prop_arraySize = 0;
boolean prop_isEnum = false;
List<String> prop_enumValues = null;
for (PropertyAssociation pa : sub.getOwnedPropertyAssociations()) {
Property p = pa.getProperty();
String key = p.getQualifiedName();
key = key == null ? p.getName() : key;
PropertyExpression v = null;
if (!pa.getOwnedValues().isEmpty()) {
v = pa.getOwnedValues().get(0).getOwnedValue();
} else {
continue;
}
if (key.equals("Data_Model::Data_Representation")) {
if (v instanceof NamedValue) {
AbstractNamedValue anv = ((NamedValue) v).getNamedValue();
if (anv instanceof EnumerationLiteral) {
EnumerationLiteral el = (EnumerationLiteral) anv;
prop_isArray = el.getName().equals("Array");
prop_isEnum = el.getName().equals("Enum");
}
}
} else if (key.equals("Data_Model::Dimension")) {
if (v instanceof ListValue) {
ListValue l = (ListValue) v;
PropertyExpression pe = l.getOwnedListElements().get(0);
prop_arraySize = Math.toIntExact(intFromPropExp(pe).orElse((long) -1).longValue());
}
} else if (key.equals("Data_Model::Enumerators")) {
if (v instanceof ListValue) {
EList<PropertyExpression> peList = ((ListValue) v).getOwnedListElements();
String prefix = c.getQualifiedName() + "_";
prop_enumValues = new ArrayList<>();
for (PropertyExpression pe : peList) {
if (pe instanceof StringLiteral) {
String enumString = prefix + ((StringLiteral) pe).getValue();
prop_enumValues.add(enumString);
}
}
}
}
}
if (prop_isArray && prop_arraySize > 0) {
TypeDef typeDef = new ArrayTypeDef(typeDefFromClassifier(sub.getClassifier()), prop_arraySize, Optional.empty());
fields.putIfAbsent(fieldName, typeDef);
} else if (prop_isEnum && prop_enumValues != null) {
String name = c.getQualifiedName();
TypeDef typeDef = new EnumTypeDef(name, prop_enumValues, c);
fields.putIfAbsent(fieldName, typeDef);
} else if (sub.getArrayDimensions().size() == 0) {
TypeDef typeDef = typeDefFromClassifier(sub.getClassifier());
fields.putIfAbsent(fieldName, typeDef);
} else if (sub.getArrayDimensions().size() == 1) {
ArrayDimension ad = sub.getArrayDimensions().get(0);
int size = Math.toIntExact(getArraySize(ad));
TypeDef stem = typeDefFromClassifier(sub.getClassifier());
TypeDef typeDef = new ArrayTypeDef(stem, size, Optional.empty());
fields.putIfAbsent(fieldName, typeDef);
}
}
}
ct = ((ComponentImplementation) currClsfr).getType();
} else if (c instanceof ComponentType) {
ct = (ComponentType) currClsfr;
}
if (ct != null) {
EList<Feature> features = ct.getAllFeatures();
for (Feature feature : features) {
String fieldName = feature.getName();
if (feature.getClassifier() != null) {
if (feature.getArrayDimensions().size() == 0) {
TypeDef typeDef = typeDefFromClassifier(feature.getClassifier());
fields.putIfAbsent(fieldName, typeDef);
} else if (feature.getArrayDimensions().size() == 1) {
ArrayDimension ad = feature.getArrayDimensions().get(0);
int size = Math.toIntExact(getArraySize(ad));
TypeDef stem = typeDefFromClassifier(feature.getClassifier());
TypeDef typeDef = new ArrayTypeDef(stem, size, Optional.empty());
fields.putIfAbsent(fieldName, typeDef);
}
}
}
for (AnnexSubclause annex : AnnexUtil.getAllAnnexSubclauses(currClsfr, AgreePackage.eINSTANCE.getAgreeContractSubclause())) {
AgreeContract contract = (AgreeContract) ((AgreeContractSubclause) annex).getContract();
for (SpecStatement spec : contract.getSpecs()) {
List<Arg> args = new ArrayList<>();
if (spec instanceof EqStatement) {
args = ((EqStatement) spec).getLhs();
} else if (spec instanceof InputStatement) {
args = ((InputStatement) spec).getLhs();
}
for (Arg arg : args) {
String fieldName = arg.getName();
TypeDef typeDef = typeDefFromNE(arg);
fields.putIfAbsent(fieldName, typeDef);
}
if (spec instanceof ConstStatement) {
String fieldName = ((ConstStatement) spec).getName();
TypeDef typeDef = AgreeTypeSystem.typeDefFromType(((ConstStatement) spec).getType());
fields.putIfAbsent(fieldName, typeDef);
}
}
}
}
currClsfr = currClsfr.getExtended();
}
String name = c.getQualifiedName();
return new RecordTypeDef(name, fields, c);
}
return Prim.ErrorTypeDef;
}
Aggregations