Search in sources :

Example 1 with Anytype_Value

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

the class IsChoosenExpression method evaluateValue.

@Override
public /**
 * {@inheritDoc}
 */
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return lastValue;
    }
    isErroneous = false;
    lastTimeChecked = timestamp;
    lastValue = this;
    if (reference == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp)) {
        return lastValue;
    }
    if (value == null) {
        return lastValue;
    }
    if (isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    IValue last = value.getValueRefdLast(timestamp, referenceChain);
    boolean result;
    switch(last.getValuetype()) {
        case CHOICE_VALUE:
            result = ((Choice_Value) last).fieldIsChosen(identifier);
            break;
        case SEQUENCE_VALUE:
            last = last.setValuetype(timestamp, Value_type.CHOICE_VALUE);
            result = ((Choice_Value) last).fieldIsChosen(identifier);
            break;
        case ANYTYPE_VALUE:
            result = ((Anytype_Value) last).fieldIsChosen(timestamp, identifier);
            break;
        default:
            setIsErroneous(true);
            return last;
    }
    lastValue = new Boolean_Value(result);
    lastValue.copyGeneralProperties(this);
    return lastValue;
}
Also used : Boolean_Value(org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value) IValue(org.eclipse.titan.designer.AST.IValue)

Example 2 with Anytype_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Anytype_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 3 with Anytype_Value

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

the class Anytype_Type method checkThisValueAnytype.

private boolean checkThisValueAnytype(final CompilationTimeStamp timestamp, final Anytype_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean strElem) {
    boolean selfReference = false;
    final Identifier name = value.getName();
    if (!hasComponentWithName(name.getName())) {
        value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTUNION, name.getDisplayName(), getFullName()));
        setIsErroneous(true);
        return selfReference;
    }
    final Type alternativeType = getComponentByName(name.getName()).getType();
    IValue alternativeValue = value.getValue();
    alternativeValue.setMyGovernor(alternativeType);
    alternativeValue = alternativeType.checkThisValueRef(timestamp, alternativeValue);
    selfReference = alternativeType.checkThisValue(timestamp, alternativeValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, false, true, false, strElem));
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : Attribute_Type(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) IValue(org.eclipse.titan.designer.AST.IValue)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)3 IType (org.eclipse.titan.designer.AST.IType)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1 Attribute_Type (org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type)1 Anytype_Value (org.eclipse.titan.designer.AST.TTCN3.values.Anytype_Value)1 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)1 Type (org.eclipse.titan.designer.AST.Type)1