Search in sources :

Example 66 with Expected_Value_type

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

the class EqualsExpression 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 (value1 == null || value2 == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp) || isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
    final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
    if (last1 == null || last2 == null) {
        setIsErroneous(true);
        return lastValue;
    }
    lastValue = new Boolean_Value(last1.checkEquality(timestamp, last2));
    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 67 with Expected_Value_type

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

the class Float2IntExpression 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 REAL_VALUE:
            lastValue = new Integer_Value((long) ((Real_Value) last).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)

Example 68 with Expected_Value_type

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

the class AddExpression 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 (value1 == null || value2 == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp) || isUnfoldable(timestamp, referenceChain)) {
        setIsErroneous(true);
        return lastValue;
    }
    final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
    final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
    if (last1.getIsErroneous(timestamp) || last2.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return lastValue;
    }
    switch(last1.getValuetype()) {
        case INTEGER_VALUE:
            // If the operands exist they must be of the same type.
            // Avoid
            // dependency from BigInteger.
            lastValue = ((Integer_Value) last1).add((Integer_Value) last2);
            lastValue.copyGeneralProperties(this);
            break;
        case REAL_VALUE:
            final double f1 = ((Real_Value) last1).getValue();
            final double f2 = ((Real_Value) last2).getValue();
            lastValue = new Real_Value(f1 + f2);
            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) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Example 69 with Expected_Value_type

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

the class And4bExpression 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 (value1 == null || value2 == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp) || isUnfoldable(timestamp, referenceChain)) {
        setIsErroneous(true);
        return lastValue;
    }
    final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
    final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
    String str1;
    String str2;
    switch(last1.getValuetype()) {
        case BITSTRING_VALUE:
            str1 = ((Bitstring_Value) last1).getValue();
            str2 = ((Bitstring_Value) last2).getValue();
            lastValue = new Bitstring_Value(and4b(str1, str2));
            lastValue.copyGeneralProperties(this);
            break;
        case HEXSTRING_VALUE:
            str1 = ((Hexstring_Value) last1).getValue();
            str2 = ((Hexstring_Value) last2).getValue();
            lastValue = new Hexstring_Value(and4b(str1, str2));
            lastValue.copyGeneralProperties(this);
            break;
        case OCTETSTRING_VALUE:
            str1 = ((Octetstring_Value) last1).getValue();
            str2 = ((Octetstring_Value) last2).getValue();
            lastValue = new Octetstring_Value(and4b(str1, str2));
            lastValue.copyGeneralProperties(this);
            break;
        default:
            setIsErroneous(true);
            break;
    }
    return lastValue;
}
Also used : Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) Bitstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)

Example 70 with Expected_Value_type

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

the class AndExpression 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 (value1 == null || value2 == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp) || isUnfoldable(timestamp, referenceChain)) {
        setIsErroneous(true);
        return lastValue;
    }
    final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
    if (Value_type.BOOLEAN_VALUE.equals(last1.getValuetype())) {
        if (((Boolean_Value) last1).getValue()) {
            final Boolean_Value temp = (Boolean_Value) value2.getValueRefdLast(timestamp, referenceChain);
            lastValue = new Boolean_Value(temp.getValue());
            lastValue.copyGeneralProperties(this);
        } else {
            lastValue = new Boolean_Value(false);
            lastValue.copyGeneralProperties(this);
        }
    } else {
        // we must keep the left operand because of the
        // potential side effects
        // the right operand can only be eliminated if it is a
        // literal "true"
        final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
        if (Value_type.BOOLEAN_VALUE.equals(last2.getValuetype()) && ((Boolean_Value) last2).getValue()) {
            final Boolean_Value temp = (Boolean_Value) value1.getValueRefdLast(timestamp, referenceChain);
            lastValue = new Boolean_Value(temp.getValue());
            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)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)149 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)54 IType (org.eclipse.titan.designer.AST.IType)47 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)45 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)39 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)37 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)31 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)24 ISubReference (org.eclipse.titan.designer.AST.ISubReference)21 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)21 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)20 Identifier (org.eclipse.titan.designer.AST.Identifier)17 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)17 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)14 Type (org.eclipse.titan.designer.AST.Type)14 Assignment (org.eclipse.titan.designer.AST.Assignment)13 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)13 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)12 CharstringExtractor (org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)11 Value (org.eclipse.titan.designer.AST.Value)11