Search in sources :

Example 66 with Type_type

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

the class And4bExpression 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 67 with Type_type

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

the class And4bExpression 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, expectedValue, referenceChain);
        final IValue last2 = value2.getValueRefdLast(timestamp, expectedValue, 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 68 with Type_type

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

the class AndExpression 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)

Example 69 with Type_type

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

the class Setverdict_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    if (myStatementBlock.getMyDefinition() == null) {
        location.reportSemanticError(INCONTROLPART);
    }
    if (verdictValue != null) {
        verdictValue.setLoweridToReference(timestamp);
        // to force its checking
        final IValue last = verdictValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
        final Type_type temp = verdictValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        switch(temp) {
            case TYPE_VERDICT:
                if (Value_type.VERDICT_VALUE.equals(last.getValuetype()) && Verdict_type.ERROR.equals(((Verdict_Value) last).getValue())) {
                    verdictValue.getLocation().reportSemanticError(ERRORCANNOTBESET);
                }
                if (Value_type.VERDICT_VALUE.equals(last.getValuetype()) && !Verdict_type.PASS.equals(((Verdict_Value) last).getValue()) && verdictReason == null) {
                    getLocation().reportConfigurableSemanticProblem(reportSetverdictWithoutReason, MessageFormat.format(WITHOUT_REASON, ((Verdict_Value) last).getValue()));
                }
                break;
            default:
                verdictValue.getLocation().reportSemanticError(OPERANDERROR);
                verdictValue.setIsErroneous(true);
                break;
        }
    }
    if (verdictReason != null) {
        verdictReason.check(timestamp);
    }
    lastTimeChecked = timestamp;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Verdict_Value(org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value)

Example 70 with Type_type

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

the class Deactivate_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    if (deactivate == null) {
        return;
    }
    deactivate.setLoweridToReference(timestamp);
    final Type_type temporalType = deactivate.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    switch(temporalType) {
        case TYPE_DEFAULT:
            deactivate.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
            return;
        default:
            location.reportSemanticError(DEFAULTEXPECTED);
            return;
    }
}
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