Changeset c0d2c572 in OpenModelica
- Timestamp:
- 2019-01-15T11:22:22+01:00 (5 years ago)
- 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, master, omlib-staging
- Children:
- 158a345
- Parents:
- 973bab3
- git-author:
- Per Östlund <per.ostlund@…> (01/15/19 11:22:21)
- git-committer:
- hudson <openmodelica@…> (01/15/19 11:22:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Compiler/NFFrontEnd/NFCeval.mo
r8481cc5 rc0d2c572 1523 1523 1524 1524 case Call.TYPED_ARRAY_CONSTRUCTOR() 1525 then evalArrayConstructor(call.exp, call. ty, call.iters);1525 then evalArrayConstructor(call.exp, call.iters); 1526 1526 1527 1527 case Call.TYPED_REDUCTION() … … 2698 2698 function evalArrayConstructor 2699 2699 input Expression exp; 2700 input Type ty;2701 2700 input list<tuple<InstNode, Expression>> iterators; 2702 2701 output Expression result; … … 2705 2704 list<Expression> ranges; 2706 2705 list<Mutable<Expression>> iters; 2706 list<Type> types = {}; 2707 Type ty; 2707 2708 algorithm 2708 2709 e := evalExpPartial(exp); 2709 2710 (e, ranges, iters) := createIterationRanges(e, iterators); 2710 result := evalArrayConstructor2(e, ranges, iters); 2711 2712 // Precompute all the types we're going to need for the arrays created. 2713 ty := Expression.typeOf(e); 2714 for r in ranges loop 2715 ty := Type.liftArrayLeftList(ty, Type.arrayDims(Expression.typeOf(r))); 2716 types := ty :: types; 2717 end for; 2718 2719 result := evalArrayConstructor2(e, ranges, iters, types); 2711 2720 end evalArrayConstructor; 2712 2721 … … 2734 2743 input list<Expression> ranges; 2735 2744 input list<Mutable<Expression>> iterators; 2745 input list<Type> types; 2736 2746 output Expression result; 2737 2747 protected … … 2743 2753 Expression value; 2744 2754 Type ty; 2755 list<Type> rest_ty; 2745 2756 algorithm 2746 2757 if listEmpty(ranges) then … … 2749 2760 range :: ranges_rest := ranges; 2750 2761 iter :: iters_rest := iterators; 2762 ty :: rest_ty := types; 2751 2763 range_iter := ExpressionIterator.fromExp(range); 2752 2764 … … 2754 2766 (range_iter, value) := ExpressionIterator.next(range_iter); 2755 2767 Mutable.update(iter, value); 2756 expl := evalArrayConstructor2(exp, ranges_rest, iters_rest ) :: expl;2768 expl := evalArrayConstructor2(exp, ranges_rest, iters_rest, rest_ty) :: expl; 2757 2769 end while; 2758 2770 2759 if listEmpty(expl) then2760 ty := Type.unliftArray(Expression.typeOf(exp));2761 else2762 ty := Expression.typeOf(listHead(expl));2763 end if;2764 2765 ty := Type.liftArrayLeft(ty, Dimension.fromInteger(listLength(expl)));2766 2771 result := Expression.makeArray(ty, listReverseInPlace(expl), literal = true); 2767 2772 end if;
Note: See TracChangeset
for help on using the changeset viewer.