Changeset c1c920a9 in OpenModelica


Ignore:
Timestamp:
2020-02-07T15:24:45+01:00 (4 years ago)
Author:
Per Östlund <per.ostlund@…>
Parents:
de5194e
git-author:
Per Östlund <per.ostlund@…> (02/07/20 15:20:31)
git-committer:
Per Östlund <per.ostlund@…> (02/07/20 15:24:45)
Message:

[NF] More function evaluation fixes.

  • Use the type of the evaluated expression instead of the cached type when evaluating reductions, since the cached type isn't evaluated.
  • Handle _-assignments in EvalFunction.assignVariable.
  • Fix handling of : subscripts in EvalFunction.assignArrayElement.
Location:
OMCompiler/Compiler/NFFrontEnd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OMCompiler/Compiler/NFFrontEnd/NFCeval.mo

    rdf2744d rc1c920a9  
    18031803
    18041804    case Call.TYPED_REDUCTION()
    1805       then evalReduction(c.fn, c.exp, c.ty, c.iters);
     1805      then evalReduction(c.fn, c.exp, c.iters);
    18061806
    18071807    else
     
    31573157  input Function fn;
    31583158  input Expression exp;
    3159   input Type ty;
    31603159  input list<tuple<InstNode, Expression>> iterators;
    31613160  output Expression result;
     
    31633162  result := evalExpPartial(exp);
    31643163  result := Expression.bindingExpMap(result,
    3165     function evalReduction2(fn = fn, ty = ty, iterators = iterators));
     3164    function evalReduction2(fn = fn, iterators = iterators));
    31663165end evalReduction;
    31673166
     
    31693168  input Function fn;
    31703169  input Expression exp;
    3171   input Type ty;
    31723170  input list<tuple<InstNode, Expression>> iterators;
    31733171  output Expression result;
     
    31773175  list<Mutable<Expression>> iters;
    31783176  ReductionFn red_fn;
     3177  Type ty;
    31793178algorithm
    31803179  (e, ranges, iters) := createIterationRanges(exp, iterators);
     3180  ty := Expression.typeOf(e);
    31813181
    31823182  (red_fn, default_exp) := match AbsynUtil.pathString(Function.name(fn))
  • OMCompiler/Compiler/NFFrontEnd/NFEvalFunction.mo

    rdf2744d rc1c920a9  
    538538      Mutable<Expression> var_ptr;
    539539
     540    // variable := value
    540541    case (Expression.MUTABLE(exp = var_ptr), _)
    541542      algorithm
     
    544545        ();
    545546
     547    // (var1, var2, ...) := (value1, value2, ...)
    546548    case (Expression.TUPLE(), Expression.TUPLE(elements = vals))
    547549      algorithm
     
    553555        ();
    554556
     557    // variable[subscript1, subscript2, ...] := value
    555558    case (Expression.SUBSCRIPTED_EXP(exp = Expression.MUTABLE(exp = var_ptr)), _)
    556559      algorithm
     
    558561      then
    559562        ();
     563
     564    // _ := value
     565    case (Expression.CREF(cref = ComponentRef.WILD()), _)
     566      then ();
    560567
    561568    else
     
    630637    case (Expression.ARRAY(), Subscript.WHOLE() :: rest_subs)
    631638      algorithm
    632         if not listEmpty(rest_subs) then
     639        if listEmpty(rest_subs) then
     640          arrayExp.elements := Expression.arrayElements(value);
     641        else
    633642          arrayExp.elements := list(assignArrayElement(e, rest_subs, v) threaded for
    634643            e in arrayExp.elements, v in Expression.arrayElements(value));
Note: See TracChangeset for help on using the changeset viewer.