Search in sources :

Example 6 with ObjectClass

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

the class Referenced_ObjectSet method getRefdObjectClass.

/**
 * Returns the referenced ObjectClass. The evaluation depends on the type of the reference
 * @param timestamp
 * @return the referenced ObjectClass if found. Otherwise returns null.
 */
public ObjectClass getRefdObjectClass(final CompilationTimeStamp timestamp) {
    ObjectClass refdClass = null;
    if (reference instanceof InformationFromObj) {
        final ObjectClass tempGovernor = getRefdLast(timestamp, null).getMyGovernor();
        if (tempGovernor == null) {
            return null;
        }
        refdClass = tempGovernor.getRefdLast(timestamp, null);
        final FieldName fn = ((InformationFromObj) reference).getFieldName();
        if (fn.getNofFields() == 1) {
            final Identifier fieldId = fn.getFieldByIndex(0);
            final FieldSpecifications fss = refdClass.getFieldSpecifications();
            FieldSpecification fs = fss.getFieldSpecificationByIdentifier(fieldId);
            if (fs instanceof Undefined_FieldSpecification) {
                fs = ((Undefined_FieldSpecification) fs).getRealFieldSpecification();
            }
            switch(fs.getFieldSpecificationType()) {
                case FS_OS:
                    refdClass = ((ObjectSet_FieldSpecification) fs).getObjectClass().getRefdLast(timestamp, null);
                    break;
                case FS_T:
                    // TODO: implement the other cases
                    break;
                default:
                    // TODO: implement the other cases
                    break;
            }
        }
    } else if (reference instanceof Parameterised_Reference) {
        final Defined_Reference dref = ((Parameterised_Reference) reference).getRefDefdSimple();
        if (dref == null) {
            return null;
        }
        final Assignment ass = dref.getRefdAssignment(timestamp, false, null);
        if (ass instanceof ObjectSet_Assignment) {
            ass.check(timestamp);
            // experimental
            osReferenced = ((ObjectSet_Assignment) ass).getObjectSet(timestamp);
            refdClass = ((ObjectSet_Assignment) ass).getObjectSet(timestamp).getMyGovernor().getRefdLast(timestamp, null);
        }
    } else if (reference instanceof Defined_Reference) {
        final Assignment ass = ((Defined_Reference) reference).getRefdAssignment(timestamp, false, null);
        if (ass instanceof ObjectSet_Assignment) {
            ass.check(timestamp);
            // experimental
            osReferenced = ((ObjectSet_Assignment) ass).getObjectSet(timestamp);
            refdClass = ((ObjectSet_Assignment) ass).getObjectSet(timestamp).getMyGovernor().getRefdLast(timestamp, null);
        }
    } else {
        // to debug
        return refdClass;
    }
    return refdClass;
}
Also used : ObjectSet_Assignment(org.eclipse.titan.designer.AST.ASN1.ObjectSet_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass) Identifier(org.eclipse.titan.designer.AST.Identifier) Parameterised_Reference(org.eclipse.titan.designer.AST.ASN1.Parameterised_Reference) Defined_Reference(org.eclipse.titan.designer.AST.ASN1.Defined_Reference) ObjectSet_Assignment(org.eclipse.titan.designer.AST.ASN1.ObjectSet_Assignment) InformationFromObj(org.eclipse.titan.designer.AST.ASN1.InformationFromObj)

Example 7 with ObjectClass

use of org.eclipse.titan.designer.AST.ASN1.ObjectClass 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 8 with ObjectClass

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

the class ObjectClass_refd method getRefd.

protected ObjectClass getRefd(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    if (null != reference && referenceChain.add(this)) {
        final Assignment assignment = reference.getRefdAssignment(timestamp, true, referenceChain);
        if (null == assignment) {
            return newObjectClassDefinitionInstance();
        }
        final ISetting setting = reference.getRefdSetting(timestamp);
        if (Setting_type.S_ERROR.equals(setting.getSettingtype())) {
            return newObjectClassDefinitionInstance();
        } else if (!Setting_type.S_OC.equals(setting.getSettingtype())) {
            reference.getLocation().reportSemanticError(OBJECTCLASSEXPECTED);
            return newObjectClassDefinitionInstance();
        }
        return (ObjectClass) setting;
    }
    return newObjectClassDefinitionInstance();
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass) ISetting(org.eclipse.titan.designer.AST.ISetting)

Example 9 with ObjectClass

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

the class ObjectClass_refd method getRefdLast.

@Override
public /**
 * {@inheritDoc}
 */
ObjectClass_Definition getRefdLast(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    final boolean newChain = null == referenceChain;
    IReferenceChain temporalReferenceChain;
    if (newChain) {
        temporalReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    } else {
        temporalReferenceChain = referenceChain;
        temporalReferenceChain.markState();
    }
    final ObjectClass objectClass = getRefd(timestamp, temporalReferenceChain);
    referencedLast = null;
    if (null != objectClass) {
        referencedLast = objectClass.getRefdLast(timestamp, temporalReferenceChain);
    }
    if (newChain) {
        temporalReferenceChain.release();
    } else {
        temporalReferenceChain.previousState();
    }
    return referencedLast;
}
Also used : ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Example 10 with ObjectClass

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

the class ObjectSetElementVisitor_objectCollector method visitObject.

@Override
public /**
 * {@inheritDoc}
 */
void visitObject(final ASN1Object p) {
    final Object_Definition object = p.getRefdLast(timestamp, null);
    if (object.getIsErroneous(timestamp)) {
        return;
    }
    if (visitedElements.contains(object)) {
        return;
    }
    final ObjectClass myClass = governor.getRefdLast(timestamp, null);
    final ObjectClass refdClass = object.getMyGovernor().getRefdLast(timestamp, null);
    if (myClass != refdClass) {
        if (location != NULL_Location.INSTANCE && refdClass != null) {
            location.reportSemanticError(MessageFormat.format(OBJECTOFCLASSEXPECTED, myClass.getFullName(), p.getFullName(), refdClass.getFullName()));
        }
        return;
    }
    visitedElements.add(object);
    objects.addObject(object);
}
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