Search in sources :

Example 21 with UniversalCharstring_Value

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

the class IncorrectRotate method getFirstRotateOperandLength.

/**
 * @param ct the compilation timestamp to be used
 * @param value the first operand of the rotate operation
 * @return the length of the first operand if it can be determined
 */
private static long getFirstRotateOperandLength(final CompilationTimeStamp ct, final Value value) {
    if (value == null) {
        return 0;
    }
    final Type_type tempType = value.getExpressionReturntype(ct, null);
    final IValue refd = value.getValueRefdLast(ct, null);
    long valueSize = 0;
    switch(tempType) {
        case TYPE_BITSTRING:
            if (Value_type.BITSTRING_VALUE.equals(refd.getValuetype())) {
                valueSize = ((Bitstring_Value) refd).getValueLength();
            }
            break;
        case TYPE_HEXSTRING:
            if (Value_type.HEXSTRING_VALUE.equals(refd.getValuetype())) {
                valueSize = ((Hexstring_Value) refd).getValueLength();
            }
            break;
        case TYPE_OCTETSTRING:
            if (Value_type.OCTETSTRING_VALUE.equals(refd.getValuetype())) {
                valueSize = ((Octetstring_Value) refd).getValueLength();
            }
            break;
        case TYPE_CHARSTRING:
            if (Value_type.CHARSTRING_VALUE.equals(refd.getValuetype())) {
                valueSize = ((Charstring_Value) refd).getValueLength();
            }
            break;
        case TYPE_UCHARSTRING:
            if (Value_type.UNIVERSALCHARSTRING_VALUE.equals(refd.getValuetype())) {
                valueSize = ((UniversalCharstring_Value) refd).getValueLength();
            }
            break;
        case TYPE_SET_OF:
            if (Value_type.SEQUENCEOF_VALUE.equals(value.getValuetype())) {
                valueSize = ((SequenceOf_Value) value).getNofComponents();
            } else if (Value_type.SETOF_VALUE.equals(value.getValuetype())) {
                valueSize = ((SetOf_Value) value).getNofComponents();
            }
            break;
        case TYPE_SEQUENCE_OF:
            if (Value_type.SEQUENCEOF_VALUE.equals(value.getValuetype())) {
                valueSize = ((SequenceOf_Value) value).getNofComponents();
            } else if (Value_type.SETOF_VALUE.equals(value.getValuetype())) {
                valueSize = ((SetOf_Value) value).getNofComponents();
            }
            break;
        case TYPE_ARRAY:
            if (Value_type.SEQUENCEOF_VALUE.equals(value.getValuetype())) {
                valueSize = ((SequenceOf_Value) value).getNofComponents();
            }
            if (Value_type.ARRAY_VALUE.equals(value.getValuetype())) {
                valueSize = ((Array_Value) value).getNofComponents();
            }
            break;
        default:
            break;
    }
    return valueSize;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) SetOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)

Example 22 with UniversalCharstring_Value

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

the class UniversalCharstring_Type method checkThisTemplateString.

/**
 * Checks if the provided template is valid for the provided type.
 * <p>
 * The type must be equivalent with the TTCN-3 universal charstring type
 *
 * @param timestamp the time stamp of the actual semantic check cycle.
 * @param type the universal charstring type used for the check.
 * @param template the template to be checked by the type.
 * @param isModified true if the template is a modified template
 */
public static void checkThisTemplateString(final CompilationTimeStamp timestamp, final Type type, final ITTCN3Template template, final boolean isModified) {
    template.setMyGovernor(type);
    PatternString ps = null;
    switch(template.getTemplatetype()) {
        case VALUE_RANGE:
            {
                final ValueRange range = ((Value_Range_Template) template).getValueRange();
                final IValue lower = checkBoundary(timestamp, type, range.getMin(), template, "lower");
                final IValue upper = checkBoundary(timestamp, type, range.getMax(), template, "upper");
                range.setTypeType(type.getTypetypeTtcn3());
                if (lower != null && upper != null) {
                    UniversalCharstring value1;
                    if (Value_type.CHARSTRING_VALUE.equals(lower.getValuetype())) {
                        value1 = new UniversalCharstring(((Charstring_Value) lower).getValue());
                    } else {
                        value1 = ((UniversalCharstring_Value) lower).getValue();
                    }
                    UniversalCharstring value2;
                    if (Value_type.CHARSTRING_VALUE.equals(upper.getValuetype())) {
                        value2 = new UniversalCharstring(((Charstring_Value) upper).getValue());
                    } else {
                        value2 = ((UniversalCharstring_Value) upper).getValue();
                    }
                    if (value1.compareWith(value2) > 0) {
                        template.getLocation().reportSemanticError(INCORRECTBOUNDARIES);
                    }
                }
                break;
            }
        case CSTR_PATTERN:
            {
                // Change the pattern type
                final CharString_Pattern_Template cstrpt = (CharString_Pattern_Template) template;
                ps = cstrpt.getPatternstring();
                ps.setPatterntype(PatternType.UNIVCHARSTRING_PATTERN);
                // FIXME might need some implementation
                break;
            }
        case USTR_PATTERN:
            // FIXME implement as soon as charstring pattern templates become handled
            ps = ((UnivCharString_Pattern_Template) template).getPatternstring();
            break;
        default:
            template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName(), type.getTypename()));
            break;
    }
}
Also used : ValueRange(org.eclipse.titan.designer.AST.TTCN3.templates.ValueRange) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) PatternString(org.eclipse.titan.designer.AST.TTCN3.templates.PatternString) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring) CharString_Pattern_Template(org.eclipse.titan.designer.AST.TTCN3.templates.CharString_Pattern_Template) UnivCharString_Pattern_Template(org.eclipse.titan.designer.AST.TTCN3.templates.UnivCharString_Pattern_Template)

Example 23 with UniversalCharstring_Value

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

the class SpecificValue_Template method checkTemplateSpecificLengthRestriction.

@Override
protected /**
 * {@inheritDoc}
 */
void checkTemplateSpecificLengthRestriction(final CompilationTimeStamp timestamp, final Type_type typeType) {
    IValue value = getValue();
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    value = value.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    switch(value.getValuetype()) {
        case BITSTRING_VALUE:
            if (Type_type.TYPE_BITSTRING.equals(typeType)) {
                lengthRestriction.checkNofElements(timestamp, ((Bitstring_Value) value).getValueLength(), false, false, false, this);
            }
            break;
        case HEXSTRING_VALUE:
            if (Type_type.TYPE_HEXSTRING.equals(typeType)) {
                lengthRestriction.checkNofElements(timestamp, ((Hexstring_Value) value).getValueLength(), false, false, false, this);
            }
            break;
        case OCTETSTRING_VALUE:
            if (Type_type.TYPE_OCTETSTRING.equals(typeType)) {
                lengthRestriction.checkNofElements(timestamp, ((Octetstring_Value) value).getValueLength(), false, false, false, this);
            }
            break;
        case CHARSTRING_VALUE:
            if (Type_type.TYPE_CHARSTRING.equals(typeType)) {
                lengthRestriction.checkNofElements(timestamp, ((Charstring_Value) value).getValueLength(), false, false, false, this);
            } else if (Type_type.TYPE_UCHARSTRING.equals(typeType)) {
                value = value.setValuetype(timestamp, Value_type.UNIVERSALCHARSTRING_VALUE);
                lengthRestriction.checkNofElements(timestamp, ((UniversalCharstring_Value) value).getValueLength(), false, false, false, this);
            }
            break;
        case UNIVERSALCHARSTRING_VALUE:
            if (Type_type.TYPE_UCHARSTRING.equals(typeType)) {
                lengthRestriction.checkNofElements(timestamp, ((UniversalCharstring_Value) value).getValueLength(), false, false, false, this);
            }
            break;
        case SEQUENCEOF_VALUE:
            if (Type_type.TYPE_SEQUENCE_OF.equals(typeType)) {
                lengthRestriction.checkNofElements(timestamp, ((SequenceOf_Value) value).getNofComponents(), false, false, false, this);
            }
            break;
        case SETOF_VALUE:
            if (Type_type.TYPE_SET_OF.equals(typeType)) {
                lengthRestriction.checkNofElements(timestamp, ((SetOf_Value) value).getNofComponents(), false, false, false, this);
            }
            break;
        case OMIT_VALUE:
            lengthRestriction.getLocation().reportSemanticError("Length restriction cannot be used with omit value");
            break;
        default:
            // they are either correct or not applicable to the type
            break;
    }
}
Also used : UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)23 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)14 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)14 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)11 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)9 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)8 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)7 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)7 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)5 UniversalChar (org.eclipse.titan.designer.AST.TTCN3.values.UniversalChar)5 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)4 IType (org.eclipse.titan.designer.AST.IType)3 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)3 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)3 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)3 SetOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)3 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)2 ISubReference (org.eclipse.titan.designer.AST.ISubReference)2 Reference (org.eclipse.titan.designer.AST.Reference)2 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)2