Search in sources :

Example 6 with Set_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Set_Value in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Set_Type method checkThisValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
    if (getIsErroneous(timestamp)) {
        return false;
    }
    boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
    IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
    if (last == null || last.getIsErroneous(timestamp)) {
        return selfReference;
    }
    // already handled ones
    switch(value.getValuetype()) {
        case OMIT_VALUE:
        case REFERENCED_VALUE:
            return selfReference;
        case UNDEFINED_LOWERIDENTIFIER_VALUE:
            if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
                return selfReference;
            }
            break;
        default:
            break;
    }
    switch(last.getValuetype()) {
        case SEQUENCE_VALUE:
            last = last.setValuetype(timestamp, Value_type.SET_VALUE);
            if (last.isAsn()) {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            } else {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            }
            break;
        case SEQUENCEOF_VALUE:
            if (((SequenceOf_Value) last).isIndexed()) {
                value.getLocation().reportSemanticError(MessageFormat.format("Indexed assignment notation cannot be used for SET type `{0}''", getFullName()));
                value.setIsErroneous(true);
            } else {
                final SequenceOf_Value temporalValue = (SequenceOf_Value) last;
                if (temporalValue.getNofComponents() == 0) {
                    if (getNofComponents(timestamp) == 0) {
                        last = last.setValuetype(timestamp, Value_type.SET_VALUE);
                    } else {
                        value.getLocation().reportSemanticError(MessageFormat.format(NONEMPTYEXPECTED, getFullName()));
                        value.setIsErroneous(true);
                    }
                } else {
                    value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? VALUELISTNOTATIONERRORASN1 : VALUELISTNOTATIONERRORTTCN3, getFullName()));
                    value.setIsErroneous(true);
                }
            }
            break;
        case SET_VALUE:
            if (last.isAsn()) {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            } else {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            }
            break;
        case UNDEFINED_BLOCK:
            last = last.setValuetype(timestamp, Value_type.SET_VALUE);
            selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            break;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? SETVALUEXPECTEDASN1 : SETVALUEXPECTEDTTCN3, getFullName()));
            value.setIsErroneous(true);
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) Set_Value(org.eclipse.titan.designer.AST.TTCN3.values.Set_Value)

Example 7 with Set_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Set_Value in project titan.EclipsePlug-ins by eclipse.

the class Set_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.SET_VALUE.equals(last.getValuetype())) {
        return false;
    }
    if (myGovernor == null) {
        return false;
    }
    final Set_Value otherSet = (Set_Value) last;
    if (values.getSize() != otherSet.values.getSize()) {
        return false;
    }
    int nofComps = 0;
    final IType leftGovernor = myGovernor.getTypeRefdLast(timestamp);
    switch(leftGovernor.getTypetype()) {
        case TYPE_TTCN3_SET:
            nofComps = ((TTCN3_Set_Type) leftGovernor).getNofComponents();
            break;
        case TYPE_ASN1_SET:
            nofComps = ((ASN1_Set_Type) leftGovernor).getNofComponents(timestamp);
            break;
        default:
            return false;
    }
    CompField compField = null;
    for (int i = 0; i < nofComps; i++) {
        switch(leftGovernor.getTypetype()) {
            case TYPE_TTCN3_SET:
                compField = ((TTCN3_Set_Type) leftGovernor).getComponentByIndex(i);
                break;
            case TYPE_ASN1_SET:
                compField = ((ASN1_Set_Type) leftGovernor).getComponentByIndex(i);
                break;
            default:
                return false;
        }
        final Identifier fieldName = compField.getIdentifier();
        if (hasComponentWithName(fieldName)) {
            final IValue leftValue = getComponentByName(fieldName).getValue();
            if (otherSet.hasComponentWithName(fieldName)) {
                final IValue otherValue = otherSet.getComponentByName(fieldName).getValue();
                if ((Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && !Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) || (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && Value_type.OMIT_VALUE.equals(otherValue.getValuetype()))) {
                    return false;
                }
                if (!leftValue.checkEquality(timestamp, otherValue)) {
                    return false;
                }
            } else {
                if (compField.hasDefault()) {
                    if (!leftValue.checkEquality(timestamp, compField.getDefault())) {
                        return false;
                    }
                } else {
                    if (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype())) {
                        return false;
                    }
                }
            }
        } else {
            if (otherSet.hasComponentWithName(fieldName)) {
                final IValue otherValue = otherSet.getComponentByName(fieldName).getValue();
                if (compField.hasDefault()) {
                    if (Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) {
                        return false;
                    }
                    if (!compField.getDefault().checkEquality(timestamp, otherValue)) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Identifier(org.eclipse.titan.designer.AST.Identifier) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) IType(org.eclipse.titan.designer.AST.IType)

Example 8 with Set_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Set_Value in project titan.EclipsePlug-ins by eclipse.

the class TTCN3_Set_Type method checkThisValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
    if (getIsErroneous(timestamp)) {
        return false;
    }
    boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
    IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
    if (last == null || last.getIsErroneous(timestamp)) {
        return selfReference;
    }
    // already handled ones
    switch(value.getValuetype()) {
        case OMIT_VALUE:
        case REFERENCED_VALUE:
            return selfReference;
        case UNDEFINED_LOWERIDENTIFIER_VALUE:
            if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
                return selfReference;
            }
            break;
        default:
            break;
    }
    switch(last.getValuetype()) {
        case SEQUENCE_VALUE:
            last = last.setValuetype(timestamp, Value_type.SET_VALUE);
            if (last.isAsn()) {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            } else {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            }
            break;
        case SEQUENCEOF_VALUE:
            if (((SequenceOf_Value) last).isIndexed()) {
                value.getLocation().reportSemanticError(MessageFormat.format("Indexed assignment notation cannot be used for set type `{0}''", getFullName()));
                value.setIsErroneous(true);
            } else {
                final SequenceOf_Value tempValue = (SequenceOf_Value) last;
                if (tempValue.getNofComponents() == 0) {
                    if (compFieldMap != null && compFieldMap.getComponentFieldMap(timestamp).isEmpty()) {
                        last = last.setValuetype(timestamp, Value_type.SET_VALUE);
                    } else {
                        value.getLocation().reportSemanticError(MessageFormat.format(NONEMPTYEXPECTED, getFullName()));
                        value.setIsErroneous(true);
                    }
                } else {
                    value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? VALUELISTNOTATIONERRORASN1 : VALUELISTNOTATIONERRORTTCN3, getFullName()));
                    value.setIsErroneous(true);
                }
            }
            break;
        case SET_VALUE:
            if (last.isAsn()) {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            } else {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            }
            break;
        case UNDEFINED_BLOCK:
            last = last.setValuetype(timestamp, Value_type.SET_VALUE);
            selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            break;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? SETVALUEXPECTEDASN1 : SETVALUEXPECTEDTTCN3, getFullName()));
            value.setIsErroneous(true);
    }
    if (valueCheckingOptions.sub_check) {
        // there is no parent type to check
        if (subType != null) {
            subType.checkThisValue(timestamp, last);
        }
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) Set_Value(org.eclipse.titan.designer.AST.TTCN3.values.Set_Value)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)7 IType (org.eclipse.titan.designer.AST.IType)4 Identifier (org.eclipse.titan.designer.AST.Identifier)3 SequenceOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)3 Set_Value (org.eclipse.titan.designer.AST.TTCN3.values.Set_Value)3 HashMap (java.util.HashMap)2 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)2 NamedValue (org.eclipse.titan.designer.AST.TTCN3.values.NamedValue)2 Omit_Value (org.eclipse.titan.designer.AST.TTCN3.values.Omit_Value)2 Type (org.eclipse.titan.designer.AST.Type)2 SyntacticErrorStorage (org.eclipse.titan.common.parsers.SyntacticErrorStorage)1 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)1 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)1 Assignment (org.eclipse.titan.designer.AST.Assignment)1 Assignment_type (org.eclipse.titan.designer.AST.Assignment.Assignment_type)1 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)1 ISubReference (org.eclipse.titan.designer.AST.ISubReference)1 Reference (org.eclipse.titan.designer.AST.Reference)1 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)1 Def_Timer (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer)1