Search in sources :

Example 6 with ObjectSet_definition

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

the class Referenced_ObjectSet method getRefd.

public ObjectSet getRefd(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    if (referenceChain.add(this)) {
        if (osReferenced != null && lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
            return osReferenced;
        }
        final Assignment assignment = reference.getRefdAssignment(timestamp, true, referenceChain);
        if (null != assignment) {
            // TODO check in the compiler too !!!
            final ISetting setting = assignment.getSetting(timestamp);
            if (null != setting && !Setting_type.S_ERROR.equals(setting.getSettingtype())) {
                if (Setting_type.S_OS.equals(setting.getSettingtype())) {
                    osReferenced = (ObjectSet) setting;
                    return osReferenced;
                }
                location.reportSemanticError(OBJECTSETEXPECTED);
            }
        }
    }
    osReferenced = new ObjectSet_definition();
    osReferenced.setFullNameParent(this);
    osReferenced.setMyGovernor(getMyGovernor());
    return osReferenced;
}
Also used : ObjectSet_Assignment(org.eclipse.titan.designer.AST.ASN1.ObjectSet_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) ISetting(org.eclipse.titan.designer.AST.ISetting)

Example 7 with ObjectSet_definition

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

the class TableConstraint method parseBlocks.

private void parseBlocks() {
    if (mObjectSetBlock == null) {
        return;
    }
    objectSet = null;
    atNotationList = null;
    if (null != mObjectSetBlock) {
        if (mAtNotationsBlock == null) {
            // SimpleTableConstraint
            Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mObjectSetBlock, 0);
            if (parser != null) {
                objectSet = parser.pr_special_ObjectSetSpec().definition;
                List<SyntacticErrorStorage> errors = parser.getErrorStorage();
                if (null != errors && !errors.isEmpty()) {
                    objectSet = null;
                    for (int i = 0; i < errors.size(); i++) {
                        ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mObjectSetBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
                    }
                }
            }
        } else {
            // ComponentRelationConstraint
            Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mObjectSetBlock, 0);
            if (parser != null) {
                objectSet = parser.pr_DefinedObjectSetBlock().objectSet;
                List<SyntacticErrorStorage> errors = parser.getErrorStorage();
                if (null != errors && !errors.isEmpty()) {
                    objectSet = null;
                    for (int i = 0; i < errors.size(); i++) {
                        ParserMarkerSupport.createOnTheFlySyntacticMarker((IFile) mObjectSetBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
                    }
                }
            }
            parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mAtNotationsBlock, 0);
            if (parser != null) {
                atNotationList = parser.pr_AtNotationList().notationList;
                List<SyntacticErrorStorage> errors = parser.getErrorStorage();
                if (null != errors && !errors.isEmpty()) {
                    objectSet = null;
                    for (int i = 0; i < errors.size(); i++) {
                        ParserMarkerSupport.createOnTheFlySyntacticMarker((IFile) mAtNotationsBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
                    }
                }
            }
            if (atNotationList == null) {
                atNotationList = new AtNotations();
            }
        }
    }
    if (objectSet == null) {
        objectSet = new ObjectSet_definition();
    }
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) ObjectSet_definition(org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage) Constraint(org.eclipse.titan.designer.AST.Constraint) AtNotations(org.eclipse.titan.designer.AST.AtNotations)

Example 8 with ObjectSet_definition

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

the class TableConstraint method collectTypesOfOpenType.

private void collectTypesOfOpenType(final CompilationTimeStamp aTimestamp, ObjectSet aObjectSet, final Open_Type aOpenType, final Identifier aObjectSetId) {
    if (aObjectSet instanceof Referenced_ObjectSet) {
        if (((Referenced_ObjectSet) aObjectSet).isReferencedDefinedReference()) {
            aObjectSet = aObjectSet.getRefdLast(aTimestamp, null);
        } else if (((Referenced_ObjectSet) aObjectSet).isReferencedInformationFromObj()) {
            // TODO: How to handle this?
            return;
        } else {
            // impossible, try it
            return;
        }
    }
    // now aObjectSet is instanceof ObjectSet_definition:
    List<IObjectSet_Element> oses = ((ObjectSet_definition) aObjectSet).getObjectSetElements();
    for (IObjectSet_Element ose : oses) {
        if (ose instanceof ReferencedObject) {
            // fspec
            ose = ((ReferencedObject) ose).getRefdLast(aTimestamp);
        }
        if (ose instanceof Object_Definition) {
            final Object_Definition od = (Object_Definition) ose;
            FieldSetting fs = od.getFieldSettingWithNameDefault(objectClassFieldname, false);
            if (fs != null) {
                // TODO: handle FieldSetting options: FieldSetting_Type, FieldSetting_ObjectSet, FieldSetting_Value
                if (fs instanceof FieldSetting_Type) {
                    final FieldSetting_Type fst = (FieldSetting_Type) fs;
                    final IASN1Type type = fst.getSetting();
                    final AtomicBoolean isStrange = new AtomicBoolean();
                    Identifier id = getOpenTypeAlternativeName(aTimestamp, (Type) type, isStrange);
                    if (!aOpenType.hasComponentWithName(id)) {
                        aOpenType.addComponent(new CompField(id, (Type) type, false, null));
                        if (isStrange.get()) {
                            aOpenType.getLocation().reportSemanticWarning(MessageFormat.format("Strange alternative name (`{0}') was added to open type `{1}'", id.getDisplayName(), aOpenType.getFullName()));
                        }
                    }
                } else {
                    // TODO: is it possible FieldSetting_ObjectSet, FieldSetting_Value ??
                    continue;
                }
            } else {
                fs = od.getFieldSettingWithNameDefault(aObjectSetId, false);
                if (fs == null) {
                    continue;
                }
                if (fs instanceof FieldSetting_ObjectSet) {
                    final ISetting objectSet1 = fs.getSetting();
                    ObjectSet objectSet2;
                    if (objectSet1 instanceof ObjectSet) {
                        objectSet2 = (ObjectSet) objectSet1;
                    } else {
                        // unexpected case
                        continue;
                    }
                    if (objectSet2 == aObjectSet) {
                        // to prevent infinite loop
                        continue;
                    }
                    collectTypesOfOpenType(aTimestamp, objectSet2, aOpenType, aObjectSetId);
                } else {
                    // TODO: is it possible??
                    continue;
                }
            }
        }
    }
    // for
    aOpenType.check(aTimestamp);
}
Also used : FieldSetting_Type(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_Type) ObjectSet_definition(org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition) FieldSetting_ObjectSet(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_ObjectSet) ISetting(org.eclipse.titan.designer.AST.ISetting) Referenced_ObjectSet(org.eclipse.titan.designer.AST.ASN1.Object.Referenced_ObjectSet) FieldSetting_ObjectSet(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_ObjectSet) FieldSetting(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) TTCN3_Set_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Type) ASN1_Sequence_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type) TTCN3_Choice_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type) Open_Type(org.eclipse.titan.designer.AST.ASN1.types.Open_Type) ASN1_Set_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type) FieldSetting_Type(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_Type) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) ObjectClassField_Type(org.eclipse.titan.designer.AST.ASN1.types.ObjectClassField_Type) TTCN3_Sequence_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type) Type(org.eclipse.titan.designer.AST.Type) ASN1_Choice_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type) IType(org.eclipse.titan.designer.AST.IType) Object_Definition(org.eclipse.titan.designer.AST.ASN1.Object.Object_Definition) Identifier(org.eclipse.titan.designer.AST.Identifier) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) ReferencedObject(org.eclipse.titan.designer.AST.ASN1.Object.ReferencedObject) Referenced_ObjectSet(org.eclipse.titan.designer.AST.ASN1.Object.Referenced_ObjectSet)

Example 9 with ObjectSet_definition

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

the class Referenced_ObjectSet 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 = getRefdObjectClass(timestamp);
    if (myClass != refdClass) {
        if (location != null && refdClass != null && myClass != null) {
            location.reportSemanticError(MessageFormat.format(MISMATCH, myClass.getFullName(), refdClass.getFullName()));
        }
        osReferenced = new ObjectSet_definition();
        osReferenced.setMyGovernor(myGovernor);
        osReferenced.check(timestamp);
    }
}
Also used : ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass)

Example 10 with ObjectSet_definition

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

the class Undefined_FieldSpecification method classifyFieldSpecification.

private void classifyFieldSpecification(final CompilationTimeStamp timestamp) {
    final IReferenceChain temporalReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    if (isOptional && (null != defaultSetting1 || null != mDefaultSetting)) {
        location.reportSemanticError("OPTIONAL and DEFAULT are mutually exclusive");
        isOptional = false;
    }
    if (temporalReferenceChain.add(this) && null != governorReference) {
        governorReference.setMyScope(myObjectClass.getMyScope());
        if (null != defaultSetting1) {
            defaultSetting1.setMyScope(myObjectClass.getMyScope());
        }
        if (identifier.isvalidAsnObjectSetFieldReference() && governorReference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
            ObjectSet defaultObjectset = null;
            if (null != mDefaultSetting) {
                defaultObjectset = new ObjectSet_definition(mDefaultSetting);
            }
            final ObjectClass_refd oc = new ObjectClass_refd(governorReference);
            oc.setLocation(governorReference.getLocation());
            fieldSpecification = new ObjectSet_FieldSpecification(identifier, oc, isOptional, defaultObjectset);
        } else if (identifier.isvalidAsnObjectFieldReference() && governorReference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
            ASN1Object defaultObject = null;
            if (null != defaultSetting1) {
                defaultObject = new ReferencedObject(defaultSetting1);
            } else if (null != mDefaultSetting) {
                defaultObject = new Object_Definition(mDefaultSetting);
            }
            fieldSpecification = new Object_FieldSpecification(identifier, new ObjectClass_refd(governorReference), isOptional, defaultObject);
        } else if (identifier.isvalidAsnValueFieldReference() && (governorReference.refersToSettingType(timestamp, Setting_type.S_T, temporalReferenceChain) || governorReference.refersToSettingType(timestamp, Setting_type.S_VS, temporalReferenceChain))) {
            IValue defaultValue = null;
            if (null != defaultSetting1) {
                if (defaultSetting1 instanceof Defined_Reference && null == defaultSetting1.getModuleIdentifier()) {
                    defaultValue = new Undefined_LowerIdentifier_Value(defaultSetting1.getId().newInstance());
                } else {
                    defaultValue = new Referenced_Value(defaultSetting1);
                }
            } else if (null != mDefaultSetting) {
                defaultValue = new Undefined_Block_Value(mDefaultSetting);
            }
            fieldSpecification = new FixedTypeValue_FieldSpecification(identifier, new Referenced_Type(governorReference), false, isOptional, null != defaultSetting1 && null != mDefaultSetting, defaultValue);
        }
    }
    if (null == fieldSpecification) {
        location.reportSemanticError(CANNOTRECOGNISE);
        fieldSpecification = new Erroneous_FieldSpecification(identifier, isOptional, null != defaultSetting1 || null != mDefaultSetting);
    } else {
        if (null != myObjectClass) {
            fieldSpecification.setMyObjectClass(myObjectClass);
        }
    }
    fieldSpecification.setFullNameParent(getNameParent());
    fieldSpecification.setLocation(location);
    temporalReferenceChain.release();
}
Also used : Defined_Reference(org.eclipse.titan.designer.AST.ASN1.Defined_Reference) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value) ObjectSet(org.eclipse.titan.designer.AST.ASN1.ObjectSet) IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Undefined_Block_Value(org.eclipse.titan.designer.AST.ASN1.values.Undefined_Block_Value) ASN1Object(org.eclipse.titan.designer.AST.ASN1.ASN1Object) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) Undefined_LowerIdentifier_Value(org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)

Aggregations

ObjectSet_definition (org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition)4 ObjectClass (org.eclipse.titan.designer.AST.ASN1.ObjectClass)3 ObjectClassField_Type (org.eclipse.titan.designer.AST.ASN1.types.ObjectClassField_Type)3 Open_Type (org.eclipse.titan.designer.AST.ASN1.types.Open_Type)3 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)3 ISetting (org.eclipse.titan.designer.AST.ISetting)3 Identifier (org.eclipse.titan.designer.AST.Identifier)3 Object_Definition (org.eclipse.titan.designer.AST.ASN1.Object.Object_Definition)2 Referenced_ObjectSet (org.eclipse.titan.designer.AST.ASN1.Object.Referenced_ObjectSet)2 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)2 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)2 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)2 Constraint (org.eclipse.titan.designer.AST.Constraint)2 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)2 IType (org.eclipse.titan.designer.AST.IType)2 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)2 Referenced_Type (org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type)2 TTCN3_Choice_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type)2 TTCN3_Sequence_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type)2 TTCN3_Set_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Type)2