use of com.rockwellcollins.atc.agree.agree.Expr 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.agree.Expr in project AGREE by loonwerks.
the class AgreeValidator method checkLemma.
@Check(CheckType.FAST)
public void checkLemma(LemmaStatement lemma) {
Classifier comp = lemma.getContainingClassifier();
if (!(comp instanceof ComponentImplementation)) {
error(lemma, "Lemma statements are allowed only in component implementations and nodes");
}
Expr expr = lemma.getExpr();
if (expr != null) {
TypeDef exprType = AgreeTypeSystem.infer(expr);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, exprType)) {
error(lemma, "Expression for lemma statement is of type '" + nameOfTypeDef(exprType) + "' but must be of type 'bool'");
}
}
if (lemma.getName() == null) {
info(lemma, "It is recommended that lemma statements be named." + " (Hint: an identifier may be placed between the \"lemma\" keyword and the quoted description.)");
}
}
use of com.rockwellcollins.atc.agree.agree.Expr in project AGREE by loonwerks.
the class AgreeValidator method checkLatchedExpr.
@Check(CheckType.FAST)
public void checkLatchedExpr(LatchedExpr latched) {
// get container
EObject container = latched.eContainer();
AgreeContract contract = null;
while (!(container instanceof ComponentClassifier)) {
if (container instanceof AgreeContract) {
contract = (AgreeContract) container;
}
container = container.eContainer();
}
if (container instanceof ComponentImplementation) {
boolean foundLatchedStatement = false;
for (SpecStatement spec : contract.getSpecs()) {
if (spec instanceof LatchedStatement) {
foundLatchedStatement = true;
break;
}
}
if (!foundLatchedStatement) {
error(latched, "Latched expressions can appear only in component implementations " + "that contain a latched synchrony statement");
}
} else {
error(latched, "Latched expressions can appear only in component implementations");
}
Expr expr = latched.getExpr();
Expr nestId = null;
if (expr instanceof NamedElmExpr) {
nestId = expr;
} else if (expr instanceof EventExpr) {
EventExpr eventExpr = (EventExpr) expr;
nestId = eventExpr.getPort();
}
if (nestId != null) {
NamedElement namedEl = null;
if (nestId instanceof NamedElmExpr) {
namedEl = ((NamedElmExpr) nestId).getElm();
} else if (nestId instanceof SelectionExpr) {
namedEl = ((SelectionExpr) nestId).getField();
}
if ((namedEl instanceof DataPort) && ((DataPort) namedEl).isIn()) {
return;
} else if ((namedEl instanceof EventDataPort) && ((EventDataPort) namedEl).isIn()) {
return;
} else {
// check to see if it is an "agree_input"
EObject namedElContainer = namedEl.eContainer();
if (namedElContainer instanceof InputStatement) {
return;
}
}
}
error(latched, "Latched expressions are valid only for input data ports or event expressions over input event data ports");
}
use of com.rockwellcollins.atc.agree.agree.Expr in project AGREE by loonwerks.
the class AgreeValidator method checkWhenOccursStatment.
@Check(CheckType.FAST)
public void checkWhenOccursStatment(WhenOccursStatment when) {
Expr condition = when.getCondition();
Expr event = when.getEvent();
Expr times = when.getTimes();
checkExprIsIdentifier(condition);
checkExprIsIdentifier(event);
TypeDef type = AgreeTypeSystem.infer(condition);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(condition, "The condition of the 'when' statement is of type '" + type + "'" + " but must be of type 'bool'");
}
type = AgreeTypeSystem.infer(event);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(event, "The effect of the 'when' statement is of type '" + type + "'" + " but must be of type 'bool'");
}
type = AgreeTypeSystem.infer(times);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.IntTypeDef, type)) {
error(event, "The 'times' of the 'when' statement is of type '" + type + "'" + " but must be of type 'int'");
}
}
use of com.rockwellcollins.atc.agree.agree.Expr in project AGREE by loonwerks.
the class AgreeValidator method checkEventExpr.
@Check(CheckType.FAST)
public void checkEventExpr(EventExpr event) {
if (isInLinearizationBody(event)) {
error(event, "'event' expressions not allowed in linearization body expressions");
return;
}
Expr expr = event.getPort();
NamedElement namedEl = null;
if (expr instanceof NamedElmExpr) {
namedEl = ((NamedElmExpr) expr).getElm();
} else if (expr instanceof SelectionExpr) {
namedEl = ((SelectionExpr) expr).getField();
}
if (namedEl == null || !(namedEl instanceof EventPort || namedEl instanceof EventDataPort)) {
error(event, "Argument of event expression must be an event port or event data port");
}
}
Aggregations