diff --git a/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBFunctionAlias.mo b/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBFunctionAlias.mo index 4455ccfacc0..b751ef9ff78 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBFunctionAlias.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBFunctionAlias.mo @@ -304,11 +304,11 @@ protected end for; debug_lst_ini := UnorderedMap.toList(map); print(StringUtil.headline_3("Simulation Function Alias")); - debug_str := list((Call_Id.toString(Util.tuple21(tpl)), Call_Aux.toString(Util.tuple22(tpl))) for tpl in debug_lst_sim); + debug_str := list((Call_Aux.toString(Util.tuple22(tpl)), Call_Id.toString(Util.tuple21(tpl))) for tpl in debug_lst_sim); debug_max_length := max(stringLength(Util.tuple21(tpl)) for tpl in debug_str) + 3; print(List.toString(debug_str, function functionAliasTplString(max_length = debug_max_length), "", " ", "\n ", "\n\n")); print(StringUtil.headline_3("Initial Function Alias")); - debug_str := list((Call_Id.toString(Util.tuple21(tpl)), Call_Aux.toString(Util.tuple22(tpl))) for tpl in debug_lst_ini); + debug_str := list((Call_Aux.toString(Util.tuple22(tpl)), Call_Id.toString(Util.tuple21(tpl))) for tpl in debug_lst_ini); debug_max_length := max(stringLength(Util.tuple21(tpl)) for tpl in debug_str) + 3; print(List.toString(debug_str, function functionAliasTplString(max_length = debug_max_length), "", " ", "\n ", "\n\n")); end if; @@ -365,8 +365,7 @@ protected // strip nested iterator for the iterators that actually occure in the function call if not Iterator.isEmpty(iter) then (names, ranges) := Iterator.getFrames(iter); - (names, ranges) := filterFrames(exp, names, ranges); - new_iter := Iterator.fromFrames(List.zip(names, ranges)); + new_iter := Iterator.fromFrames(filterFrames(exp, names, ranges)); else new_iter := iter; end if; @@ -453,17 +452,19 @@ protected function filterFrames "filters the list of frames for all iterators that occure in exp" input Expression exp; - input output list names; - input output list ranges; + input list names; + input list ranges; + output list> frames; protected UnorderedMap frame_map = UnorderedMap.fromLists(names, ranges, ComponentRef.hash, ComponentRef.isEqual); + UnorderedMap new_map = UnorderedMap.new(ComponentRef.hash, ComponentRef.isEqual); + Pointer> names_acc = Pointer.create({}); Pointer> ranges_acc = Pointer.create({}); function collectFrames input output Expression exp; input UnorderedMap frame_map; - input Pointer> names_acc; - input Pointer> ranges_acc; + input UnorderedMap new_map; algorithm _ := match exp local @@ -471,17 +472,15 @@ protected case Expression.CREF() algorithm range := UnorderedMap.get(exp.cref, frame_map); if isSome(range) then - Pointer.update(names_acc, exp.cref :: Pointer.access(names_acc)); - Pointer.update(ranges_acc, Util.getOption(range) :: Pointer.access(ranges_acc)); + UnorderedMap.add(exp.cref, Util.getOption(range), new_map); end if; then (); else (); end match; end collectFrames; algorithm - _ := Expression.map(exp, function collectFrames(frame_map = frame_map, names_acc = names_acc, ranges_acc = ranges_acc)); - names := Pointer.access(names_acc); - ranges := Pointer.access(ranges_acc); + _ := Expression.map(exp, function collectFrames(frame_map = frame_map, new_map = new_map)); + frames := UnorderedMap.toList(new_map); end filterFrames; function addAuxVar diff --git a/testsuite/simulation/modelica/NBackend/records/simple_tuple.mos b/testsuite/simulation/modelica/NBackend/records/simple_tuple.mos index b4dc9119406..b04d407bd43 100644 --- a/testsuite/simulation/modelica/NBackend/records/simple_tuple.mos +++ b/testsuite/simulation/modelica/NBackend/records/simple_tuple.mos @@ -36,10 +36,10 @@ simulate(simple_tuple); getErrorString(); // "" // Simulation Function Alias // --------------------------- -// sin(time) ......... $FUN_1 -// cos(time) ......... $FUN_2 -// some_func(a, b) ... ($FUN_3, $FUN_4) -// some_func(x, y) ... ($FUN_5, $FUN_6) +// $FUN_1 ............. sin(time) +// $FUN_2 ............. cos(time) +// ($FUN_3, $FUN_4) ... some_func(a, b) +// ($FUN_5, $FUN_6) ... some_func(x, y) // // Initial Function Alias // ------------------------