Search in sources :

Example 1 with Def_Timer

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer in project titan.EclipsePlug-ins by eclipse.

the class SizeOfExpression 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.
 *
 * @return the size of the expression, or -1 in case of error
 */
private long checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    Expected_Value_type internalExpectedValue;
    if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
        internalExpectedValue = Expected_Value_type.EXPECTED_TEMPLATE;
    } else {
        internalExpectedValue = expectedValue;
    }
    ITTCN3Template template = templateInstance.getTemplateBody();
    template.setLoweridToReference(timestamp);
    template = template.getTemplateReferencedLast(timestamp, referenceChain);
    if (template.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return -1;
    }
    // Timer and port arrays are handled separately
    if (template.getTemplatetype() == Template_type.SPECIFIC_VALUE) {
        final SpecificValue_Template specValTempl = (SpecificValue_Template) template;
        IValue val = specValTempl.getSpecificValue();
        val.setMyGovernor(specValTempl.getMyGovernor());
        if (val.getValuetype() == Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE) {
            val = val.setLoweridToReference(timestamp);
        }
        if (val != null && val.getValuetype() == Value_type.REFERENCED_VALUE) {
            final Referenced_Value referencedValue = (Referenced_Value) val;
            final Reference ref = referencedValue.getReference();
            final Assignment temporalAss = ref.getRefdAssignment(timestamp, true);
            if (temporalAss != null) {
                final Assignment_type asstype = temporalAss.getAssignmentType();
                ArrayDimensions dimensions;
                if (asstype == Assignment_type.A_PORT) {
                    dimensions = ((Def_Port) temporalAss).getDimensions();
                    return checkTimerPort(timestamp, ref, dimensions, temporalAss);
                } else if (asstype == Assignment_type.A_TIMER) {
                    dimensions = ((Def_Timer) temporalAss).getDimensions();
                    return checkTimerPort(timestamp, ref, dimensions, temporalAss);
                }
            }
        }
    }
    IType governor = templateInstance.getExpressionGovernor(timestamp, internalExpectedValue);
    if (governor == null) {
        final ITTCN3Template templ = template.setLoweridToReference(timestamp);
        governor = templ.getExpressionGovernor(timestamp, internalExpectedValue);
    }
    if (governor == null) {
        if (!template.getIsErroneous(timestamp)) {
            templateInstance.getLocation().reportSemanticError("Cannot determine the type of the argument in the `sizeof' operation. If type is known, use valueof(<type>: ...) as argument.");
        }
        setIsErroneous(true);
        return -1;
    }
    IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance, governor, referenceChain, internalExpectedValue);
    if (isErroneous) {
        return -1;
    }
    IType type = governor.getTypeRefdLast(timestamp);
    switch(type.getTypetype()) {
        case TYPE_SEQUENCE_OF:
        case TYPE_SET_OF:
        case TYPE_TTCN3_SEQUENCE:
        case TYPE_TTCN3_SET:
        case TYPE_ASN1_SEQUENCE:
        case TYPE_ASN1_SET:
        case TYPE_ARRAY:
        case TYPE_OBJECTID:
        case TYPE_ROID:
        case TYPE_UNDEFINED:
            break;
        default:
            templateInstance.getLocation().reportSemanticError("Reference to a value or template of type record, record of, set, set of, objid or array was expected");
            setIsErroneous(true);
            return -1;
    }
    IValue value = null;
    Reference reference = null;
    Assignment assignment = null;
    List<ISubReference> subreferences = null;
    switch(template.getTemplatetype()) {
        case INDEXED_TEMPLATE_LIST:
            return -1;
        case TEMPLATE_REFD:
            reference = ((Referenced_Template) template).getReference();
            assignment = reference.getRefdAssignment(timestamp, false);
            subreferences = reference.getSubreferences();
            break;
        case TEMPLATE_LIST:
        case NAMED_TEMPLATE_LIST:
        case SUBSET_MATCH:
        case SUPERSET_MATCH:
            // compute later
            break;
        case SPECIFIC_VALUE:
            value = ((SpecificValue_Template) template).getSpecificValue().getValueRefdLast(timestamp, referenceChain);
            if (value != null) {
                switch(value.getValuetype()) {
                    case SEQUENCEOF_VALUE:
                    case SETOF_VALUE:
                    case ARRAY_VALUE:
                    case RELATIVEOBJECTIDENTIFIER_VALUE:
                    case OBJECTID_VALUE:
                    case SEQUENCE_VALUE:
                    case SET_VALUE:
                        break;
                    case REFERENCED_VALUE:
                        {
                            reference = ((Referenced_Value) value).getReference();
                            assignment = reference.getRefdAssignment(timestamp, false);
                            subreferences = reference.getSubreferences();
                            break;
                        }
                    default:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("`sizeof'' operation is not applicable to `{0}''", value.createStringRepresentation()));
                        setIsErroneous(true);
                        return -1;
                }
            }
            break;
        default:
            templateInstance.getLocation().reportSemanticError(MessageFormat.format("`sizeof'' operation is not applicable to {0}", template.getTemplateTypeName()));
            setIsErroneous(true);
            return -1;
    }
    if (assignment != null) {
        if (assignment.getIsErroneous()) {
            setIsErroneous(true);
            return -1;
        }
        switch(assignment.getAssignmentType()) {
            case A_CONST:
                value = ((Def_Const) assignment).getValue();
                break;
            case A_EXT_CONST:
            case A_MODULEPAR:
            case A_MODULEPAR_TEMPLATE:
                if (Expected_Value_type.EXPECTED_CONSTANT.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to an (evaluable) constant value was expected instead of {0}", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_VAR:
            case A_PAR_VAL:
            case A_PAR_VAL_IN:
            case A_PAR_VAL_OUT:
            case A_PAR_VAL_INOUT:
                switch(internalExpectedValue) {
                    case EXPECTED_CONSTANT:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a constant value was expected instead of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    case EXPECTED_STATIC_VALUE:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a static value was expected instead of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    default:
                        break;
                }
                break;
            case A_TEMPLATE:
                template = ((Def_Template) assignment).getTemplate(timestamp);
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a value was expected instead of {0}", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_VAR_TEMPLATE:
            case A_PAR_TEMP_IN:
            case A_PAR_TEMP_OUT:
            case A_PAR_TEMP_INOUT:
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a value was expected instead of {0}", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_FUNCTION_RVAL:
            case A_EXT_FUNCTION_RVAL:
                switch(internalExpectedValue) {
                    case EXPECTED_CONSTANT:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a constant value was expected instead of the return value of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    case EXPECTED_STATIC_VALUE:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a static value was expected instead of the return value of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    default:
                        break;
                }
                break;
            case A_FUNCTION_RTEMP:
            case A_EXT_FUNCTION_RTEMP:
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a value was expected instead of a call of {0}, which returns a template", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_TIMER:
            case A_PORT:
                // were already checked separately.
                break;
            default:
                templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a {0} was expected instead of {1}", Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue) ? "value or template" : "value", assignment.getDescription()));
                setIsErroneous(true);
                return -1;
        }
        type = assignment.getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
        if (type == null || type.getIsErroneous(timestamp)) {
            setIsErroneous(true);
            return -1;
        }
        type = type.getTypeRefdLast(timestamp);
        switch(type.getTypetype()) {
            case TYPE_SEQUENCE_OF:
            case TYPE_SET_OF:
            case TYPE_TTCN3_SEQUENCE:
            case TYPE_TTCN3_SET:
            case TYPE_ASN1_SEQUENCE:
            case TYPE_ASN1_SET:
            case TYPE_ARRAY:
            case TYPE_OBJECTID:
            case TYPE_ROID:
            case TYPE_UNDEFINED:
                break;
            default:
                templateInstance.getLocation().reportSemanticError("Reference to a value or template of type record, record of, set, set of, objid or array was expected");
                setIsErroneous(true);
                return -1;
        }
    }
    // check for index overflows in subrefs if possible
    if (value != null) {
        switch(value.getValuetype()) {
            case SEQUENCEOF_VALUE:
                if (((SequenceOf_Value) value).isIndexed()) {
                    return -1;
                }
                break;
            case SETOF_VALUE:
                if (((SetOf_Value) value).isIndexed()) {
                    return -1;
                }
                break;
            case ARRAY_VALUE:
                if (((Array_Value) value).isIndexed()) {
                    return -1;
                }
                break;
            default:
                break;
        }
        /* The reference points to a constant.  */
        if (subreferences != null && !reference.hasUnfoldableIndexSubReference(timestamp)) {
            value = value.getReferencedSubValue(timestamp, reference, 1, referenceChain);
            if (value == null) {
                setIsErroneous(true);
                return -1;
            }
            value = value.getValueRefdLast(timestamp, referenceChain);
        } else {
            // stop processing
            value = null;
        }
    } else if (template != null) {
        /* The size of INDEXED_TEMPLATE_LIST nodes is unknown at compile
		         time.  Don't try to evaluate it at compile time.  */
        if (reference != null && reference.hasUnfoldableIndexSubReference(timestamp)) {
            return -1;
        }
        if (reference != null && subreferences != null) {
            template = template.getReferencedSubTemplate(timestamp, reference, referenceChain);
            if (template == null) {
                setIsErroneous(true);
                return -1;
            }
            template = template.getTemplateReferencedLast(timestamp);
        }
    }
    if (template != null) {
        if (template.getIsErroneous(timestamp)) {
            setIsErroneous(true);
            return -1;
        }
        switch(template.getTemplatetype()) {
            case TEMPLATE_REFD:
                template = null;
                break;
            case SPECIFIC_VALUE:
                value = ((SpecificValue_Template) template).getSpecificValue().getValueRefdLast(timestamp, referenceChain);
                template = null;
                break;
            case TEMPLATE_LIST:
            case NAMED_TEMPLATE_LIST:
            case SUBSET_MATCH:
            case SUPERSET_MATCH:
                break;
            default:
                // FIXME this can not happen
                templateInstance.getLocation().reportSemanticError(MessageFormat.format("`sizeof'' operation is not applicable to {0}", template.getTemplateTypeName()));
                setIsErroneous(true);
                return -1;
        }
    }
    if (value != null) {
        switch(value.getValuetype()) {
            case SEQUENCEOF_VALUE:
            case SETOF_VALUE:
            case ARRAY_VALUE:
            case RELATIVEOBJECTIDENTIFIER_VALUE:
            case OBJECTID_VALUE:
            case SEQUENCE_VALUE:
            case SET_VALUE:
                break;
            default:
                value = null;
                return -1;
        }
    }
    /* evaluation */
    if (Type_type.TYPE_ARRAY.equals(type.getTypetype())) {
        return ((Array_Type) type).getDimension().getSize();
    } else if (template != null) {
        return evaluateTemplate(template, timestamp);
    } else if (value != null) {
        return evaluateValue(value);
    } else {
        return -1;
    }
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Assignment_type(org.eclipse.titan.designer.AST.Assignment.Assignment_type) Array_Value(org.eclipse.titan.designer.AST.TTCN3.values.Array_Value) ISubReference(org.eclipse.titan.designer.AST.ISubReference) Reference(org.eclipse.titan.designer.AST.Reference) Def_Timer(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value) SetOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value) IType(org.eclipse.titan.designer.AST.IType) Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) IValue(org.eclipse.titan.designer.AST.IValue) ArrayDimensions(org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimensions) Expected_Value_type(org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)

Example 2 with Def_Timer

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer in project titan.EclipsePlug-ins by eclipse.

the class TimerRunningExpression 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 (reference == null) {
        return;
    }
    final Assignment assignment = reference.getRefdAssignment(timestamp, true);
    if (assignment == null) {
        setIsErroneous(true);
        return;
    }
    switch(assignment.getAssignmentType()) {
        case A_TIMER:
            {
                final ArrayDimensions dimensions = ((Def_Timer) assignment).getDimensions();
                if (dimensions != null) {
                    dimensions.checkIndices(timestamp, reference, "timer", false, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
                } else if (reference.getSubreferences().size() > 1) {
                    reference.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR, assignment.getIdentifier().getDisplayName()));
                }
                break;
            }
        case A_PAR_TIMER:
            if (reference.getSubreferences().size() > 1) {
                reference.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR, assignment.getIdentifier().getDisplayName()));
            }
            break;
        default:
            reference.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR2, assignment.getDescription()));
            setIsErroneous(true);
            break;
    }
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ArrayDimensions(org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimensions)

Example 3 with Def_Timer

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer in project titan.EclipsePlug-ins by eclipse.

the class FormalParameter method checkActualParameterTimer.

/**
 * Checks if the actual parameter paired with this formal parameter is
 * semantically correct as a timer parameter.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param actualParameter
 *                the template instance assigned as actual parameter to
 *                this formal parameter
 * @param expectedValue
 *                the value kind expected from the actual parameter.
 *
 * @return the actual parameter created from the value, or null if there
 *         was an error.
 */
private ActualParameter checkActualParameterTimer(final CompilationTimeStamp timestamp, final TemplateInstance actualParameter, final Expected_Value_type expectedValue) {
    final IType parameterType = actualParameter.getType();
    if (parameterType != null) {
        actualParameter.getLocation().reportSemanticError(EXPLICITESPECIFICATIONFORTIMER);
        actualParameter.checkType(timestamp, null);
    }
    final Reference derivedReference = actualParameter.getDerivedReference();
    if (derivedReference != null) {
        derivedReference.getLocation().reportSemanticError(INLINETEMPLATEFORTIMER);
        actualParameter.checkDerivedReference(timestamp, null);
    }
    final ITTCN3Template template = actualParameter.getTemplateBody();
    if (Template_type.SPECIFIC_VALUE.equals(template.getTemplatetype()) && ((SpecificValue_Template) template).isReference()) {
        final Reference reference = ((SpecificValue_Template) template).getReference();
        final Assignment assignment = reference.getRefdAssignment(timestamp, true, null);
        if (assignment == null) {
            final ActualParameter temp = new Value_ActualParameter(null);
            temp.setIsErroneous();
            return temp;
        }
        switch(assignment.getAssignmentType()) {
            case A_TIMER:
                final ArrayDimensions dimensions = ((Def_Timer) assignment).getDimensions();
                if (dimensions != null) {
                    dimensions.checkIndices(timestamp, reference, "timer", false, expectedValue);
                } else if (reference.getSubreferences().size() > 1) {
                    reference.getLocation().reportSemanticError(MessageFormat.format(SUBREFERENCEERROR1, assignment.getDescription()));
                }
                break;
            case A_PAR_TIMER:
                if (reference.getSubreferences().size() > 1) {
                    reference.getLocation().reportSemanticError(MessageFormat.format(SUBREFERENCEERROR2, assignment.getDescription()));
                }
                break;
            default:
                reference.getLocation().reportSemanticError(MessageFormat.format(TIMEREXPECTED1, assignment.getAssignmentName()));
                break;
        }
        return new Referenced_ActualParameter(reference);
    }
    actualParameter.getLocation().reportSemanticError(TIMEREXPECTED2);
    final ActualParameter temp = new Value_ActualParameter(null);
    temp.setIsErroneous();
    return temp;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Assignment(org.eclipse.titan.designer.AST.Assignment) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ArrayDimensions(org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimensions) IType(org.eclipse.titan.designer.AST.IType)

Example 4 with Def_Timer

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer 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)

Example 5 with Def_Timer

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer in project titan.EclipsePlug-ins by eclipse.

the class LogArgument method checkReference.

/**
 * Does the semantic checking of the log argument. Once it was
 * determined that it is a reference.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param reference
 *                the reference contained in the log argument.
 */
private void checkReference(final CompilationTimeStamp timestamp, final Reference reference) {
    if (reference == null) {
        return;
    }
    final Assignment assignment = reference.getRefdAssignment(timestamp, true);
    if (assignment == null || assignment.getIsErroneous()) {
        return;
    }
    switch(assignment.getAssignmentType()) {
        case A_FUNCTION_RVAL:
        case A_FUNCTION_RTEMP:
        case A_EXT_FUNCTION_RVAL:
        case A_EXT_FUNCTION_RTEMP:
            {
                reference.getMyScope().checkRunsOnScope(timestamp, assignment, reference, "call");
                final IType assingmentType = assignment.getType(timestamp);
                if (assingmentType != null) {
                    assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                }
                break;
            }
        case A_CONST:
            {
                final IType assingmentType = assignment.getType(timestamp);
                if (assingmentType != null && assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false) != null) {
                    final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                    if (assignment instanceof Def_Const) {
                        ((Def_Const) assignment).getValue().getReferencedSubValue(timestamp, reference, 1, chain);
                    } else {
                        ((Value_Assignment) assignment).getValue().getReferencedSubValue(timestamp, reference, 1, chain);
                    }
                    chain.release();
                }
                break;
            }
        case A_TEMPLATE:
            {
                final IType assingmentType = assignment.getType(timestamp);
                if (assingmentType != null && assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false) != null) {
                    final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                    ((Def_Template) assignment).getTemplate(timestamp).getReferencedSubTemplate(timestamp, reference, chain);
                    chain.release();
                }
                break;
            }
        case A_MODULEPAR_TEMPLATE:
            {
                final IType assingmentType = assignment.getType(timestamp);
                if (assingmentType != null) {
                    assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                }
                break;
            }
        case A_EXT_CONST:
        case A_MODULEPAR:
        case A_VAR:
        case A_VAR_TEMPLATE:
        case A_PAR_VAL:
        case A_PAR_VAL_IN:
        case A_PAR_VAL_OUT:
        case A_PAR_VAL_INOUT:
        case A_PAR_TEMP_IN:
        case A_PAR_TEMP_OUT:
        case A_PAR_TEMP_INOUT:
            {
                final IType assingmentType = assignment.getType(timestamp);
                if (assingmentType != null) {
                    assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                }
                break;
            }
        case A_PORT:
            {
                final ArrayDimensions dimensions = ((Def_Port) assignment).getDimensions();
                if (dimensions != null) {
                    dimensions.checkIndices(timestamp, reference, assignment.getAssignmentName(), true, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
                } else if (reference.getSubreferences().size() > 1) {
                    getLocation().reportSemanticError(MessageFormat.format("Reference to single {0} cannot have field or array sub-references", assignment.getDescription()));
                    isErroneous = true;
                }
                break;
            }
        case A_TIMER:
            {
                final ArrayDimensions dimensions = ((Def_Timer) assignment).getDimensions();
                if (dimensions != null) {
                    dimensions.checkIndices(timestamp, reference, assignment.getAssignmentName(), true, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
                } else if (reference.getSubreferences().size() > 1) {
                    getLocation().reportSemanticError(MessageFormat.format("Reference to single {0} cannot have field or array sub-references", assignment.getDescription()));
                    isErroneous = true;
                }
                break;
            }
        case A_PAR_TIMER:
        case A_PAR_PORT:
            if (reference.getSubreferences().size() > 1) {
                getLocation().reportSemanticError(MessageFormat.format("Reference to {0} cannot have field or array sub-references", assignment.getDescription()));
                isErroneous = true;
            }
            break;
        case A_FUNCTION:
        case A_EXT_FUNCTION:
            getLocation().reportSemanticError(MessageFormat.format("Reference to a value, template, timer or port was ecpected instead of a call of {0}, which does not have a return type", assignment.getDescription()));
            isErroneous = true;
            break;
        default:
            getLocation().reportSemanticError(MessageFormat.format("Reference to a value, template, timer or port was expected instead of {0}", assignment.getDescription()));
            isErroneous = true;
            break;
    }
}
Also used : Value_Assignment(org.eclipse.titan.designer.AST.ASN1.Value_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) Value_Assignment(org.eclipse.titan.designer.AST.ASN1.Value_Assignment) Def_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) ArrayDimensions(org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimensions) Def_Const(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

Assignment (org.eclipse.titan.designer.AST.Assignment)6 ArrayDimensions (org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimensions)5 Def_Timer (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer)4 IType (org.eclipse.titan.designer.AST.IType)3 ISubReference (org.eclipse.titan.designer.AST.ISubReference)2 IValue (org.eclipse.titan.designer.AST.IValue)2 Reference (org.eclipse.titan.designer.AST.Reference)2 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)2 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)2 Value_Assignment (org.eclipse.titan.designer.AST.ASN1.Value_Assignment)1 Assignment_type (org.eclipse.titan.designer.AST.Assignment.Assignment_type)1 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)1 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)1 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)1 Def_Const (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const)1 Def_Template (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template)1 Array_Value (org.eclipse.titan.designer.AST.TTCN3.values.Array_Value)1 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)1 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)1 SequenceOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)1