Search in sources :

Example 11 with Undefined_LowerIdentifier_Value

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

the class Signature_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:
            selfReference = checkThisValueSequence(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            break;
        case SEQUENCEOF_VALUE:
            last = last.setValuetype(timestamp, Value_type.SEQUENCE_VALUE);
            selfReference = checkThisValueSequence(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            break;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            value.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREEXPECTED, getTypename()));
            value.setIsErroneous(true);
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Sequence_Value(org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value)

Example 12 with Undefined_LowerIdentifier_Value

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

the class TTCN3_Choice_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:
            if (value.isAsn()) {
                value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
                value.setIsErroneous(true);
            } else {
                last = last.setValuetype(timestamp, Value_type.CHOICE_VALUE);
                if (!last.getIsErroneous(timestamp)) {
                    selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.str_elem);
                }
            }
            break;
        case CHOICE_VALUE:
            selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.str_elem);
            break;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            if (value.isAsn()) {
                value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
            } else {
                value.getLocation().reportSemanticError(MessageFormat.format(UNIONEXPECTED, 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) Choice_Value(org.eclipse.titan.designer.AST.TTCN3.values.Choice_Value)

Example 13 with Undefined_LowerIdentifier_Value

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

the class TTCN3_Sequence_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:
            if (last.isAsn()) {
                selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            } else {
                selfReference = checkThisValueSeq(timestamp, (Sequence_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 record type `{0}''", getFullName()));
                value.setIsErroneous(true);
            } else {
                last = last.setValuetype(timestamp, Value_type.SEQUENCE_VALUE);
                if (last.isAsn()) {
                    selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
                } else {
                    selfReference = checkThisValueSeq(timestamp, (Sequence_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.SEQUENCE_VALUE);
            selfReference = checkThisValueSeq(timestamp, (Sequence_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(SEQUANCEEPECTED, 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) Sequence_Value(org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)

Example 14 with Undefined_LowerIdentifier_Value

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

the class SetOf_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;
    }
    if (Value_type.UNDEFINED_BLOCK.equals(last.getValuetype())) {
        last = last.setValuetype(timestamp, Value_type.SETOF_VALUE);
    }
    if (last.getIsErroneous(timestamp)) {
        return selfReference;
    }
    switch(last.getValuetype()) {
        case SEQUENCEOF_VALUE:
            last = last.setValuetype(timestamp, Value_type.SETOF_VALUE);
            selfReference = checkThisValueSetOf(timestamp, (SetOf_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            break;
        case SETOF_VALUE:
            selfReference = checkThisValueSetOf(timestamp, (SetOf_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            break;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            if (value.isAsn()) {
                value.getLocation().reportSemanticError(SETOFVALUEEXPECTED1);
            } else {
                value.getLocation().reportSemanticError(SETOFVALUEEXPECTED2);
            }
            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) SetOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)

Example 15 with Undefined_LowerIdentifier_Value

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

the class Function_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;
    }
    Assignment assignment = null;
    switch(last.getValuetype()) {
        case FUNCTION_REFERENCE_VALUE:
            assignment = ((Function_Reference_Value) last).getReferredFunction();
            if (assignment == null) {
                value.setIsErroneous(true);
                return selfReference;
            }
            assignment.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(FUNCTIONREFERENCEVALUEEXPECTED);
            value.setIsErroneous(true);
            return selfReference;
    }
    // external functions do not have runs on clauses
    if (assignment instanceof Def_Function) {
        formalParList.checkCompatibility(timestamp, ((Def_Function) assignment).getFormalParameterList(), value.getLocation());
        final IType tempRunsOnType = ((Def_Function) assignment).getRunsOnType(timestamp);
        if (tempRunsOnType != null) {
            if (runsOnSelf) {
                // check against the runs on component type of the scope of the value
                final Scope valueScope = value.getMyScope();
                if (valueScope == null) {
                    value.setIsErroneous(true);
                    value.setLastTimeChecked(timestamp);
                    return selfReference;
                }
                final RunsOnScope runsOnScope = valueScope.getScopeRunsOn();
                if (runsOnScope != null) {
                    final Component_Type componentType = runsOnScope.getComponentType();
                    if (!tempRunsOnType.isCompatible(timestamp, componentType, null, null, null)) {
                        value.getLocation().reportSemanticError(MessageFormat.format("Runs on clause mismatch: type `{0}'' has a `runs on self'' clause and the current scope expects " + "component type `{1}'', but {2} runs on `{3}''", getTypename(), componentType.getTypename(), assignment.getDescription(), tempRunsOnType.getTypename()));
                    }
                } else {
                    // compatibility using this component type as the scope
                    if (valueScope instanceof ComponentTypeBody) {
                        final ComponentTypeBody body = (ComponentTypeBody) valueScope;
                        if (!tempRunsOnType.isCompatible(timestamp, body.getMyType(), null, null, null)) {
                            value.getLocation().reportSemanticError(MessageFormat.format("Runs on clause mismatch: type `{0}'' has a `runs on self'' clause and the current component definition " + "is of type `{1}'', but {2} runs on `{3}''", getTypename(), body.getMyType().getTypename(), assignment.getDescription(), tempRunsOnType.getTypename()));
                        }
                    } else {
                        value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' has a `runs on self'' " + "clause and the current scope does not have a `runs on'' clause, but {1} runs on `{2}''", getTypename(), assignment.getDescription(), tempRunsOnType.getTypename()));
                    }
                }
            } else {
                if (runsOnRef == null) {
                    value.getLocation().reportSemanticError(MessageFormat.format(RUNSONLESSEXPECTED, getTypename(), assignment.getAssignmentName(), tempRunsOnType.getTypename()));
                    value.setIsErroneous(true);
                } else {
                    if (runsOnType != null && !tempRunsOnType.isCompatible(timestamp, runsOnType, null, null, null)) {
                        value.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLERUNSONTYPESERROR, getTypename(), runsOnType.getTypename(), assignment.getAssignmentName(), tempRunsOnType.getTypename()));
                        value.setIsErroneous(true);
                    }
                }
            }
        }
    }
    switch(assignment.getAssignmentType()) {
        case A_FUNCTION:
        case A_EXT_FUNCTION:
            if (returnType != null) {
                value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' expects a function or external function that returns a {1} of type `{2}'', but {3} does not have a return type", getTypename(), returnsTemplate ? "template" : "value", returnType.getTypename(), assignment.getDescription()));
            }
            break;
        case A_FUNCTION_RTEMP:
            {
                final Restriction_type restriction = ((Def_Function) assignment).getTemplateRestriction();
                if (!templateRestriction.equals(restriction)) {
                    value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' expects a function or external function that returns a template with {1} restriction, " + "but {2} returns a template with {3} restriction", getTypename(), Restriction_type.TR_NONE.equals(templateRestriction) ? "no" : templateRestriction.getDisplayName(), assignment.getDescription(), Restriction_type.TR_NONE.equals(restriction) ? "no" : restriction.getDisplayName()));
                }
                if (returnType != null) {
                    final IType tempReturnType = assignment.getType(timestamp);
                    if (!returnType.isIdentical(timestamp, tempReturnType)) {
                        value.getLocation().reportSemanticError(MessageFormat.format("Return type mismatch: type `{0}'' expects a function or external function that returns a {1} of type `{2}'', " + "but {3} returns a template of type `{3}''", getTypename(), returnsTemplate ? "template" : "value", returnType.getTypename(), assignment.getDescription(), tempReturnType.getTypename()));
                    } else if (!returnsTemplate) {
                        value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' expects a function or external function that returns a value of type `{1}'', but {2} returns a template", getTypename(), returnType.getTypename(), assignment.getDescription()));
                    }
                } else {
                    value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' expects a function or external function without return type, but {1} returns a template of type `{2}''", getTypename(), assignment.getDescription(), assignment.getType(timestamp).getTypename()));
                }
                break;
            }
        case A_EXT_FUNCTION_RTEMP:
            {
                final Restriction_type restriction = ((Def_Extfunction) assignment).getTemplateRestriction();
                if (!templateRestriction.equals(restriction)) {
                    value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' expects a function or external function that returns a template with {1} restriction, " + "but {2} returns a template with {3} restriction", getTypename(), Restriction_type.TR_NONE.equals(templateRestriction) ? "no" : templateRestriction.getDisplayName(), assignment.getDescription(), Restriction_type.TR_NONE.equals(restriction) ? "no" : restriction.getDisplayName()));
                }
                if (returnType != null) {
                    final IType tempReturnType = assignment.getType(timestamp);
                    if (!returnType.isIdentical(timestamp, tempReturnType)) {
                        value.getLocation().reportSemanticError(MessageFormat.format("Return type mismatch: type `{0}'' expects a function or external function that returns a {1} of type `{2}'', " + "but {3} returns a template of type `{3}''", getTypename(), returnsTemplate ? "template" : "value", returnType.getTypename(), assignment.getDescription(), tempReturnType.getTypename()));
                    } else if (!returnsTemplate) {
                        value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' expects a function or external function that returns a value of type `{1}'', but {2} returns a template", getTypename(), returnType.getTypename(), assignment.getDescription()));
                    }
                } else {
                    value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' expects a function or external function without return type, but {1} returns a template of type `{2}''", getTypename(), assignment.getDescription(), assignment.getType(timestamp).getTypename()));
                }
                break;
            }
        case A_FUNCTION_RVAL:
        case A_EXT_FUNCTION_RVAL:
            if (returnType != null) {
                final IType tempReturnType = assignment.getType(timestamp);
                if (!returnType.isIdentical(timestamp, tempReturnType)) {
                    value.getLocation().reportSemanticError(MessageFormat.format("Return type mismatch: type `{0}'' expects a function or external function that returns a {1} of type `{2}''," + " but {3} returns a value of type `{3}''", getTypename(), returnsTemplate ? "template" : "value", returnType.getTypename(), assignment.getDescription(), tempReturnType.getTypename()));
                } else if (returnsTemplate) {
                    value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' expects a function or external function that returns a template of type `{1}'', but {2} returns a value", getTypename(), returnType.getTypename(), assignment.getDescription()));
                }
            } else {
                value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' expects a function or external function without return type, but {1} returns a value of type `{2}''", getTypename(), assignment.getDescription(), assignment.getType(timestamp).getTypename()));
            }
            break;
        default:
            break;
    }
    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 : Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) Scope(org.eclipse.titan.designer.AST.Scope) RunsOnScope(org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope) Restriction_type(org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function) IType(org.eclipse.titan.designer.AST.IType) RunsOnScope(org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)25 Undefined_LowerIdentifier_Value (org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)9 Identifier (org.eclipse.titan.designer.AST.Identifier)7 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)6 IType (org.eclipse.titan.designer.AST.IType)5 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)5 SequenceOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)5 Scope (org.eclipse.titan.designer.AST.Scope)4 ReferenceChain (org.eclipse.titan.designer.AST.ReferenceChain)3 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)3 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)3 Sequence_Value (org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value)3 Named_Integer_Value (org.eclipse.titan.designer.AST.ASN1.values.Named_Integer_Value)2 Undefined_Block_Value (org.eclipse.titan.designer.AST.ASN1.values.Undefined_Block_Value)2 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)2 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)2 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)2 Module (org.eclipse.titan.designer.AST.Module)2 Reference (org.eclipse.titan.designer.AST.Reference)2 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)2