Search in sources :

Example 11 with TypeDef

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);
    }
}
Also used : AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) Arg(com.rockwellcollins.atc.agree.agree.Arg) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) Check(org.eclipse.xtext.validation.Check)

Example 12 with TypeDef

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.");
    }
}
Also used : AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) Check(org.eclipse.xtext.validation.Check)

Example 13 with TypeDef

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.");
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) Connection(org.osate.aadl2.Connection) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 14 with TypeDef

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.)");
    }
}
Also used : ComponentType(org.osate.aadl2.ComponentType) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Check(org.eclipse.xtext.validation.Check)

Example 15 with TypeDef

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) + "'");
    }
}
Also used : AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) Check(org.eclipse.xtext.validation.Check)

Aggregations

RecordTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef)36 TypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef)36 ArrayTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef)34 AgreeTypeSystem.nameOfTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef)34 Check (org.eclipse.xtext.validation.Check)31 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)23 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)22 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)22 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)22 BinaryExpr (com.rockwellcollins.atc.agree.agree.BinaryExpr)22 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)22 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)22 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)22 ExistsExpr (com.rockwellcollins.atc.agree.agree.ExistsExpr)22 Expr (com.rockwellcollins.atc.agree.agree.Expr)22 FlatmapExpr (com.rockwellcollins.atc.agree.agree.FlatmapExpr)22 FoldLeftExpr (com.rockwellcollins.atc.agree.agree.FoldLeftExpr)22 FoldRightExpr (com.rockwellcollins.atc.agree.agree.FoldRightExpr)22 ForallExpr (com.rockwellcollins.atc.agree.agree.ForallExpr)22 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)22