Search in sources :

Example 1 with Expected_Value_type

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

the class ShiftLeftExpression 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) {
    Type_type tempType1 = null;
    Type_type tempType2 = null;
    long stringSize = 0;
    long shiftSize = 0;
    IValue tempValue;
    if (value1 != null) {
        value1.setLoweridToReference(timestamp);
        tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType1) {
            case TYPE_BITSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.BITSTRING_VALUE.equals(tempValue.getValuetype())) {
                    stringSize = ((Bitstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_HEXSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.HEXSTRING_VALUE.equals(tempValue.getValuetype())) {
                    stringSize = ((Hexstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_OCTETSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.OCTETSTRING_VALUE.equals(tempValue.getValuetype())) {
                    stringSize = ((Octetstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(FIRSTOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
    if (value2 != null) {
        value2.setLoweridToReference(timestamp);
        tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType2) {
            case TYPE_INTEGER:
                tempValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.INTEGER_VALUE.equals(tempValue.getValuetype()) && !getIsErroneous(timestamp)) {
                    if (!((Integer_Value) tempValue).isNative()) {
                        value2.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERSECONDOPERANDERROR, ((Integer_Value) tempValue).getValueValue()));
                        setIsErroneous(true);
                        break;
                    }
                    shiftSize = ((Integer_Value) tempValue).getValue();
                    if (value1 != null && !value1.isUnfoldable(timestamp)) {
                        final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINCORRECTSHIFTROTATESIZE, GeneralConstants.WARNING, null);
                        if (shiftSize < 0) {
                            location.reportConfigurableSemanticProblem(severity, NEGATIVESHIFTPROBLEM);
                        } else if (shiftSize == 0) {
                            location.reportConfigurableSemanticProblem(severity, ZEROSHIFTPROBLEM);
                        } else if (shiftSize > stringSize) {
                            location.reportConfigurableSemanticProblem(severity, MessageFormat.format(TOOBIGSHIFTPROBLEM, stringSize, shiftSize));
                        }
                    }
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(SECONDOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)

Example 2 with Expected_Value_type

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

the class ShiftRightExpression 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;
    long shiftSize;
    switch(last1.getValuetype()) {
        case BITSTRING_VALUE:
            string = ((Bitstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).getValue();
            lastValue = new Bitstring_Value(shiftRight(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case HEXSTRING_VALUE:
            string = ((Hexstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).getValue();
            lastValue = new Hexstring_Value(shiftRight(string, shiftSize));
            lastValue.copyGeneralProperties(this);
            break;
        case OCTETSTRING_VALUE:
            string = ((Octetstring_Value) last1).getValue();
            shiftSize = ((Integer_Value) last2).getValue() * 2;
            lastValue = new Octetstring_Value(shiftRight(string, shiftSize));
            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) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)

Example 3 with Expected_Value_type

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

the class ShiftRightExpression 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) {
    Type_type tempType1 = null;
    Type_type tempType2 = null;
    long stringSize = 0;
    long shiftSize = 0;
    IValue tempValue;
    if (value1 != null) {
        value1.setLoweridToReference(timestamp);
        tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType1) {
            case TYPE_BITSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.BITSTRING_VALUE.equals(tempValue.getValuetype())) {
                    stringSize = ((Bitstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_HEXSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.HEXSTRING_VALUE.equals(tempValue.getValuetype())) {
                    stringSize = ((Hexstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_OCTETSTRING:
                tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.OCTETSTRING_VALUE.equals(tempValue.getValuetype())) {
                    stringSize = ((Octetstring_Value) tempValue).getValueLength();
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(FIRSTOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
    if (value2 != null) {
        value2.setLoweridToReference(timestamp);
        tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType2) {
            case TYPE_INTEGER:
                tempValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (Value_type.INTEGER_VALUE.equals(tempValue.getValuetype()) && !getIsErroneous(timestamp)) {
                    if (!((Integer_Value) tempValue).isNative()) {
                        value2.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERSECONDOPERANDERROR, ((Integer_Value) tempValue).getValueValue()));
                        setIsErroneous(true);
                        break;
                    }
                    shiftSize = ((Integer_Value) tempValue).getValue();
                    if (value1 != null && !value1.isUnfoldable(timestamp)) {
                        final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINCORRECTSHIFTROTATESIZE, GeneralConstants.WARNING, null);
                        if (shiftSize < 0) {
                            location.reportConfigurableSemanticProblem(severity, NEGATIVESHIFTPROBLEM);
                        } else if (shiftSize == 0) {
                            location.reportConfigurableSemanticProblem(severity, ZEROSHIFTPROBLEM);
                        } else if (shiftSize > stringSize) {
                            location.reportConfigurableSemanticProblem(severity, MessageFormat.format(TOOBIGSHIFTPROBLEM, stringSize, shiftSize));
                        }
                    }
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(SECONDOPERANDERROR);
                setIsErroneous(true);
                break;
        }
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)

Example 4 with Expected_Value_type

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

the class SizeOfExpression 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.
 *
 * @return the size of the expression, or -1 in case of error
 */
private long checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    Expected_Value_type internalExpectedValue;
    if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
        internalExpectedValue = Expected_Value_type.EXPECTED_TEMPLATE;
    } else {
        internalExpectedValue = expectedValue;
    }
    ITTCN3Template template = templateInstance.getTemplateBody();
    template.setLoweridToReference(timestamp);
    template = template.getTemplateReferencedLast(timestamp, referenceChain);
    if (template.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return -1;
    }
    // Timer and port arrays are handled separately
    if (template.getTemplatetype() == Template_type.SPECIFIC_VALUE) {
        final SpecificValue_Template specValTempl = (SpecificValue_Template) template;
        IValue val = specValTempl.getSpecificValue();
        val.setMyGovernor(specValTempl.getMyGovernor());
        if (val.getValuetype() == Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE) {
            val = val.setLoweridToReference(timestamp);
        }
        if (val != null && val.getValuetype() == Value_type.REFERENCED_VALUE) {
            final Referenced_Value referencedValue = (Referenced_Value) val;
            final Reference ref = referencedValue.getReference();
            final Assignment temporalAss = ref.getRefdAssignment(timestamp, true);
            if (temporalAss != null) {
                final Assignment_type asstype = temporalAss.getAssignmentType();
                ArrayDimensions dimensions;
                if (asstype == Assignment_type.A_PORT) {
                    dimensions = ((Def_Port) temporalAss).getDimensions();
                    return checkTimerPort(timestamp, ref, dimensions, temporalAss);
                } else if (asstype == Assignment_type.A_TIMER) {
                    dimensions = ((Def_Timer) temporalAss).getDimensions();
                    return checkTimerPort(timestamp, ref, dimensions, temporalAss);
                }
            }
        }
    }
    IType governor = templateInstance.getExpressionGovernor(timestamp, internalExpectedValue);
    if (governor == null) {
        final ITTCN3Template templ = template.setLoweridToReference(timestamp);
        governor = templ.getExpressionGovernor(timestamp, internalExpectedValue);
    }
    if (governor == null) {
        if (!template.getIsErroneous(timestamp)) {
            templateInstance.getLocation().reportSemanticError("Cannot determine the type of the argument in the `sizeof' operation. If type is known, use valueof(<type>: ...) as argument.");
        }
        setIsErroneous(true);
        return -1;
    }
    IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance, governor, referenceChain, internalExpectedValue);
    if (isErroneous) {
        return -1;
    }
    IType type = governor.getTypeRefdLast(timestamp);
    switch(type.getTypetype()) {
        case TYPE_SEQUENCE_OF:
        case TYPE_SET_OF:
        case TYPE_TTCN3_SEQUENCE:
        case TYPE_TTCN3_SET:
        case TYPE_ASN1_SEQUENCE:
        case TYPE_ASN1_SET:
        case TYPE_ARRAY:
        case TYPE_OBJECTID:
        case TYPE_ROID:
        case TYPE_UNDEFINED:
            break;
        default:
            templateInstance.getLocation().reportSemanticError("Reference to a value or template of type record, record of, set, set of, objid or array was expected");
            setIsErroneous(true);
            return -1;
    }
    IValue value = null;
    Reference reference = null;
    Assignment assignment = null;
    List<ISubReference> subreferences = null;
    switch(template.getTemplatetype()) {
        case INDEXED_TEMPLATE_LIST:
            return -1;
        case TEMPLATE_REFD:
            reference = ((Referenced_Template) template).getReference();
            assignment = reference.getRefdAssignment(timestamp, false);
            subreferences = reference.getSubreferences();
            break;
        case TEMPLATE_LIST:
        case NAMED_TEMPLATE_LIST:
        case SUBSET_MATCH:
        case SUPERSET_MATCH:
            // compute later
            break;
        case SPECIFIC_VALUE:
            value = ((SpecificValue_Template) template).getSpecificValue().getValueRefdLast(timestamp, referenceChain);
            if (value != null) {
                switch(value.getValuetype()) {
                    case SEQUENCEOF_VALUE:
                    case SETOF_VALUE:
                    case ARRAY_VALUE:
                    case RELATIVEOBJECTIDENTIFIER_VALUE:
                    case OBJECTID_VALUE:
                    case SEQUENCE_VALUE:
                    case SET_VALUE:
                        break;
                    case REFERENCED_VALUE:
                        {
                            reference = ((Referenced_Value) value).getReference();
                            assignment = reference.getRefdAssignment(timestamp, false);
                            subreferences = reference.getSubreferences();
                            break;
                        }
                    default:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("`sizeof'' operation is not applicable to `{0}''", value.createStringRepresentation()));
                        setIsErroneous(true);
                        return -1;
                }
            }
            break;
        default:
            templateInstance.getLocation().reportSemanticError(MessageFormat.format("`sizeof'' operation is not applicable to {0}", template.getTemplateTypeName()));
            setIsErroneous(true);
            return -1;
    }
    if (assignment != null) {
        if (assignment.getIsErroneous()) {
            setIsErroneous(true);
            return -1;
        }
        switch(assignment.getAssignmentType()) {
            case A_CONST:
                value = ((Def_Const) assignment).getValue();
                break;
            case A_EXT_CONST:
            case A_MODULEPAR:
            case A_MODULEPAR_TEMPLATE:
                if (Expected_Value_type.EXPECTED_CONSTANT.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to an (evaluable) constant value was expected instead of {0}", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_VAR:
            case A_PAR_VAL:
            case A_PAR_VAL_IN:
            case A_PAR_VAL_OUT:
            case A_PAR_VAL_INOUT:
                switch(internalExpectedValue) {
                    case EXPECTED_CONSTANT:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a constant value was expected instead of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    case EXPECTED_STATIC_VALUE:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a static value was expected instead of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    default:
                        break;
                }
                break;
            case A_TEMPLATE:
                template = ((Def_Template) assignment).getTemplate(timestamp);
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a value was expected instead of {0}", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_VAR_TEMPLATE:
            case A_PAR_TEMP_IN:
            case A_PAR_TEMP_OUT:
            case A_PAR_TEMP_INOUT:
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a value was expected instead of {0}", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_FUNCTION_RVAL:
            case A_EXT_FUNCTION_RVAL:
                switch(internalExpectedValue) {
                    case EXPECTED_CONSTANT:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a constant value was expected instead of the return value of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    case EXPECTED_STATIC_VALUE:
                        templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a static value was expected instead of the return value of {0}", assignment.getDescription()));
                        setIsErroneous(true);
                        return -1;
                    default:
                        break;
                }
                break;
            case A_FUNCTION_RTEMP:
            case A_EXT_FUNCTION_RTEMP:
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue)) {
                    templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a value was expected instead of a call of {0}, which returns a template", assignment.getDescription()));
                    setIsErroneous(true);
                    return -1;
                }
                break;
            case A_TIMER:
            case A_PORT:
                // were already checked separately.
                break;
            default:
                templateInstance.getLocation().reportSemanticError(MessageFormat.format("Reference to a {0} was expected instead of {1}", Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectedValue) ? "value or template" : "value", assignment.getDescription()));
                setIsErroneous(true);
                return -1;
        }
        type = assignment.getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
        if (type == null || type.getIsErroneous(timestamp)) {
            setIsErroneous(true);
            return -1;
        }
        type = type.getTypeRefdLast(timestamp);
        switch(type.getTypetype()) {
            case TYPE_SEQUENCE_OF:
            case TYPE_SET_OF:
            case TYPE_TTCN3_SEQUENCE:
            case TYPE_TTCN3_SET:
            case TYPE_ASN1_SEQUENCE:
            case TYPE_ASN1_SET:
            case TYPE_ARRAY:
            case TYPE_OBJECTID:
            case TYPE_ROID:
            case TYPE_UNDEFINED:
                break;
            default:
                templateInstance.getLocation().reportSemanticError("Reference to a value or template of type record, record of, set, set of, objid or array was expected");
                setIsErroneous(true);
                return -1;
        }
    }
    // check for index overflows in subrefs if possible
    if (value != null) {
        switch(value.getValuetype()) {
            case SEQUENCEOF_VALUE:
                if (((SequenceOf_Value) value).isIndexed()) {
                    return -1;
                }
                break;
            case SETOF_VALUE:
                if (((SetOf_Value) value).isIndexed()) {
                    return -1;
                }
                break;
            case ARRAY_VALUE:
                if (((Array_Value) value).isIndexed()) {
                    return -1;
                }
                break;
            default:
                break;
        }
        /* The reference points to a constant.  */
        if (subreferences != null && !reference.hasUnfoldableIndexSubReference(timestamp)) {
            value = value.getReferencedSubValue(timestamp, reference, 1, referenceChain);
            if (value == null) {
                setIsErroneous(true);
                return -1;
            }
            value = value.getValueRefdLast(timestamp, referenceChain);
        } else {
            // stop processing
            value = null;
        }
    } else if (template != null) {
        /* The size of INDEXED_TEMPLATE_LIST nodes is unknown at compile
		         time.  Don't try to evaluate it at compile time.  */
        if (reference != null && reference.hasUnfoldableIndexSubReference(timestamp)) {
            return -1;
        }
        if (reference != null && subreferences != null) {
            template = template.getReferencedSubTemplate(timestamp, reference, referenceChain);
            if (template == null) {
                setIsErroneous(true);
                return -1;
            }
            template = template.getTemplateReferencedLast(timestamp);
        }
    }
    if (template != null) {
        if (template.getIsErroneous(timestamp)) {
            setIsErroneous(true);
            return -1;
        }
        switch(template.getTemplatetype()) {
            case TEMPLATE_REFD:
                template = null;
                break;
            case SPECIFIC_VALUE:
                value = ((SpecificValue_Template) template).getSpecificValue().getValueRefdLast(timestamp, referenceChain);
                template = null;
                break;
            case TEMPLATE_LIST:
            case NAMED_TEMPLATE_LIST:
            case SUBSET_MATCH:
            case SUPERSET_MATCH:
                break;
            default:
                // FIXME this can not happen
                templateInstance.getLocation().reportSemanticError(MessageFormat.format("`sizeof'' operation is not applicable to {0}", template.getTemplateTypeName()));
                setIsErroneous(true);
                return -1;
        }
    }
    if (value != null) {
        switch(value.getValuetype()) {
            case SEQUENCEOF_VALUE:
            case SETOF_VALUE:
            case ARRAY_VALUE:
            case RELATIVEOBJECTIDENTIFIER_VALUE:
            case OBJECTID_VALUE:
            case SEQUENCE_VALUE:
            case SET_VALUE:
                break;
            default:
                value = null;
                return -1;
        }
    }
    /* evaluation */
    if (Type_type.TYPE_ARRAY.equals(type.getTypetype())) {
        return ((Array_Type) type).getDimension().getSize();
    } else if (template != null) {
        return evaluateTemplate(template, timestamp);
    } else if (value != null) {
        return evaluateValue(value);
    } else {
        return -1;
    }
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Assignment_type(org.eclipse.titan.designer.AST.Assignment.Assignment_type) Array_Value(org.eclipse.titan.designer.AST.TTCN3.values.Array_Value) ISubReference(org.eclipse.titan.designer.AST.ISubReference) Reference(org.eclipse.titan.designer.AST.Reference) Def_Timer(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value) SetOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value) IType(org.eclipse.titan.designer.AST.IType) Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) IValue(org.eclipse.titan.designer.AST.IValue) ArrayDimensions(org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimensions) Expected_Value_type(org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)

Example 5 with Expected_Value_type

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

the class Str2BitExpression 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_CHARSTRING:
            final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
            if (!last.isUnfoldable(timestamp)) {
                final String string = ((Charstring_Value) last).getValue();
                final byte[] bytes = string.getBytes();
                for (int i = 0; i < bytes.length; i++) {
                    if (bytes[i] != '0' && bytes[i] != '1') {
                        value.getLocation().reportSemanticError(OPERANDERROR2);
                        setIsErroneous(true);
                        return;
                    }
                }
            }
            return;
        case TYPE_UNDEFINED:
            setIsErroneous(true);
            return;
        default:
            if (!isErroneous) {
                location.reportSemanticError(OPERANDERROR1);
                setIsErroneous(true);
            }
            return;
    }
}
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)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)149 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)54 IType (org.eclipse.titan.designer.AST.IType)47 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)45 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)39 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)37 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)31 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)24 ISubReference (org.eclipse.titan.designer.AST.ISubReference)21 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)21 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)20 Identifier (org.eclipse.titan.designer.AST.Identifier)17 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)17 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)14 Type (org.eclipse.titan.designer.AST.Type)14 Assignment (org.eclipse.titan.designer.AST.Assignment)13 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)13 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)12 CharstringExtractor (org.eclipse.titan.designer.AST.TTCN3.values.CharstringExtractor)11 Value (org.eclipse.titan.designer.AST.Value)11