Search in sources :

Example 71 with IReferenceChain

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

the class SubType method checkThisTemplateLengthRestriction.

private void checkThisTemplateLengthRestriction(final CompilationTimeStamp timestamp, final TTCN3Template template) {
    final LengthRestriction lengthRestriction = template.getLengthRestriction();
    if ((lengthRestriction == null) || (subtypeConstraint == null)) {
        return;
    }
    // if there is a length restriction on the template then check
    // if
    // the intersection of the two restrictions is not empty
    SizeLimit tmplMinLen, tmplMaxLen;
    lengthRestriction.check(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (lengthRestriction instanceof SingleLenghtRestriction) {
        final SingleLenghtRestriction realRestriction = (SingleLenghtRestriction) lengthRestriction;
        final IValue lower = realRestriction.getRestriction(timestamp);
        if (lower.getIsErroneous(timestamp)) {
            return;
        }
        final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
        final IValue last = lower.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, chain);
        chain.release();
        if (!Value_type.INTEGER_VALUE.equals(last.getValuetype())) {
            return;
        }
        final BigInteger length = ((Integer_Value) last).getValueValue();
        tmplMinLen = new SizeLimit(length);
        tmplMaxLen = tmplMinLen;
    } else {
        final RangeLenghtRestriction realRestriction = (RangeLenghtRestriction) lengthRestriction;
        final IValue lower = realRestriction.getLowerValue(timestamp);
        IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
        final IValue lastLower = lower.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, chain);
        chain.release();
        if (lastLower.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(lastLower.getValuetype())) {
            return;
        }
        final IValue upper = realRestriction.getUpperValue(timestamp);
        if (upper == null) {
            return;
        }
        chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
        final IValue lastUpper = upper.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, chain);
        chain.release();
        if (lastUpper.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(lastUpper.getValuetype())) {
            return;
        }
        tmplMinLen = new SizeLimit(((Integer_Value) lastLower).getValueValue());
        tmplMaxLen = new SizeLimit(((Integer_Value) lastUpper).getValueValue());
    }
    SubtypeConstraint tmplConstraint;
    switch(subtypeType) {
        case ST_BITSTRING:
            tmplConstraint = new StringSizeAndValueListConstraint(StringSizeAndValueListConstraint.Type.BITSTRING, tmplMinLen, tmplMaxLen);
            break;
        case ST_HEXSTRING:
            tmplConstraint = new StringSizeAndValueListConstraint(StringSizeAndValueListConstraint.Type.HEXSTRING, tmplMinLen, tmplMaxLen);
            break;
        case ST_OCTETSTRING:
            tmplConstraint = new StringSizeAndValueListConstraint(StringSizeAndValueListConstraint.Type.OCTETSTRING, tmplMinLen, tmplMaxLen);
            break;
        case ST_CHARSTRING:
            tmplConstraint = new StringSetConstraint(StringSubtypeTreeElement.StringType.CHARSTRING, StringSetConstraint.ConstraintType.SIZE_CONSTRAINT, new RangeListConstraint(tmplMinLen, tmplMaxLen));
            break;
        case ST_UNIVERSAL_CHARSTRING:
            tmplConstraint = new StringSetConstraint(StringSubtypeTreeElement.StringType.UNIVERSAL_CHARSTRING, StringSetConstraint.ConstraintType.SIZE_CONSTRAINT, new RangeListConstraint(tmplMinLen, tmplMaxLen));
            break;
        case ST_RECORDOF:
        case ST_SETOF:
            tmplConstraint = new ValueListAndSizeConstraint(tmplMinLen, tmplMaxLen);
            break;
        default:
            return;
    }
    if (subtypeConstraint.intersection(tmplConstraint).isEmpty() == TernaryBool.TTRUE) {
        template.getLocation().reportSemanticWarning(MessageFormat.format("Template's length restriction {0} is outside of the type's subtype constraint {1}", (new RangeListConstraint(tmplMinLen, tmplMaxLen)).toString(), subtypeConstraint.toString()));
    }
}
Also used : LengthRestriction(org.eclipse.titan.designer.AST.TTCN3.templates.LengthRestriction) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) SingleLenghtRestriction(org.eclipse.titan.designer.AST.TTCN3.templates.SingleLenghtRestriction) IValue(org.eclipse.titan.designer.AST.IValue) RangeLenghtRestriction(org.eclipse.titan.designer.AST.TTCN3.templates.RangeLenghtRestriction) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) BigInteger(java.math.BigInteger)

Example 72 with IReferenceChain

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

the class SubType method addTtcnSingle.

/**
 * add TTCN-3 single value sub-type constraint to this sub-type
 */
private boolean addTtcnSingle(final CompilationTimeStamp timestamp, final Value value, final int restrictionIndex) {
    value.setMyScope(myOwner.getMyScope());
    value.setMyGovernor(myOwner);
    final BridgingNamedNode bridge = new BridgingNamedNode(myOwner, myOwner.getTypename() + ".<single_restriction_" + restrictionIndex + ">");
    value.setFullNameParent(bridge);
    IValue last = myOwner.checkThisValueRef(timestamp, value);
    // check if this is type reference, if not then fall through
    final IValue refValue = value.setLoweridToReference(timestamp);
    // Value_type.REFERENCED_VALUE);
    if (refValue.getValuetype() == Value.Value_type.REFERENCED_VALUE) {
        final Reference ref = ((Referenced_Value) refValue).getReference();
        final Assignment ass = ref.getRefdAssignment(timestamp, false);
        if (ass == null) {
            // definition was not found, error was reported
            return false;
        }
        if (ass.getAssignmentType() == Assignment.Assignment_type.A_TYPE) {
            IType t = ass.getType(timestamp);
            t.check(timestamp);
            if (t.getIsErroneous(timestamp)) {
                return false;
            }
            final List<ISubReference> subrefs = ref.getSubreferences();
            if (subrefs.size() > 1) {
                // if there were sub-references then get the referenced field's type
                t = t.getFieldType(timestamp, ref, 1, Expected_Value_type.EXPECTED_CONSTANT, false);
                if ((t == null) || t.getIsErroneous(timestamp)) {
                    return false;
                }
                t.check(timestamp);
                if (t.getIsErroneous(timestamp)) {
                    return false;
                }
            }
            if (!t.isIdentical(timestamp, myOwner)) {
                value.getLocation().reportSemanticError(MessageFormat.format("Reference `{0}'' must refer to a type which has the same root type as this type", ref.getDisplayName()));
                return false;
            }
            // check subtype of referenced type
            final SubType tSt = t.getSubtype();
            if ((tSt == null) || (tSt.subtypeConstraint == null)) {
                value.getLocation().reportSemanticError(MessageFormat.format("Type referenced by `{0}'' does not have a subtype", ref.getDisplayName()));
                return false;
            }
            // check circular sub-type reference
            if (!addParentSubtype(tSt)) {
                return false;
            }
            if (tSt.getIsErroneous(timestamp)) {
                return false;
            }
            if (tSt.subtypeType != subtypeType) {
                ErrorReporter.INTERNAL_ERROR();
                return false;
            }
            // add the sub-type as union
            if (subtypeConstraint == null) {
                subtypeConstraint = tSt.subtypeConstraint;
            } else {
                subtypeConstraint = subtypeConstraint.union(tSt.subtypeConstraint);
            }
            return true;
        }
    }
    myOwner.checkThisValue(timestamp, last, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_CONSTANT, false, false, false, false, false));
    final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    last = last.getValueRefdLast(timestamp, chain);
    chain.release();
    if (last.getIsErroneous(timestamp) || last.isUnfoldable(timestamp)) {
        return false;
    }
    // create a single value constraint
    SubtypeConstraint sc;
    switch(subtypeType) {
        case ST_INTEGER:
            sc = new RangeListConstraint(new IntegerLimit(((Integer_Value) last).getValueValue()));
            break;
        case ST_FLOAT:
            sc = new RealRangeListConstraint(((Real_Value) last).getValue());
            break;
        case ST_BOOLEAN:
            sc = new BooleanListConstraint(((Boolean_Value) last).getValue());
            break;
        case ST_VERDICTTYPE:
            sc = new VerdicttypeListConstraint(((Verdict_Value) last).getValue());
            break;
        case ST_BITSTRING:
            sc = new StringSizeAndValueListConstraint(StringSizeAndValueListConstraint.Type.BITSTRING, ((Bitstring_Value) last).getValue());
            break;
        case ST_HEXSTRING:
            sc = new StringSizeAndValueListConstraint(StringSizeAndValueListConstraint.Type.HEXSTRING, ((Hexstring_Value) last).getValue());
            break;
        case ST_OCTETSTRING:
            sc = new StringSizeAndValueListConstraint(StringSizeAndValueListConstraint.Type.OCTETSTRING, ((Octetstring_Value) last).getValue());
            break;
        case ST_CHARSTRING:
            if (last.getValuetype() != Value.Value_type.CHARSTRING_VALUE) {
                return false;
            }
            sc = new StringSetConstraint(StringSubtypeTreeElement.StringType.CHARSTRING, StringSetConstraint.ConstraintType.VALUE_CONSTRAINT, new StringValueConstraint(((Charstring_Value) last).getValue()));
            break;
        case ST_UNIVERSAL_CHARSTRING:
            switch(last.getValuetype()) {
                case CHARSTRING_VALUE:
                    sc = new StringSetConstraint(StringSubtypeTreeElement.StringType.UNIVERSAL_CHARSTRING, StringSetConstraint.ConstraintType.VALUE_CONSTRAINT, new UStringValueConstraint(new UniversalCharstring(((Charstring_Value) last).getValue())));
                    break;
                case UNIVERSALCHARSTRING_VALUE:
                    sc = new StringSetConstraint(StringSubtypeTreeElement.StringType.UNIVERSAL_CHARSTRING, StringSetConstraint.ConstraintType.VALUE_CONSTRAINT, new UStringValueConstraint(((UniversalCharstring_Value) last).getValue()));
                    break;
                default:
                    return false;
            }
            break;
        case ST_OBJID:
        case ST_ENUM:
        case ST_UNION:
        case ST_RECORD:
        case ST_SET:
        case ST_FUNCTION:
        case ST_ALTSTEP:
        case ST_TESTCASE:
            sc = new ValueListConstraint(last);
            break;
        case ST_RECORDOF:
        case ST_SETOF:
            sc = new ValueListAndSizeConstraint(last);
            break;
        default:
            ErrorReporter.INTERNAL_ERROR();
            return false;
    }
    // add next value using union operation
    if (subtypeConstraint == null) {
        subtypeConstraint = sc;
    } else {
        subtypeConstraint = subtypeConstraint.union(sc);
    }
    return true;
}
Also used : IType(org.eclipse.titan.designer.AST.IType) Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) Bitstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value) 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) Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) Boolean_Value(org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value) ISubReference(org.eclipse.titan.designer.AST.ISubReference) Reference(org.eclipse.titan.designer.AST.Reference) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value) Verdict_Value(org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value) ISubReference(org.eclipse.titan.designer.AST.ISubReference)

Example 73 with IReferenceChain

use of org.eclipse.titan.designer.AST.IReferenceChain 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 74 with IReferenceChain

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

the class Altstep_Reference_Value method checkEquality.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = other.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    return Value_type.ALTSTEP_REFERENCE_VALUE.equals(last.getValuetype()) && referredAltstep == ((Altstep_Reference_Value) last).getReferredAltstep();
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Example 75 with IReferenceChain

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

the class Anytype_Value method checkEquality.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = other.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    if (!Value_type.ANYTYPE_VALUE.equals(last.getValuetype())) {
        return false;
    }
    final Anytype_Value otherAny = (Anytype_Value) last;
    if (!name.equals(otherAny.name) || !value.checkEquality(timestamp, otherAny.value)) {
        return false;
    }
    return true;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Aggregations

IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)154 IValue (org.eclipse.titan.designer.AST.IValue)102 IType (org.eclipse.titan.designer.AST.IType)55 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)21 ISubReference (org.eclipse.titan.designer.AST.ISubReference)18 Value (org.eclipse.titan.designer.AST.Value)18 Assignment (org.eclipse.titan.designer.AST.Assignment)16 BigInteger (java.math.BigInteger)15 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)14 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)13 Identifier (org.eclipse.titan.designer.AST.Identifier)12 Reference (org.eclipse.titan.designer.AST.Reference)9 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)8 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)7 Expression_Value (org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value)7 HashMap (java.util.HashMap)6 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)6 Referenced_Type (org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type)6 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)6 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)5