Changeset 8481cc5 in OpenModelica


Ignore:
Timestamp:
2019-01-14T15:13:35+01:00 (5 years ago)
Author:
hudson <openmodelica@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
d681d71
Parents:
3c1d34e
git-author:
Per Östlund <per.ostlund@…> (01/14/19 15:13:35)
git-committer:
hudson <openmodelica@…> (01/14/19 15:13:35)
Message:

[NF] Fix type in Ceval.evalArrayConstructor.

  • Create a new type based on the actual sizes of the created arrays in evalArrayConstructor, instead of using the original type which might have non-constant dimensions.

Belonging to [master]:

  • OpenModelica/OMCompiler#2870
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Compiler/NFFrontEnd/NFCeval.mo

    rc8cc40e r8481cc5  
    27082708  e := evalExpPartial(exp);
    27092709  (e, ranges, iters) := createIterationRanges(e, iterators);
    2710   result := evalArrayConstructor2(e, ty, ranges, iters);
     2710  result := evalArrayConstructor2(e, ranges, iters);
    27112711end evalArrayConstructor;
    27122712
     
    27322732function evalArrayConstructor2
    27332733  input Expression exp;
    2734   input Type ty;
    27352734  input list<Expression> ranges;
    27362735  input list<Mutable<Expression>> iterators;
    27372736  output Expression result;
    27382737protected
    2739   Expression range;
     2738  Expression range, e;
    27402739  list<Expression> ranges_rest, expl = {};
    27412740  Mutable<Expression> iter;
     
    27432742  ExpressionIterator range_iter;
    27442743  Expression value;
    2745   Type el_ty;
     2744  Type ty;
    27462745algorithm
    27472746  if listEmpty(ranges) then
     
    27512750    iter :: iters_rest := iterators;
    27522751    range_iter := ExpressionIterator.fromExp(range);
    2753     el_ty := Type.unliftArray(ty);
    27542752
    27552753    while ExpressionIterator.hasNext(range_iter) loop
    27562754      (range_iter, value) := ExpressionIterator.next(range_iter);
    27572755      Mutable.update(iter, value);
    2758       expl := evalArrayConstructor2(exp, el_ty, ranges_rest, iters_rest) :: expl;
     2756      expl := evalArrayConstructor2(exp, ranges_rest, iters_rest) :: expl;
    27592757    end while;
    27602758
     2759    if listEmpty(expl) then
     2760      ty := Type.unliftArray(Expression.typeOf(exp));
     2761    else
     2762      ty := Expression.typeOf(listHead(expl));
     2763    end if;
     2764
     2765    ty := Type.liftArrayLeft(ty, Dimension.fromInteger(listLength(expl)));
    27612766    result := Expression.makeArray(ty, listReverseInPlace(expl), literal = true);
    27622767  end if;
Note: See TracChangeset for help on using the changeset viewer.