Search in sources :

Example 1 with ObjectSet_Assignment

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

the class Undefined_Assignment_OS_or_VS method classifyAssignment.

@Override
protected void classifyAssignment(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    final boolean newChain = null == referenceChain;
    IReferenceChain temporalReferenceChain;
    if (newChain) {
        temporalReferenceChain = ReferenceChain.getInstance(CIRCULARASSIGNMENTCHAIN, true);
    } else {
        temporalReferenceChain = referenceChain;
        temporalReferenceChain.markState();
    }
    realAssignment = null;
    if (temporalReferenceChain.add(this)) {
        if (null != reference) {
            reference.setMyScope(getMyScope());
            if (!reference.refersToSettingType(timestamp, Setting_type.S_ERROR, temporalReferenceChain)) {
                if (identifier.isvalidAsnObjectSetReference() && reference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
                    final ObjectClass_refd oc = new ObjectClass_refd(reference);
                    oc.setLocation(reference.getLocation());
                    realAssignment = new ObjectSet_Assignment(identifier, assPard, oc, newObjectSetDefinitionInstance());
                // assPard = null;
                // left = null;
                // right = null;
                // asstype = A_OS;
                } else if (identifier.isvalidAsnValueSetReference() && (reference.refersToSettingType(timestamp, Setting_type.S_T, temporalReferenceChain) || reference.refersToSettingType(timestamp, Setting_type.S_VS, temporalReferenceChain))) {
                    final Referenced_Type type = new Referenced_Type(reference);
                    type.setLocation(reference.getLocation());
                    realAssignment = newValueSetAssignmentInstance(type);
                // left = null;
                // right = null;
                // asstype = A_VS;
                }
            }
        }
    }
    if (null == realAssignment) {
        location.reportSemanticError(UNRECOGNISABLEASSIGNMENT);
        isErroneous = true;
    } else {
        realAssignment.setLocation(location);
        realAssignment.setMyScope(myScope);
        realAssignment.setRightScope(rightScope);
        realAssignment.setFullNameParent(this);
    }
    if (newChain) {
        temporalReferenceChain.release();
    } else {
        temporalReferenceChain.previousState();
    }
}
Also used : IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) ObjectClass_refd(org.eclipse.titan.designer.AST.ASN1.Object.ObjectClass_refd) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type)

Example 2 with ObjectSet_Assignment

use of org.eclipse.titan.designer.AST.ASN1.ObjectSet_Assignment 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)

Aggregations

Defined_Reference (org.eclipse.titan.designer.AST.ASN1.Defined_Reference)1 InformationFromObj (org.eclipse.titan.designer.AST.ASN1.InformationFromObj)1 ObjectClass_refd (org.eclipse.titan.designer.AST.ASN1.Object.ObjectClass_refd)1 ObjectClass (org.eclipse.titan.designer.AST.ASN1.ObjectClass)1 ObjectSet_Assignment (org.eclipse.titan.designer.AST.ASN1.ObjectSet_Assignment)1 Parameterised_Reference (org.eclipse.titan.designer.AST.ASN1.Parameterised_Reference)1 Assignment (org.eclipse.titan.designer.AST.Assignment)1 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1 Referenced_Type (org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type)1