Search in sources :

Example 21 with Real_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.

the class Def_Timer method checkSingleDuration.

private void checkSingleDuration(final CompilationTimeStamp timestamp, final IValue duration) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final Value v = (Value) duration.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    if (v.getValuetype() == Value_type.REAL_VALUE) {
        final Real_Value value = (Real_Value) v;
        final double valueReal = value.getValue();
        if (valueReal < 0.0 || value.isSpecialFloat()) {
            duration.getLocation().reportSemanticError("A non-negative float value was expected as timer duration instead of" + valueReal);
        }
    } else {
        duration.getLocation().reportSemanticError("Value is not real");
    }
}
Also used : IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Value(org.eclipse.titan.designer.AST.Value) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value) IValue(org.eclipse.titan.designer.AST.IValue) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Example 22 with Real_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.

the class Def_Timer method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    isUsed = false;
    if (getMyScope() instanceof ComponentTypeBody) {
        NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_COMPONENT_TIMER, identifier, this);
    } else if (isLocal()) {
        NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_LOCAL_TIMER, identifier, this);
    } else {
        NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_GLOBAL_TIMER, identifier, this);
    }
    NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
    if (dimensions != null) {
        dimensions.check(timestamp);
    }
    if (defaultDuration != null) {
        if (dimensions == null) {
            defaultDuration.setLoweridToReference(timestamp);
            final Type_type tempType = defaultDuration.getExpressionReturntype(timestamp, isLocal() ? Expected_Value_type.EXPECTED_DYNAMIC_VALUE : Expected_Value_type.EXPECTED_STATIC_VALUE);
            switch(tempType) {
                case TYPE_REAL:
                    final IValue last = defaultDuration.getValueRefdLast(timestamp, null);
                    if (!last.isUnfoldable(timestamp)) {
                        final Real_Value real = (Real_Value) last;
                        final double value = real.getValue();
                        if (value < 0.0f) {
                            defaultDuration.getLocation().reportSemanticError(MessageFormat.format(NEGATIVDURATIONERROR, value));
                        } else if (real.isPositiveInfinity()) {
                            final String message = MessageFormat.format(INFINITYDURATIONERROR, real.createStringRepresentation());
                            defaultDuration.getLocation().reportSemanticError(message);
                        }
                    }
                    return;
                default:
                    defaultDuration.getLocation().reportSemanticError(OPERANDERROR);
            }
        } else {
            checkArrayDuration(timestamp, defaultDuration, 0);
        }
        defaultDuration.setCodeSection(CodeSectionType.CS_POST_INIT);
    }
    if (withAttributesPath != null) {
        withAttributesPath.checkGlobalAttributes(timestamp, false);
        withAttributesPath.checkAttributes(timestamp);
    }
    lastTimeChecked = timestamp;
}
Also used : ComponentTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.ComponentTypeBody) IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Example 23 with Real_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.

the class Call_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    final Port_Type portType = Port_Utility.checkPortReference(timestamp, this, portReference);
    if (parameter == null) {
        return;
    }
    IType signatureType = null;
    boolean signatureTypeDetermined = false;
    if (portType != null) {
        // the port type is known
        final PortTypeBody portTypeBody = portType.getPortBody();
        final TypeSet outSignatures = portTypeBody.getOutSignatures();
        if (OperationModes.OP_Message.equals(portTypeBody.getOperationMode())) {
            portReference.getLocation().reportSemanticError(MessageFormat.format(SENDONPORT, portType.getTypename()));
        } else if (outSignatures != null) {
            if (outSignatures.getNofTypes() == 1) {
                signatureType = outSignatures.getTypeByIndex(0);
            } else {
                signatureType = Port_Utility.getOutgoingType(timestamp, parameter);
                if (signatureType == null) {
                    parameter.getLocation().reportSemanticError(UNKNOWNSIGNATURE);
                } else {
                    if (!outSignatures.hasType(timestamp, signatureType)) {
                        parameter.getLocation().reportSemanticError(MessageFormat.format(TYPENOTPRESENT, signatureType.getTypename(), portType.getTypename()));
                    }
                }
            }
            signatureTypeDetermined = true;
        } else {
            portReference.getLocation().reportSemanticError(MessageFormat.format(NOOUTGOINGSIGNATURETYPES, portType.getTypename()));
        }
    }
    if (!signatureTypeDetermined) {
        signatureType = Port_Utility.getOutgoingType(timestamp, parameter);
    }
    boolean isNonblocking = false;
    if (signatureType != null) {
        parameter.check(timestamp, signatureType);
        signatureType = signatureType.getTypeRefdLast(timestamp);
        switch(signatureType.getTypetype()) {
            case TYPE_SIGNATURE:
                ((Signature_Type) signatureType).checkThisTemplate(timestamp, parameter.getTemplateBody(), false, false, null);
                isNonblocking = ((Signature_Type) signatureType).isNonblocking();
                break;
            default:
                parameter.getLocation().reportSemanticError(MessageFormat.format(CALLPARAMETERNOTSIGNATURE, signatureType.getTypename()));
                break;
        }
        if (isNonblocking) {
            if (timerValue != null) {
                timerValue.getLocation().reportSemanticError(MessageFormat.format(NONBLOCKINGWITHTIMER, signatureType.getTypename()));
            } else if (noWait) {
                location.reportSemanticError(MessageFormat.format(NONBLOCKINGWITHNOWAIT, signatureType.getTypename()));
            }
            if (altGuards != null) {
                location.reportSemanticError(MessageFormat.format(NONBLOCKINGWITHRESPONSEPART, signatureType.getTypename()));
            }
        } else if (noWait) {
            if (altGuards != null) {
                location.reportSemanticError(NOWAITWITHRESPONSEPART);
            }
        } else {
            if (!getIsErroneous() && altGuards == null) {
                location.reportSemanticError(RESPONSEPARTMISSING);
            }
        }
    }
    if (timerValue != null) {
        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 (Value_type.REAL_VALUE.equals(last.getValuetype()) && !last.getIsErroneous(timestamp)) {
                    final double temp = ((Real_Value) last).getValue();
                    if (temp < 0) {
                        timerValue.getLocation().reportSemanticError(MessageFormat.format(CALLTIMERNEGATIVE, temp));
                    }
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous();
                break;
            default:
                if (!isErroneous) {
                    location.reportSemanticError(FLOATTIMEREXPECTED);
                }
                break;
        }
    }
    Port_Utility.checkToClause(timestamp, this, portType, toClause);
    if (altGuards != null) {
        checkCallBody(timestamp, portType, signatureType);
    }
    lastTimeChecked = timestamp;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) TypeSet(org.eclipse.titan.designer.AST.TTCN3.types.TypeSet) Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) Port_Type(org.eclipse.titan.designer.AST.TTCN3.types.Port_Type) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) PortTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody) IType(org.eclipse.titan.designer.AST.IType) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Example 24 with Real_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.

the class RNDWithValueExpression 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_REAL:
            {
                final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (!last.isUnfoldable(timestamp)) {
                    final Real_Value real = (Real_Value) last;
                    if (real.isSpecialFloat()) {
                        value.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR2, real.createStringRepresentation()));
                        setIsErroneous(true);
                    }
                }
                break;
            }
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR);
                setIsErroneous(true);
            }
            return;
    }
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Example 25 with Real_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.

the class ExecuteDereferedExpression 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) {
        IType type;
        value.setLoweridToReference(timestamp);
        final IValue last = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_TEMPLATE, referenceChain);
        if (last.getIsErroneous(timestamp)) {
            type = null;
        } else {
            type = last.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
            if (type != null) {
                type = type.getTypeRefdLast(timestamp);
            }
        }
        if (type == null || type.getIsErroneous(timestamp)) {
            setIsErroneous(true);
        } else if (Type_type.TYPE_TESTCASE.equals(type.getTypetype())) {
            final FormalParameterList formalParameters = ((Testcase_Type) type).getFormalParameters();
            actualParameters = new ActualParameterList();
            final boolean isErroneous = formalParameters.checkActualParameterList(timestamp, actualParameterList, actualParameters);
            if (isErroneous) {
                setIsErroneous(true);
            }
        } else {
            value.getLocation().reportSemanticError(MessageFormat.format("Reference to a value of type testcase was expected in the argument of `derefers()'' instead of `{0}''", type.getTypename()));
            setIsErroneous(true);
        }
    }
    if (timerValue != null) {
        timerValue.setLoweridToReference(timestamp);
        final Type_type tempType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        switch(tempType) {
            case TYPE_REAL:
                final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, referenceChain);
                if (!last.isUnfoldable(timestamp)) {
                    final Real_Value real = (Real_Value) last;
                    final double i = real.getValue();
                    if (i < 0.0) {
                        timerValue.getLocation().reportSemanticError(MessageFormat.format(NEGATIVEDURATION, real.createStringRepresentation()));
                    } else if (real.isPositiveInfinity()) {
                        timerValue.getLocation().reportSemanticError(MessageFormat.format(FLOATEXPECTED, real.createStringRepresentation()));
                    }
                }
                return;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                return;
            default:
                if (!isErroneous) {
                    timerValue.getLocation().reportSemanticError(OPERANDERROR);
                    setIsErroneous(true);
                }
                return;
        }
    }
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, false, false);
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) IType(org.eclipse.titan.designer.AST.IType) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)33 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)27 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)14 IType (org.eclipse.titan.designer.AST.IType)9 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)9 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)6 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)5 TTCN3_Enumerated_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type)5 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)5 Assignment (org.eclipse.titan.designer.AST.Assignment)4 EnumItem (org.eclipse.titan.designer.AST.TTCN3.types.EnumItem)4 Enumerated_Value (org.eclipse.titan.designer.AST.TTCN3.values.Enumerated_Value)4 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)3 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)3 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)2 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)2 Reference (org.eclipse.titan.designer.AST.Reference)2 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)2 FormalParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList)2 Integer_Type (org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type)2