Search in sources :

Example 1 with RecordTypeDef

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);
    }
}
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 2 with RecordTypeDef

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;
    }
}
Also used : RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) IScope(org.eclipse.xtext.scoping.IScope) NamedElement(org.osate.aadl2.NamedElement) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef)

Example 3 with RecordTypeDef

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;
    }
}
Also used : RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) IScope(org.eclipse.xtext.scoping.IScope) NamedElement(org.osate.aadl2.NamedElement) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef)

Aggregations

RecordTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef)3 TypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef)3 IScope (org.eclipse.xtext.scoping.IScope)2 NamedElement (org.osate.aadl2.NamedElement)2 ArrayTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef)1 AgreeTypeSystem.nameOfTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef)1 Arg (com.rockwellcollins.atc.agree.agree.Arg)1 Check (org.eclipse.xtext.validation.Check)1