Search in sources :

Example 1 with UniversalCharstring

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

the class StringConcatenationExpression 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.getIsErroneous(timestamp) || last2.getIsErroneous(timestamp)) {
        return lastValue;
    }
    switch(last1.getValuetype()) {
        case BITSTRING_VALUE:
            {
                final String string1 = ((Bitstring_Value) last1).getValue();
                final String string2 = ((Bitstring_Value) last2).getValue();
                lastValue = new Bitstring_Value(string1 + string2);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case HEXSTRING_VALUE:
            {
                final String string1 = ((Hexstring_Value) last1).getValue();
                final String string2 = ((Hexstring_Value) last2).getValue();
                lastValue = new Hexstring_Value(string1 + string2);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case OCTETSTRING_VALUE:
            {
                final String string1 = ((Octetstring_Value) last1).getValue();
                final String string2 = ((Octetstring_Value) last2).getValue();
                lastValue = new Octetstring_Value(string1 + string2);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case CHARSTRING_VALUE:
            {
                final String string1 = ((Charstring_Value) last1).getValue();
                if (Value_type.UNIVERSALCHARSTRING_VALUE.equals(last2.getValuetype())) {
                    final UniversalCharstring string2 = ((UniversalCharstring_Value) last2).getValue();
                    lastValue = new UniversalCharstring_Value(new UniversalCharstring(string1).append(string2));
                } else {
                    final String string2 = ((Charstring_Value) last2).getValue();
                    lastValue = new Charstring_Value(string1 + string2);
                }
                lastValue.copyGeneralProperties(this);
                break;
            }
        case UNIVERSALCHARSTRING_VALUE:
            {
                final UniversalCharstring string1 = ((UniversalCharstring_Value) last1).getValue();
                if (Value_type.UNIVERSALCHARSTRING_VALUE.equals(last2.getValuetype())) {
                    final UniversalCharstring string2 = ((UniversalCharstring_Value) last2).getValue();
                    lastValue = new UniversalCharstring_Value(new UniversalCharstring(string1).append(string2));
                } else {
                    final String string2 = ((Charstring_Value) last2).getValue();
                    lastValue = new UniversalCharstring_Value(new UniversalCharstring(string1).append(string2));
                }
                lastValue.copyGeneralProperties(this);
                break;
            }
        default:
            setIsErroneous(true);
            break;
    }
    return lastValue;
}
Also used : Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) Bitstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)

Example 2 with UniversalCharstring

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

the class Unichar2IntExpression 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 int result = (uchar.group() << 24) | (uchar.plane() << 16) | (uchar.row() << 8) | uchar.cell();
                lastValue = new Integer_Value(result);
                break;
            }
        case CHARSTRING_VALUE:
            {
                final String string = ((Charstring_Value) last).getValue();
                lastValue = new Integer_Value(string.charAt(0));
                break;
            }
        default:
            setIsErroneous(true);
            return this;
    }
    lastValue.copyGeneralProperties(this);
    return lastValue;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) UniversalChar(org.eclipse.titan.designer.AST.TTCN3.values.UniversalChar) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)

Example 3 with UniversalCharstring

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

the class RotateLeftExpression 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 string;
    int shiftSize;
    switch(last1.getValuetype()) {
        case BITSTRING_VALUE:
            string = ((Bitstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue();
            lastValue = new Bitstring_Value(rotateLeft(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case HEXSTRING_VALUE:
            string = ((Hexstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue();
            lastValue = new Hexstring_Value(rotateLeft(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case OCTETSTRING_VALUE:
            string = ((Octetstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue() * 2;
            lastValue = new Octetstring_Value(rotateLeft(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case CHARSTRING_VALUE:
            string = ((Charstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue();
            lastValue = new Charstring_Value(rotateLeft(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case UNIVERSALCHARSTRING_VALUE:
            final UniversalCharstring string2 = ((UniversalCharstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue();
            lastValue = new UniversalCharstring_Value(rotateLeft(string2, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        default:
            setIsErroneous(true);
            break;
    }
    return lastValue;
}
Also used : Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) Bitstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)

Example 4 with UniversalCharstring

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

the class RotateRightExpression 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);
    String string;
    int shiftSize;
    switch(last1.getValuetype()) {
        case BITSTRING_VALUE:
            string = ((Bitstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue();
            lastValue = new Bitstring_Value(rotateRight(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case HEXSTRING_VALUE:
            string = ((Hexstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue();
            lastValue = new Hexstring_Value(rotateRight(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case OCTETSTRING_VALUE:
            string = ((Octetstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue() * 2;
            lastValue = new Octetstring_Value(rotateRight(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case CHARSTRING_VALUE:
            string = ((Charstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue();
            lastValue = new Charstring_Value(rotateRight(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case UNIVERSALCHARSTRING_VALUE:
            final UniversalCharstring string2 = ((UniversalCharstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).intValue();
            lastValue = new UniversalCharstring_Value(rotateRight(string2, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        default:
            setIsErroneous(true);
            break;
    }
    return lastValue;
}
Also used : Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) Bitstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)

Example 5 with UniversalCharstring

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

the class Unichar2CharExpression 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) {
    if (value == null) {
        return;
    }
    value.setLoweridToReference(timestamp);
    final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_UCHARSTRING:
            final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                UniversalCharstring string;
                if (last instanceof Charstring_Value) {
                    // check not necessary, trivial case
                    return;
                } else if (last instanceof UniversalCharstring_Value) {
                    string = ((UniversalCharstring_Value) last).getValue();
                    if (string == null) {
                        setIsErroneous(true);
                        return;
                    }
                } else {
                    value.getLocation().reportSemanticError(OPERANDERROR1);
                    setIsErroneous(true);
                    return;
                }
                for (int i = 0; i < string.length(); i++) {
                    final UniversalChar uchar = string.get(i);
                    if (uchar.group() != 0 || uchar.plane() != 0 || uchar.row() != 0 || uchar.cell() > 127) {
                        value.getLocation().reportSemanticError(OPERANDERROR2);
                        setIsErroneous(true);
                        return;
                    }
                }
            }
            return;
        case TYPE_CHARSTRING:
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR1);
                setIsErroneous(true);
            }
            return;
    }
}
Also used : UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) 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) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) UniversalChar(org.eclipse.titan.designer.AST.TTCN3.values.UniversalChar) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)

Aggregations

UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)16 IValue (org.eclipse.titan.designer.AST.IValue)14 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)11 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)9 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)7 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)6 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)6 UniversalChar (org.eclipse.titan.designer.AST.TTCN3.values.UniversalChar)5 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)4 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)3 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)2 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)2 IType (org.eclipse.titan.designer.AST.IType)2 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)2 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)2 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)2 PatternString (org.eclipse.titan.designer.AST.TTCN3.templates.PatternString)2 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)2 Verdict_Value (org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value)2 TreeSet (java.util.TreeSet)1