Search in sources :

Example 6 with Boolean_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type in project titan.EclipsePlug-ins by eclipse.

the class DoWhile_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    isInfiniteLoop = false;
    if (statementblock != null) {
        statementblock.setMyLaicStmt(null, this);
        statementblock.check(timestamp);
    }
    if (expression != null) {
        final IValue last = expression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
        final Type_type temporalType = last.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        if (!last.getIsErroneous(timestamp)) {
            if (!Type_type.TYPE_BOOL.equals(temporalType)) {
                last.getLocation().reportSemanticError(BOOLEANEXPECTED);
                expression.setIsErroneous(true);
            } else if (!expression.isUnfoldable(timestamp)) {
                if (!((Boolean_Value) last).getValue()) {
                    final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null);
                    expression.getLocation().reportConfigurableSemanticProblem(severity, UNNECESSARYCONTROL);
                } else if (ReturnStatus_type.RS_NO.equals(hasReturn(timestamp))) {
                    isInfiniteLoop = true;
                    final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINFINITELOOPS, GeneralConstants.WARNING, null);
                    location.reportConfigurableSemanticProblem(severity, INFINITELOOP);
                }
            }
            if (expression.getMyGovernor() == null) {
                expression.setMyGovernor(new Boolean_Type());
            }
        }
    }
    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)

Example 7 with Boolean_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type in project titan.EclipsePlug-ins by eclipse.

the class If_Clause method check.

/**
 * Does the semantic checking of this branch.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param unreachable
 *                boolean parameter telling if this if statement was
 *                already found unreachable by previous clauses or not
 *
 * @return true if following clauses are unreachable
 */
public boolean check(final CompilationTimeStamp timestamp, final boolean unreachable) {
    if (unreachable) {
        location.reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), NEVERREACH1);
    }
    boolean unreachable2 = unreachable;
    if (expression != null) {
        final IValue last = expression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
        final Type_type temporalType = last.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        if (!last.getIsErroneous(timestamp) && !Type_type.TYPE_UNDEFINED.equals(temporalType)) {
            if (!Type_type.TYPE_BOOL.equals(temporalType)) {
                last.getLocation().reportSemanticError(BOOLEANEXPECTED);
                expression.setIsErroneous(true);
            } else if (!expression.isUnfoldable(timestamp)) {
                if (((Boolean_Value) last).getValue()) {
                    expression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), UNNECESSARYCONTROL1);
                    unreachable2 = true;
                } else {
                    expression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), UNNECESSARYCONTROL2);
                    statementblock.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), NEVERREACH2);
                }
            }
            if (expression.getMyGovernor() == null) {
                expression.setMyGovernor(new Boolean_Type());
            }
        }
    }
    if (statementblock != null) {
        statementblock.check(timestamp);
    }
    return unreachable2;
}
Also used : 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)

Example 8 with Boolean_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type in project titan.EclipsePlug-ins by eclipse.

the class Invoke_Altguard method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    if (expression != null) {
        final IValue last = expression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
        final Type_type temporalType = last.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        if (!last.getIsErroneous(timestamp) && !Type_type.TYPE_BOOL.equals(temporalType)) {
            last.getLocation().reportSemanticError(BOOLEANEXPECTED);
            expression.setIsErroneous(true);
        }
        if (expression.getMyGovernor() == null) {
            expression.setMyGovernor(new Boolean_Type());
        }
    }
    IType type = value.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (type == null) {
        lastTimeChecked = timestamp;
        return;
    }
    type = type.getTypeRefdLast(timestamp);
    if (type == null || type.getIsErroneous(timestamp)) {
        lastTimeChecked = timestamp;
        return;
    }
    if (!Type_type.TYPE_ALTSTEP.equals(type.getTypetype())) {
        value.getLocation().reportSemanticError(MessageFormat.format("A value of type altstep was expected instead of `{0}''", type.getTypename()));
        lastTimeChecked = timestamp;
        return;
    }
    value.getMyScope().checkRunsOnScope(timestamp, type, this, "call");
    final FormalParameterList formalParmaterList = ((Altstep_Type) type).getFormalParameters();
    actualParameterList = new ActualParameterList();
    formalParmaterList.checkActualParameterList(timestamp, parsedParameters, actualParameterList);
    if (statementblock != null) {
        statementblock.check(timestamp);
    }
    lastTimeChecked = timestamp;
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) 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) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Altstep_Type(org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

Boolean_Type (org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type)8 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)7 IValue (org.eclipse.titan.designer.AST.IValue)7 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)3 Assignment (org.eclipse.titan.designer.AST.Assignment)1 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)1 IType (org.eclipse.titan.designer.AST.IType)1 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)1 FormalParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList)1 Altstep_Type (org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type)1