Search in sources :

Example 6 with Hexstring_Value

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

the class SubstrExpression 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 (templateInstance1 == null || value2 == null || value3 == null) {
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp) || isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    final ITTCN3Template temp = templateInstance1.getTemplateBody();
    final IValue value1 = ((SpecificValue_Template) temp).getSpecificValue();
    final IValue v1 = value1.getValueRefdLast(timestamp, referenceChain);
    final IValue v2 = value2.getValueRefdLast(timestamp, referenceChain);
    final IValue v3 = value3.getValueRefdLast(timestamp, referenceChain);
    final int index = (int) ((Integer_Value) v2).getValue();
    final int len = (int) ((Integer_Value) v3).getValue();
    switch(v1.getValuetype()) {
        case BITSTRING_VALUE:
            lastValue = new Bitstring_Value(((Bitstring_Value) v1).getValue().substring(index, index + len));
            lastValue.copyGeneralProperties(this);
            break;
        case HEXSTRING_VALUE:
            lastValue = new Hexstring_Value(((Hexstring_Value) v1).getValue().substring(index, index + len));
            lastValue.copyGeneralProperties(this);
            break;
        case OCTETSTRING_VALUE:
            lastValue = new Octetstring_Value(((Octetstring_Value) v1).getValue().substring(index * 2, (index + len) * 2));
            lastValue.copyGeneralProperties(this);
            break;
        case CHARSTRING_VALUE:
            lastValue = new Charstring_Value(((Charstring_Value) v1).getValue().substring(index, index + len));
            lastValue.copyGeneralProperties(this);
            break;
        case UNIVERSALCHARSTRING_VALUE:
            lastValue = new UniversalCharstring_Value(((UniversalCharstring_Value) v1).getValue().substring(index, index + len));
            lastValue.copyGeneralProperties(this);
            break;
        default:
            setIsErroneous(true);
            break;
    }
    return lastValue;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) 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) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) 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) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)

Example 7 with Hexstring_Value

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

the class Int2HexExpression 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);
    if (last1.getIsErroneous(timestamp) || last2.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return lastValue;
    }
    final Integer_Value i1 = (Integer_Value) last1;
    final long i2 = ((Integer_Value) last2).getValue();
    lastValue = new Hexstring_Value(int2hex(i1, (int) i2));
    lastValue.copyGeneralProperties(this);
    return lastValue;
}
Also used : Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)

Example 8 with Hexstring_Value

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

the class Xor4bExpression 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 str1;
    String str2;
    switch(last1.getValuetype()) {
        case BITSTRING_VALUE:
            str1 = ((Bitstring_Value) last1).getValue();
            str2 = ((Bitstring_Value) last2).getValue();
            lastValue = new Bitstring_Value(xor4b(str1, str2));
            lastValue.copyGeneralProperties(this);
            break;
        case HEXSTRING_VALUE:
            str1 = ((Hexstring_Value) last1).getValue();
            str2 = ((Hexstring_Value) last2).getValue();
            lastValue = new Hexstring_Value(xor4b(str1, str2));
            lastValue.copyGeneralProperties(this);
            break;
        case OCTETSTRING_VALUE:
            str1 = ((Octetstring_Value) last1).getValue();
            str2 = ((Octetstring_Value) last2).getValue();
            lastValue = new Octetstring_Value(xor4b(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 9 with Hexstring_Value

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

the class ReplaceExpression method checkExpressionOperandsHelper.

private void checkExpressionOperandsHelper(final CompilationTimeStamp timestamp, final IValue value1, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (templateInstance1 == null || getIsErroneous(timestamp)) {
        return;
    }
    long valueSize = -1;
    if (!value1.isUnfoldable(timestamp)) {
        IValue temp = value1.setLoweridToReference(timestamp);
        temp = temp.getValueRefdLast(timestamp, referenceChain);
        switch(temp.getValuetype()) {
            case BITSTRING_VALUE:
                valueSize = ((Bitstring_Value) temp).getValueLength();
                break;
            case HEXSTRING_VALUE:
                valueSize = ((Hexstring_Value) temp).getValueLength();
                break;
            case OCTETSTRING_VALUE:
                valueSize = ((Octetstring_Value) temp).getValueLength();
                break;
            case CHARSTRING_VALUE:
                valueSize = ((Charstring_Value) temp).getValueLength();
                break;
            case UNIVERSALCHARSTRING_VALUE:
                valueSize = ((UniversalCharstring_Value) temp).getValueLength();
                break;
            case SETOF_VALUE:
                valueSize = ((SetOf_Value) temp).getNofComponents();
                break;
            case SEQUENCEOF_VALUE:
                valueSize = ((SequenceOf_Value) temp).getNofComponents();
                break;
            default:
                break;
        }
    }
    if (valueSize < 0) {
        return;
    }
    if (value2 == null || value3 == null || templateInstance4 == null) {
        return;
    }
    if (value2.isUnfoldable(timestamp)) {
        if (!value3.isUnfoldable(timestamp)) {
            final IValue last3 = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
            final long last3Value = ((Integer_Value) last3).getValue();
            if (last3Value > valueSize) {
                location.reportSemanticError(MessageFormat.format(OPERANDERROR8, last3Value, valueSize));
                setIsErroneous(true);
            }
        }
    } else {
        final IValue last2 = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
        final long last2Value = ((Integer_Value) last2).getValue();
        if (value3.isUnfoldable(timestamp)) {
            if (last2Value > valueSize) {
                location.reportSemanticError(MessageFormat.format(OPERANDERROR9, last2Value, valueSize));
                setIsErroneous(true);
            }
        } else {
            final IValue last3 = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
            final long last3Value = ((Integer_Value) last3).getValue();
            if (last2Value + last3Value > valueSize) {
                location.reportSemanticError(MessageFormat.format(OPERANDERROR10, last2Value, last3Value, valueSize));
                setIsErroneous(true);
            }
        }
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)

Example 10 with Hexstring_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value 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)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)33 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)22 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)16 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)15 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)13 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)10 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)9 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)6 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)6 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)4 IType (org.eclipse.titan.designer.AST.IType)3 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)3 SetOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)3 ISubReference (org.eclipse.titan.designer.AST.ISubReference)2 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)2 Identifier (org.eclipse.titan.designer.AST.Identifier)2 Reference (org.eclipse.titan.designer.AST.Reference)2 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)2 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)2 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)2