Search in sources :

Example 56 with IValue

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

the class Oct2CharExpression 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(oct2char(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 57 with IValue

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

the class Oct2StrExpression 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(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) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)

Example 58 with IValue

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

the class Or4bExpression 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)) {
        return lastValue;
    }
    if (isUnfoldable(timestamp, referenceChain)) {
        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(or4b(str1, str2));
            lastValue.copyGeneralProperties(this);
            break;
        case HEXSTRING_VALUE:
            str1 = ((Hexstring_Value) last1).getValue();
            str2 = ((Hexstring_Value) last2).getValue();
            lastValue = new Hexstring_Value(or4b(str1, str2));
            lastValue.copyGeneralProperties(this);
            break;
        case OCTETSTRING_VALUE:
            str1 = ((Octetstring_Value) last1).getValue();
            str2 = ((Octetstring_Value) last2).getValue();
            lastValue = new Octetstring_Value(or4b(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 59 with IValue

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

the class OrExpression 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);
    if (Value_type.BOOLEAN_VALUE.equals(last1.getValuetype())) {
        if (((Boolean_Value) last1).getValue()) {
            lastValue = new Boolean_Value(true);
            lastValue.copyGeneralProperties(this);
        } else {
            final Boolean_Value temp = (Boolean_Value) value2.getValueRefdLast(timestamp, referenceChain);
            lastValue = new Boolean_Value(temp.getValue());
            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 "false"
        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)

Example 60 with IValue

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

the class Octetstring_Value method checkEquality.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = other.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    return Value_type.OCTETSTRING_VALUE.equals(last.getValuetype()) && value.equals(((Octetstring_Value) last).getValue());
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

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