Search in sources :

Example 76 with Type_type

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

the class String2Ttcn_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_CHARSTRING:
                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 Assignment assignment = reference.getRefdAssignment(timestamp, false);
        if (assignment == null) {
            reference.getLocation().reportSemanticError(OPERANDERROR2);
            setIsErroneous();
        } else {
            switch(assignment.getAssignmentType()) {
                case A_PAR_VAL:
                case A_PAR_VAL_IN:
                case A_PAR_TEMP_IN:
                case A_VAR:
                case A_VAR_TEMPLATE:
                case A_PAR_VAL_OUT:
                case A_PAR_VAL_INOUT:
                case A_PAR_TEMP_OUT:
                case A_PAR_TEMP_INOUT:
                    // valid assignment types
                    break;
                default:
                    reference.getLocation().reportSemanticError(OPERANDERROR3);
                    setIsErroneous();
            }
        }
    }
    lastTimeChecked = timestamp;
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 77 with Type_type

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

the class Testcase_Instance_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    if (testcaseReference == null) {
        return;
    }
    final Assignment assignment = testcaseReference.getRefdAssignment(timestamp, true);
    if (assignment == null) {
        return;
    }
    if (!Assignment_type.A_TESTCASE.semanticallyEquals(assignment.getAssignmentType())) {
        testcaseReference.getLocation().reportSemanticError(MessageFormat.format(TESTCASEEXPECTED, assignment.getFullName()));
        return;
    }
    if (myStatementBlock.getScopeRunsOn() != null) {
        testcaseReference.getLocation().reportSemanticError(DEFINITIONWITHOUTRUNSONEXPECTED);
        return;
    }
    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 (!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(FLOATEXPECTED2, real.createStringRepresentation()));
                    }
                }
                break;
            default:
                timerValue.getLocation().reportSemanticError(FLOATEXPECTED);
                break;
        }
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) 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 78 with Type_type

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

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

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

the class Unichar2IntExpression 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);
    IValue last;
    switch(tempType) {
        case TYPE_UCHARSTRING:
        case TYPE_CHARSTRING:
            last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                final Value_type tempType1 = last.getValuetype();
                // UniversalCharstring string; // = ((UniversalCharstring_Value) last).getValue();
                switch(tempType1) {
                    case UNIVERSALCHARSTRING_VALUE:
                        {
                            final UniversalCharstring string = ((UniversalCharstring_Value) last).getValue();
                            if (string.isErrorneous()) {
                                value.getLocation().reportSemanticError(string.getErrorMessage());
                                setIsErroneous(true);
                            } else if (string.length() != 1) {
                                value.getLocation().reportSemanticError(OPERANDERROR2);
                                setIsErroneous(true);
                            }
                            break;
                        }
                    case CHARSTRING_VALUE:
                        {
                            final String originalString = ((Charstring_Value) last).getValue();
                            final CharstringExtractor cs = new CharstringExtractor(originalString);
                            if (cs.isErrorneous()) {
                                value.getLocation().reportSemanticError(cs.getErrorMessage());
                                setIsErroneous(true);
                            } else {
                                final String string = cs.getExtractedString();
                                if (string != null && string.length() != 1) {
                                    value.getLocation().reportSemanticError(OPERANDERROR2);
                                    setIsErroneous(true);
                                }
                            }
                        }
                    default:
                        // error???
                        break;
                }
            // switch
            }
            // if
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR1);
                setIsErroneous(true);
            }
            break;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Expected_Value_type(org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) CharstringExtractor(org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)

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