use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project VERDICT by ge-high-assurance.
the class Agree2Vdm method translateAgreeDataTypeToVdmDataType.
private void translateAgreeDataTypeToVdmDataType(Type type, HashSet<String> dataTypeDecl, Model model) {
if (type instanceof DoubleDotRef) {
DoubleDotRef ddrefType = (DoubleDotRef) type;
if (ddrefType.getElm() instanceof DataImplementation) {
// if it is a AADL data implementation definition
DataImplementation dataImplementationImpl = (DataImplementation) ddrefType.getElm();
resolveAADLDataImplementationType(dataImplementationImpl, dataTypeDecl, model);
} else if (ddrefType.getElm() instanceof org.osate.aadl2.DataType) {
// if it is a AADL data implementation definition
org.osate.aadl2.DataType aadlDataType = (org.osate.aadl2.DataType) ddrefType.getElm();
resolveAADLDataType(aadlDataType, dataTypeDecl, model);
} else {
System.out.println("Unresolved data type " + ddrefType.getElm().getName() + " in doubledotref. Not AADL DataImplementation or DataType type.");
}
} else {
System.out.println("Unresolved type value is " + type.toString());
}
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class EnumLitExprImpl method basicSetEnumType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetEnumType(DoubleDotRef newEnumType, NotificationChain msgs) {
DoubleDotRef oldEnumType = enumType;
enumType = newEnumType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AgreePackage.ENUM_LIT_EXPR__ENUM_TYPE, oldEnumType, newEnumType);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeASTBuilder method caseCallExpr.
/*
* CallExpr could be a node call, a regular function call, or an uninterpreted function call.
* The former two cases will return a NodeCallExpr, the third case will return a FunctionCallExpr.
*/
@Override
public Expr caseCallExpr(CallExpr expr) {
NamedElement namedEl = expr.getRef().getElm();
String fnName = AgreeUtils.getNodeName(namedEl);
boolean found = false;
for (Node node : globalNodes) {
if (node.id.equals(fnName)) {
found = true;
break;
}
}
if (!found) {
for (Function function : uninterpretedFunc) {
if (function.id.equals(fnName)) {
found = true;
break;
}
}
}
if (!found) {
DoubleDotRef fn = expr.getRef();
doSwitch(fn.getElm());
// for dReal integration
if (fnName.substring(0, 7).equalsIgnoreCase("dreal__")) {
fnName = namedEl.getName();
}
}
List<Expr> argResults = new ArrayList<>();
for (com.rockwellcollins.atc.agree.agree.Expr argExpr : expr.getArgs()) {
argResults.add(doSwitch(argExpr));
}
if (functionNameExists(fnName)) {
FunctionCallExpr functionCall = new FunctionCallExpr(fnName.replace("::", "__"), argResults);
return functionCall;
}
NodeCallExpr nodeCall = new NodeCallExpr(fnName.replace("::", "__"), argResults);
return nodeCall;
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class RenamingVisitor method argToString.
private String argToString(Arg arg) {
String result = arg.getName() + " : ";
if (arg.getType() instanceof PrimType) {
PrimType primType = (PrimType) arg.getType();
result += primType.getName();
String lowLit = (primType.getLowNeg() != null) ? primType.getLowNeg() : "";
String highLit = (primType.getHighNeg() != null) ? primType.getHighNeg() : "";
if (primType.getRangeLow() != null) {
result += " [" + lowLit + primType.getRangeLow() + ", " + highLit + primType.getRangeHigh() + "]";
}
} else {
result += ((DoubleDotRef) arg.getType()).getElm().getName();
}
return result;
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeTypeSystem method typeDefFromType.
public static TypeDef typeDefFromType(Type t) {
if (t instanceof PrimType) {
int lowSign = ((PrimType) t).getLowNeg() == null ? 1 : -1;
int highSign = ((PrimType) t).getHighNeg() == null ? 1 : -1;
String lowStr = ((PrimType) t).getRangeLow();
String highStr = ((PrimType) t).getRangeHigh();
if (((PrimType) t).getName().equals("int")) {
if (lowStr == null || highStr == null) {
return Prim.IntTypeDef;
} else {
long low = Long.valueOf(lowStr) * lowSign;
long high = Long.valueOf(highStr) * highSign;
return new RangeIntTypeDef(low, high);
}
} else if (((PrimType) t).getName().equals("real")) {
if (lowStr == null || highStr == null) {
return Prim.RealTypeDef;
} else {
double low = Double.valueOf(lowStr) * lowSign;
double high = Double.valueOf(highStr) * highSign;
return new RangeRealTypeDef(low, high);
}
} else if (((PrimType) t).getName().equals("bool")) {
return Prim.BoolTypeDef;
} else {
return Prim.ErrorTypeDef;
}
} else if (t instanceof ArrayType) {
String size = ((ArrayType) t).getSize();
TypeDef baseTypeDef = typeDefFromType(((ArrayType) t).getStem());
return new ArrayTypeDef(baseTypeDef, Integer.parseInt(size), Optional.empty());
} else if (t instanceof DoubleDotRef) {
return typeDefFromNE(((DoubleDotRef) t).getElm());
} else {
return Prim.ErrorTypeDef;
}
}
Aggregations