Search in sources :

Example 1 with RelativeObjectIdentifier_Value

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

the class ObjectIdentifierComponent method checkDefdValueOID.

/**
 * Checks the defined value form in an OID component.
 *
 * @param timestamp the timestamp of the actual compilation cycle.
 * @param refChain the reference chain used to detect cyclic references.
 * @param state the state of checking.
 *
 * @param the new state after this check was done.
 */
private oidState_type checkDefdValueOID(final CompilationTimeStamp timestamp, final IReferenceChain refChain, final oidState_type state) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue value = definedValue.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    if (value.getIsErroneous(timestamp)) {
        return oidState_type.LATER;
    }
    switch(value.getValuetype()) {
        case INTEGER_VALUE:
            final ObjectIdentifierComponent temp = new ObjectIdentifierComponent(null, definedValue);
            temp.setFullNameParent(this);
            temp.setMyScope(myScope);
            return temp.checkNumberFormOID(timestamp, state);
        case OBJECTID_VALUE:
            if (!oidState_type.START.equals(state)) {
                definedValue.getLocation().reportSemanticError("INTEGER or RELATIVE-OID value was expected");
            }
            ((ObjectIdentifier_Value) value).checkOID(timestamp, refChain);
            return oidState_type.LATER;
        case RELATIVEOBJECTIDENTIFIER_VALUE:
            switch(state) {
                case ITU_REC:
                    return oidState_type.LATER;
                case LATER:
                    return oidState_type.LATER;
                default:
                    definedValue.getLocation().reportSemanticError(MessageFormat.format("RELATIVE-OID value cannot be used as the {0} component of an OBJECTIDENTIFIER value", oidState_type.START.equals(state) ? "first" : "second"));
                    return oidState_type.LATER;
            }
        case REFERENCED_VALUE:
            {
                final Reference reference = ((Referenced_Value) value).getReference();
                final Assignment assignment = reference.getRefdAssignment(timestamp, false);
                final IType type = assignment.getType(timestamp).getTypeRefdLast(timestamp);
                if (type.getTypetype() == Type_type.TYPE_INTEGER) {
                // FIXME implement handling of the variable form
                } else {
                    definedValue.getLocation().reportSemanticError("INTEGER variable was expected");
                }
                return oidState_type.LATER;
            }
        default:
            if (oidState_type.START.equals(state)) {
                definedValue.getLocation().reportSemanticError("INTEGER or OBJECT IDENTIFIER value was expected for the first component");
            } else {
                definedValue.getLocation().reportSemanticError("INTEGER or RELATIVE-OID value was expected");
            }
            return oidState_type.LATER;
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) Defined_Reference(org.eclipse.titan.designer.AST.ASN1.Defined_Reference) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) RelativeObjectIdentifier_Value(org.eclipse.titan.designer.AST.ASN1.values.RelativeObjectIdentifier_Value) IType(org.eclipse.titan.designer.AST.IType)

Example 2 with RelativeObjectIdentifier_Value

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

the class ObjectIdentifierComponent method checkDefdValueROID.

/**
 * Checks the defined value form in an ROID component.
 *
 * @param timestamp the timestamp of the actual compilation cycle.
 * @param refChain the reference chain used to detect cyclic references.
 *
 * @param the new state after this check was done.
 */
private void checkDefdValueROID(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue value = definedValue.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    if (value.getIsErroneous(timestamp)) {
        return;
    }
    switch(value.getValuetype()) {
        case INTEGER_VALUE:
            final ObjectIdentifierComponent temp = new ObjectIdentifierComponent(null, definedValue);
            temp.setFullNameParent(this);
            temp.setMyScope(myScope);
            temp.checkNumberFormROID(timestamp);
            break;
        case RELATIVEOBJECTIDENTIFIER_VALUE:
            ((RelativeObjectIdentifier_Value) value).checkROID(timestamp, referenceChain);
            break;
        default:
            definedValue.getLocation().reportSemanticError("INTEGER or RELATIVE-OID value was expected");
            break;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) RelativeObjectIdentifier_Value(org.eclipse.titan.designer.AST.ASN1.values.RelativeObjectIdentifier_Value)

Aggregations

RelativeObjectIdentifier_Value (org.eclipse.titan.designer.AST.ASN1.values.RelativeObjectIdentifier_Value)2 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)2 IValue (org.eclipse.titan.designer.AST.IValue)2 Defined_Reference (org.eclipse.titan.designer.AST.ASN1.Defined_Reference)1 Assignment (org.eclipse.titan.designer.AST.Assignment)1 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)1 ISubReference (org.eclipse.titan.designer.AST.ISubReference)1 IType (org.eclipse.titan.designer.AST.IType)1 Reference (org.eclipse.titan.designer.AST.Reference)1