Search in sources :

Example 91 with IValue

use of org.eclipse.titan.designer.AST.IValue in project titan.EclipsePlug-ins by eclipse.

the class Expression_Value method getReferencedSubValue.

@Override
public final /**
 * {@inheritDoc}
 */
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return this;
    }
    IValue result = getValueRefdLast(timestamp, refChain);
    if (result != null && result != this) {
        result = result.getReferencedSubValue(timestamp, reference, actualSubReference, refChain);
        if (result != null && result.getIsErroneous(timestamp)) {
            setIsErroneous(true);
        }
    }
    return this;
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) IValue(org.eclipse.titan.designer.AST.IValue)

Example 92 with IValue

use of org.eclipse.titan.designer.AST.IValue in project titan.EclipsePlug-ins by eclipse.

the class ComponentRunnningExpression 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) {
    final IValue tempValue = value.setLoweridToReference(timestamp);
    Component_Type.checkExpressionOperandComponentRefernce(timestamp, tempValue, OPERATIONNAME);
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, false, true, false);
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue)

Example 93 with IValue

use of org.eclipse.titan.designer.AST.IValue in project titan.EclipsePlug-ins by eclipse.

the class DecvalueUnicharExpression method checkExpressionOperand3.

/**
 * Checks the 3rd operand
 * in charstring (optional)
 * @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 checkExpressionOperand3(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (value3 == null) {
        return;
    }
    value3.setLoweridToReference(timestamp);
    final Type_type tempType = value3.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_CHARSTRING:
            final IValue last = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                final String originalString = ((Charstring_Value) last).getValue();
                final CharstringExtractor cs = new CharstringExtractor(originalString);
                if (cs.isErrorneous()) {
                    value3.getLocation().reportSemanticError(cs.getErrorMessage());
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERAND3_ERROR1);
                setIsErroneous(true);
            }
            break;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) CharstringExtractor(org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)

Example 94 with IValue

use of org.eclipse.titan.designer.AST.IValue in project titan.EclipsePlug-ins by eclipse.

the class EncodeBase64Expression 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 (value == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp)) {
        return lastValue;
    }
    if (isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    final IValue last = value.getValueRefdLast(timestamp, referenceChain);
    if (last.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return lastValue;
    }
    switch(last.getValuetype()) {
        case OCTETSTRING_VALUE:
            {
                final String octetString = ((Octetstring_Value) last).getValue();
                lastValue = new Charstring_Value(calculateValue(octetString));
                lastValue.copyGeneralProperties(this);
                break;
            }
        default:
            setIsErroneous(true);
            break;
    }
    return lastValue;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)

Example 95 with IValue

use of org.eclipse.titan.designer.AST.IValue in project titan.EclipsePlug-ins by eclipse.

the class Enum2IntExpression 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 (value == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp)) {
        return lastValue;
    }
    if (isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    final IValue last = value.getValueRefdLast(timestamp, referenceChain);
    if (last == null || last.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return lastValue;
    }
    IType type = last.getExpressionGovernor(timestamp, expectedValue);
    type = type.getTypeRefdLast(timestamp);
    switch(type.getTypetype()) {
        case TYPE_ASN1_ENUMERATED:
            {
                final EnumItem item = ((ASN1_Enumerated_Type) type).getEnumItemWithName(((Enumerated_Value) last).getValue());
                lastValue = new Integer_Value(((Integer_Value) item.getValue()).getValue());
                lastValue.copyGeneralProperties(this);
                break;
            }
        case TYPE_TTCN3_ENUMERATED:
            {
                final EnumItem item = ((TTCN3_Enumerated_Type) type).getEnumItemWithName(((Enumerated_Value) last).getValue());
                lastValue = new Integer_Value(((Integer_Value) item.getValue()).getValue());
                lastValue.copyGeneralProperties(this);
                break;
            }
        default:
            setIsErroneous(true);
            break;
    }
    return lastValue;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) EnumItem(org.eclipse.titan.designer.AST.TTCN3.types.EnumItem) Enumerated_Value(org.eclipse.titan.designer.AST.TTCN3.values.Enumerated_Value) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)431 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)105 IType (org.eclipse.titan.designer.AST.IType)97 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)79 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)78 ISubReference (org.eclipse.titan.designer.AST.ISubReference)49 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)41 Value (org.eclipse.titan.designer.AST.Value)35 Identifier (org.eclipse.titan.designer.AST.Identifier)34 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)33 Assignment (org.eclipse.titan.designer.AST.Assignment)30 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)28 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)26 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)25 Reference (org.eclipse.titan.designer.AST.Reference)25 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)23 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)22 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)22 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)21 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)21