Ignore:
Timestamp:
Jul 9, 2019 3:08:30 PM (5 months ago)
Author:
tgutzmann
Message:

Merge from trunk

Location:
branches/dev-mj-1626
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-mj-1626

  • branches/dev-mj-1626/Compiler/ModelicaFrontEnd/src/jastadd/errorcheck/TypeCheck.jrag

    r12962 r13095  
    445445            new ErrorProducerUnlessDisabled("ARRAY_SIZE_MISMATCH_IN_CONNECT", ProblemKind.SEMANTIC,
    446446                    "Sizes do not match in connection, size of '%s' is %s and size of '%s' is %s");
     447    public static final ErrorProducerUnlessDisabled ASTNode.EXPANDABLE_ARRAY_SIZE_MISMATCH_IN_CONNECT =
     448            new ErrorProducerUnlessDisabled("ARRAY_SIZE_MISMATCH_IN_CONNECT", ProblemKind.SEMANTIC,
     449                    "Sizes do not match in connection, size of the part of '%s' referring to " +
     450                    "the expandable connector is %s and size of '%s' is %s");
    447451
    448452    public void FConnectClause.typeCheck(ErrorCheckType checkType) {
     
    450454        InstAccess right = getConnector2();
    451455        boolean checkTypes = !isDisabled();
     456        boolean isExpandable = false;
    452457        boolean expandableSame = true;
    453458        for (InstAccess access = left; access != null; access = (access == left) ? right : null) {
    454             if (!access.isExpandableConnectorPart() && !access.isUnknown() && !access.myInstComponentDecl().myInstClass().isUnknown()) {
     459            if (access.isExpandableConnectorPart()) {
     460                isExpandable = true;
     461            } else if (!access.isUnknown() && !access.myInstComponentDecl().myInstClass().isUnknown()) {
    455462                if (!access.myInstComponentDecl().isConnector())
    456463                    CONNECT_WITH_INVALID_TYPE.invoke(access);
     
    458465                checkTypes = false;
    459466            }
    460             if (access.myInstComponentDecl().isExpandableConnector())
     467            if (access.myInstComponentDecl().isExpandableConnector()) {
    461468                expandableSame = !expandableSame;
    462         }
    463         if (!expandableSame && !left.isUnknown() && !right.isUnknown())
     469            }
     470        }
     471        if (!expandableSame && !left.isUnknown() && !right.isUnknown()) {
    464472            CONNECT_EXPANDABLE_AND_NON_EXPANDABLE_TYPE.invoke(this);
     473        }
    465474        if (checkTypes) {
    466             InstComponentDecl leftComp  = left.lookupEvaluatingIndices();
    467             InstComponentDecl rightComp = right.lookupEvaluatingIndices();
    468             if (!leftComp.connectableTo(rightComp)) {
    469                 TYPE_MISMATCH_IN_CONNECT.invoke(this);
    470             } else if (!left.size().equivalent(right.size(), false)) {
    471                 ARRAY_SIZE_MISMATCH_IN_CONNECT.invokeWithCondition(this, left.ndims() == right.ndims(),
    472                         left, left.size(), right, right.size());
     475            if (isExpandable) {
     476                boolean leftUnknown = left.isExpandableConnectorPart();
     477                InstAccess known   = leftUnknown ? right : left;
     478                InstAccess unknown = leftUnknown ? left  : right;
     479                Size knownSize   = known.size();
     480                Size unknownSize = unknown.findExpandableConnectorPart().partSize();
     481                if (knownSize.ndims() < unknownSize.ndims() ||
     482                        !unknownSize.equivalent(knownSize.contractRight(unknownSize.ndims()), false)) {
     483                    EXPANDABLE_ARRAY_SIZE_MISMATCH_IN_CONNECT.invoke(
     484                            this, unknown, unknownSize, known, knownSize);
     485                }
     486            } else {
     487                InstComponentDecl leftComp  = left.lookupEvaluatingIndices();
     488                InstComponentDecl rightComp = right.lookupEvaluatingIndices();
     489                if (!leftComp.connectableTo(rightComp)) {
     490                    TYPE_MISMATCH_IN_CONNECT.invoke(this);
     491                } else if (!left.size().equivalent(right.size(), false)) {
     492                    ARRAY_SIZE_MISMATCH_IN_CONNECT.invokeWithCondition(this, left.ndims() == right.ndims(),
     493                            left, left.size(), right, right.size());
     494                }
    473495            }
    474496        }
Note: See TracChangeset for help on using the changeset viewer.