Search in sources :

Example 41 with Type_type

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

the class GreaterThanExpression 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;
    }
    ExpressionUtilities.checkExpressionOperatorCompatibility(timestamp, this, referenceChain, expectedValue, value1, value2);
    value1.setLoweridToReference(timestamp);
    final Type_type tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType1) {
        case TYPE_INTEGER:
        case TYPE_REAL:
        case TYPE_TTCN3_ENUMERATED:
        case TYPE_ASN1_ENUMERATED:
            value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            value1.getLocation().reportSemanticError(FIRSTOPERANDERROR);
            setIsErroneous(true);
            break;
    }
    value2.setLoweridToReference(timestamp);
    final Type_type tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType2) {
        case TYPE_INTEGER:
        case TYPE_REAL:
        case TYPE_TTCN3_ENUMERATED:
        case TYPE_ASN1_ENUMERATED:
            value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            value2.getLocation().reportSemanticError(SECONDOPERANDERROR);
            setIsErroneous(true);
            break;
    }
}
Also used : Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 42 with Type_type

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

the class Hex2IntExpression 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_HEXSTRING:
            final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                final String hexstring = ((Hexstring_Value) last).getValue();
                int startIndex = 0;
                while (startIndex < hexstring.length() && '0' == hexstring.charAt(startIndex)) {
                    startIndex++;
                }
            }
            return;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR1);
                setIsErroneous(true);
            }
            return;
    }
}
Also used : Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 43 with Type_type

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

the class Hex2OctExpression 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_HEXSTRING:
            value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            return;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR);
                setIsErroneous(true);
            }
            return;
    }
}
Also used : Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 44 with Type_type

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

the class Bit2HexExpression 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_BITSTRING:
            value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            return;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR);
                setIsErroneous(true);
            }
            return;
    }
}
Also used : Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 45 with Type_type

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

the class For_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    if (definitions != null) {
        definitions.check(timestamp);
    }
    if (initialAssignment != null) {
        initialAssignment.check(timestamp);
    }
    if (finalExpression != null) {
        finalExpression.setLoweridToReference(timestamp);
        final IValue lastValue = finalExpression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
        final Type_type temp = lastValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        switch(temp) {
            case TYPE_BOOL:
                if (!lastValue.isUnfoldable(timestamp)) {
                    if (((Boolean_Value) lastValue).getValue()) {
                        finalExpression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), UNNECESSARYCONTROL);
                    } else {
                        finalExpression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), NEVERREACH);
                    }
                }
                break;
            default:
                location.reportSemanticError(OPERANDERROR);
                finalExpression.setIsErroneous(true);
                break;
        }
        if (finalExpression.getMyGovernor() == null) {
            finalExpression.setMyGovernor(new Boolean_Type());
        }
    }
    if (stepAssignment != null) {
        stepAssignment.check(timestamp);
    }
    if (statementblock != null) {
        statementblock.setMyLaicStmt(null, this);
        statementblock.check(timestamp);
    // warning for "return" has been removed. Not valid problem
    }
    lastTimeChecked = timestamp;
}
Also used : Boolean_Value(org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value) IValue(org.eclipse.titan.designer.AST.IValue) Boolean_Type(org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type) 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