Search in sources :

Example 51 with Type_type

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

the class SingleArrayDimension method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    setIsErroneous(false);
    if (value == null) {
        return;
    }
    final IValue last = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_CONSTANT, null);
    if (last == null || last.getIsErroneous(timestamp)) {
        return;
    }
    final Type_type ttype = value.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_CONSTANT);
    switch(ttype) {
        case TYPE_INTEGER:
            if (last.isUnfoldable(timestamp)) {
                value.getLocation().reportSemanticError(OPERANDERROR);
                setIsErroneous(true);
            } else if (Value.Value_type.INTEGER_VALUE.equals(last.getValuetype())) {
                if (!((Integer_Value) last).isNative()) {
                    value.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERERROR, ((Integer_Value) last).getValueValue()));
                    setIsErroneous(true);
                } else {
                    size = ((Integer_Value) last).getValue();
                    if (size < 0) {
                        value.getLocation().reportSemanticError(OPERANDERROR);
                        setIsErroneous(true);
                    }
                }
            }
            return;
        default:
            value.getLocation().reportSemanticError(INTEGERVALUEEXPECTED);
            value.setIsErroneous(true);
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 52 with Type_type

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

the class CheckStateExpression method checkExpressionOperand1.

/**
 * Checks the operand
 * in charstring (mandatory)
 * @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 checkExpressionOperand1(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(OPERAND1_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 53 with Type_type

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

the class ComponentCreateExpression 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) {
    checkCreate(timestamp);
    if (name != null) {
        final IValue last = name.setLoweridToReference(timestamp);
        final Type_type typeType = last.getExpressionReturntype(timestamp, expectedValue);
        if (!last.getIsErroneous(timestamp)) {
            switch(typeType) {
                case TYPE_CHARSTRING:
                    last.getValueRefdLast(timestamp, referenceChain);
                    break;
                case TYPE_UNDEFINED:
                    break;
                default:
                    name.getLocation().reportSemanticError(FIRSTOPERANDERROR);
                    setIsErroneous(true);
                    break;
            }
        }
    }
    if (location != null) {
        final IValue last = location.setLoweridToReference(timestamp);
        final Type_type typeType = last.getExpressionReturntype(timestamp, expectedValue);
        if (!last.getIsErroneous(timestamp)) {
            switch(typeType) {
                case TYPE_CHARSTRING:
                    last.getValueRefdLast(timestamp, referenceChain);
                    break;
                case TYPE_UNDEFINED:
                    break;
                default:
                    name.getLocation().reportSemanticError(SECONDOPERANDERROR);
                    setIsErroneous(true);
                    break;
            }
        }
    }
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, false, true, false);
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 54 with Type_type

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

the class DivideExpression 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_REAL:
                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.getIsErroneous(timestamp) && !lastValue.isUnfoldable(timestamp)) {
                        if (((Integer_Value) lastValue).equals(new Integer_Value(0L))) {
                            value2.getLocation().reportSemanticError(ZEROOPERANDERROR);
                            setIsErroneous(true);
                        }
                    }
                    break;
                }
            case TYPE_REAL:
                value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                value2.getLocation().reportSemanticError(SECONDOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
    if (value1 != null && value2 != null && !getIsErroneous(timestamp)) {
        if (value1.getIsErroneous(timestamp) || value2.getIsErroneous(timestamp)) {
            setIsErroneous(true);
            return;
        }
        if (tempType1 != tempType2) {
            location.reportSemanticError(SAMEOPERANDERROR);
            setIsErroneous(true);
        }
    }
}
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 55 with Type_type

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

the class DivideExpression method getExpressionReturntype.

@Override
public /**
 * {@inheritDoc}
 */
Type_type getExpressionReturntype(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
    if (value1 == null) {
        return Type_type.TYPE_UNDEFINED;
    }
    value1.setLoweridToReference(timestamp);
    final Type_type tempType = value1.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_INTEGER:
        case TYPE_REAL:
            return tempType;
        case TYPE_UNDEFINED:
            return tempType;
        default:
            getValueRefdLast(timestamp, expectedValue, null);
            setIsErroneous(true);
            return Type_type.TYPE_UNDEFINED;
    }
}
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