Search in sources :

Example 81 with Type_type

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

the class Unichar2OctExpression 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) {
    if (value == null) {
        return;
    }
    value.setLoweridToReference(timestamp);
    final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_UCHARSTRING:
            // TODO: implement missing part if range check is needed
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!value.getIsErroneous(timestamp)) {
                location.reportSemanticError(OPERANDERROR1);
                setIsErroneous(true);
            }
            break;
    }
    if (code_string == null) {
        return;
    }
    code_string.setLoweridToReference(timestamp);
    final Type_type tempType2 = code_string.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType2) {
        case TYPE_CHARSTRING:
            // TODO: implement missing part if range check is needed
            return;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            if (!code_string.getIsErroneous(timestamp)) {
                location.reportSemanticError(OPERANDERROR2);
                setIsErroneous(true);
            }
            return;
    }
}
Also used : Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 82 with Type_type

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

the class Xor4bExpression 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;
    if (value1 != null) {
        value1.setLoweridToReference(timestamp);
        tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType1) {
            case TYPE_BITSTRING:
            case TYPE_HEXSTRING:
            case TYPE_OCTETSTRING:
                value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                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_BITSTRING:
            case TYPE_HEXSTRING:
            case TYPE_OCTETSTRING:
                value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(SECONDOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
    if (value1 != null && value2 != null && !getIsErroneous(timestamp)) {
        if (value1.getIsErroneous(timestamp) || value2.getIsErroneous(timestamp)) {
            setIsErroneous(true);
            return;
        }
        // the operands must be of the same kind
        if (tempType1 != tempType2) {
            location.reportSemanticError(SAMEOPERANDERROR);
            setIsErroneous(true);
            return;
        }
        if (value1.isUnfoldable(timestamp) || value2.isUnfoldable(timestamp)) {
            return;
        }
        // the operands must have the same length
        final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
        final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
        switch(last1.getValuetype()) {
            case BITSTRING_VALUE:
                if (((Bitstring_Value) last1).getValueLength() != ((Bitstring_Value) last2).getValueLength()) {
                    location.reportSemanticError(SAMEOPERANDLENGTHERROR);
                    setIsErroneous(true);
                }
                break;
            case HEXSTRING_VALUE:
                if (((Hexstring_Value) last1).getValueLength() != ((Hexstring_Value) last2).getValueLength()) {
                    location.reportSemanticError(SAMEOPERANDLENGTHERROR);
                    setIsErroneous(true);
                }
                break;
            case OCTETSTRING_VALUE:
                if (((Octetstring_Value) last1).getValueLength() != ((Octetstring_Value) last2).getValueLength()) {
                    location.reportSemanticError(SAMEOPERANDLENGTHERROR);
                    setIsErroneous(true);
                }
                break;
            default:
                setIsErroneous(true);
        }
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 83 with Type_type

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

the class Xor4bExpression method getExpressionReturntype.

@Override
public /**
 * {@inheritDoc}
 */
Type_type getExpressionReturntype(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
    final IValue last = getValueRefdLast(timestamp, expectedValue, null);
    if (last.getIsErroneous(timestamp) || value1 == null) {
        return Type_type.TYPE_UNDEFINED;
    }
    if (last.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return Type_type.TYPE_UNDEFINED;
    }
    value1.setLoweridToReference(timestamp);
    final Type_type tempType = value1.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_BITSTRING:
        case TYPE_HEXSTRING:
        case TYPE_OCTETSTRING:
            return tempType;
        case TYPE_UNDEFINED:
            return tempType;
        default:
            setIsErroneous(true);
            return Type_type.TYPE_UNDEFINED;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 84 with Type_type

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

the class RNDWithValueExpression 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) {
    if (value == null) {
        return;
    }
    value.setLoweridToReference(timestamp);
    final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_REAL:
            {
                final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (!last.isUnfoldable(timestamp)) {
                    final Real_Value real = (Real_Value) last;
                    if (real.isSpecialFloat()) {
                        value.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR2, real.createStringRepresentation()));
                        setIsErroneous(true);
                    }
                }
                break;
            }
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR);
                setIsErroneous(true);
            }
            return;
    }
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Example 85 with Type_type

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

the class RemainderExpression 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;
    if (value1 != null) {
        value1.setLoweridToReference(timestamp);
        tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType1) {
            case TYPE_INTEGER:
                value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                value1.getLocation().reportSemanticError(FIRSTOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
    if (value2 != null) {
        value2.setLoweridToReference(timestamp);
        tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType2) {
            case TYPE_INTEGER:
                final IValue lastValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (lastValue != null && !lastValue.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(lastValue.getValuetype())) {
                    if (((Integer_Value) lastValue).equals(new Integer_Value(0))) {
                        value2.getLocation().reportSemanticError(ZEROOPERANDERROR);
                        setIsErroneous(true);
                    }
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                value2.getLocation().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)

Aggregations

Type_type (org.eclipse.titan.designer.AST.IType.Type_type)130 IValue (org.eclipse.titan.designer.AST.IValue)79 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)19 IType (org.eclipse.titan.designer.AST.IType)13 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)13 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)12 CharstringExtractor (org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)9 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)9 Assignment (org.eclipse.titan.designer.AST.Assignment)7 Boolean_Type (org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type)7 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)5 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)3 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)3 Identifier (org.eclipse.titan.designer.AST.Identifier)3 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)3 FormalParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList)3 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)3 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)3 SetOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)3 Module (org.eclipse.titan.designer.AST.Module)2