@@ -1163,7 +1163,7 @@ function evalBinaryArrayScalar
11631163algorithm
11641164 exp := match arrayExp
11651165 case Expression . ARRAY ()
1166- then Expression . ARRAY (arrayExp. ty,
1166+ then Expression . makeArray (arrayExp. ty,
11671167 list(evalBinaryArrayScalar(e, scalarExp, opFunc) for e in arrayExp. elements),
11681168 literal = true );
11691169
@@ -2898,22 +2898,10 @@ protected
28982898 list< Expression > expl;
28992899 Type ty;
29002900algorithm
2901- expl := Expression . fold(arg, evalBuiltinVector2, {});
2902- ty := Type . liftArrayLeft(Type . arrayElementType(Expression . typeOf(arg)),
2903- Dimension . fromInteger(listLength(expl)));
2904- result := Expression . makeArray(ty, listReverse(expl), literal = true );
2901+ expl := Expression . arrayScalarElements(arg);
2902+ result := Expression . makeExpArray(expl, isLiteral = true );
29052903end evalBuiltinVector;
29062904
2907- function evalBuiltinVector2
2908- input Expression exp;
2909- input output list< Expression > expl;
2910- algorithm
2911- expl := match exp
2912- case Expression . ARRAY () then expl;
2913- else exp :: expl;
2914- end match;
2915- end evalBuiltinVector2;
2916-
29172905function evalBuiltinZeros
29182906 input list< Expression > args;
29192907 output Expression result;
@@ -3196,13 +3184,18 @@ protected
31963184 Function fn;
31973185 Expression exp, default_exp;
31983186 list< tuple< InstNode , Expression >> iters;
3199- list< Mutable < Expression >> iter_exps;
3200- list< Expression > ranges;
32013187 Type ty;
32023188 ReductionFn red_fn;
3189+
3190+ function reductionFn
3191+ input Expression exp1;
3192+ input Expression exp2;
3193+ input EvalTarget target;
3194+ input ReductionFn fn;
3195+ output Expression result = fn(exp1, evalExp_impl(exp2, target));
3196+ end reductionFn;
32033197algorithm
32043198 Expression . CALL (call = Call . TYPED_REDUCTION (fn = fn, exp = exp, iters = iters)) := callExp;
3205- (exp, ranges, iter_exps) := createIterationRanges(exp, iters);
32063199 ty := Expression . typeOf(exp);
32073200
32083201 (red_fn, default_exp) := match AbsynUtil . pathString(Function . name(fn))
@@ -3218,41 +3211,10 @@ algorithm
32183211 fail();
32193212 end match;
32203213
3221- result := evalReduction2(exp, ranges, iter_exps, default_exp, red_fn);
3214+ result := Expression . foldReduction(exp, iters, default_exp,
3215+ function evalExp_impl(target = EvalTarget . IGNORE_ERRORS ()), red_fn);
32223216end evalReduction;
32233217
3224- function evalReduction2
3225- input Expression exp;
3226- input list< Expression > ranges;
3227- input list< Mutable < Expression >> iterators;
3228- input Expression foldExp;
3229- input ReductionFn fn;
3230- output Expression result;
3231- protected
3232- Expression range;
3233- list< Expression > ranges_rest, expl = {};
3234- Mutable < Expression > iter;
3235- list< Mutable < Expression >> iters_rest;
3236- ExpressionIterator range_iter;
3237- Expression value;
3238- Type el_ty;
3239- algorithm
3240- if listEmpty(ranges) then
3241- result := fn(foldExp, evalExp_impl(exp, EvalTarget . IGNORE_ERRORS ()));
3242- else
3243- range :: ranges_rest := ranges;
3244- iter :: iters_rest := iterators;
3245- range_iter := ExpressionIterator . fromExp(range);
3246- result := foldExp;
3247-
3248- while ExpressionIterator . hasNext(range_iter) loop
3249- (range_iter, value) := ExpressionIterator . next(range_iter);
3250- Mutable . update(iter, value);
3251- result := evalReduction2(exp, ranges_rest, iters_rest, result, fn);
3252- end while ;
3253- end if ;
3254- end evalReduction2;
3255-
32563218function evalSize
32573219 input Expression exp;
32583220 input Option < Expression > optIndex;
0 commit comments