Search in sources :

Example 71 with Type_type

use of org.eclipse.titan.designer.AST.IType.Type_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 72 with Type_type

use of org.eclipse.titan.designer.AST.IType.Type_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 73 with Type_type

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

the class Int2Enum_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    if (value != null) {
        value.setLoweridToReference(timestamp);
        final Type_type temporalType = value.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        switch(temporalType) {
            case TYPE_INTEGER:
            case TYPE_INTEGER_A:
                value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
                break;
            case TYPE_UNDEFINED:
                setIsErroneous();
                break;
            default:
                if (!isErroneous) {
                    value.getLocation().reportSemanticError(OPERANDERROR1);
                    setIsErroneous();
                }
        }
    }
    if (reference != null) {
        final IType refType = reference.checkVariableReference(timestamp).getTypeRefdLast(timestamp);
        if (Type_type.TYPE_TTCN3_ENUMERATED != refType.getTypetype() && !isErroneous) {
            value.getLocation().reportSemanticError(OPERANDERROR2);
            setIsErroneous();
        }
    }
    lastTimeChecked = timestamp;
}
Also used : Type_type(org.eclipse.titan.designer.AST.IType.Type_type) IType(org.eclipse.titan.designer.AST.IType)

Example 74 with Type_type

use of org.eclipse.titan.designer.AST.IType.Type_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)

Example 75 with Type_type

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

the class Start_Timer_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    checkTimerReference(timestamp, timerReference);
    if (timerValue == null) {
        final Assignment assignment = timerReference.getRefdAssignment(timestamp, true);
        if (assignment != null && Assignment_type.A_TIMER.semanticallyEquals(assignment.getAssignmentType())) {
            final Def_Timer defTimer = (Def_Timer) assignment;
            if (!defTimer.hasDefaultDuration(timestamp, timerReference)) {
                location.reportSemanticError(MessageFormat.format(MISSINGDEFAULTDURATION, assignment.getDescription()));
            }
        }
    } else {
        timerValue.setLoweridToReference(timestamp);
        final Type_type temporalType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        switch(temporalType) {
            case TYPE_REAL:
                {
                    final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
                    if (!last.isUnfoldable(timestamp)) {
                        final Real_Value real = (Real_Value) last;
                        final double val = real.getValue();
                        if (val < 0.0) {
                            timerValue.getLocation().reportSemanticError(MessageFormat.format(NEGATIVEDURATION, real));
                        } else if (real.isPositiveInfinity()) {
                            timerValue.getLocation().reportSemanticError(MessageFormat.format(INFINITYDURATION, real.createStringRepresentation()));
                        }
                    }
                    return;
                }
            case TYPE_UNDEFINED:
                return;
            default:
                timerValue.getLocation().reportSemanticError(FLOATEXPECTED);
                return;
        }
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) Def_Timer(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

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