use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeAnnexContentAssist method getNestedDotIDCandidates.
private List<String> getNestedDotIDCandidates(SelectionExpr id) {
NamedElement base = ((NamedElmExpr) id).getElm();
NamedElement namedEl = null;
if (base instanceof Arg) {
Type type = ((Arg) base).getType();
DoubleDotRef elID = ((DoubleDotRef) type);
namedEl = elID.getElm();
// =======
// DoubleDotRef elID = ((RecordType) type).getRecord();
// namedEl = elID.getElm();
// >>>>>>> origin/develop
} else if (base instanceof DataPort) {
namedEl = ((DataPort) base).getDataFeatureClassifier();
} else if (base instanceof EventDataPort) {
namedEl = ((EventDataPort) base).getDataFeatureClassifier();
} else if (base instanceof AadlPackage) {
return getNestedDotIDCandidates((AadlPackage) base);
} else {
return new ArrayList<>();
}
return getNestedDotIDCandidates(namedEl);
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeValidator method checkArg.
@Check(CheckType.FAST)
public void checkArg(Arg arg) {
Type type = arg.getType();
if (type instanceof PrimType) {
PrimType primType = (PrimType) type;
String strType = primType.getName();
String rangeLow = primType.getRangeLow();
String rangeHigh = primType.getRangeHigh();
if (rangeLow != null && rangeHigh != null) {
// this is a ranged argument. It can show up only in an equation statement
EObject container = arg.eContainer();
if (!(container instanceof EqStatement || container instanceof InputStatement)) {
error(arg, "Ranged arguments can appear only in equation statements or agree_input statements");
}
boolean rangeLowDot = rangeLow.contains(".");
boolean rangeHighDot = rangeHigh.contains(".");
if (rangeLowDot != rangeHighDot) {
error(arg, "The range intervals are of differing types");
}
if (strType.equals("int") && (rangeLowDot || rangeHighDot)) {
error(arg, "Ranged variable of type 'int' contains a 'real' value in its interval");
}
if (strType.equals("real") && (!rangeLowDot || !rangeHighDot)) {
error(arg, "Ranged variable of type 'real' contains an 'int' value in its interval");
}
float low = Float.valueOf(rangeLow);
float high = Float.valueOf(rangeHigh);
low *= primType.getLowNeg() == null ? 1.0 : -1.0;
high *= primType.getHighNeg() == null ? 1.0 : -1.0;
if (low >= high) {
error(arg, "The low value of the interval is greater than or equal to the high end");
}
}
} else if (type instanceof DoubleDotRef) {
DoubleDotRef recType = (DoubleDotRef) type;
NamedElement finalId = recType.getElm();
if (!(finalId instanceof DataImplementation) && !(finalId instanceof RecordDef) && !(finalId instanceof DataType) && !(finalId instanceof EnumStatement)) {
error(recType, "types must be record definition, array definition, data implementation, enumeration, or datatype");
}
if (finalId instanceof DataImplementation) {
if (AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.ErrorTypeDef)) {
error(recType, "Data Implementations with no subcomponents must extend" + " a Base_Type that AGREE can reason about.");
return;
}
if (((DataImplementation) finalId).getAllSubcomponents().size() != 0) {
if (AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.BoolTypeDef) || AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.IntTypeDef) || AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.RealTypeDef)) {
error(finalId, "Data implementations with subcomponents cannot be" + " interpreted by AGREE if they extend Base_Types");
}
}
// dataImplCycleCheck(recId);
return;
}
if (finalId instanceof DataType) {
if (AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.ErrorTypeDef)) {
error(recType, "AADL Datatypes must extend" + " a Base_Type that AGREE can reason about.");
return;
}
}
}
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class CallRecursionHelper method caseCallExpr.
@Override
public Expr caseCallExpr(CallExpr object) {
DoubleDotRef id = object.getRef();
Abstraction callDef = null;
try {
callDef = (Abstraction) id.getElm();
// =======
// public Expr caseFnCallExpr(FnCallExpr object) {
//
// CallDef callDef = null;
//
// try {
// callDef = (CallDef) object.getFn().getBase();
// >>>>>>> origin/develop:fm-workbench/agree/com.rockwellcollins.atc.agree/src/com/rockwellcollins/atc/agree/validation/FnCallRecursionHelper.java
//
} catch (ClassCastException e) {
return null;
}
doSwitch(callDef);
return null;
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeValidator method checkRecordDefExpr.
// =======
// // private List<AgreeType> getArgTypes(NestedDotID recId){
// //
// // NamedElement rec = getFinalNestId(recId);
// // List<AgreeType> types = new ArrayList<AgreeType>();
// //
// // if(rec instanceof RecordDefExpr){
// // RecordDefExpr recDef = (RecordDefExpr)rec;
// // for(Arg arg : recDef.getArgs()){
// // types.add(getAgreeType(arg.getType()));
// // }
// // }else if(rec instanceof FeatureGroupType){
// // FeatureGroupType featGroup = (FeatureGroupType)rec;
// // for(Feature feat : featGroup.getAllFeatures()){
// // types.add(getAgreeType(feat));
// // }
// // }
// //
// // return types;
// // }
//
// private void dataImplCycleCheck(NestedDotID dataID) {
// NamedElement finalId = dataID.getBase();
// DataImplementation dataImpl = (DataImplementation) finalId;
// dataImplCycleCheck(dataImpl, dataID);
// }
//
// private void dataImplCycleCheck(DoubleDotRef dataID) {
// NamedElement finalId = dataID.getElm();
// DataImplementation dataImpl = (DataImplementation) finalId;
// dataImplCycleCheck(dataImpl, dataID);
// }
//
//
// private void dataImplCycleCheck(DataImplementation dataImpl, EObject errorSource) {
// Set<DataImplementation> dataClosure = new HashSet<>();
// Set<DataImplementation> prevClosure = null;
//
// for (Subcomponent sub : dataImpl.getAllSubcomponents()) {
// ComponentImplementation subImpl = sub.getComponentImplementation();
// if (subImpl != null) {
// dataClosure.add((DataImplementation) subImpl);
// }
// }
//
// do {
// prevClosure = new HashSet<>(dataClosure);
// for (DataImplementation subImpl : prevClosure) {
// if (subImpl == dataImpl) {
// error(errorSource, "The component implementation '" + dataImpl.getName()
// + "' has a cyclic definition. This cannot be reasoned about by AGREE.");
// break;
// }
// for (Subcomponent subSub : subImpl.getAllSubcomponents()) {
// ComponentImplementation subSubImpl = subSub.getComponentImplementation();
// if (subSubImpl != null) {
// dataClosure.add((DataImplementation) subSubImpl);
// }
// }
//
// }
//
// } while (!prevClosure.equals(dataClosure));
//
// }
// >>>>>>> origin/develop
@Check(CheckType.FAST)
public void checkRecordDefExpr(RecordDef recordDef) {
Set<RecordDef> recordClosure = new HashSet<>();
Set<RecordDef> prevClosure = null;
for (Arg arg : recordDef.getArgs()) {
Type type = arg.getType();
if (type instanceof DoubleDotRef) {
NamedElement finalId = ((DoubleDotRef) type).getElm();
if (finalId instanceof RecordDef) {
recordClosure.add((RecordDef) finalId);
}
}
}
do {
prevClosure = new HashSet<>(recordClosure);
for (RecordDef subRecDef : prevClosure) {
if (subRecDef == recordDef) {
error(recordDef, "The definition of type '" + recordDef.getName() + "' is involved in a cyclic definition");
break;
}
for (Arg arg : subRecDef.getArgs()) {
Type type = arg.getType();
if (type instanceof DoubleDotRef) {
NamedElement subFinalEl = ((DoubleDotRef) type).getElm();
if (subFinalEl instanceof RecordDef) {
recordClosure.add((RecordDef) subFinalEl);
// =======
// if (type instanceof RecordType) {
// DoubleDotRef subRecId = ((RecordType) type).getRecord();
// NamedElement subFinalEl = subRecId.getElm();
// if (subFinalEl instanceof RecordDefExpr) {
// recordClosure.add((RecordDefExpr) subFinalEl);
// >>>>>>> origin/develop
}
}
}
}
} while (!prevClosure.equals(recordClosure));
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.
the class SafetyUtil method getFaultNode.
/**
* Gets a fault node from a fault statement.
* @param faultStatement fault definition statement created by user.
* @return NodeDef object referenced in fault statement
*/
public static NodeDef getFaultNode(FaultStatement faultStatement) {
// defName: faults.fail_to
DoubleDotRef defName = faultStatement.getFaultDefName();
// defNameSub: fail_to
NamedElement defNameField = null;
if (defName != null) {
defNameField = defName.getElm();
} else {
new Exception("Fault definition name in " + faultStatement.getName() + " is not allowed.");
}
if (!(defNameField instanceof NodeDef)) {
new Exception("Fault node definition is not working correctly. " + "A possible reason is that the project needs to be cleaned.");
} else {
return (NodeDef) defNameField;
}
return null;
}
Aggregations