Search in sources :

Example 46 with Referenced_Value

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

the class TTCN3_Set_Type method checkThisValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
    if (getIsErroneous(timestamp)) {
        return false;
    }
    boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
    IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
    if (last == null || last.getIsErroneous(timestamp)) {
        return selfReference;
    }
    // already handled ones
    switch(value.getValuetype()) {
        case OMIT_VALUE:
        case REFERENCED_VALUE:
            return selfReference;
        case UNDEFINED_LOWERIDENTIFIER_VALUE:
            if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
                return selfReference;
            }
            break;
        default:
            break;
    }
    switch(last.getValuetype()) {
        case SEQUENCE_VALUE:
            last = last.setValuetype(timestamp, Value_type.SET_VALUE);
            if (last.isAsn()) {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            } else {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            }
            break;
        case SEQUENCEOF_VALUE:
            if (((SequenceOf_Value) last).isIndexed()) {
                value.getLocation().reportSemanticError(MessageFormat.format("Indexed assignment notation cannot be used for set type `{0}''", getFullName()));
                value.setIsErroneous(true);
            } else {
                final SequenceOf_Value tempValue = (SequenceOf_Value) last;
                if (tempValue.getNofComponents() == 0) {
                    if (compFieldMap != null && compFieldMap.getComponentFieldMap(timestamp).isEmpty()) {
                        last = last.setValuetype(timestamp, Value_type.SET_VALUE);
                    } else {
                        value.getLocation().reportSemanticError(MessageFormat.format(NONEMPTYEXPECTED, getFullName()));
                        value.setIsErroneous(true);
                    }
                } else {
                    value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? VALUELISTNOTATIONERRORASN1 : VALUELISTNOTATIONERRORTTCN3, getFullName()));
                    value.setIsErroneous(true);
                }
            }
            break;
        case SET_VALUE:
            if (last.isAsn()) {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            } else {
                selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            }
            break;
        case UNDEFINED_BLOCK:
            last = last.setValuetype(timestamp, Value_type.SET_VALUE);
            selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            break;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? SETVALUEXPECTEDASN1 : SETVALUEXPECTEDTTCN3, getFullName()));
            value.setIsErroneous(true);
    }
    if (valueCheckingOptions.sub_check) {
        // there is no parent type to check
        if (subType != null) {
            subType.checkThisValue(timestamp, last);
        }
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) Set_Value(org.eclipse.titan.designer.AST.TTCN3.values.Set_Value)

Example 47 with Referenced_Value

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

the class Testcase_Type method checkThisValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
    final boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
    final IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
    if (last == null || last.getIsErroneous(timestamp)) {
        return selfReference;
    }
    last.setMyGovernor(this);
    // already handled ones
    switch(value.getValuetype()) {
        case OMIT_VALUE:
        case REFERENCED_VALUE:
            return selfReference;
        case UNDEFINED_LOWERIDENTIFIER_VALUE:
            if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
                return selfReference;
            }
            break;
        default:
            break;
    }
    Def_Testcase testcase = null;
    switch(last.getValuetype()) {
        case TESTCASE_REFERENCE_VALUE:
            testcase = ((Testcase_Reference_Value) last).getReferredTestcase();
            if (testcase == null) {
                setIsErroneous(true);
                return selfReference;
            }
            testcase.check(timestamp);
            break;
        case TTCN3_NULL_VALUE:
            value.setValuetype(timestamp, Value_type.FAT_NULL_VALUE);
            return selfReference;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            return selfReference;
        default:
            value.getLocation().reportSemanticError(TESTCASEREFERENCEVALUEEXPECTED);
            value.setIsErroneous(true);
            return selfReference;
    }
    final Component_Type temporalRunsOnType = testcase.getRunsOnType(timestamp);
    if (temporalRunsOnType != null) {
        if (runsOnType != null && !temporalRunsOnType.isCompatible(timestamp, runsOnType, null, null, null)) {
            value.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLERUNSONTYPESERROR, getTypename(), runsOnType.getTypename(), testcase.getAssignmentName(), temporalRunsOnType.getTypename()));
            value.setIsErroneous(true);
        }
    }
    formalParList.checkCompatibility(timestamp, testcase.getFormalParameterList(), value.getLocation());
    Component_Type temporalSystemType = testcase.getSystemType(timestamp);
    if (temporalSystemType == null) {
        temporalSystemType = temporalRunsOnType;
    }
    if (systemRef == null) {
        if (temporalSystemType != null && runsOnType != null && !temporalSystemType.isCompatible(timestamp, runsOnType, null, null, null)) {
            value.getLocation().reportSemanticError(MessageFormat.format(SYSTEMCLAUSEMISMATCHERROR, getTypename(), runsOnType.getTypename(), testcase.getAssignmentName(), temporalSystemType.getTypename()));
            value.setIsErroneous(true);
        }
    } else {
        if (temporalSystemType != null && systemType != null && !temporalSystemType.isCompatible(timestamp, systemType, null, null, null)) {
            value.getLocation().reportSemanticError(MessageFormat.format(SYSTEMCLAUSEMISMATCHERROR, getTypename(), systemType.getTypename(), testcase.getAssignmentName(), temporalSystemType.getTypename()));
            value.setIsErroneous(true);
        }
    }
    if (valueCheckingOptions.sub_check) {
        // there is no parent type to check
        if (subType != null) {
            subType.checkThisValue(timestamp, value);
        }
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase)

Example 48 with Referenced_Value

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

the class SpecificValue_Template method isValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean isValue(final CompilationTimeStamp timestamp) {
    if (lengthRestriction != null || isIfpresent || getIsErroneous(timestamp)) {
        return false;
    }
    if (realTemplate != null && realTemplate != this) {
        return realTemplate.isValue(timestamp);
    }
    if (Value_type.FUNCTION_REFERENCE_VALUE.equals(specificValue.getValuetype())) {
        final IType governor = ((Function_Reference_Value) specificValue).getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        if (governor == null) {
            return true;
        }
        final IType last = governor.getTypeRefdLast(timestamp);
        if (Type_type.TYPE_FUNCTION.equals(last.getTypetype()) && ((Function_Type) last).returnsTemplate()) {
            return false;
        }
    } else if (Value_type.REFERENCED_VALUE.equals(specificValue.getValuetype())) {
        final Reference reference = ((Referenced_Value) specificValue).getReference();
        final Assignment assignment = reference.getRefdAssignment(timestamp, true);
        if (assignment == null) {
            return true;
        }
        switch(assignment.getAssignmentType()) {
            case A_CONST:
            case A_TIMER:
            case A_EXT_CONST:
            case A_PAR_VAL:
            case A_PAR_VAL_IN:
            case A_PAR_VAL_OUT:
            case A_PAR_VAL_INOUT:
            case A_VAR:
            case A_FUNCTION_RVAL:
            case A_EXT_FUNCTION_RVAL:
            case A_MODULEPAR:
            case A_MODULEPAR_TEMPLATE:
                // runtime evaluation!
                return true;
            case A_TEMPLATE:
            case A_PAR_TEMP_IN:
            case A_PAR_TEMP_INOUT:
            case A_FUNCTION_RTEMP:
            case A_VAR_TEMPLATE:
                boolean result = true;
                final Restriction_type rt = ((Definition) assignment).getTemplateRestriction();
                if (TemplateRestriction.Restriction_type.TR_OMIT.equals(rt) || TemplateRestriction.Restriction_type.TR_PRESENT.equals(rt)) {
                    result = false;
                }
                final TTCN3Template ttemplate = getTemplateReferencedLast(timestamp);
                if ((!ttemplate.equals(this)) && (ttemplate.isValue(timestamp))) {
                    // ok
                    return result;
                } else {
                    return false;
                }
            default:
                return false;
        }
    }
    return true;
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Reference(org.eclipse.titan.designer.AST.Reference) Restriction_type(org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type) Function_Reference_Value(org.eclipse.titan.designer.AST.TTCN3.values.Function_Reference_Value) IType(org.eclipse.titan.designer.AST.IType)

Example 49 with Referenced_Value

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

the class Integer_Type method checkThisValueLimit.

/**
 * Checks if a given value is a valid integer limit.
 * <p>
 * The special float values infinity and -infinity are valid integer range limits too.
 *
 * @param timestamp the time stamp of the actual semantic check cycle.
 * @param value the value to be checked
 * @param expectedValue the kind of the value to be expected
 * @param incompleteAllowed true if an incomplete value can be accepted at the given location, false otherwise
 * @param omitAllowed true if the omit value can be accepted at the given location, false otherwise
 * @param subCheck true if the subtypes should also be checked.
 * @param implicitOmit true if the implicit omit optional attribute was set for the value, false otherwise
 */
public void checkThisValueLimit(final CompilationTimeStamp timestamp, final IValue value, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean omitAllowed, final boolean subCheck, final boolean implicitOmit) {
    super.checkThisValue(timestamp, value, null, new ValueCheckingOptions(expectedValue, incompleteAllowed, omitAllowed, subCheck, implicitOmit, false));
    final IValue last = value.getValueRefdLast(timestamp, expectedValue, null);
    if (last == null || last.getIsErroneous(timestamp)) {
        return;
    }
    // already handled ones
    switch(value.getValuetype()) {
        case OMIT_VALUE:
        case REFERENCED_VALUE:
            return;
        case UNDEFINED_LOWERIDENTIFIER_VALUE:
            if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
                return;
            }
            break;
        default:
            break;
    }
    switch(last.getValuetype()) {
        case INTEGER_VALUE:
            break;
        case REAL_VALUE:
            {
                final Real_Value real = (Real_Value) last;
                if (!real.isNegativeInfinity() && !real.isPositiveInfinity()) {
                    value.getLocation().reportSemanticError(INTEGERVALUEEXPECTED);
                    value.setIsErroneous(true);
                }
                break;
            }
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            value.getLocation().reportSemanticError(INTEGERVALUEEXPECTED);
            value.setIsErroneous(true);
    }
    if (subCheck) {
        // there is no parent type to check
        if (subType != null) {
            subType.checkThisValue(timestamp, last);
        }
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)40 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)22 Assignment (org.eclipse.titan.designer.AST.Assignment)17 Reference (org.eclipse.titan.designer.AST.Reference)15 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)13 IType (org.eclipse.titan.designer.AST.IType)11 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)10 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)9 ISubReference (org.eclipse.titan.designer.AST.ISubReference)7 TTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)6 Referenced_Template (org.eclipse.titan.designer.AST.TTCN3.templates.Referenced_Template)5 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)5 SequenceOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)5 Identifier (org.eclipse.titan.designer.AST.Identifier)4 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)4 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)4 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)4 Expression_Value (org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value)4 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)4 ReferenceChain (org.eclipse.titan.designer.AST.ReferenceChain)3