use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeValidator method checkRecordLitExpr.
@Check(CheckType.FAST)
public void checkRecordLitExpr(RecordLitExpr recExpr) {
DoubleDotRef recType = recExpr.getRecordType();
// =======
// DoubleDotRef recType = recExpr.getRecord();
// >>>>>>> origin/develop
List<NamedElement> defArgs = getArgNames(recType);
EList<NamedElement> exprArgs = recExpr.getArgs();
EList<Expr> argExprs = recExpr.getArgExpr();
NamedElement finalId = recExpr.getRecordType().getElm();
if (!(finalId instanceof DataImplementation) && !(finalId instanceof RecordDef)) {
error(recType, "types must be record definition or data implementation");
// =======
// DoubleDotRef recId = recExpr.getRecord();
// NamedElement finalId = recId.getElm();
//
// if (!(finalId instanceof DataImplementation) && !(finalId instanceof RecordDefExpr)) {
// error(recId, "types must be record definition or data implementation");
// }
//
// if (finalId instanceof DataImplementation) {
// dataImplCycleCheck(recId);
// >>>>>>> origin/develop
}
if (exprArgs.size() != defArgs.size()) {
error(recExpr, "Incorrect number of arguments");
return;
}
for (NamedElement argDefName : defArgs) {
boolean foundArg = false;
for (NamedElement argExprEl : exprArgs) {
if (argExprEl.getName().equals(argDefName.getName())) {
foundArg = true;
break;
}
}
if (!foundArg) {
error(recExpr, "No assignment to defined variable '" + argDefName + "' in record expression.");
}
}
// check typing
Map<String, TypeDef> argNameMap = getFieldTypes(recType);
for (int i = 0; i < recExpr.getArgs().size(); i++) {
NamedElement actArg = recExpr.getArgs().get(i);
String actArgName = actArg.getName();
TypeDef defType = argNameMap.get(actArgName);
checkTypeExists(argExprs.get(i));
TypeDef exprType = AgreeTypeSystem.infer(argExprs.get(i));
if (!AgreeTypeSystem.typesEqual(defType, exprType)) {
error(recExpr, "The expression assigned to '" + actArgName + "' does not match its definition type of '" + defType + "'");
}
}
}
Aggregations