Search in sources :

Example 96 with Expected_Value_type

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

the class ASN1_Set_Type method getFieldType.

// This is the same as in ASN1_Sequence_Type
@Override
public /**
 * {@inheritDoc}
 */
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
        return this;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDSUBREFERENCE, getTypename()));
            return null;
        case fieldSubReference:
            final Identifier id = subreference.getId();
            final CompField compField = components.getCompByName(id);
            if (compField == null) {
                subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.NONEXISTENTSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
                return null;
            }
            if (interruptIfOptional && compField.isOptional()) {
                return null;
            }
            final Expected_Value_type internalExpectation = (expectedIndex == Expected_Value_type.EXPECTED_TEMPLATE) ? Expected_Value_type.EXPECTED_DYNAMIC_VALUE : expectedIndex;
            return compField.getType().getFieldType(timestamp, reference, actualSubReference + 1, internalExpectation, refChain, interruptIfOptional);
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Expected_Value_type(org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)

Example 97 with Expected_Value_type

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

the class BMPString_Type method getFieldType.

@Override
public /**
 * {@inheritDoc}
 */
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
        return this;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            if (subreferences.size() > actualSubReference + 1) {
                subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
                return null;
            } else if (subreferences.size() == actualSubReference + 1) {
                reference.setStringElementReferencing();
            }
            final Value indexValue = ((ArraySubReference) subreference).getValue();
            checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
            return this;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Example 98 with Expected_Value_type

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

the class Open_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();
    final CompField field = getComponentByName(name);
    if (field == null) {
        if (value.isAsn()) {
            value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTCHOICE, name.getDisplayName(), getFullName()));
        } else {
            value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTUNION, name.getDisplayName(), getFullName()));
        }
    } else {
        IValue alternativeValue = value.getValue();
        if (null == alternativeValue) {
            return selfReference;
        }
        final Type alternativeType = field.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 : IASN1Type(org.eclipse.titan.designer.AST.ASN1.IASN1Type) Type(org.eclipse.titan.designer.AST.Type) ASN1Type(org.eclipse.titan.designer.AST.ASN1.ASN1Type) 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)

Example 99 with Expected_Value_type

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

the class UTF8String_Type method getFieldType.

@Override
public /**
 * {@inheritDoc}
 */
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
        return this;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            if (subreferences.size() > actualSubReference + 1) {
                subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
                return null;
            } else if (subreferences.size() == actualSubReference + 1) {
                reference.setStringElementReferencing();
            }
            final Value indexValue = ((ArraySubReference) subreference).getValue();
            checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
            return this;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Example 100 with Expected_Value_type

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

the class ActivateDereferedExpression 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.
 */
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    value.setLoweridToReference(timestamp);
    IType type = value.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (type != null) {
        type = type.getTypeRefdLast(timestamp);
    }
    if (type == null || type.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return;
    }
    if (!Type_type.TYPE_ALTSTEP.equals(type.getTypetype())) {
        value.getLocation().reportSemanticError(MessageFormat.format(ALTSTEPEXPECTED, type.getTypename()));
        setIsErroneous(true);
        return;
    }
    actualParameters = new ActualParameterList();
    final FormalParameterList formalParameterList = ((Altstep_Type) type).getFormalParameters();
    if (formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameters)) {
        setIsErroneous(true);
        return;
    }
    actualParameters.setFullNameParent(this);
    actualParameters.setMyScope(getMyScope());
    if (!formalParameterList.checkActivateArgument(timestamp, actualParameters, createStringRepresentation())) {
        setIsErroneous(true);
    }
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Altstep_Type(org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)149 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)54 IType (org.eclipse.titan.designer.AST.IType)47 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)45 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)39 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)37 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)31 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)24 ISubReference (org.eclipse.titan.designer.AST.ISubReference)21 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)21 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)20 Identifier (org.eclipse.titan.designer.AST.Identifier)17 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)17 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)14 Type (org.eclipse.titan.designer.AST.Type)14 Assignment (org.eclipse.titan.designer.AST.Assignment)13 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)13 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)12 CharstringExtractor (org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)11 Value (org.eclipse.titan.designer.AST.Value)11