Search in sources :

Example 1 with CharstringExtractor

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

the class IsTemplateKindExpression method checkExpressionOperand2.

/**
 * Checks the 2nd operand
 * in charstring (optional)
 * @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 checkExpressionOperand2(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (value == null) {
        setIsErroneous(true);
        return;
    }
    value.setLoweridToReference(timestamp);
    final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_CHARSTRING:
            final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                final String originalString = ((Charstring_Value) last).getValue();
                final CharstringExtractor cs = new CharstringExtractor(originalString);
                if (cs.isErrorneous()) {
                    value.getLocation().reportSemanticError(cs.getErrorMessage());
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERAND2_ERROR1);
                setIsErroneous(true);
            }
            break;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) CharstringExtractor(org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)

Example 2 with CharstringExtractor

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

the class DecvalueUnicharExpression method checkExpressionOperand3.

/**
 * Checks the 3rd operand
 * in charstring (optional)
 * @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 checkExpressionOperand3(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (value3 == null) {
        return;
    }
    value3.setLoweridToReference(timestamp);
    final Type_type tempType = value3.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_CHARSTRING:
            final IValue last = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                final String originalString = ((Charstring_Value) last).getValue();
                final CharstringExtractor cs = new CharstringExtractor(originalString);
                if (cs.isErrorneous()) {
                    value3.getLocation().reportSemanticError(cs.getErrorMessage());
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERAND3_ERROR1);
                setIsErroneous(true);
            }
            break;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) CharstringExtractor(org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)

Example 3 with CharstringExtractor

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

the class Char2IntExpression 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 CHARSTRING_VALUE:
            final String string = ((Charstring_Value) last).getValue();
            final CharstringExtractor cs = new CharstringExtractor(string);
            lastValue = new Integer_Value(cs.getExtractedString().charAt(0));
            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) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) CharstringExtractor(org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)

Example 4 with CharstringExtractor

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

the class CheckStateExpression method checkExpressionOperand1.

/**
 * Checks the operand
 * in charstring (mandatory)
 * @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 checkExpressionOperand1(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (value == null) {
        setIsErroneous(true);
        return;
    }
    value.setLoweridToReference(timestamp);
    final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_CHARSTRING:
            final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                final String originalString = ((Charstring_Value) last).getValue();
                final CharstringExtractor cs = new CharstringExtractor(originalString);
                if (cs.isErrorneous()) {
                    value.getLocation().reportSemanticError(cs.getErrorMessage());
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERAND1_ERROR1);
                setIsErroneous(true);
            }
            break;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) CharstringExtractor(org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)

Example 5 with CharstringExtractor

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

the class AnyPortCheckStateExpression method checkExpressionOperand1.

/**
 * Checks the operand
 * in charstring (mandatory)
 * @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 checkExpressionOperand1(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (value == null) {
        setIsErroneous(true);
        return;
    }
    value.setLoweridToReference(timestamp);
    final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_CHARSTRING:
            final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                final String originalString = ((Charstring_Value) last).getValue();
                final CharstringExtractor cs = new CharstringExtractor(originalString);
                if (cs.isErrorneous()) {
                    value.getLocation().reportSemanticError(cs.getErrorMessage());
                    setIsErroneous(true);
                }
            }
            break;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            break;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERAND1_ERROR1);
                setIsErroneous(true);
            }
            break;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) CharstringExtractor(org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)11 CharstringExtractor (org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)11 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)10 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)9 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_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 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)1