Search in sources :

Example 6 with Type

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

the class Def_Extfunction method checkPrototype.

/**
 * Checks the prototype attribute set for this external function
 * definition.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 */
private void checkPrototype(final CompilationTimeStamp timestamp) {
    if (EncodingPrototype_type.NONE.equals(prototype)) {
        return;
    }
    // checking formal parameter list
    if (EncodingPrototype_type.CONVERT.equals(prototype)) {
        if (formalParList.getNofParameters() == 1) {
            final FormalParameter parameter = formalParList.getParameterByIndex(0);
            switch(parameter.getRealAssignmentType()) {
                case A_PAR_VAL:
                case A_PAR_VAL_IN:
                    inputType = parameter.getType(timestamp);
                    break;
                default:
                    {
                        final String message = MessageFormat.format("The parameter must be an `in'' value parameter for attribute `prototype({0})'' instead of {1}", prototype.getName(), parameter.getAssignmentName());
                        parameter.getLocation().reportSemanticError(message);
                        break;
                    }
            }
        } else {
            final String message = MessageFormat.format("The external function must have one parameter instead of {0} for attribute `prototype({1})''", formalParList.getNofParameters(), prototype.getName());
            formalParList.getLocation().reportSemanticError(message);
        }
    } else if (formalParList.getNofParameters() == 2) {
        final FormalParameter firstParameter = formalParList.getParameterByIndex(0);
        if (EncodingPrototype_type.SLIDING.equals(prototype)) {
            if (Assignment_type.A_PAR_VAL_INOUT.semanticallyEquals(firstParameter.getRealAssignmentType())) {
                final Type firstParameterType = firstParameter.getType(timestamp);
                final IType last = firstParameterType.getTypeRefdLast(timestamp);
                if (last.getIsErroneous(timestamp)) {
                    inputType = firstParameterType;
                } else {
                    switch(last.getTypetypeTtcn3()) {
                        case TYPE_OCTETSTRING:
                        case TYPE_CHARSTRING:
                        case TYPE_BITSTRING:
                            inputType = firstParameterType;
                            break;
                        default:
                            {
                                final String message = MessageFormat.format("The type of the first parameter must be `octetstring'' or `charstring'' for attribute `prototype({0})''", prototype.getName());
                                firstParameter.getLocation().reportSemanticError(message);
                                break;
                            }
                    }
                }
            } else {
                firstParameter.getLocation().reportSemanticError(MessageFormat.format("The first parameter must be an `inout'' value parameter for attribute `prototype({0})'' instead of {1}", prototype.getName(), firstParameter.getAssignmentName()));
            }
        } else {
            if (Assignment_type.A_PAR_VAL_IN.semanticallyEquals(firstParameter.getRealAssignmentType())) {
                inputType = firstParameter.getType(timestamp);
            } else {
                firstParameter.getLocation().reportSemanticError(MessageFormat.format("The first parameter must be an `in'' value parameter for attribute `prototype({0})'' instead of {1}", prototype.getName(), firstParameter.getAssignmentName()));
            }
        }
        final FormalParameter secondParameter = formalParList.getParameterByIndex(1);
        if (Assignment_type.A_PAR_VAL_OUT.semanticallyEquals(secondParameter.getRealAssignmentType())) {
            outputType = secondParameter.getType(timestamp);
        } else {
            secondParameter.getLocation().reportSemanticError(MessageFormat.format("The second parameter must be an `out'' value parameter for attribute `prototype({0})'' instead of {1}", prototype.getName(), secondParameter.getAssignmentName()));
        }
    } else {
        formalParList.getLocation().reportSemanticError(MessageFormat.format("The function must have two parameters for attribute `prototype({0})'' instead of {1}", prototype.getName(), formalParList.getNofParameters()));
    }
    // checking the return type
    if (EncodingPrototype_type.FAST.equals(prototype)) {
        if (returnType != null) {
            returnType.getLocation().reportSemanticError(MessageFormat.format("The external function cannot have return type fo attribute `prototype({0})''", prototype.getName()));
        }
    } else {
        if (returnType == null) {
            location.reportSemanticError(MessageFormat.format("The external function must have a return type for attribute `prototype({0})''", prototype.getName()));
        } else {
            if (Assignment_type.A_FUNCTION_RTEMP.semanticallyEquals(assignmentType)) {
                returnType.getLocation().reportSemanticError(MessageFormat.format("The external function must return a value instead of a template for attribute `prototype({0})''", prototype.getName()));
            }
            if (EncodingPrototype_type.CONVERT.equals(prototype)) {
                outputType = returnType;
            } else {
                final IType last = returnType.getTypeRefdLast(timestamp);
                if (!last.getIsErroneous(timestamp) && !Type_type.TYPE_INTEGER.equals(last.getTypetypeTtcn3())) {
                    returnType.getLocation().reportSemanticError(MessageFormat.format("The return type of the function must be `integer'' instead of `{0}'' for attribute `prototype({1})''", returnType.getTypename(), prototype.getName()));
                }
            }
        }
    }
}
Also used : IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) PrintingType(org.eclipse.titan.designer.AST.TTCN3.attributes.PrintingType) Attribute_Type(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) IType(org.eclipse.titan.designer.AST.IType)

Example 7 with Type

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

the class Getreply_Statement method checkGetreply.

public static void checkGetreply(final CompilationTimeStamp timestamp, final Statement source, final String statementName, final Reference portReference, final TemplateInstance parameter, final TemplateInstance valueMatch, final TemplateInstance fromClause, final Reference redirectValue, final Parameter_Redirect redirectParameter, final Reference redirectSender) {
    final Port_Type portType = Port_Utility.checkPortReference(timestamp, source, portReference);
    if (parameter == null) {
        if (portType != null) {
            final PortTypeBody body = portType.getPortBody();
            if (!body.getreplyAllowed(timestamp)) {
                if (OperationModes.OP_Message.equals(body.getOperationMode())) {
                    portReference.getLocation().reportSemanticError(MessageFormat.format(GETREPLYONMESSAGEPORT, statementName, portType.getTypename()));
                } else {
                    portReference.getLocation().reportSemanticError(MessageFormat.format(GETREPLYNOTSUPPORTEDONPORT, portType.getTypename()));
                }
            }
        }
        if (redirectValue != null) {
            redirectValue.getLocation().reportSemanticError(VALUEREDIRECTWITHOUTSIGNATURE);
            Port_Utility.checkValueRedirect(timestamp, redirectValue, null);
        }
        if (redirectParameter != null) {
            // true?
            redirectParameter.check(timestamp, null, true);
            redirectParameter.getLocation().reportSemanticError(PARAMETERREDIRECTWITHOUTSIGNATURE);
        }
    } else {
        IType signature = null;
        boolean signatureDetermined = false;
        if (portType != null) {
            final PortTypeBody body = portType.getPortBody();
            if (OperationModes.OP_Message.equals(body.getOperationMode())) {
                portReference.getLocation().reportSemanticError(MessageFormat.format(GETREPLYONMESSAGEPORT, statementName, portType.getTypename()));
            } else if (body.getreplyAllowed(timestamp)) {
                final TypeSet outSignatures = body.getOutSignatures();
                if (outSignatures.getNofTypes() == 1) {
                    signature = outSignatures.getTypeByIndex(0);
                } else {
                    signature = Port_Utility.getOutgoingType(timestamp, parameter);
                    if (signature == null) {
                        parameter.getLocation().reportSemanticError(UNKNOWNSIGNATURETYPE);
                    } else {
                        if (!outSignatures.hasType(timestamp, signature)) {
                            parameter.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREMISSING, signature.getTypename(), portType.getTypename()));
                        }
                    }
                }
                signatureDetermined = true;
            } else {
                portReference.getLocation().reportSemanticError(MessageFormat.format(GETREPLYNOTSUPPORTEDONPORT, portType.getTypename()));
            }
        } else if (portReference == null) {
            // the statement refers to any port or there was
            // a syntax error
            parameter.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHPARAMETER, statementName));
            if (valueMatch != null) {
                valueMatch.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHVALUEMATCH, statementName));
            }
            if (redirectValue != null) {
                redirectValue.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHVALUEREDIRECTION, statementName));
            }
            if (redirectParameter != null) {
                redirectParameter.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHPARAMETERREDIRECTION, statementName));
            }
        }
        if (!signatureDetermined) {
            signature = Port_Utility.getOutgoingType(timestamp, parameter);
        }
        if (signature != null) {
            parameter.check(timestamp, signature);
            signature = signature.getTypeRefdLast(timestamp);
            Type returnType = null;
            switch(signature.getTypetype()) {
                case TYPE_SIGNATURE:
                    {
                        final Signature_Type signatureType = (Signature_Type) signature;
                        if (signatureType.isNonblocking()) {
                            final String message = MessageFormat.format(NONBLOCKINGSIGNATURE, statementName, signatureType.getTypename());
                            source.getLocation().reportSemanticError(message);
                        } else {
                            returnType = signatureType.getSignatureReturnType();
                        }
                        if (redirectParameter != null) {
                            redirectParameter.check(timestamp, signatureType, true);
                        }
                        if (returnType == null) {
                            if (valueMatch != null) {
                                valueMatch.getLocation().reportSemanticError(MessageFormat.format(VALUEMATCHWITHOUTRETURNTYPE, signature.getTypename()));
                            }
                            if (redirectValue != null) {
                                final String message = MessageFormat.format(VALUEREDIRECTWITHOUTRETURNTYPE, signature.getTypename());
                                redirectValue.getLocation().reportSemanticError(message);
                            }
                        }
                        break;
                    }
                default:
                    parameter.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREEXPECTED, signature.getTypename()));
                    if (redirectParameter != null) {
                        redirectParameter.checkErroneous(timestamp);
                    }
                    break;
            }
            if (valueMatch != null) {
                if (returnType != null) {
                    valueMatch.check(timestamp, returnType);
                }
            }
            Port_Utility.checkValueRedirect(timestamp, redirectValue, returnType);
        }
    }
    Port_Utility.checkFromClause(timestamp, source, portType, fromClause, redirectSender);
}
Also used : Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) Port_Type(org.eclipse.titan.designer.AST.TTCN3.types.Port_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) TypeSet(org.eclipse.titan.designer.AST.TTCN3.types.TypeSet) Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) Port_Type(org.eclipse.titan.designer.AST.TTCN3.types.Port_Type) PortTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody) IType(org.eclipse.titan.designer.AST.IType)

Example 8 with Type

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

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

the class ASN1_Sequence_Type method checkThisNamedTemplateList.

private boolean checkThisNamedTemplateList(final CompilationTimeStamp timestamp, final Named_Template_List templateList, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
    templateList.removeGeneratedValues();
    boolean selfReference = false;
    final Map<String, NamedTemplate> componentMap = new HashMap<String, NamedTemplate>();
    final int nofTypeComponents = getNofComponents(timestamp);
    final int nofTemplateComponents = templateList.getNofTemplates();
    boolean inSync = true;
    CompField lastComponentField = null;
    int nextIndex = 0;
    for (int i = 0; i < nofTemplateComponents; i++) {
        final NamedTemplate namedTemplate = templateList.getTemplateByIndex(i);
        final Identifier identifier = namedTemplate.getName();
        final String templateName = identifier.getName();
        if (hasComponentWithName(identifier)) {
            if (componentMap.containsKey(templateName)) {
                namedTemplate.getLocation().reportSemanticError(MessageFormat.format(DUPLICATETEMPLATEFIELDFIRST, identifier.getDisplayName()));
                final Location tempLocation = componentMap.get(templateName).getLocation();
                tempLocation.reportSemanticError(MessageFormat.format(DUPLICATETEMPLATEFIELDAGAIN, identifier.getDisplayName()));
                inSync = false;
            } else {
                componentMap.put(templateName, namedTemplate);
            }
            final CompField componentField = getComponentByName(identifier);
            if (inSync) {
                if (isModified) {
                    boolean found = false;
                    for (int j = nextIndex; j < nofTypeComponents && !found; j++) {
                        final CompField componentField2 = getComponentByIndex(j);
                        if (templateName.equals(componentField2.getIdentifier().getName())) {
                            lastComponentField = componentField2;
                            nextIndex = j + 1;
                            found = true;
                        }
                    }
                    if (!found && lastComponentField != null) {
                        namedTemplate.getLocation().reportSemanticError(MessageFormat.format(INCORRECTTEMPLATEFIELDORDER, identifier.getDisplayName(), lastComponentField.getIdentifier().getDisplayName(), getFullName()));
                        inSync = false;
                    }
                } else if (strictConstantCheckingSeverity) {
                    final CompField componentField2 = getComponentByIndex(i);
                    if (componentField2 != componentField) {
                        if (!componentField2.isOptional() || (componentField2.isOptional() && !implicitOmit)) {
                            namedTemplate.getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDTEMPLATEFIELD, identifier.getDisplayName(), componentField2.getIdentifier().getDisplayName()));
                            inSync = false;
                        }
                    }
                }
            }
            final Type type = componentField.getType();
            if (type != null && !type.getIsErroneous(timestamp)) {
                ITTCN3Template componentTemplate = namedTemplate.getTemplate();
                componentTemplate.setMyGovernor(type);
                componentTemplate = type.checkThisTemplateRef(timestamp, componentTemplate);
                boolean isOptional = componentField.isOptional();
                if (!isOptional && componentField.hasDefault() && defaultAsOptional) {
                    isOptional = true;
                }
                selfReference |= componentTemplate.checkThisTemplateGeneric(timestamp, type, isModified, isOptional, isOptional, true, implicitOmit, lhs);
            }
        } else {
            namedTemplate.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTTEMPLATEFIELDREFERENCE, identifier.getDisplayName(), getTypename()));
            inSync = false;
        }
    }
    if (!isModified && strictConstantCheckingSeverity) {
        // check missing fields
        for (int i = 0; i < nofTypeComponents; i++) {
            final Identifier identifier = getComponentIdentifierByIndex(i);
            if (!componentMap.containsKey(identifier.getName())) {
                if (getComponentByIndex(i).isOptional() && implicitOmit) {
                    templateList.addNamedValue(new NamedTemplate(new Identifier(Identifier_type.ID_TTCN, identifier.getDisplayName()), new OmitValue_Template(), false));
                } else {
                    templateList.getLocation().reportSemanticError(MessageFormat.format(MISSINGTEMPLATEFIELD, identifier.getDisplayName(), getTypename()));
                }
            }
        }
    }
    return selfReference;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) 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) HashMap(java.util.HashMap) NamedTemplate(org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) OmitValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.OmitValue_Template) Location(org.eclipse.titan.designer.AST.Location)

Example 10 with Type

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

the class ASN1_Set_Type method checkThisValueSet.

/**
 * Checks the Set_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 set type.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param value
 *                the value to be checked
 * @param expectedValue
 *                the kind of value expected here.
 * @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 checkThisValueSet(final CompilationTimeStamp timestamp, final Set_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>();
    value.removeGeneratedValues();
    final boolean isAsn = value.isAsn();
    final int nofValueComponents = value.getNofComponents();
    for (int i = 0; i < nofValueComponents; i++) {
        final NamedValue namedValue = value.getSequenceValueByIndex(i);
        final Identifier valueId = namedValue.getName();
        if (!hasComponentWithName(valueId)) {
            namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? NONEXISTENTFIELDASN1 : NONEXISTENTFIELDTTCN3, namedValue.getName().getDisplayName(), getTypename()));
        } else {
            if (componentMap.containsKey(valueId.getName())) {
                namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? DUPLICATEFIELDAGAINASN1 : DUPLICATEFIELDAGAINTTCN3, valueId.getDisplayName()));
                componentMap.get(valueId.getName()).getLocation().reportSingularSemanticError(MessageFormat.format(isAsn ? DUPLICATEFIELDFIRSTASN1 : DUPLICATEFIELDFIRSTTTCN3, valueId.getDisplayName()));
            } else {
                componentMap.put(valueId.getName(), namedValue);
            }
            final CompField componentField = getComponentByName(valueId);
            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) {
        final int nofTypeComponents = getNofComponents(timestamp);
        CompField field;
        for (int i = 0; i < nofTypeComponents; i++) {
            field = getComponentByIndex(i);
            final Identifier id = field.getIdentifier();
            if (!componentMap.containsKey(id.getName())) {
                if (field.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 : IASN1Type(org.eclipse.titan.designer.AST.ASN1.IASN1Type) TTCN3_Set_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Type) SetOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SetOf_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) HashMap(java.util.HashMap) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) NamedValue(org.eclipse.titan.designer.AST.TTCN3.values.NamedValue) Omit_Value(org.eclipse.titan.designer.AST.TTCN3.values.Omit_Value)

Aggregations

Type (org.eclipse.titan.designer.AST.Type)69 IType (org.eclipse.titan.designer.AST.IType)56 Identifier (org.eclipse.titan.designer.AST.Identifier)35 IValue (org.eclipse.titan.designer.AST.IValue)13 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)13 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)12 HashMap (java.util.HashMap)11 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)11 ISubReference (org.eclipse.titan.designer.AST.ISubReference)10 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)9 NamedTemplate (org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate)9 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)8 Reference (org.eclipse.titan.designer.AST.Reference)8 SubType (org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType)8 Attribute_Type (org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type)7 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)6 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)6 TTCN3_Choice_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type)6 TTCN3_Sequence_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type)6 NamedValue (org.eclipse.titan.designer.AST.TTCN3.values.NamedValue)6