Search in sources :

Example 11 with Type_type

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

the class Int2CharExpression 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_INTEGER:
            final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last.getValuetype())) {
                final Integer_Value i = (Integer_Value) last;
                if (i.signum() < 0 || i.compareTo(new Integer_Value(127)) > 0) {
                    value.getLocation().reportSemanticError(OPERANDERROR2);
                    setIsErroneous(true);
                }
            }
            return;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR1);
                setIsErroneous(true);
            }
            return;
    }
}
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)

Example 12 with Type_type

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

the class Int2HexExpression 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 (value1 == null || value2 == null) {
        return;
    }
    IValue last1 = null;
    IValue last2 = null;
    value1.setLoweridToReference(timestamp);
    final Type_type tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType1) {
        case TYPE_INTEGER:
            last1 = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
                if (((Integer_Value) last1).signum() < 0) {
                    value1.getLocation().reportSemanticError(OPERANDERROR2);
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR1);
                setIsErroneous(true);
            }
            break;
    }
    value2.setLoweridToReference(timestamp);
    final Type_type tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType2) {
        case TYPE_INTEGER:
            last2 = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last2.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last2.getValuetype())) {
                if (((Integer_Value) last2).isNative()) {
                    final long i2 = ((Integer_Value) last2).getValue();
                    if (i2 < 0) {
                        value2.getLocation().reportSemanticError(OPERANDERROR4);
                        setIsErroneous(true);
                    } else if (last1 != null && !last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
                        if ((((Integer_Value) last1).shiftRight((int) i2 * 4)).signum() > 0) {
                            location.reportSemanticError(MessageFormat.format(OPERANDERROR5, ((Integer_Value) last1).intValue(), i2));
                            setIsErroneous(true);
                        }
                    }
                } else {
                    value2.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR6, ((Integer_Value) last2).getValueValue()));
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR3);
                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)

Example 13 with Type_type

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

the class Int2OctExpression 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 (value1 == null || value2 == null) {
        return;
    }
    IValue last1 = null;
    IValue last2 = null;
    Integer_Value i1 = new Integer_Value(0);
    value1.setLoweridToReference(timestamp);
    final Type_type tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType1) {
        case TYPE_INTEGER:
            last1 = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
                i1 = (Integer_Value) last1;
                if (i1.signum() < 0) {
                    value1.getLocation().reportSemanticError(OPERANDERROR2);
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR1);
                setIsErroneous(true);
            }
            break;
    }
    value2.setLoweridToReference(timestamp);
    final Type_type tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType2) {
        case TYPE_INTEGER:
            last2 = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last2.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last2.getValuetype())) {
                if (((Integer_Value) last2).isNative()) {
                    final long i2 = ((Integer_Value) last2).getValue();
                    if (i2 < 0) {
                        value2.getLocation().reportSemanticError(OPERANDERROR4);
                        setIsErroneous(true);
                    } else if (last1 != null && !last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
                        if ((i1.shiftRight((int) i2 * 8)).signum() > 0) {
                            location.reportSemanticError(MessageFormat.format(OPERANDERROR5, ((Integer_Value) last1).intValue(), i2));
                            setIsErroneous(true);
                        }
                    }
                } else {
                    value2.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR6, ((Integer_Value) last2).getValueValue()));
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR3);
                setIsErroneous(true);
            }
            break;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 14 with Type_type

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

the class IsTemplateKindExpression method checkExpressionOperand2.

/**
 * Checks the 2nd operand
 * in charstring (optional)
 * @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 checkExpressionOperand2(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (value == null) {
        setIsErroneous(true);
        return;
    }
    value.setLoweridToReference(timestamp);
    final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_CHARSTRING:
            final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                final String originalString = ((Charstring_Value) last).getValue();
                final CharstringExtractor cs = new CharstringExtractor(originalString);
                if (cs.isErrorneous()) {
                    value.getLocation().reportSemanticError(cs.getErrorMessage());
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERAND2_ERROR1);
                setIsErroneous(true);
            }
            break;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) CharstringExtractor(org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)

Example 15 with Type_type

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

the class XorExpression 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_BOOL:
                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_BOOL:
                value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                value2.getLocation().reportSemanticError(SECONDOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
}
Also used : Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

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