Search in sources :

Example 1 with Sequence_Value

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

the class SizeOfExpression method checkExpressionOperands.

/**
 * Checks the parameters of the expression and if they are valid in
 * their position in the expression or not.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param expectedValue
 *                the kind of value expected.
 * @param referenceChain
 *                a reference chain to detect cyclic references.
 *
 * @return the size of the expression, or -1 in case of error
 */
private long checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    Expected_Value_type internalExpectedValue;
    if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
        internalExpectedValue = Expected_Value_type.EXPECTED_TEMPLATE;
    } else {
        internalExpectedValue = expectedValue;
    }
    ITTCN3Template template = templateInstance.getTemplateBody();
    template.setLoweridToReference(timestamp);
    template = template.getTemplateReferencedLast(timestamp, referenceChain);
    if (template.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return -1;
    }
    // Timer and port arrays are handled separately
    if (template.getTemplatetype() == Template_type.SPECIFIC_VALUE) {
        final SpecificValue_Template specValTempl = (SpecificValue_Template) template;
        IValue val = specValTempl.getSpecificValue();
        val.setMyGovernor(specValTempl.getMyGovernor());
        if (val.getValuetype() == Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE) {
            val = val.setLoweridToReference(timestamp);
        }
        if (val != null && val.getValuetype() == Value_type.REFERENCED_VALUE) {
            final Referenced_Value referencedValue = (Referenced_Value) val;
            final Reference ref = referencedValue.getReference();
            final Assignment temporalAss = ref.getRefdAssignment(timestamp, true);
            if (temporalAss != null) {
                final Assignment_type asstype = temporalAss.getAssignmentType();
                ArrayDimensions dimensions;
                if (asstype == Assignment_type.A_PORT) {
                    dimensions = ((Def_Port) temporalAss).getDimensions();
                    return checkTimerPort(timestamp, ref, dimensions, temporalAss);
                } else if (asstype == Assignment_type.A_TIMER) {
                    dimensions = ((Def_Timer) temporalAss).getDimensions();
                    return checkTimerPort(timestamp, ref, dimensions, temporalAss);
                }
            }
        }
    }
    IType governor = templateInstance.getExpressionGovernor(timestamp, internalExpectedValue);
    if (governor == null) {
        final ITTCN3Template templ = template.setLoweridToReference(timestamp);
        governor = templ.getExpressionGovernor(timestamp, internalExpectedValue);
    }
    if (governor == null) {
        if (!template.getIsErroneous(timestamp)) {
            templateInstance.getLocation().reportSemanticError("Cannot determine the type of the argument in the `sizeof' operation. If type is known, use valueof(<type>: ...) as argument.");
        }
        setIsErroneous(true);
        return -1;
    }
    IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance, governor, referenceChain, internalExpectedValue);
    if (isErroneous) {
        return -1;
    }
    IType type = governor.getTypeRefdLast(timestamp);
    switch(type.getTypetype()) {
        case TYPE_SEQUENCE_OF:
        case TYPE_SET_OF:
        case TYPE_TTCN3_SEQUENCE:
        case TYPE_TTCN3_SET:
        case TYPE_ASN1_SEQUENCE:
        case TYPE_ASN1_SET:
        case TYPE_ARRAY:
        case TYPE_OBJECTID:
        case TYPE_ROID:
        case TYPE_UNDEFINED:
            break;
        default:
            templateInstance.getLocation().reportSemanticError("Reference to a value or template of type record, record of, set, set of, objid or array was expected");
            setIsErroneous(true);
            return -1;
    }
    IValue value = null;
    Reference reference = null;
    Assignment assignment = null;
    List<ISubReference> subreferences = null;
    switch(template.getTemplatetype()) {
        case INDEXED_TEMPLATE_LIST:
            return -1;
        case TEMPLATE_REFD:
            reference = ((Referenced_Template) template).getReference();
            assignment = reference.getRefdAssignment(timestamp, false);
            subreferences = reference.getSubreferences();
            break;
        case TEMPLATE_LIST:
        case NAMED_TEMPLATE_LIST:
        case SUBSET_MATCH:
        case SUPERSET_MATCH:
            // compute later
            break;
        case SPECIFIC_VALUE:
            value = ((SpecificValue_Template) template).getSpecificValue().getValueRefdLast(timestamp, referenceChain);
            if (value != null) {
                switch(value.getValuetype()) {
                    case SEQUENCEOF_VALUE:
                    case SETOF_VALUE:
                    case ARRAY_VALUE:
                    case RELATIVEOBJECTIDENTIFIER_VALUE:
                    case OBJECTID_VALUE:
                    case SEQUENCE_VALUE:
                    case SET_VALUE:
                        break;
                    case REFERENCED_VALUE:
                        {
                            reference = ((Referenced_Value) value).getReference();
                            assignment = reference.getRefdAssignment(timestamp, false);
                            subreferences = reference.getSubreferences();
                            break;
                        }
                    default:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("`sizeof'' operation is not applicable to `{0}''", value.createStringRepresentation()));
                        setIsErroneous(true);
                        return -1;
                }
            }
            break;
        default:
            templateInstance.getLocation().reportSemanticError(MessageFormat.format("`sizeof'' operation is not applicable to {0}", template.getTemplateTypeName()));
            setIsErroneous(true);
            return -1;
    }
    if (assignment != null) {
        if (assignment.getIsErroneous()) {
            setIsErroneous(true);
            return -1;
        }
        switch(assignment.getAssignmentType()) {
            case A_CONST:
                value = ((Def_Const) assignment).getValue();
                break;
            case A_EXT_CONST:
            case A_MODULEPAR:
            case A_MODULEPAR_TEMPLATE:
                if (Expected_Value_type.EXPECTED_CONSTANT.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to an (evaluable) constant value was expected instead of {0}", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_VAR:
            case A_PAR_VAL:
            case A_PAR_VAL_IN:
            case A_PAR_VAL_OUT:
            case A_PAR_VAL_INOUT:
                switch(internalExpectedValue) {
                    case EXPECTED_CONSTANT:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a constant value was expected instead of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    case EXPECTED_STATIC_VALUE:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a static value was expected instead of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    default:
                        break;
                }
                break;
            case A_TEMPLATE:
                template = ((Def_Template) assignment).getTemplate(timestamp);
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a value was expected instead of {0}", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_VAR_TEMPLATE:
            case A_PAR_TEMP_IN:
            case A_PAR_TEMP_OUT:
            case A_PAR_TEMP_INOUT:
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a value was expected instead of {0}", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_FUNCTION_RVAL:
            case A_EXT_FUNCTION_RVAL:
                switch(internalExpectedValue) {
                    case EXPECTED_CONSTANT:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a constant value was expected instead of the return value of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    case EXPECTED_STATIC_VALUE:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a static value was expected instead of the return value of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    default:
                        break;
                }
                break;
            case A_FUNCTION_RTEMP:
            case A_EXT_FUNCTION_RTEMP:
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a value was expected instead of a call of {0}, which returns a template", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_TIMER:
            case A_PORT:
                // were already checked separately.
                break;
            default:
                templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a {0} was expected instead of {1}", Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue) ? "value or template" : "value", assignment.getDescription()));
                setIsErroneous(true);
                return -1;
        }
        type = assignment.getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
        if (type == null || type.getIsErroneous(timestamp)) {
            setIsErroneous(true);
            return -1;
        }
        type = type.getTypeRefdLast(timestamp);
        switch(type.getTypetype()) {
            case TYPE_SEQUENCE_OF:
            case TYPE_SET_OF:
            case TYPE_TTCN3_SEQUENCE:
            case TYPE_TTCN3_SET:
            case TYPE_ASN1_SEQUENCE:
            case TYPE_ASN1_SET:
            case TYPE_ARRAY:
            case TYPE_OBJECTID:
            case TYPE_ROID:
            case TYPE_UNDEFINED:
                break;
            default:
                templateInstance.getLocation().reportSemanticError("Reference to a value or template of type record, record of, set, set of, objid or array was expected");
                setIsErroneous(true);
                return -1;
        }
    }
    // check for index overflows in subrefs if possible
    if (value != null) {
        switch(value.getValuetype()) {
            case SEQUENCEOF_VALUE:
                if (((SequenceOf_Value) value).isIndexed()) {
                    return -1;
                }
                break;
            case SETOF_VALUE:
                if (((SetOf_Value) value).isIndexed()) {
                    return -1;
                }
                break;
            case ARRAY_VALUE:
                if (((Array_Value) value).isIndexed()) {
                    return -1;
                }
                break;
            default:
                break;
        }
        /* The reference points to a constant.  */
        if (subreferences != null && !reference.hasUnfoldableIndexSubReference(timestamp)) {
            value = value.getReferencedSubValue(timestamp, reference, 1, referenceChain);
            if (value == null) {
                setIsErroneous(true);
                return -1;
            }
            value = value.getValueRefdLast(timestamp, referenceChain);
        } else {
            // stop processing
            value = null;
        }
    } else if (template != null) {
        /* The size of INDEXED_TEMPLATE_LIST nodes is unknown at compile
		         time.  Don't try to evaluate it at compile time.  */
        if (reference != null && reference.hasUnfoldableIndexSubReference(timestamp)) {
            return -1;
        }
        if (reference != null && subreferences != null) {
            template = template.getReferencedSubTemplate(timestamp, reference, referenceChain);
            if (template == null) {
                setIsErroneous(true);
                return -1;
            }
            template = template.getTemplateReferencedLast(timestamp);
        }
    }
    if (template != null) {
        if (template.getIsErroneous(timestamp)) {
            setIsErroneous(true);
            return -1;
        }
        switch(template.getTemplatetype()) {
            case TEMPLATE_REFD:
                template = null;
                break;
            case SPECIFIC_VALUE:
                value = ((SpecificValue_Template) template).getSpecificValue().getValueRefdLast(timestamp, referenceChain);
                template = null;
                break;
            case TEMPLATE_LIST:
            case NAMED_TEMPLATE_LIST:
            case SUBSET_MATCH:
            case SUPERSET_MATCH:
                break;
            default:
                // FIXME this can not happen
                templateInstance.getLocation().reportSemanticError(MessageFormat.format("`sizeof'' operation is not applicable to {0}", template.getTemplateTypeName()));
                setIsErroneous(true);
                return -1;
        }
    }
    if (value != null) {
        switch(value.getValuetype()) {
            case SEQUENCEOF_VALUE:
            case SETOF_VALUE:
            case ARRAY_VALUE:
            case RELATIVEOBJECTIDENTIFIER_VALUE:
            case OBJECTID_VALUE:
            case SEQUENCE_VALUE:
            case SET_VALUE:
                break;
            default:
                value = null;
                return -1;
        }
    }
    /* evaluation */
    if (Type_type.TYPE_ARRAY.equals(type.getTypetype())) {
        return ((Array_Type) type).getDimension().getSize();
    } else if (template != null) {
        return evaluateTemplate(template, timestamp);
    } else if (value != null) {
        return evaluateValue(value);
    } else {
        return -1;
    }
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Assignment_type(org.eclipse.titan.designer.AST.Assignment.Assignment_type) Array_Value(org.eclipse.titan.designer.AST.TTCN3.values.Array_Value) ISubReference(org.eclipse.titan.designer.AST.ISubReference) Reference(org.eclipse.titan.designer.AST.Reference) Def_Timer(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value) SetOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value) IType(org.eclipse.titan.designer.AST.IType) Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) IValue(org.eclipse.titan.designer.AST.IValue) ArrayDimensions(org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimensions) Expected_Value_type(org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)

Example 2 with Sequence_Value

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

the class IsChoosenExpression method evaluateValue.

@Override
public /**
 * {@inheritDoc}
 */
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return lastValue;
    }
    isErroneous = false;
    lastTimeChecked = timestamp;
    lastValue = this;
    if (reference == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp)) {
        return lastValue;
    }
    if (value == null) {
        return lastValue;
    }
    if (isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    IValue last = value.getValueRefdLast(timestamp, referenceChain);
    boolean result;
    switch(last.getValuetype()) {
        case CHOICE_VALUE:
            result = ((Choice_Value) last).fieldIsChosen(identifier);
            break;
        case SEQUENCE_VALUE:
            last = last.setValuetype(timestamp, Value_type.CHOICE_VALUE);
            result = ((Choice_Value) last).fieldIsChosen(identifier);
            break;
        case ANYTYPE_VALUE:
            result = ((Anytype_Value) last).fieldIsChosen(timestamp, identifier);
            break;
        default:
            setIsErroneous(true);
            return last;
    }
    lastValue = new Boolean_Value(result);
    lastValue.copyGeneralProperties(this);
    return lastValue;
}
Also used : Boolean_Value(org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value) IValue(org.eclipse.titan.designer.AST.IValue)

Example 3 with Sequence_Value

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

the class ASN1_Sequence_Type method checkThisValueSeq.

/**
 * Checks the Sequence_Value kind value against this type.
 * <p>
 * Please note, that this function can only be called once we know for
 * sure that the value is of sequence type.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param value
 *                the value to be checked
 * @param expectedValue
 *                the expected kind of the value.
 * @param incompleteAllowed
 *                wheather incomplete value is allowed or not.
 * @param implicitOmit
 *                true if the implicit omit optional attribute was set
 *                for the value, false otherwise
 */
private boolean checkThisValueSeq(final CompilationTimeStamp timestamp, final Sequence_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean implicitOmit, final boolean strElem) {
    boolean selfReference = false;
    final Map<String, NamedValue> componentMap = new HashMap<String, NamedValue>();
    final CompilationTimeStamp valueTimeStamp = value.getLastTimeChecked();
    if (valueTimeStamp == null || valueTimeStamp.isLess(timestamp)) {
        value.removeGeneratedValues();
    }
    final boolean isAsn = value.isAsn();
    boolean inSnyc = true;
    final int nofTypeComponents = getNofComponents(timestamp);
    final int nofValueComponents = value.getNofComponents();
    int nextIndex = 0;
    CompField lastCompField = null;
    int sequenceIndex = 0;
    for (int i = 0; i < nofValueComponents; i++, sequenceIndex++) {
        final NamedValue namedValue = value.getSeqValueByIndex(i);
        final Identifier valueId = namedValue.getName();
        if (!hasComponentWithName(valueId)) {
            namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? NONEXISTENTFIELDERRORASN1 : NONEXISTENTFIELDERRORTTCN3, namedValue.getName().getDisplayName(), getTypename()));
            inSnyc = false;
        } else {
            if (componentMap.containsKey(valueId.getName())) {
                namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? DUBLICATEDFIELDAGAINASN1 : DUBLICATEDFIELDAGAINTTCN3, valueId.getDisplayName()));
                final Location tempLocation = componentMap.get(valueId.getName()).getLocation();
                tempLocation.reportSingularSemanticError(MessageFormat.format(isAsn ? DUPLICATEDFIELDFIRSTASN1 : DUPLICATEDFIELDFIRSTTTCN3, valueId.getDisplayName()));
                inSnyc = false;
            } else {
                componentMap.put(valueId.getName(), namedValue);
            }
            final CompField componentField = getComponentByName(valueId);
            if (inSnyc) {
                if (incompleteAllowed) {
                    boolean found = false;
                    for (int j = nextIndex; j < nofTypeComponents && !found; j++) {
                        final CompField field2 = getComponentByIndex(j);
                        if (valueId.getName().equals(field2.getIdentifier().getName())) {
                            lastCompField = field2;
                            nextIndex = j + 1;
                            found = true;
                        }
                    }
                    if (lastCompField != null && !found) {
                        namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? WRONGFIELDORDERASN1 : WRONGFIELDORDERTTCN3, valueId.getDisplayName(), lastCompField.getIdentifier().getDisplayName()));
                    }
                } else {
                    CompField field2 = getComponentByIndex(sequenceIndex);
                    final CompField field2Original = field2;
                    boolean isOptional = field2.isOptional();
                    if (!isOptional && field2.hasDefault() && defaultAsOptional) {
                        isOptional = true;
                    }
                    while (implicitOmit && sequenceIndex < getNofComponents(timestamp) && componentField != field2 && isOptional) {
                        ++sequenceIndex;
                        field2 = getComponentByIndex(sequenceIndex);
                    }
                    if (sequenceIndex >= getNofComponents(timestamp) || componentField != field2) {
                        namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? UNEXPECTEDFIELDASN1 : UNEXPECTEDFIELDTTCN3, valueId.getDisplayName(), field2Original.getIdentifier().getDisplayName()));
                    }
                }
            }
            final Type type = componentField.getType();
            final IValue componentValue = namedValue.getValue();
            if (componentValue != null) {
                componentValue.setMyGovernor(type);
                final IValue temporalValue = type.checkThisValueRef(timestamp, componentValue);
                boolean isOptional = componentField.isOptional();
                if (!isOptional && componentField.hasDefault() && defaultAsOptional) {
                    isOptional = true;
                }
                selfReference |= type.checkThisValue(timestamp, temporalValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, isOptional, true, implicitOmit, strElem));
            }
        }
    }
    if (!incompleteAllowed || strictConstantCheckingSeverity) {
        for (int i = 0; i < nofTypeComponents; i++) {
            final Identifier id = getComponentByIndex(i).getIdentifier();
            if (!componentMap.containsKey(id.getName())) {
                if (getComponentByIndex(i).isOptional() && implicitOmit) {
                    value.addNamedValue(new NamedValue(new Identifier(Identifier_type.ID_TTCN, id.getDisplayName()), new Omit_Value(), false));
                } else {
                    value.getLocation().reportSemanticError(MessageFormat.format(isAsn ? MISSINGFIELDASN1 : MISSINGFIELDTTCN3, id.getDisplayName()));
                }
            }
        }
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : HashMap(java.util.HashMap) NamedValue(org.eclipse.titan.designer.AST.TTCN3.values.NamedValue) SequenceOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SequenceOf_Type) IASN1Type(org.eclipse.titan.designer.AST.ASN1.IASN1Type) Array_Type(org.eclipse.titan.designer.AST.TTCN3.types.Array_Type) TTCN3_Sequence_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) IValue(org.eclipse.titan.designer.AST.IValue) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) CompilationTimeStamp(org.eclipse.titan.designer.parsers.CompilationTimeStamp) Omit_Value(org.eclipse.titan.designer.AST.TTCN3.values.Omit_Value) Location(org.eclipse.titan.designer.AST.Location)

Example 4 with Sequence_Value

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

the class ASN1_Sequence_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 (last.isAsn()) {
                selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            } else {
                selfReference = checkThisValueSeq(timestamp, (Sequence_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 SEQUENCE type `{0}''", getFullName()));
                value.setIsErroneous(true);
            } else {
                last = last.setValuetype(timestamp, Value_type.SEQUENCE_VALUE);
                if (last.isAsn()) {
                    selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
                } else {
                    selfReference = checkThisValueSeq(timestamp, (Sequence_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.SEQUENCE_VALUE);
            selfReference = checkThisValueSeq(timestamp, (Sequence_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(SEQUANCEEPECTED, getFullName()));
            value.setIsErroneous(true);
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Sequence_Value(org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)

Example 5 with Sequence_Value

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

the class Undefined_Block_Value method parseBlockSequenceValue.

private Sequence_Value parseBlockSequenceValue() {
    if (null == mBlock) {
        return null;
    }
    final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mBlock);
    if (null == parser) {
        return null;
    }
    final Sequence_Value value = parser.pr_special_SequenceValue().value;
    final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
    if (null != errors && !errors.isEmpty()) {
        isErroneous = true;
        for (int i = 0; i < errors.size(); i++) {
            ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
        }
        return null;
    }
    return value;
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage) Sequence_Value(org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)16 Sequence_Value (org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value)6 IType (org.eclipse.titan.designer.AST.IType)5 SequenceOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)5 Identifier (org.eclipse.titan.designer.AST.Identifier)4 NamedValue (org.eclipse.titan.designer.AST.TTCN3.values.NamedValue)4 Type (org.eclipse.titan.designer.AST.Type)4 HashMap (java.util.HashMap)3 Choice_Value (org.eclipse.titan.designer.AST.TTCN3.values.Choice_Value)3 Location (org.eclipse.titan.designer.AST.Location)2 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)2 TTCN3_Sequence_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type)2 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)2 Omit_Value (org.eclipse.titan.designer.AST.TTCN3.values.Omit_Value)2 Set_Value (org.eclipse.titan.designer.AST.TTCN3.values.Set_Value)2 CompilationTimeStamp (org.eclipse.titan.designer.parsers.CompilationTimeStamp)2 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 InsertEdit (org.eclipse.text.edits.InsertEdit)1 SyntacticErrorStorage (org.eclipse.titan.common.parsers.SyntacticErrorStorage)1