Search in sources :

Example 6 with Choice_Value

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

the class Open_Type method checkThisValue.

// FIXME add tests
@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 (null == last || 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;
    }
    this.check(timestamp);
    switch(last.getValuetype()) {
        case SEQUENCE_VALUE:
            if (value.isAsn()) {
                value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
                value.setIsErroneous(true);
            } else {
                last = last.setValuetype(timestamp, Value_type.CHOICE_VALUE);
                if (!last.getIsErroneous(timestamp)) {
                    selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.str_elem);
                }
            }
            break;
        case CHOICE_VALUE:
            selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.str_elem);
            break;
        default:
            if (value.isAsn()) {
                value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
            } else {
                value.getLocation().reportSemanticError(MessageFormat.format(UNIONEXPECTED, getFullName()));
            }
            value.setIsErroneous(true);
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Choice_Value(org.eclipse.titan.designer.AST.TTCN3.values.Choice_Value)

Example 7 with Choice_Value

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

the class ASN1_Choice_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:
            if (value.isAsn()) {
                value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
                value.setIsErroneous(true);
            } else {
                last = last.setValuetype(timestamp, Value_type.CHOICE_VALUE);
                if (!last.getIsErroneous(timestamp)) {
                    selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed);
                }
            }
            break;
        case CHOICE_VALUE:
            selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed);
            break;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            if (value.isAsn()) {
                value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
                value.setIsErroneous(true);
            } else {
                value.getLocation().reportSemanticError(MessageFormat.format(UNIONEXPECTED, getFullName()));
                value.setIsErroneous(true);
            }
            value.setIsErroneous(true);
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Choice_Value(org.eclipse.titan.designer.AST.TTCN3.values.Choice_Value)

Example 8 with Choice_Value

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

the class TTCN3_Choice_Type method checkThisValueChoice.

private boolean checkThisValueChoice(final CompilationTimeStamp timestamp, final Choice_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean strElem) {
    boolean selfReference = false;
    final Identifier name = value.getName();
    if (!hasComponentWithName(name.getName())) {
        if (value.isAsn()) {
            value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTCHOICE, name.getDisplayName(), getFullName()));
            value.setIsErroneous(true);
        } else {
            value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTUNION, name.getDisplayName(), getFullName()));
            value.setIsErroneous(true);
        }
        return selfReference;
    }
    IValue alternativeValue = value.getValue();
    if (alternativeValue == null) {
        return selfReference;
    }
    final Type alternativeType = getComponentByName(name.getName()).getType();
    alternativeValue.setMyGovernor(alternativeType);
    alternativeValue = alternativeType.checkThisValueRef(timestamp, alternativeValue);
    selfReference = alternativeType.checkThisValue(timestamp, alternativeValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, false, true, false, strElem));
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : Type(org.eclipse.titan.designer.AST.Type) SubType(org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType) ASN1_Choice_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) IValue(org.eclipse.titan.designer.AST.IValue)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)8 IType (org.eclipse.titan.designer.AST.IType)3 Identifier (org.eclipse.titan.designer.AST.Identifier)3 Choice_Value (org.eclipse.titan.designer.AST.TTCN3.values.Choice_Value)3 Type (org.eclipse.titan.designer.AST.Type)3 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)2 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)2 ASN1Type (org.eclipse.titan.designer.AST.ASN1.ASN1Type)1 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)1 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)1 TTCN3_Choice_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type)1 SubType (org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType)1 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)1 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)1 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)1 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)1 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)1 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)1 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)1 Verdict_Value (org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value)1