use of com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef 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.RecordTypeDef in project AMASE by loonwerks.
the class SafetyScopeProvider method scope_RecordUpdateExpr_key.
IScope scope_RecordUpdateExpr_key(RecordUpdateExpr ctx, EReference ref) {
IScope prevScope = prevScope(ctx, ref);
TypeDef typ = AgreeTypeSystem.infer(ctx.getRecord());
if (typ instanceof RecordTypeDef) {
NamedElement ne = ((RecordTypeDef) typ).namedElement;
return Scopes.scopeFor(getFieldsOfNE(ne), prevScope);
} else {
return IScope.NULLSCOPE;
}
}
use of com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef in project AGREE by loonwerks.
the class AgreeScopeProvider method scope_RecordUpdateExpr_key.
IScope scope_RecordUpdateExpr_key(RecordUpdateExpr ctx, EReference ref) {
IScope prevScope = prevScope(ctx, ref);
TypeDef typ = AgreeTypeSystem.infer(ctx.getRecord());
if (typ instanceof RecordTypeDef) {
NamedElement ne = ((RecordTypeDef) typ).namedElement;
return Scopes.scopeFor(getFieldsOfNE(ne), prevScope);
} else {
return IScope.NULLSCOPE;
}
}
Aggregations