Search in sources :

Example 11 with Expression_Value

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

the class LogArgument method checkValue.

/**
 * Does the semantic checking of the log argument. Once it was
 * determined that it is a value.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param value
 *                the value contained in the log argument.
 */
private void checkValue(final CompilationTimeStamp timestamp, final IValue value) {
    final IValue temp = value.setLoweridToReference(timestamp);
    switch(temp.getValuetype()) {
        case CHARSTRING_VALUE:
            internalLogArgument = new String_InternalLogArgument(((Charstring_Value) temp).getValue());
            break;
        case REFERENCED_VALUE:
            final Reference reference = ((Referenced_Value) temp).getReference();
            internalLogArgument = new Reference_InternalLogArgument(reference);
            checkReference(timestamp, reference);
            return;
        case EXPRESSION_VALUE:
            final Expression_Value castedValue = (Expression_Value) temp;
            if (Operation_type.MATCH_OPERATION.equals(castedValue.getOperationType())) {
                internalLogArgument = new Match_InternalLogArgument((MatchExpression) castedValue);
            } else {
                internalLogArgument = new Value_InternalLogArgument(temp);
            }
            break;
        case MACRO_VALUE:
            internalLogArgument = new Macro_InternalLogArgument((Macro_Value) temp);
            break;
        default:
            internalLogArgument = new Value_InternalLogArgument(temp);
            break;
    }
    final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
    if (governor == null) {
        getLocation().reportSemanticError("Cannot determine the type of the argument");
        isErroneous = true;
        return;
    }
    // TODO: Is the next part necessary ???
    temp.setMyGovernor(governor);
    // TODO:WHY
    governor.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_TEMPLATE, true, true, true, true, false));
    final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    if (ArgumentType.Value.equals(internalLogArgument.getArgumentType()) && !temp.isUnfoldable(timestamp)) {
        final IValue last = temp.getValueRefdLast(timestamp, chain);
        if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
            internalLogArgument = new String_InternalLogArgument(((Charstring_Value) last).getValue());
        }
    } else if (ArgumentType.Macro.equals(internalLogArgument.getArgumentType())) {
        final IValue last = temp.getValueRefdLast(timestamp, chain);
        switch(last.getValuetype()) {
            case CHARSTRING_VALUE:
                internalLogArgument = new String_InternalLogArgument(((Charstring_Value) last).getValue());
                break;
            case MACRO_VALUE:
                break;
            default:
                internalLogArgument = new Value_InternalLogArgument(temp);
                break;
        }
    }
    chain.release();
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) Expression_Value(org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value) Macro_Value(org.eclipse.titan.designer.AST.TTCN3.values.Macro_Value) MatchExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.MatchExpression) IType(org.eclipse.titan.designer.AST.IType) IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)

Example 12 with Expression_Value

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

the class Anytype_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.ANYTYPE_VALUE);
            if (!last.getIsErroneous(timestamp)) {
                selfReference = checkThisValueAnytype(timestamp, (Anytype_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.str_elem);
            }
            break;
        case ANYTYPE_VALUE:
            selfReference = checkThisValueAnytype(timestamp, (Anytype_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.str_elem);
            break;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            value.getLocation().reportSemanticError(MessageFormat.format(ANYTYPEEXPECTED, getFullName()));
            value.setIsErroneous(true);
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Anytype_Value(org.eclipse.titan.designer.AST.TTCN3.values.Anytype_Value)

Example 13 with Expression_Value

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

the class Array_Type method checkThisValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
    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 SEQUENCEOF_VALUE:
            last = last.setValuetype(timestamp, Value_type.ARRAY_VALUE);
            selfReference = checkThisValueArray(timestamp, value, lhs, (Array_Value) last, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
            break;
        case ARRAY_VALUE:
            selfReference = checkThisValueArray(timestamp, value, lhs, (Array_Value) last, 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(ARRAYVALUEEXPECTED);
            value.setIsErroneous(true);
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : Array_Value(org.eclipse.titan.designer.AST.TTCN3.values.Array_Value) IValue(org.eclipse.titan.designer.AST.IValue)

Example 14 with Expression_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Expression_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 15 with Expression_Value

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

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)30 IType (org.eclipse.titan.designer.AST.IType)13 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)11 Expression_Value (org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value)11 Identifier (org.eclipse.titan.designer.AST.Identifier)5 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)5 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)5 Scope (org.eclipse.titan.designer.AST.Scope)4 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)4 SequenceOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)4 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)3 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)3 ReferenceChain (org.eclipse.titan.designer.AST.ReferenceChain)3 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)3 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)3 Referenced_Template (org.eclipse.titan.designer.AST.TTCN3.templates.Referenced_Template)3 Function_Type (org.eclipse.titan.designer.AST.TTCN3.types.Function_Type)3 Sequence_Value (org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value)3 Value_Assignment (org.eclipse.titan.designer.AST.ASN1.Value_Assignment)2 Named_Integer_Value (org.eclipse.titan.designer.AST.ASN1.values.Named_Integer_Value)2