Search in sources :

Example 1 with Integer_Type

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

the class Def_Type_Visit_Handler method visitDefTypeChildrenNodes.

public void visitDefTypeChildrenNodes(IVisitableNode node) {
    if (node instanceof Def_Port) {
        Def_Port port = (Def_Port) node;
        componentPortNames.add(port.getIdentifier().toString());
    }
    if (node instanceof Def_Var) {
        Def_Var var = (Def_Var) node;
        componentVarNames.add(var.getIdentifier().toString());
        if (var.getType(compilationCounter) instanceof Integer_Type) {
            componentVarTypes.add("INTEGER");
        }
    }
    if (waitForCompReference && (node instanceof Reference)) {
        componentPortTypes.add(((Reference) node).getId().toString());
    }
    if (waitForSetOfFieldType) {
        if (node instanceof Reference) {
            setOfFieldType = node.toString();
            myASTVisitor.nodeNameSetOfTypesHashMap.put(parentName, setOfFieldType);
            waitForSetOfFieldType = false;
        } else if (node instanceof Type && !(node instanceof Referenced_Type) && !(node instanceof SetOf_Type)) {
            Type type = (Type) node;
            setOfFieldType = TypeMapper.map(type.getTypename());
            myASTVisitor.nodeNameSetOfTypesHashMap.put(parentName, setOfFieldType);
            waitForSetOfFieldType = false;
        }
    }
    if (waitForRecordOfFieldType) {
        if (node instanceof Reference) {
            recordOfFieldType = node.toString();
            myASTVisitor.nodeNameRecordOfTypesHashMap.put(parentName, recordOfFieldType);
            waitForRecordOfFieldType = false;
        } else if (node instanceof Type && !(node instanceof Referenced_Type) && !(node instanceof SequenceOf_Type)) {
            Type type = (Type) node;
            recordOfFieldType = TypeMapper.map(type.getTypename());
            myASTVisitor.nodeNameRecordOfTypesHashMap.put(parentName, recordOfFieldType);
            waitForRecordOfFieldType = false;
        }
    }
    if (node instanceof CompField) {
        // component
        CompField compFieldNode = (CompField) node;
        if (compFieldNode.getType() instanceof Referenced_Type) {
            compFieldTypes.add(((Referenced_Type) compFieldNode.getType()).getReference().getId().toString());
        } else {
            compFieldTypes.add(myASTVisitor.cutModuleNameFromBeginning(compFieldNode.getType().getTypename()));
        }
        compFieldNames.add(compFieldNode.getIdentifier().toString());
    }
    if (node instanceof Charstring_Value) {
        // charstring
        Charstring_Value singleValuedNode = (Charstring_Value) node;
        charstringValue = singleValuedNode.getValue();
    }
    if (node instanceof Integer_Value) {
        String value = ((Integer_Value) node).toString();
        if (myASTVisitor.isNextIntegerNegative) {
            value = "-" + value;
        }
        expressionValue.add("new INTEGER(\"" + value + "\")");
    }
    if (node instanceof Real_Value) {
        String value = ((Real_Value) node).toString();
        if (myASTVisitor.isNextIntegerNegative) {
            value = "-" + value;
        }
        if (value.equals("-Infinity") || value.equals("Infinity")) {
            value = "null";
        }
        expressionValue.add(value);
    }
    if (node instanceof Undefined_LowerIdentifier_Value) {
        String value = ((Undefined_LowerIdentifier_Value) node).getIdentifier().toString();
        if (myASTVisitor.isNextIntegerNegative) {
            value = "-" + value;
        }
        expressionValue.add(value);
    }
    if (node instanceof EnumerationItems) {
        for (int i = 0; i < ((EnumerationItems) node).getItems().size(); i++) {
            enumItems.add(((EnumerationItems) node).getItems().get(i).getId().toString());
            if (((EnumerationItems) node).getItems().get(i).getValue() != null) {
                enumItemValues.add(((EnumerationItems) node).getItems().get(i).getValue().toString());
            } else {
                enumItemValues.add(null);
            }
        }
    }
    if (waitingForPortAttriburtes && (node instanceof Referenced_Type)) {
        isPortTypeAReferencedType = true;
    }
    if (waitingForPortAttriburtes && (node instanceof PortTypeBody)) {
        PortTypeBody body = (PortTypeBody) node;
        int inCount = body.getInMessages().getNofTypes();
        int outCount = body.getOutMessage().getNofTypes();
        for (int i = 0; i < inCount; i++) {
            inMessageName.add(myASTVisitor.cutModuleNameFromBeginning(body.getInMessages().getTypeByIndex(i).getTypename()));
        }
        for (int i = 0; i < outCount; i++) {
            outMessageName.add(myASTVisitor.cutModuleNameFromBeginning(body.getOutMessage().getTypeByIndex(i).getTypename()));
        }
        int shorterListSize = inMessageName.size() <= outMessageName.size() ? inMessageName.size() : outMessageName.size();
        // if inout delete from both lists and add to inout
        for (int i = 0; i < inMessageName.size(); i++) {
            for (int j = 0; j < outMessageName.size(); j++) {
                if (inMessageName.get(i).equals(outMessageName.get(j))) {
                    inOutMessageName.add(inMessageName.get(i));
                    inMessageName.remove(i);
                    if (j == (outMessageName.size() - 1)) {
                        i--;
                    }
                    outMessageName.remove(j);
                    j--;
                }
            }
        }
        myASTVisitor.portNamePortTypeHashMap.put(currentPortName, body.getTestportType().toString());
        portTypeList.add(body.getTestportType().toString());
    }
}
Also used : Def_Var(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var) Reference(org.eclipse.titan.designer.AST.Reference) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) Def_Port(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Port) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value) Range_ParsedSubType(org.eclipse.titan.designer.AST.TTCN3.types.subtypes.Range_ParsedSubType) SequenceOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SequenceOf_Type) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) TTCN3_Enumerated_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type) SetOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SetOf_Type) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) Type(org.eclipse.titan.designer.AST.Type) Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) CharString_Type(org.eclipse.titan.designer.AST.TTCN3.types.CharString_Type) SetOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SetOf_Type) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) EnumerationItems(org.eclipse.titan.designer.AST.TTCN3.types.EnumerationItems) PortTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) SequenceOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SequenceOf_Type) Undefined_LowerIdentifier_Value(org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)

Example 2 with Integer_Type

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

the class Def_Type_Visit_Handler method visitDefTypeNodes.

public void visitDefTypeNodes(IVisitableNode node) {
    Def_Type typeNode = (Def_Type) node;
    String nodeName = typeNode.getIdentifier().toString();
    myASTVisitor.currentFileName = nodeName;
    myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
    Type type = typeNode.getType(compilationCounter);
    if (type.getTypetype().equals(TYPE_TTCN3_SEQUENCE)) {
        // record
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "record");
        parentName = nodeName;
    } else if (type.getTypetype().equals(TYPE_TTCN3_SET)) {
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "set");
        parentName = nodeName;
    } else if (type.getTypetype().equals(TYPE_TTCN3_CHOICE)) {
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "union");
        parentName = nodeName;
    } else if (type instanceof Integer_Type) {
        Def_Type_Integer_Writer.getInstance(typeNode);
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "INTEGER");
        parentName = nodeName;
        isInteger = true;
    } else if (type instanceof CharString_Type) {
        Def_Type_Charstring_Writer.getInstance(typeNode);
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "CHARSTRING");
        parentName = nodeName;
    } else if (type instanceof TTCN3_Enumerated_Type) {
        Def_Type_Enum_Writer.getInstance(typeNode);
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "enum");
        parentName = nodeName;
    } else if (type.getTypetype().equals(TYPE_SET_OF)) {
        waitForSetOfFieldType = true;
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "setof");
        parentName = nodeName;
    } else if (type.getTypetype().equals(TYPE_SEQUENCE_OF)) {
        waitForRecordOfFieldType = true;
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "recordof");
        parentName = nodeName;
    } else if (type.getTypetype().equals(TYPE_PORT)) {
        Def_Type_Port_Writer.getInstance(typeNode);
        waitingForPortAttriburtes = true;
        currentPortName = nodeName;
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "port");
        parentName = nodeName;
    } else if (type.getTypetype().equals(TYPE_COMPONENT)) {
        Def_Type_Component_Writer.getInstance(typeNode);
        waitForCompReference = true;
        AstWalkerJava.componentList.add(nodeName);
        myASTVisitor.nodeNameNodeTypeHashMap.put(nodeName, "component");
        parentName = nodeName;
    }
}
Also used : Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) Range_ParsedSubType(org.eclipse.titan.designer.AST.TTCN3.types.subtypes.Range_ParsedSubType) SequenceOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SequenceOf_Type) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) TTCN3_Enumerated_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type) SetOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SetOf_Type) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) Type(org.eclipse.titan.designer.AST.Type) Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) CharString_Type(org.eclipse.titan.designer.AST.TTCN3.types.CharString_Type) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) TTCN3_Enumerated_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type) CharString_Type(org.eclipse.titan.designer.AST.TTCN3.types.CharString_Type)

Example 3 with Integer_Type

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

the class SubType method addTtcnRange.

private boolean addTtcnRange(final CompilationTimeStamp timestamp, final Value min, final boolean minExclusive, final Value max, final boolean maxExclusive, final int restrictionIndex) {
    switch(subtypeType) {
        case ST_INTEGER:
        case ST_FLOAT:
        case ST_CHARSTRING:
        case ST_UNIVERSAL_CHARSTRING:
            break;
        default:
            myOwner.getLocation().reportSemanticError(MessageFormat.format("Range subtyping is not allowed for type `{0}''", myOwner.getTypename()));
            return false;
    }
    if (min == null || max == null) {
        return false;
    }
    IValue vmin = null, vmax = null;
    min.setMyScope(myOwner.getMyScope());
    min.setMyGovernor(myOwner);
    BridgingNamedNode bridge = new BridgingNamedNode(myOwner, myOwner.getFullName() + ".<range_restriction_" + restrictionIndex + "_lower>");
    min.setFullNameParent(bridge);
    IValue last = myOwner.checkThisValueRef(timestamp, min);
    IType lastOwner = myOwner.getTypeRefdLast(timestamp);
    if (lastOwner instanceof Integer_Type) {
        ((Integer_Type) lastOwner).checkThisValueLimit(timestamp, last, Expected_Value_type.EXPECTED_CONSTANT, false, false, false, false);
    } else {
        myOwner.checkThisValue(timestamp, last, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_CONSTANT, false, false, false, false, false));
    }
    IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    vmin = last.getValueRefdLast(timestamp, chain);
    chain.release();
    max.setMyScope(myOwner.getMyScope());
    max.setMyGovernor(myOwner);
    bridge = new BridgingNamedNode(myOwner, myOwner.getFullName() + ".<range_restriction_" + restrictionIndex + "_upper>");
    max.setFullNameParent(bridge);
    last = myOwner.checkThisValueRef(timestamp, max);
    lastOwner = myOwner.getTypeRefdLast(timestamp);
    if (lastOwner instanceof Integer_Type) {
        ((Integer_Type) lastOwner).checkThisValueLimit(timestamp, last, Expected_Value_type.EXPECTED_CONSTANT, false, false, false, false);
    } else {
        myOwner.checkThisValue(timestamp, last, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_CONSTANT, false, false, false, false, false));
    }
    chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    vmax = last.getValueRefdLast(timestamp, chain);
    chain.release();
    if (vmin.getIsErroneous(timestamp) || vmin.isUnfoldable(timestamp)) {
        // the error was already reported
        return false;
    }
    if (vmax.getIsErroneous(timestamp) || vmax.isUnfoldable(timestamp)) {
        // the error was already reported
        return false;
    }
    SubtypeConstraint rangeConstraint;
    switch(subtypeType) {
        case ST_INTEGER:
            {
                IntegerLimit minLimit;
                if (Value_type.REAL_VALUE.equals(vmin.getValuetype())) {
                    final Real_Value real = (Real_Value) vmin;
                    if (real.isNegativeInfinity()) {
                        minLimit = IntegerLimit.MINIMUM;
                    } else {
                        minLimit = IntegerLimit.MAXIMUM;
                    }
                } else {
                    minLimit = new IntegerLimit(((Integer_Value) vmin).getValueValue());
                }
                IntegerLimit maxLimit;
                if (Value_type.REAL_VALUE.equals(vmax.getValuetype())) {
                    final Real_Value real = (Real_Value) vmax;
                    if (real.isPositiveInfinity()) {
                        maxLimit = IntegerLimit.MAXIMUM;
                    } else {
                        maxLimit = IntegerLimit.MINIMUM;
                    }
                } else {
                    maxLimit = new IntegerLimit(((Integer_Value) vmax).getValueValue());
                }
                if (minExclusive) {
                    if (minLimit.compareTo(IntegerLimit.MINIMUM) == 0) {
                        myOwner.getLocation().reportSemanticError("invalid lower boundary, -infinity cannot be excluded from an integer subtype range");
                        return false;
                    }
                    if (minLimit.compareTo(IntegerLimit.MAXIMUM) == 0) {
                        myOwner.getLocation().reportSemanticError("!infinity is not a valid lower boundary");
                        return false;
                    }
                    minLimit = (IntegerLimit) minLimit.increment();
                }
                if (maxExclusive) {
                    if (maxLimit.compareTo(IntegerLimit.MAXIMUM) == 0) {
                        myOwner.getLocation().reportSemanticError("invalid upper boundary, infinity cannot be excluded from an integer subtype range");
                        return false;
                    }
                    if (maxLimit.compareTo(IntegerLimit.MINIMUM) == 0) {
                        myOwner.getLocation().reportSemanticError("!-infinity is not a valid upper boundary");
                        return false;
                    }
                    maxLimit = (IntegerLimit) maxLimit.decrement();
                }
                if (maxLimit.compareTo(minLimit) < 0) {
                    Location.interval(min.getLocation(), max.getLocation()).reportSemanticError("lower boundary is bigger than upper boundary in integer subtype range");
                    return false;
                }
                rangeConstraint = new RangeListConstraint(minLimit, maxLimit);
                break;
            }
        case ST_FLOAT:
            {
                if (Double.isNaN(((Real_Value) vmin).getValue())) {
                    min.getLocation().reportSemanticError("lower boundary cannot be not_a_number in float subtype range");
                    return false;
                }
                if (Double.isNaN(((Real_Value) vmax).getValue())) {
                    max.getLocation().reportSemanticError("upper boundary cannot be not_a_number in float subtype range");
                    return false;
                }
                RealLimit minLimit = new RealLimit(((Real_Value) vmin).getValue());
                RealLimit maxLimit = new RealLimit(((Real_Value) vmax).getValue());
                if (minExclusive) {
                    if (minLimit.compareTo(RealLimit.MAXIMUM) == 0) {
                        myOwner.getLocation().reportSemanticError("!infinity is not a valid lower boundary");
                        return false;
                    }
                    minLimit = (RealLimit) minLimit.increment();
                }
                if (maxExclusive) {
                    if (maxLimit.compareTo(RealLimit.MINIMUM) == 0) {
                        myOwner.getLocation().reportSemanticError("!-infinity is not a valid upper boundary");
                        return false;
                    }
                    maxLimit = (RealLimit) maxLimit.decrement();
                }
                if (maxLimit.compareTo(minLimit) < 0) {
                    Location.interval(min.getLocation(), max.getLocation()).reportSemanticError("lower boundary is bigger than upper boundary in float subtype range");
                    return false;
                }
                rangeConstraint = new RealRangeListConstraint(minLimit, maxLimit);
                break;
            }
        case ST_CHARSTRING:
            {
                boolean erroneous = false;
                if (Value_type.REAL_VALUE.equals(vmin.getValuetype()) && ((Real_Value) vmin).isNegativeInfinity()) {
                    getParsedLocation().reportSemanticError("lower boundary of a charstring subtype range cannot be -infinity");
                    erroneous = true;
                }
                if (Value_type.REAL_VALUE.equals(vmax.getValuetype()) && ((Real_Value) vmax).isPositiveInfinity()) {
                    getParsedLocation().reportSemanticError("upper boundary of a charstring subtype range cannot be infinity");
                    erroneous = true;
                }
                if (erroneous) {
                    return false;
                }
                String minString;
                switch(vmin.getValuetype()) {
                    case CHARSTRING_VALUE:
                        minString = ((Charstring_Value) vmin).getValue();
                        break;
                    case UNIVERSALCHARSTRING_VALUE:
                        {
                            final UniversalCharstring ustr = ((UniversalCharstring_Value) vmin).getValue();
                            if ((ustr.length() < 1) || !ustr.get(0).isValidChar()) {
                                min.getLocation().reportSemanticError("lower boundary of charstring subtype range is not a valid char");
                                return false;
                            }
                            minString = String.valueOf((char) ustr.get(0).cell());
                            break;
                        }
                    default:
                        return false;
                }
                String maxString;
                switch(vmax.getValuetype()) {
                    case CHARSTRING_VALUE:
                        maxString = ((Charstring_Value) vmax).getValue();
                        break;
                    case UNIVERSALCHARSTRING_VALUE:
                        {
                            final UniversalCharstring ustr = ((UniversalCharstring_Value) vmax).getValue();
                            if ((ustr.length() < 1) || !ustr.get(0).isValidChar()) {
                                max.getLocation().reportSemanticError("upper boundary of charstring subtype range is not a valid char");
                                return false;
                            }
                            maxString = String.valueOf((char) ustr.get(0).cell());
                            break;
                        }
                    default:
                        return false;
                }
                if (minString.length() != 1) {
                    min.getLocation().reportSemanticError("lower boundary of charstring subtype range must be a single element string");
                    return false;
                }
                if (maxString.length() != 1) {
                    max.getLocation().reportSemanticError("upper boundary of charstring subtype range must be a single element string");
                    return false;
                }
                CharLimit minLimit = new CharLimit(minString.charAt(0));
                CharLimit maxLimit = new CharLimit(maxString.charAt(0));
                if (minExclusive) {
                    if (minLimit.compareTo(CharLimit.MAXIMUM) == 0) {
                        min.getLocation().reportSemanticError("exclusive lower boundary is not a legal charstring character");
                        return false;
                    }
                    minLimit = (CharLimit) minLimit.increment();
                }
                if (maxExclusive) {
                    if (maxLimit.compareTo(CharLimit.MINIMUM) == 0) {
                        max.getLocation().reportSemanticError("exclusive upper boundary is not a legal charstring character");
                        return false;
                    }
                    maxLimit = (CharLimit) maxLimit.decrement();
                }
                if (maxLimit.compareTo(minLimit) < 0) {
                    Location.interval(min.getLocation(), max.getLocation()).reportSemanticError("lower boundary is bigger than upper boundary in charstring subtype range");
                    return false;
                }
                rangeConstraint = new StringSetConstraint(StringSubtypeTreeElement.StringType.CHARSTRING, StringSetConstraint.ConstraintType.ALPHABET_CONSTRAINT, new RangeListConstraint(minLimit, maxLimit));
                break;
            }
        case ST_UNIVERSAL_CHARSTRING:
            {
                boolean erroneous = false;
                if (Value_type.REAL_VALUE.equals(vmin.getValuetype()) && ((Real_Value) vmin).isNegativeInfinity()) {
                    min.getLocation().reportSemanticError("lower boundary of a universal charstring subtype range cannot be -infinity");
                    erroneous = true;
                }
                if (Value_type.REAL_VALUE.equals(vmax.getValuetype()) && ((Real_Value) vmax).isPositiveInfinity()) {
                    max.getLocation().reportSemanticError("upper boundary of a universal charstring subtype range cannot be infinity");
                    erroneous = true;
                }
                if (erroneous) {
                    return false;
                }
                UniversalCharstring minString;
                switch(vmin.getValuetype()) {
                    case CHARSTRING_VALUE:
                        minString = new UniversalCharstring(((Charstring_Value) vmin).getValue());
                        break;
                    case UNIVERSALCHARSTRING_VALUE:
                        minString = ((UniversalCharstring_Value) vmin).getValue();
                        break;
                    default:
                        return false;
                }
                UniversalCharstring maxString;
                switch(vmax.getValuetype()) {
                    case CHARSTRING_VALUE:
                        maxString = new UniversalCharstring(((Charstring_Value) vmax).getValue());
                        break;
                    case UNIVERSALCHARSTRING_VALUE:
                        maxString = ((UniversalCharstring_Value) vmax).getValue();
                        break;
                    default:
                        return false;
                }
                if (minString.length() != 1) {
                    min.getLocation().reportSemanticError("lower boundary of universal charstring subtype range must be a single element string");
                    return false;
                }
                if (maxString.length() != 1) {
                    max.getLocation().reportSemanticError("upper boundary of universal charstring subtype range must be a single element string");
                    return false;
                }
                UCharLimit minLimit = new UCharLimit(minString.get(0));
                UCharLimit maxLimit = new UCharLimit(maxString.get(0));
                if (minExclusive) {
                    if (minLimit.compareTo(UCharLimit.MAXIMUM) == 0) {
                        min.getLocation().reportSemanticError("exclusive lower boundary is not a legal universal charstring character");
                        return false;
                    }
                    minLimit = (UCharLimit) minLimit.increment();
                }
                if (maxExclusive) {
                    if (maxLimit.compareTo(UCharLimit.MINIMUM) == 0) {
                        max.getLocation().reportSemanticError("exclusive upper boundary is not a legal universal charstring character");
                        return false;
                    }
                    maxLimit = (UCharLimit) maxLimit.decrement();
                }
                if (maxLimit.compareTo(minLimit) < 0) {
                    Location.interval(min.getLocation(), max.getLocation()).reportSemanticError("lower boundary is bigger than upper boundary in universal charstring subtype range");
                    return false;
                }
                rangeConstraint = new StringSetConstraint(StringSubtypeTreeElement.StringType.UNIVERSAL_CHARSTRING, StringSetConstraint.ConstraintType.ALPHABET_CONSTRAINT, new RangeListConstraint(minLimit, maxLimit));
                break;
            }
        default:
            ErrorReporter.INTERNAL_ERROR();
            return false;
    }
    subtypeConstraint = (subtypeConstraint == null) ? rangeConstraint : subtypeConstraint.union(rangeConstraint);
    return true;
}
Also used : UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) PatternString(org.eclipse.titan.designer.AST.TTCN3.templates.PatternString) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) IType(org.eclipse.titan.designer.AST.IType) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value) IValue(org.eclipse.titan.designer.AST.IValue) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)

Example 4 with Integer_Type

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

the class Def_Type_Visit_Handler method handleDefTypeNodes.

public void handleDefTypeNodes(IVisitableNode node) {
    Def_Type typeNode = (Def_Type) node;
    CompilationTimeStamp compilationCounter = CompilationTimeStamp.getNewCompilationCounter();
    myASTVisitor.currentFileName = typeNode.getIdentifier().toString();
    Type type = typeNode.getType(compilationCounter);
    if (type.getTypetype().equals(TYPE_TTCN3_SEQUENCE)) {
        // record
        Def_Type_Record_Writer recordNode = new Def_Type_Record_Writer(typeNode);
        // add component fields
        recordNode.add(compFieldTypes, compFieldNames);
        String[] typeArray = (String[]) compFieldTypes.toArray(new String[compFieldTypes.size()]);
        String[] nameArray = (String[]) compFieldNames.toArray(new String[compFieldNames.size()]);
        myASTVisitor.nodeNameChildrenTypesHashMap.put(parentName, typeArray);
        myASTVisitor.nodeNameChildrenNamesHashMap.put(parentName, nameArray);
        compFieldTypes.clear();
        compFieldNames.clear();
        myASTVisitor.visualizeNodeToJava(recordNode.getJavaSource());
    } else if (type.getTypetype().equals(TYPE_TTCN3_SET)) {
        // set
        Def_Type_Set_Writer setNode = new Def_Type_Set_Writer(typeNode);
        // add component fields
        setNode.add(compFieldTypes, compFieldNames);
        String[] typeArray = (String[]) compFieldTypes.toArray(new String[compFieldTypes.size()]);
        String[] nameArray = (String[]) compFieldNames.toArray(new String[compFieldNames.size()]);
        myASTVisitor.nodeNameChildrenTypesHashMap.put(parentName, typeArray);
        myASTVisitor.nodeNameChildrenNamesHashMap.put(parentName, nameArray);
        compFieldTypes.clear();
        compFieldNames.clear();
        myASTVisitor.visualizeNodeToJava(setNode.getJavaSource());
    } else if (type.getTypetype().equals(TYPE_TTCN3_CHOICE)) {
        // union
        Def_Type_Union_Writer union_writer = new Def_Type_Union_Writer(typeNode);
        // add component fields
        union_writer.add(compFieldTypes, compFieldNames);
        String[] typeArray = compFieldTypes.toArray(new String[compFieldTypes.size()]);
        String[] nameArray = compFieldNames.toArray(new String[compFieldNames.size()]);
        myASTVisitor.nodeNameChildrenTypesHashMap.put(parentName, typeArray);
        myASTVisitor.nodeNameChildrenNamesHashMap.put(parentName, nameArray);
        compFieldTypes.clear();
        compFieldNames.clear();
        myASTVisitor.visualizeNodeToJava(union_writer.getJavaSource());
    } else if (type instanceof Integer_Type) {
        Def_Type_Integer_Writer integerNode = Def_Type_Integer_Writer.getInstance(typeNode);
        integerNode.clearLists();
        myASTVisitor.visualizeNodeToJava(integerNode.getJavaSource());
    } else if (type instanceof CharString_Type) {
        Def_Type_Charstring_Writer charstringNode = Def_Type_Charstring_Writer.getInstance(typeNode);
        charstringNode.clearLists();
        charstringNode.addCharStringValue(charstringValue);
        charstringValue = null;
        myASTVisitor.visualizeNodeToJava(charstringNode.getJavaSource());
    } else if (type instanceof TTCN3_Enumerated_Type) {
        Def_Type_Enum_Writer enumTypeNode = Def_Type_Enum_Writer.getInstance(typeNode);
        enumTypeNode.clearLists();
        enumTypeNode.enumItems.addAll(enumItems);
        enumTypeNode.enumItemValues.addAll(enumItemValues);
        enumItemValues.clear();
        enumItems.clear();
        myASTVisitor.visualizeNodeToJava(enumTypeNode.getJavaSource());
    } else if (type.getTypetype().equals(TYPE_SET_OF)) {
        Def_Type_Set_Of_Writer setOfNode = new Def_Type_Set_Of_Writer(typeNode);
        setOfNode.setFieldType(setOfFieldType);
        setOfFieldType = null;
        myASTVisitor.visualizeNodeToJava(setOfNode.getJavaSource());
    } else if (type.getTypetype().equals(TYPE_SEQUENCE_OF)) {
        Def_Type_Record_Of_Writer writer = new Def_Type_Record_Of_Writer(typeNode);
        writer.setFieldType(recordOfFieldType);
        myASTVisitor.visualizeNodeToJava(writer.getJavaSource());
    } else if (type.getTypetype().equals(TYPE_PORT)) {
        Def_Type_Port_Writer portNode = Def_Type_Port_Writer.getInstance(typeNode);
        portNode.clearLists();
        portNode.inMessageName.addAll(inMessageName);
        portNode.outMessageName.addAll(outMessageName);
        portNode.inOutMessageName.addAll(inOutMessageName);
        portNode.setPortTypeAReferencedType(isPortTypeAReferencedType);
        waitingForPortAttriburtes = false;
        isPortTypeAReferencedType = false;
        inMessageName.clear();
        outMessageName.clear();
        inOutMessageName.clear();
        myASTVisitor.visualizeNodeToJava(portNode.getJavaSource());
    } else if (type.getTypetype().equals(TYPE_COMPONENT)) {
        Def_Type_Component_Writer compNode = Def_Type_Component_Writer.getInstance(typeNode);
        compNode.clearLists();
        // add component fields
        compNode.compFieldPortTypes.addAll(componentPortTypes);
        compNode.compFieldPortNames.addAll(componentPortNames);
        compNode.compFieldVarTypes.addAll(componentVarTypes);
        compNode.compFieldVarNames.addAll(componentVarNames);
        componentPortTypes.clear();
        componentPortNames.clear();
        componentVarTypes.clear();
        componentVarNames.clear();
        waitForCompReference = false;
        myASTVisitor.visualizeNodeToJava(compNode.getJavaSource());
    }
    parentName = null;
}
Also used : Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) TTCN3_Enumerated_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type) CharString_Type(org.eclipse.titan.designer.AST.TTCN3.types.CharString_Type) Range_ParsedSubType(org.eclipse.titan.designer.AST.TTCN3.types.subtypes.Range_ParsedSubType) SequenceOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SequenceOf_Type) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) TTCN3_Enumerated_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type) SetOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SetOf_Type) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) Type(org.eclipse.titan.designer.AST.Type) Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) CharString_Type(org.eclipse.titan.designer.AST.TTCN3.types.CharString_Type) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) CompilationTimeStamp(org.eclipse.titan.designer.parsers.CompilationTimeStamp)

Example 5 with Integer_Type

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

the class SelectWithNumbersSorted method process.

@Override
protected void process(final IVisitableNode node, final Problems problems) {
    if (!(node instanceof SelectCase_Statement)) {
        return;
    }
    final SelectCase_Statement s = (SelectCase_Statement) node;
    final Value v = s.getExpression();
    if (v == null || v.getIsErroneous(timestamp)) {
        return;
    }
    final SelectCases scs = s.getSelectCases();
    if (scs == null || scs.getSelectCaseArray() == null) {
        return;
    }
    // if there is an else branch, no smell will be reported
    for (final SelectCase sc : scs.getSelectCaseArray()) {
        if (sc.hasElse()) {
            return;
        }
    }
    IType itype = v.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
    // TODO Kristof: az ellenorzes folosleges.
    if (itype instanceof Referenced_Type) {
        itype = itype.getTypeRefdLast(timestamp);
    }
    if (itype == null || !(itype instanceof Integer_Type)) {
        return;
    }
    // count number of cases in select, get used integer type case-items
    final CaseVisitorInteger caseVisitorInteger = new CaseVisitorInteger();
    scs.accept(caseVisitorInteger);
    if (caseVisitorInteger.containsUnfoldable()) {
        return;
    }
    final List<Long> usedIntegerItems = caseVisitorInteger.getItemsUsed();
    if (!checkIfIntegerCasesSorted(usedIntegerItems)) {
        problems.report(s.getLocation(), ERR_MSG);
    }
}
Also used : SelectCase_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.SelectCase_Statement) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) SelectCases(org.eclipse.titan.designer.AST.TTCN3.statements.SelectCases) SelectCase(org.eclipse.titan.designer.AST.TTCN3.statements.SelectCase) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

Integer_Type (org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type)7 IValue (org.eclipse.titan.designer.AST.IValue)4 Referenced_Type (org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type)4 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)3 Def_Type (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type)3 CharString_Type (org.eclipse.titan.designer.AST.TTCN3.types.CharString_Type)3 SequenceOf_Type (org.eclipse.titan.designer.AST.TTCN3.types.SequenceOf_Type)3 SetOf_Type (org.eclipse.titan.designer.AST.TTCN3.types.SetOf_Type)3 TTCN3_Enumerated_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type)3 Range_ParsedSubType (org.eclipse.titan.designer.AST.TTCN3.types.subtypes.Range_ParsedSubType)3 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)3 Type (org.eclipse.titan.designer.AST.Type)3 BigInteger (java.math.BigInteger)2 IType (org.eclipse.titan.designer.AST.IType)2 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)2 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)2 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)2 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)1 Reference (org.eclipse.titan.designer.AST.Reference)1 Def_Port (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Port)1