Search in sources :

Example 21 with Hexstring_Value

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

the class SubType method checkThisValue.

/**
 * Checks if a given value is valid according to this sub-type.
 *
 * @param timestamp
 *                the time stamp of the actual semantic check cycle.
 * @param value
 *                the value to be checked
 */
public void checkThisValue(final CompilationTimeStamp timestamp, final IValue value) {
    if (getIsErroneous(timestamp) || (subtypeConstraint == null)) {
        return;
    }
    if (value.getIsErroneous(timestamp)) {
        return;
    }
    final IValue last = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
    if (last.getIsErroneous(timestamp)) {
        return;
    }
    boolean isValid = true;
    switch(last.getValuetype()) {
        case INTEGER_VALUE:
            if (subtypeType != SubType_type.ST_INTEGER) {
                ErrorReporter.INTERNAL_ERROR();
                return;
            }
            isValid = subtypeConstraint.isElement(new IntegerLimit(((Integer_Value) last).getValueValue()));
            break;
        case REAL_VALUE:
            if (subtypeType == SubType_type.ST_FLOAT) {
                isValid = subtypeConstraint.isElement(((Real_Value) last).getValue());
                break;
            } else if (subtypeType == SubType_type.ST_INTEGER) {
                final Real_Value real = (Real_Value) last;
                if (real.isNegativeInfinity()) {
                    isValid = subtypeConstraint.isElement(IntegerLimit.MINIMUM);
                    break;
                } else if (real.isPositiveInfinity()) {
                    isValid = subtypeConstraint.isElement(IntegerLimit.MAXIMUM);
                    break;
                }
            }
            ErrorReporter.INTERNAL_ERROR();
            return;
        case BOOLEAN_VALUE:
            if (subtypeType != SubType_type.ST_BOOLEAN) {
                ErrorReporter.INTERNAL_ERROR();
                return;
            }
            isValid = subtypeConstraint.isElement(((Boolean_Value) last).getValue());
            break;
        case VERDICT_VALUE:
            if (subtypeType != SubType_type.ST_VERDICTTYPE) {
                ErrorReporter.INTERNAL_ERROR();
                return;
            }
            isValid = subtypeConstraint.isElement(((Verdict_Value) last).getValue());
            break;
        case BITSTRING_VALUE:
            if (subtypeType != SubType_type.ST_BITSTRING) {
                ErrorReporter.INTERNAL_ERROR();
                return;
            }
            isValid = subtypeConstraint.isElement(((Bitstring_Value) last).getValue());
            break;
        case HEXSTRING_VALUE:
            if (subtypeType != SubType_type.ST_HEXSTRING) {
                ErrorReporter.INTERNAL_ERROR();
                return;
            }
            isValid = subtypeConstraint.isElement(((Hexstring_Value) last).getValue());
            break;
        case OCTETSTRING_VALUE:
            if (subtypeType != SubType_type.ST_OCTETSTRING) {
                ErrorReporter.INTERNAL_ERROR();
                return;
            }
            isValid = subtypeConstraint.isElement(((Octetstring_Value) last).getValue());
            break;
        case CHARSTRING_VALUE:
            switch(subtypeType) {
                case ST_CHARSTRING:
                    isValid = subtypeConstraint.isElement(((Charstring_Value) last).getValue());
                    break;
                case ST_UNIVERSAL_CHARSTRING:
                    isValid = subtypeConstraint.isElement(new UniversalCharstring(((Charstring_Value) last).getValue()));
                    break;
                default:
                    ErrorReporter.INTERNAL_ERROR();
                    return;
            }
            break;
        case UNIVERSALCHARSTRING_VALUE:
            if (subtypeType != SubType_type.ST_UNIVERSAL_CHARSTRING) {
                ErrorReporter.INTERNAL_ERROR();
                return;
            }
            isValid = subtypeConstraint.isElement(((UniversalCharstring_Value) last).getValue());
            break;
        case SEQUENCEOF_VALUE:
        case SETOF_VALUE:
        case OBJECTID_VALUE:
        case ENUMERATED_VALUE:
        case CHOICE_VALUE:
        case SEQUENCE_VALUE:
        case SET_VALUE:
        case FUNCTION_REFERENCE_VALUE:
        case ALTSTEP_REFERENCE_VALUE:
        case TESTCASE_REFERENCE_VALUE:
            if (value.isUnfoldable(timestamp)) {
                return;
            }
            isValid = subtypeConstraint.isElement(last);
            break;
        default:
            return;
    }
    if (!isValid) {
        value.getLocation().reportSemanticError(MessageFormat.format("{0} is not a valid value for type `{1}'' which has subtype {2}", last.createStringRepresentation(), myOwner.getTypename(), subtypeConstraint.toString()));
    }
}
Also used : Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Boolean_Value(org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value) IValue(org.eclipse.titan.designer.AST.IValue) Bitstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Verdict_Value(org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)

Example 22 with Hexstring_Value

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

the class ReplaceExpression 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 (templateInstance1 == null || value2 == null || value3 == null || templateInstance4 == null) {
        setIsErroneous(true);
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp)) {
        return lastValue;
    }
    if (isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    ITTCN3Template temp = templateInstance1.getTemplateBody();
    final IValue value1 = ((SpecificValue_Template) temp).getSpecificValue();
    final IValue v1 = value1.getValueRefdLast(timestamp, referenceChain);
    final IValue v2 = value2.getValueRefdLast(timestamp, referenceChain);
    final IValue v3 = value3.getValueRefdLast(timestamp, referenceChain);
    temp = templateInstance4.getTemplateBody();
    final IValue value4 = ((SpecificValue_Template) temp).getSpecificValue();
    final IValue v4 = value4.getValueRefdLast(timestamp, referenceChain);
    final Value_type vt = v1.getValuetype();
    final int index = ((Integer_Value) v2).intValue();
    final int len = ((Integer_Value) v3).intValue();
    switch(vt) {
        case BITSTRING_VALUE:
            {
                final String v1Str = ((Bitstring_Value) v1).getValue();
                final String v4Str = ((Bitstring_Value) v4).getValue();
                String result = v1Str.substring(0, index);
                result = result.concat(v4Str);
                result = result.concat(v1Str.substring(index + len));
                lastValue = new Bitstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case HEXSTRING_VALUE:
            {
                final String v1Str = ((Hexstring_Value) v1).getValue();
                final String v4Str = ((Hexstring_Value) v4).getValue();
                String result = v1Str.substring(0, index);
                result = result.concat(v4Str);
                result = result.concat(v1Str.substring(index + len));
                lastValue = new Hexstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case OCTETSTRING_VALUE:
            {
                final String v1Str = ((Octetstring_Value) v1).getValue();
                final String v4Str = ((Octetstring_Value) v4).getValue();
                String result = v1Str.substring(0, index * 2);
                result = result.concat(v4Str);
                result = result.concat(v1Str.substring((index + len) * 2));
                lastValue = new Octetstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case CHARSTRING_VALUE:
            {
                final String v1Str = ((Charstring_Value) v1).getValue();
                final String v4Str = ((Charstring_Value) v4).getValue();
                String result = v1Str.substring(0, index);
                result = result.concat(v4Str);
                result = result.concat(v1Str.substring(index + len));
                lastValue = new Charstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case UNIVERSALCHARSTRING_VALUE:
            {
                final UniversalCharstring v1Str = ((UniversalCharstring_Value) v1).getValue();
                final UniversalCharstring v4Str = ((UniversalCharstring_Value) v4).getValue();
                final UniversalCharstring result = v1Str.substring(0, index);
                // This append() is not like concat().
                result.append(v4Str);
                result.append(v1Str.substring(index + len));
                lastValue = new UniversalCharstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        default:
            setIsErroneous(true);
            break;
    }
    return lastValue;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Expected_Value_type(org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type) Bitstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)

Example 23 with Hexstring_Value

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

the class RotateLeftExpression 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) {
    Type_type tempType1 = null;
    Type_type tempType2 = null;
    long valueSize = 0;
    long rotationSize = 0;
    IValue tempValue;
    if (value1 != null) {
        value1.setLoweridToReference(timestamp);
        tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType1) {
            case TYPE_BITSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.BITSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Bitstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_HEXSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.HEXSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Hexstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_OCTETSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.OCTETSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Octetstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_CHARSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.CHARSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Charstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_UCHARSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.UNIVERSALCHARSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((UniversalCharstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_SET_OF:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
                    tempValue = tempValue.setValuetype(timestamp, Value_type.SETOF_VALUE);
                }
                if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((SetOf_Value) tempValue).getNofComponents();
                }
                break;
            case TYPE_SEQUENCE_OF:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((SequenceOf_Value) tempValue).getNofComponents();
                } else if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((SetOf_Value) tempValue).getNofComponents();
                }
                break;
            case TYPE_ARRAY:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
                    tempValue = tempValue.setValuetype(timestamp, Value_type.ARRAY_VALUE);
                }
                if (Value_type.ARRAY_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Array_Value) tempValue).getNofComponents();
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(FIRSTOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
    if (value2 != null) {
        value2.setLoweridToReference(timestamp);
        tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType2) {
            case TYPE_INTEGER:
                tempValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.INTEGER_VALUE.equals(tempValue.getValuetype()) && !getIsErroneous(timestamp)) {
                    if (!((Integer_Value) tempValue).isNative()) {
                        value2.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERSECONDOPERANDERROR, ((Integer_Value) tempValue).getValueValue()));
                        setIsErroneous(true);
                        break;
                    }
                    rotationSize = ((Integer_Value) tempValue).getValue();
                    if (value1 != null && !value1.isUnfoldable(timestamp)) {
                        final String severtiy = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINCORRECTSHIFTROTATESIZE, GeneralConstants.WARNING, null);
                        if (valueSize == 0 || valueSize == 1) {
                            location.reportConfigurableSemanticProblem(severtiy, EFFECTLESSROTATION);
                        } else if (rotationSize < 0) {
                            location.reportConfigurableSemanticProblem(severtiy, NEGATIVEROTATEPROBLEM);
                        } else if (rotationSize == 0) {
                            location.reportConfigurableSemanticProblem(severtiy, ZEROROTATEPROBLEM);
                        } else if (rotationSize > valueSize) {
                            location.reportConfigurableSemanticProblem(severtiy, MessageFormat.format(TOOBIGROTATEPROBLEM, valueSize, rotationSize, rotationSize % valueSize));
                        }
                    }
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(SECONDOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) SetOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)

Example 24 with Hexstring_Value

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

the class RotateRightExpression 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) {
    Type_type tempType1 = null;
    Type_type tempType2 = null;
    long valueSize = 0;
    long rotationSize = 0;
    IValue tempValue;
    if (value1 != null) {
        value1.setLoweridToReference(timestamp);
        tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType1) {
            case TYPE_BITSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.BITSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Bitstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_HEXSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.HEXSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Hexstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_OCTETSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.OCTETSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Octetstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_CHARSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.CHARSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Charstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_UCHARSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.UNIVERSALCHARSTRING_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((UniversalCharstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_SET_OF:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
                    tempValue = tempValue.setValuetype(timestamp, Value_type.SETOF_VALUE);
                }
                if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((SetOf_Value) tempValue).getNofComponents();
                }
                break;
            case TYPE_SEQUENCE_OF:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((SequenceOf_Value) tempValue).getNofComponents();
                } else if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((SetOf_Value) tempValue).getNofComponents();
                }
                break;
            case TYPE_ARRAY:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
                    tempValue = tempValue.setValuetype(timestamp, Value_type.ARRAY_VALUE);
                }
                if (Value_type.ARRAY_VALUE.equals(tempValue.getValuetype())) {
                    valueSize = ((Array_Value) tempValue).getNofComponents();
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(FIRSTOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
    if (value2 != null) {
        value2.setLoweridToReference(timestamp);
        tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType2) {
            case TYPE_INTEGER:
                tempValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.INTEGER_VALUE.equals(tempValue.getValuetype()) && !getIsErroneous(timestamp)) {
                    if (!((Integer_Value) tempValue).isNative()) {
                        value2.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERSECONDOPERANDERROR, ((Integer_Value) tempValue).getValueValue()));
                        setIsErroneous(true);
                        break;
                    }
                    rotationSize = ((Integer_Value) tempValue).getValue();
                    if (value1 != null && !value1.isUnfoldable(timestamp)) {
                        final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINCORRECTSHIFTROTATESIZE, GeneralConstants.WARNING, null);
                        if (valueSize == 0 || valueSize == 1) {
                            location.reportConfigurableSemanticProblem(severity, EFFECTLESSROTATION);
                        } else if (rotationSize < 0) {
                            location.reportConfigurableSemanticProblem(severity, NEGATIVEROTATEPROBLEM);
                        } else if (rotationSize == 0) {
                            location.reportConfigurableSemanticProblem(severity, ZEROROTATEPROBLEM);
                        } else if (rotationSize > valueSize) {
                            location.reportConfigurableSemanticProblem(severity, MessageFormat.format(TOOBIGROTATEPROBLEM, valueSize, rotationSize, rotationSize % valueSize));
                        }
                    }
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(SECONDOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) SetOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)

Example 25 with Hexstring_Value

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

the class LengthofExpression 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 (templateInstance == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp)) {
        return lastValue;
    }
    if (isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    final ITTCN3Template template = templateInstance.getTemplateBody();
    final IValue value = ((SpecificValue_Template) template).getSpecificValue().getValueRefdLast(timestamp, referenceChain);
    int length;
    switch(value.getValuetype()) {
        case CHARSTRING_VALUE:
            length = ((Charstring_Value) value).getValueLength();
            break;
        case UNIVERSALCHARSTRING_VALUE:
            length = ((UniversalCharstring_Value) value).getValueLength();
            break;
        case BITSTRING_VALUE:
            length = ((Bitstring_Value) value).getValueLength();
            break;
        case HEXSTRING_VALUE:
            length = ((Hexstring_Value) value).getValueLength();
            break;
        case OCTETSTRING_VALUE:
            length = ((Octetstring_Value) value).getValueLength();
            break;
        case SEQUENCEOF_VALUE:
            length = ((SequenceOf_Value) value).getNofComponents();
            break;
        case SETOF_VALUE:
            length = ((SetOf_Value) value).getNofComponents();
            break;
        case ARRAY_VALUE:
            length = ((Array_Value) value).getNofComponents();
            break;
        default:
            setIsErroneous(true);
            return lastValue;
    }
    lastValue = new Integer_Value(length);
    lastValue.copyGeneralProperties(this);
    return lastValue;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) IValue(org.eclipse.titan.designer.AST.IValue) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)33 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)22 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)16 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)15 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)13 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)10 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)9 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)6 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)6 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)4 IType (org.eclipse.titan.designer.AST.IType)3 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)3 SetOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)3 ISubReference (org.eclipse.titan.designer.AST.ISubReference)2 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)2 Identifier (org.eclipse.titan.designer.AST.Identifier)2 Reference (org.eclipse.titan.designer.AST.Reference)2 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)2 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)2 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)2