Search in sources :

Example 6 with UniversalChar

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

the class Unichar2CharExpression 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) || isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    final IValue last = value.getValueRefdLast(timestamp, referenceChain);
    if (last.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return lastValue;
    }
    switch(last.getValuetype()) {
        case UNIVERSALCHARSTRING_VALUE:
            {
                final UniversalCharstring string = ((UniversalCharstring_Value) last).getValue();
                final UniversalChar uchar = string.get(0);
                final byte[] bytes = new byte[] { (byte) uchar.cell() };
                lastValue = new Charstring_Value(new String(bytes));
                break;
            }
        case CHARSTRING_VALUE:
            {
                lastValue = new Charstring_Value(((Charstring_Value) last).getValue());
                break;
            }
        default:
            return this;
    }
    lastValue.copyGeneralProperties(this);
    return lastValue;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) UniversalChar(org.eclipse.titan.designer.AST.TTCN3.values.UniversalChar) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)

Aggregations

UniversalChar (org.eclipse.titan.designer.AST.TTCN3.values.UniversalChar)6 IValue (org.eclipse.titan.designer.AST.IValue)5 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)5 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)3 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)2 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)1 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)1 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)1