Search in sources :

Example 1 with ObjectClass

use of org.eclipse.titan.designer.AST.ASN1.ObjectClass in project titan.EclipsePlug-ins by eclipse.

the class ObjectSetElementVisitor_objectCollector method visitObjectSet.

public void visitObjectSet(final ObjectSet p, final boolean force) {
    if (governor == null || p == null) {
        return;
    }
    final ObjectClass myClass = governor.getRefdLast(timestamp, null);
    ObjectClass refdClass = null;
    if (p instanceof Referenced_ObjectSet) {
        refdClass = ((Referenced_ObjectSet) p).getRefdObjectClass(timestamp);
    }
    if (myClass != refdClass && myClass != null && refdClass != null) {
        p.getLocation().reportSemanticError(MessageFormat.format(OBJECTOFCLASSEXPECTED, myClass.getFullName(), p.getFullName(), refdClass.getFullName()));
        return;
    }
    final ObjectSet_definition os = p.getRefdLast(timestamp, null);
    if (visitedElements.contains(os)) {
        if (!force) {
            return;
        }
    } else {
        visitedElements.add(os);
    }
    // ^Par ref ^^^^^^ObjectSet
    if (((Referenced_ObjectSet) p).isReferencedParameterisedReference()) {
        return;
    }
    // TODO: check this!
    if (((Referenced_ObjectSet) p).isReferencedDefinedReference()) {
        return;
    }
    final ASN1Objects otherObjects = os.getObjs();
    otherObjects.trimToSize();
    for (int i = 0; i < otherObjects.getNofObjects(); i++) {
        visitObject(otherObjects.getObjectByIndex(i));
    }
}
Also used : ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass)

Example 2 with ObjectClass

use of org.eclipse.titan.designer.AST.ASN1.ObjectClass in project titan.EclipsePlug-ins by eclipse.

the class ReferencedObject method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    if (null == myGovernor) {
        return;
    }
    final ObjectClass myClass = myGovernor.getRefdLast(timestamp, null);
    final ObjectClass refdClass = getRefdLast(timestamp, null).getMyGovernor().getRefdLast(timestamp, null);
    if (myClass != refdClass) {
        location.reportSemanticError(MessageFormat.format(Referenced_ObjectSet.MISMATCH, myClass.getFullName(), refdClass.getFullName()));
        objectReferenced = new Object_Definition(null);
        objectReferenced.setIsErroneous(true);
        objectReferenced.setMyGovernor(myGovernor);
    }
}
Also used : ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass)

Example 3 with ObjectClass

use of org.eclipse.titan.designer.AST.ASN1.ObjectClass in project titan.EclipsePlug-ins by eclipse.

the class InformationFromObj method getRefdSetting.

@Override
public /**
 * {@inheritDoc}
 */
ISetting getRefdSetting(final CompilationTimeStamp timestamp) {
    setIsErroneous(false);
    ISetting temporalSetting = reference.getRefdSetting(timestamp);
    if (null == temporalSetting) {
        setIsErroneous(true);
        return new Error_Setting();
    }
    SettingDetectionState currentState;
    ObjectClass_Definition objectClass = null;
    ObjectSet_definition objectSet = null;
    Object_Definition object = null;
    object = new Object_Definition(null);
    ObjectSet_definition fromObjectSet = newObjectSetDefinitionInstance();
    /* the first part */
    switch(temporalSetting.getSettingtype()) {
        case S_OS:
            currentState = SettingDetectionState.ObjectSet;
            objectSet = ((ObjectSet) temporalSetting).getRefdLast(timestamp, null);
            objectClass = objectSet.getMyGovernor().getRefdLast(timestamp, null);
            final ObjectSetElementVisitor_objectCollector objectCollector = new ObjectSetElementVisitor_objectCollector(objectSet.getLocation(), objectClass, timestamp);
            objectCollector.visitObjectSet(objectSet, false);
            fromObjectSet = newObjectSetDefinitionInstance(objectCollector.giveObjects());
            fromObjectSet.setMyGovernor(objectClass);
            break;
        case S_O:
            currentState = SettingDetectionState.Object;
            object = ((ASN1Object) temporalSetting).getRefdLast(timestamp, null);
            objectClass = object.getMyGovernor().getRefdLast(timestamp, null);
            break;
        case S_OC:
            currentState = SettingDetectionState.ObjectClass;
            objectClass = ((ObjectClass) temporalSetting).getRefdLast(timestamp, null);
            break;
        case S_ERROR:
            setIsErroneous(true);
            return new Error_Setting();
        default:
            location.reportSemanticError(MessageFormat.format(INVALIDREFERENCE, getDisplayName()));
            setIsErroneous(true);
            return new Error_Setting();
    }
    final int nofFields = fieldName.getNofFields();
    /* the middle part */
    Identifier currentFieldName;
    FieldSpecification currentFieldSpecification;
    for (int i = 0; i < nofFields - 1; i++) {
        currentFieldName = fieldName.getFieldByIndex(i);
        currentFieldSpecification = objectClass.getFieldSpecifications().getFieldSpecificationByIdentifier(currentFieldName).getLast();
        if (Fieldspecification_types.FS_ERROR.equals(currentFieldSpecification.getFieldSpecificationType())) {
            setIsErroneous(true);
            return new Error_Setting();
        }
        switch(currentState) {
            case ObjectClass:
                switch(currentFieldSpecification.getFieldSpecificationType()) {
                    case FS_O:
                        {
                            final Object_FieldSpecification temporalFieldspec = (Object_FieldSpecification) currentFieldSpecification;
                            objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
                        }
                        break;
                    case FS_OS:
                        {
                            final ObjectSet_FieldSpecification temporalFieldspec = (ObjectSet_FieldSpecification) currentFieldSpecification;
                            objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
                        }
                        break;
                    case FS_ERROR:
                        setIsErroneous(true);
                        return new Error_Setting();
                    default:
                        location.reportSemanticError(INVALIDNOTATION1);
                        setIsErroneous(true);
                        return new Error_Setting();
                }
                break;
            case ObjectSet:
                switch(currentFieldSpecification.getFieldSpecificationType()) {
                    case FS_O:
                        {
                            final Object_FieldSpecification temporalFieldspec = (Object_FieldSpecification) currentFieldSpecification;
                            objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
                            final ObjectSetElementVisitor_objectCollector objectCollector = new ObjectSetElementVisitor_objectCollector(location, objectClass, timestamp);
                            final ASN1Objects temporalObjects = fromObjectSet.getObjs();
                            temporalObjects.trimToSize();
                            for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
                                object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
                                if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
                                    continue;
                                }
                                temporalSetting = object.getSettingByNameDefault(currentFieldName);
                                object = ((Object_Definition) temporalSetting).getRefdLast(timestamp, null);
                                objectCollector.visitObject(object);
                            }
                            fromObjectSet = newObjectSetDefinitionInstance(objectCollector.giveObjects());
                            fromObjectSet.setLocation(location);
                            fromObjectSet.setMyGovernor(objectClass);
                        }
                        break;
                    case FS_OS:
                        {
                            final ObjectSet_FieldSpecification temporalFieldspec = (ObjectSet_FieldSpecification) currentFieldSpecification;
                            objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
                            final ObjectSetElementVisitor_objectCollector objectCollector2 = new ObjectSetElementVisitor_objectCollector(location, objectClass, timestamp);
                            final ASN1Objects temporalObjects = fromObjectSet.getObjs();
                            for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
                                object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
                                if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
                                    continue;
                                }
                                temporalSetting = object.getSettingByNameDefault(currentFieldName);
                                objectSet = ((ObjectSet_definition) temporalSetting).getRefdLast(timestamp, null);
                                objectCollector2.visitObjectSet(objectSet, false);
                            }
                            fromObjectSet = newObjectSetDefinitionInstance(objectCollector2.giveObjects());
                            fromObjectSet.setLocation(location);
                            fromObjectSet.setMyGovernor(objectClass);
                        }
                        break;
                    case FS_ERROR:
                        setIsErroneous(true);
                        return new Error_Setting();
                    default:
                        location.reportSemanticError(INVALIDNOTATION1);
                        setIsErroneous(true);
                        return new Error_Setting();
                }
                break;
            case Object:
                switch(currentFieldSpecification.getFieldSpecificationType()) {
                    case FS_O:
                        {
                            final Object_FieldSpecification temporalFieldspec = (Object_FieldSpecification) currentFieldSpecification;
                            objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
                            temporalSetting = object.getSettingByNameDefault(currentFieldName);
                            object = ((Object_Definition) temporalSetting).getRefdLast(timestamp, null);
                        }
                        break;
                    case FS_OS:
                        {
                            currentState = SettingDetectionState.ObjectSet;
                            final ObjectSet_FieldSpecification temporalFieldspec = (ObjectSet_FieldSpecification) currentFieldSpecification;
                            objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
                            final ObjectSetElementVisitor_objectCollector objectCollector = new ObjectSetElementVisitor_objectCollector(fromObjectSet, timestamp);
                            final ASN1Objects temporalObjects = fromObjectSet.getObjs();
                            for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
                                object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
                                if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
                                    continue;
                                }
                                temporalSetting = object.getSettingByNameDefault(currentFieldName);
                                objectSet = ((ObjectSet_definition) temporalSetting).getRefdLast(timestamp, null);
                                objectCollector.visitObjectSet(objectSet, false);
                            }
                            fromObjectSet = newObjectSetDefinitionInstance(objectCollector.giveObjects());
                            fromObjectSet.setLocation(location);
                            fromObjectSet.setMyGovernor(objectClass);
                        }
                        break;
                    case FS_ERROR:
                        setIsErroneous(true);
                        return new Error_Setting();
                    default:
                        location.reportSemanticError(INVALIDNOTATION1);
                        setIsErroneous(true);
                        return new Error_Setting();
                }
                break;
            default:
                // if this could happen it would be FATAL ERROR
                break;
        }
    }
    /* and the last part... */
    currentFieldName = fieldName.getFieldByIndex(nofFields - 1);
    currentFieldSpecification = objectClass.getFieldSpecifications().getFieldSpecificationByIdentifier(currentFieldName).getLast();
    temporalSetting = null;
    switch(currentState) {
        case ObjectClass:
            switch(currentFieldSpecification.getFieldSpecificationType()) {
                case FS_T:
                    {
                        final Open_Type type = new Open_Type(objectClass, currentFieldName);
                        type.setLocation(location);
                        type.setMyScope(myScope);
                        temporalSetting = type;
                    }
                    break;
                case FS_V_FT:
                    {
                        final FixedTypeValue_FieldSpecification temporalFielspecification = (FixedTypeValue_FieldSpecification) currentFieldSpecification;
                        final ObjectClassField_Type type = new ObjectClassField_Type(temporalFielspecification.getType(), objectClass, currentFieldName);
                        type.setLocation(location);
                        temporalSetting = type;
                    }
                    break;
                case FS_V_VT:
                case FS_VS_FT:
                case FS_VS_VT:
                    location.reportSemanticError(UNSUPPORTEDCONSTRUCT);
                    setIsErroneous(true);
                    break;
                case FS_O:
                case FS_OS:
                    location.reportSemanticError(INVALIDNOTATION2);
                    setIsErroneous(true);
                    break;
                default:
                    setIsErroneous(true);
                    break;
            }
            break;
        case ObjectSet:
            switch(currentFieldSpecification.getFieldSpecificationType()) {
                case FS_O:
                    {
                        final Object_FieldSpecification temporalFieldspec = (Object_FieldSpecification) currentFieldSpecification;
                        objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
                        final ObjectSetElementVisitor_objectCollector objectCollector = new ObjectSetElementVisitor_objectCollector(location, objectClass, timestamp);
                        final ASN1Objects temporalObjects = fromObjectSet.getObjs();
                        for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
                            object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
                            if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
                                continue;
                            }
                            temporalSetting = object.getSettingByNameDefault(currentFieldName);
                            object = ((Object_Definition) temporalSetting).getRefdLast(timestamp, null);
                            objectCollector.visitObject(object);
                        }
                        fromObjectSet = newObjectSetDefinitionInstance(objectCollector.giveObjects());
                        fromObjectSet.setLocation(location);
                        fromObjectSet.setMyGovernor(objectClass);
                        fromObjectSet.setMyScope(myScope);
                        temporalSetting = fromObjectSet;
                    }
                    break;
                case FS_OS:
                    {
                        final ObjectSet_FieldSpecification temporalFieldspec = (ObjectSet_FieldSpecification) currentFieldSpecification;
                        objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
                        final ObjectSetElementVisitor_objectCollector objectCollector2 = new ObjectSetElementVisitor_objectCollector(location, objectClass, timestamp);
                        final ASN1Objects temporalObjects = fromObjectSet.getObjs();
                        for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
                            object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
                            if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
                                continue;
                            }
                            temporalSetting = object.getSettingByNameDefault(currentFieldName);
                            objectSet = ((ObjectSet_definition) temporalSetting).getRefdLast(timestamp, null);
                            objectCollector2.visitObjectSet(objectSet, false);
                        }
                        fromObjectSet = newObjectSetDefinitionInstance(objectCollector2.giveObjects());
                        fromObjectSet.setLocation(location);
                        fromObjectSet.setMyGovernor(objectClass);
                        fromObjectSet.setMyScope(myScope);
                        temporalSetting = fromObjectSet;
                    }
                    break;
                case FS_V_FT:
                case FS_VS_FT:
                    location.reportSemanticError(VALUESETFROMOBJECTS_NOT_SUPPORTED);
                    setIsErroneous(true);
                    break;
                case FS_ERROR:
                    setIsErroneous(true);
                    break;
                default:
                    location.reportSemanticError(INVALIDNOTATION3);
                    setIsErroneous(true);
                    break;
            }
            break;
        case Object:
            temporalSetting = object.getSettingByNameDefault(currentFieldName);
            break;
        default:
            setIsErroneous(true);
            break;
    }
    return temporalSetting;
}
Also used : ObjectSet_FieldSpecification(org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_FieldSpecification) Open_Type(org.eclipse.titan.designer.AST.ASN1.types.Open_Type) ObjectClass_Definition(org.eclipse.titan.designer.AST.ASN1.Object.ObjectClass_Definition) ObjectSet_definition(org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition) Error_Setting(org.eclipse.titan.designer.AST.Error_Setting) ObjectClassField_Type(org.eclipse.titan.designer.AST.ASN1.types.ObjectClassField_Type) ISetting(org.eclipse.titan.designer.AST.ISetting) ObjectSet_FieldSpecification(org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_FieldSpecification) Object_FieldSpecification(org.eclipse.titan.designer.AST.ASN1.Object.Object_FieldSpecification) FieldSpecification(org.eclipse.titan.designer.AST.ASN1.Object.FieldSpecification) FixedTypeValue_FieldSpecification(org.eclipse.titan.designer.AST.ASN1.Object.FixedTypeValue_FieldSpecification) FixedTypeValue_FieldSpecification(org.eclipse.titan.designer.AST.ASN1.Object.FixedTypeValue_FieldSpecification) Object_Definition(org.eclipse.titan.designer.AST.ASN1.Object.Object_Definition) Identifier(org.eclipse.titan.designer.AST.Identifier) Object_FieldSpecification(org.eclipse.titan.designer.AST.ASN1.Object.Object_FieldSpecification) ObjectSetElementVisitor_objectCollector(org.eclipse.titan.designer.AST.ASN1.Object.ObjectSetElementVisitor_objectCollector) ASN1Objects(org.eclipse.titan.designer.AST.ASN1.Object.ASN1Objects)

Example 4 with ObjectClass

use of org.eclipse.titan.designer.AST.ASN1.ObjectClass in project titan.EclipsePlug-ins by eclipse.

the class FieldSetting_Object method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final FieldSpecification fieldSpecification) {
    if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    if (!Fieldspecification_types.FS_O.equals(fieldSpecification.getFieldSpecificationType())) {
        location.reportSemanticError(OBJECTEXPECTED);
        object = new Object_Definition(null);
        object.setFullNameParent(this);
    }
    final Object_FieldSpecification fs = (Object_FieldSpecification) fieldSpecification;
    final ObjectClass oc = fs.getObjectClass();
    object.setMyGovernor(oc);
    lastTimeChecked = timestamp;
    object.check(timestamp);
}
Also used : ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass)

Example 5 with ObjectClass

use of org.eclipse.titan.designer.AST.ASN1.ObjectClass in project titan.EclipsePlug-ins by eclipse.

the class FieldSetting_ObjectSet method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final FieldSpecification fieldSpecification) {
    if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    if (!Fieldspecification_types.FS_OS.equals(fieldSpecification.getFieldSpecificationType())) {
        location.reportSemanticError(OBJECTSETEXPECTED);
        objectSet = new ObjectSet_definition();
        objectSet.setFullNameParent(this);
        objectSet.setLocation(fieldSpecification.getLocation());
    }
    final ObjectSet_FieldSpecification fs = (ObjectSet_FieldSpecification) fieldSpecification;
    final ObjectClass oc = fs.getObjectClass();
    objectSet.setMyGovernor(oc);
    lastTimeChecked = timestamp;
    objectSet.check(timestamp);
}
Also used : ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass)

Aggregations

ObjectClass (org.eclipse.titan.designer.AST.ASN1.ObjectClass)9 Assignment (org.eclipse.titan.designer.AST.Assignment)2 ISetting (org.eclipse.titan.designer.AST.ISetting)2 Identifier (org.eclipse.titan.designer.AST.Identifier)2 Defined_Reference (org.eclipse.titan.designer.AST.ASN1.Defined_Reference)1 InformationFromObj (org.eclipse.titan.designer.AST.ASN1.InformationFromObj)1 ASN1Objects (org.eclipse.titan.designer.AST.ASN1.Object.ASN1Objects)1 FieldSpecification (org.eclipse.titan.designer.AST.ASN1.Object.FieldSpecification)1 FixedTypeValue_FieldSpecification (org.eclipse.titan.designer.AST.ASN1.Object.FixedTypeValue_FieldSpecification)1 ObjectClass_Definition (org.eclipse.titan.designer.AST.ASN1.Object.ObjectClass_Definition)1 ObjectSetElementVisitor_objectCollector (org.eclipse.titan.designer.AST.ASN1.Object.ObjectSetElementVisitor_objectCollector)1 ObjectSet_FieldSpecification (org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_FieldSpecification)1 ObjectSet_definition (org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition)1 Object_Definition (org.eclipse.titan.designer.AST.ASN1.Object.Object_Definition)1 Object_FieldSpecification (org.eclipse.titan.designer.AST.ASN1.Object.Object_FieldSpecification)1 ObjectSet_Assignment (org.eclipse.titan.designer.AST.ASN1.ObjectSet_Assignment)1 Parameterised_Reference (org.eclipse.titan.designer.AST.ASN1.Parameterised_Reference)1 ObjectClassField_Type (org.eclipse.titan.designer.AST.ASN1.types.ObjectClassField_Type)1 Open_Type (org.eclipse.titan.designer.AST.ASN1.types.Open_Type)1 Error_Setting (org.eclipse.titan.designer.AST.Error_Setting)1