use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkRecordUpdateExpr.
@Check(CheckType.FAST)
public void checkRecordUpdateExpr(RecordUpdateExpr upExpr) {
if (isInLinearizationBody(upExpr)) {
error(upExpr, "Record update expressions not allowed in linearization body expression");
return;
}
checkTypeExists(upExpr.getRecord());
TypeDef recordType = AgreeTypeSystem.infer(upExpr.getRecord());
if (recordType instanceof RecordTypeDef) {
// scoping should ensure the key is a proper Arg
Arg arg = (Arg) upExpr.getKey();
TypeDef keyType = AgreeTypeSystem.typeDefFromType(arg.getType());
checkTypeExists(upExpr.getExpr());
TypeDef expType = AgreeTypeSystem.infer(upExpr.getExpr());
if (!AgreeTypeSystem.typesEqual(keyType, expType)) {
error(upExpr, "the update field is of type '" + nameOfTypeDef(keyType) + "', but the expression is of type '" + nameOfTypeDef(expType) + "'");
}
} else {
error("Record to be updated must be a data implementation or AGREE record type. " + "Found type '" + nameOfTypeDef(recordType) + "'.", upExpr, AgreePackage.Literals.RECORD_UPDATE_EXPR__RECORD, -1);
}
}
use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkPrevExpr.
@Check(CheckType.FAST)
public void checkPrevExpr(PrevExpr prevExpr) {
checkTypeExists(prevExpr.getDelay());
TypeDef delayType = AgreeTypeSystem.infer(prevExpr.getDelay());
checkTypeExists(prevExpr.getInit());
TypeDef initType = AgreeTypeSystem.infer(prevExpr.getInit());
if (!AgreeTypeSystem.typesEqual(initType, delayType)) {
error(prevExpr, "The first and second arguments of the 'prev' function are of non-matching types '" + delayType + "' and '" + initType + "'");
}
if (isInLinearizationBody(prevExpr)) {
error(prevExpr, "'prev' expressions are not allowed in linearization body expressions.");
}
}
use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkConnectionStatement.
@Check(CheckType.FAST)
public void checkConnectionStatement(ConnectionStatement conn) {
Classifier container = conn.getContainingClassifier();
if (container instanceof ComponentImplementation) {
NamedElement aadlConn = conn.getConn();
if (aadlConn == null) {
return;
}
if (!(aadlConn instanceof Connection)) {
error(conn, "The connection label in the connection statement is not a connection");
return;
}
TypeDef rhsType = (AgreeTypeSystem.infer(conn.getExpr()));
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, rhsType)) {
error(conn, "The expression for the connection statement is of type '" + nameOfTypeDef(rhsType) + "' but must be of type 'bool'");
}
} else {
error(conn, "Connection statements are allowed only in component implementations.");
}
warning(conn, "Connection statements are deprecated and will be removed in a future version of AGREE.");
}
use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkGuarantee.
@Check(CheckType.FAST)
public void checkGuarantee(GuaranteeStatement guar) {
Classifier comp = guar.getContainingClassifier();
if (!(comp instanceof ComponentType)) {
error(guar, "Guarantee statements are allowed only in component types");
}
// the expression could be null if a pattern is used
Expr expr = guar.getExpr();
if (expr != null) {
TypeDef exprType = AgreeTypeSystem.infer(expr);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, exprType)) {
error(guar, "Expression for guarantee statement is of type '" + nameOfTypeDef(exprType) + "' but must be of type 'bool'");
}
}
if (guar.getName() == null) {
info(guar, "It is recommended that guarantee statements be named." + " (Hint: an identifier may be placed between the \"guarantee\" keyword and the quoted description.)");
}
}
use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkFnDefExpr.
@Check(CheckType.FAST)
public void checkFnDefExpr(FnDef fnDef) {
TypeDef fnType = AgreeTypeSystem.typeDefFromType(fnDef.getType());
TypeDef exprType = AgreeTypeSystem.infer(fnDef.getExpr());
if (!AgreeTypeSystem.typesEqual(exprType, fnType)) {
error(fnDef, "Function '" + fnDef.getName() + "' is of type '" + nameOfTypeDef(fnType) + "' but its expression is of type '" + nameOfTypeDef(exprType) + "'");
}
}
Aggregations