Search in sources :

Example 11 with IReferenceChain

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

the class Notused_Value method checkEquality.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = other.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    return getValuetype().equals(last.getValuetype());
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Example 12 with IReferenceChain

use of org.eclipse.titan.designer.AST.IReferenceChain 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 13 with IReferenceChain

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

the class ObjectIdentifierComponent method checkNameAndNumberForm.

/**
 * Checks if the object identifier component in name and value form is valid.
 *
 * @param timestamp the timestamp of the actual compilation cycle.
 * @param state the state of checking.
 *
 * @param the new state after this check was done.
 */
private oidState_type checkNameAndNumberForm(final CompilationTimeStamp timestamp, final oidState_type state) {
    oidState_type actualState = state;
    actualState = checkNumberFormOID(timestamp, actualState);
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = number.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    if (last.getIsErroneous(timestamp)) {
        return actualState;
    }
    if (!Value_type.INTEGER_VALUE.equals(last.getValuetype())) {
        return actualState;
    }
    final BigInteger value = ((Integer_Value) last).getValueValue();
    if (value.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) == 1) {
        return actualState;
    }
    final String tempName = this.name.getName();
    final int tempInt = value.intValue();
    switch(state) {
        case START:
            if (!isValidNameForNumber(tempName, tempInt, NAMES_ROOT)) {
                number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the first OBJECT IDENTIFIER component", getExpectedNameForNumber(tempInt, number.isAsn(), NAMES_ROOT), name.getDisplayName(), value));
            }
            break;
        case ITU:
            if (!isValidNameForNumber(tempName, tempInt, NAMES_ITU)) {
                number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the second OBJECT IDENTIFIER component", getExpectedNameForNumber(tempInt, number.isAsn(), NAMES_ITU), name.getDisplayName(), value));
            }
            break;
        case ISO:
            if (!isValidNameForNumber(tempName, tempInt, NAMES_ISO)) {
                number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the second OBJECT IDENTIFIER component", getExpectedNameForNumber(tempInt, number.isAsn(), NAMES_ISO), name.getDisplayName(), value));
            }
            break;
        case JOINT:
            if (!isValidNameForNumber(tempName, tempInt, NAMES_JOINT)) {
                number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the second OBJECT IDENTIFIER component", getExpectedNameForNumber(tempInt, number.isAsn(), NAMES_JOINT), name.getDisplayName(), value));
            }
            break;
        case ITU_REC:
            if (tempInt >= 1 && tempInt <= 26 && (tempName.length() != 1 || tempName.getBytes()[0] != 'a' + tempInt - 1)) {
                number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the third OBJECT IDENTIFIER component", ('a' + tempInt - 1), name.getDisplayName(), value));
            }
            break;
        default:
            break;
    }
    return actualState;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) BigInteger(java.math.BigInteger)

Example 14 with IReferenceChain

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

Example 15 with IReferenceChain

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

the class ObjectIdentifier_Value method checkEquality.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = other.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    if (!Value_type.OBJECTID_VALUE.equals(last.getValuetype())) {
        return false;
    }
    final ObjectIdentifier_Value otherObjid = (ObjectIdentifier_Value) last;
    if (objectIdComponents.size() != otherObjid.objectIdComponents.size()) {
        return false;
    }
    for (int i = 0, size = objectIdComponents.size(); i < size; i++) {
        if (objectIdComponents.get(i) != otherObjid.objectIdComponents.get(i)) {
            return false;
        }
    }
    return true;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Aggregations

IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)154 IValue (org.eclipse.titan.designer.AST.IValue)102 IType (org.eclipse.titan.designer.AST.IType)55 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)21 ISubReference (org.eclipse.titan.designer.AST.ISubReference)18 Value (org.eclipse.titan.designer.AST.Value)18 Assignment (org.eclipse.titan.designer.AST.Assignment)16 BigInteger (java.math.BigInteger)15 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)14 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)13 Identifier (org.eclipse.titan.designer.AST.Identifier)12 Reference (org.eclipse.titan.designer.AST.Reference)9 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)8 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)7 Expression_Value (org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value)7 HashMap (java.util.HashMap)6 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)6 Referenced_Type (org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type)6 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)6 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)5