diff --git a/Compiler/BackEnd/BackendDAETransform.mo b/Compiler/BackEnd/BackendDAETransform.mo index 5ae1c9aa764..69dd26245a5 100644 --- a/Compiler/BackEnd/BackendDAETransform.mo +++ b/Compiler/BackEnd/BackendDAETransform.mo @@ -129,16 +129,9 @@ public function varAssignmentNonScalar input array mapIncRowEqn; output array outAcc; protected - Integer e; - list acc = {}; + list acc; algorithm - for i in 1:arrayLength(ass1) loop - e := ass1[i]; - e := if e > 0 then mapIncRowEqn[e] else -1; - acc := e :: acc; - end for; - - acc := Dangerous.listReverseInPlace(acc); + acc := list(if ass1[i] > 0 then mapIncRowEqn[ass1[i]] else -1 for i in 1:arrayLength(ass1)); outAcc := listArray(acc); end varAssignmentNonScalar; diff --git a/Compiler/BackEnd/RemoveSimpleEquations.mo b/Compiler/BackEnd/RemoveSimpleEquations.mo index 8924c6b6468..f02f6f1d510 100644 --- a/Compiler/BackEnd/RemoveSimpleEquations.mo +++ b/Compiler/BackEnd/RemoveSimpleEquations.mo @@ -4531,12 +4531,9 @@ protected function removeStateDerInfo "BB, remove stateDerInfo! This information should be collected after removeSimpleEquations " input list inVarList; - output list vars = {}; + output list vars; algorithm - for var in inVarList loop - vars := (if BackendVariable.isStateVar(var) then BackendVariable.setStateDerivative(var, NONE()) else var) :: vars; - end for; - vars := MetaModelica.Dangerous.listReverseInPlace(vars); + vars := list(if BackendVariable.isStateVar(var) then BackendVariable.setStateDerivative(var, NONE()) else var for var in inVarList); end removeStateDerInfo; protected function findSimpleEquations "BB, diff --git a/Compiler/FrontEnd/Mod.mo b/Compiler/FrontEnd/Mod.mo index 4e5307de130..3d29d0451a8 100644 --- a/Compiler/FrontEnd/Mod.mo +++ b/Compiler/FrontEnd/Mod.mo @@ -525,61 +525,24 @@ protected function unelabSubmods input list inTypesSubModLst; output list outSCodeSubModLst; algorithm - outSCodeSubModLst:= - match (inTypesSubModLst) - local - list x_1,xs_1,res; - DAE.SubMod x; - list xs; - case ({}) then {}; - case ((x :: xs)) - equation - x_1 = unelabSubmod(x); - xs_1 = unelabSubmods(xs); - res = listAppend(x_1, xs_1); - then - res; - end match; + outSCodeSubModLst := list(match (x) + local + SCode.Mod m_1; + String i; + DAE.Mod m; + case (DAE.NAMEMOD(ident = i,mod = m)) + equation + m_1 = unelabMod(m); + then + SCode.NAMEMOD(i,m_1); + end match for x in inTypesSubModLst); end unelabSubmods; -protected function unelabSubmod -"This function unelaborates on a submodification." - input DAE.SubMod inSubMod; - output list outSCodeSubModLst; -algorithm - outSCodeSubModLst:= - match (inSubMod) - local - SCode.Mod m_1; - String i; - DAE.Mod m; - list ss_1; - list ss; - case (DAE.NAMEMOD(ident = i,mod = m)) - equation - m_1 = unelabMod(m); - then - {SCode.NAMEMOD(i,m_1)}; - end match; -end unelabSubmod; - protected function unelabSubscript input list inIntegerLst; - output list outSCodeSubscriptLst; + output list outSCodeSubscriptLst = {}; algorithm - outSCodeSubscriptLst:= - match (inIntegerLst) - local - list xs; - Integer i; - list is; - case ({}) then {}; - case ((i :: is)) - equation - xs = unelabSubscript(is); - then - (Absyn.SUBSCRIPT(Absyn.INTEGER(i)) :: xs); - end match; + outSCodeSubscriptLst := list(Absyn.SUBSCRIPT(Absyn.INTEGER(i)) for i in inIntegerLst); end unelabSubscript; public function updateMod @@ -661,62 +624,21 @@ protected function updateSubmods "" input list inTypesSubModLst; input Boolean inBoolean; input SourceInfo info; - output FCore.Cache outCache; - output list outTypesSubModLst; -algorithm - (outCache,outTypesSubModLst):= - match (inCache,inEnv,inIH,inPrefix,inTypesSubModLst,inBoolean,info) - local - Boolean impl; - list x_1,xs_1,res,xs; - FCore.Graph env; - Prefix.Prefix pre; - DAE.SubMod x; - FCore.Cache cache; - InstanceHierarchy ih; - - case (cache,_,_,_,{},_,_) then (cache,{}); /* impl */ - case (cache,env,ih,pre,(x :: xs),impl,_) - equation - (cache,x_1) = updateSubmod(cache, env, ih, pre, x, impl, info); - (cache,xs_1) = updateSubmods(cache, env, ih, pre, xs, impl, info); - res = listAppend(x_1, xs_1); - then - (cache,res); - end match; -end updateSubmods; - -protected function updateSubmod " " - input FCore.Cache inCache; - input FCore.Graph inEnv; - input InnerOuter.InstHierarchy inIH; - input Prefix.Prefix inPrefix; - input DAE.SubMod inSubMod; - input Boolean inBoolean; - input SourceInfo info; - output FCore.Cache outCache; + output FCore.Cache outCache = inCache; output list outTypesSubModLst; algorithm - (outCache,outTypesSubModLst):= - match (inCache,inEnv,inIH,inPrefix,inSubMod,inBoolean,info) + outTypesSubModLst := list(match x local DAE.Mod m_1,m; - FCore.Graph env; - Prefix.Prefix pre; String i; - Boolean impl; - FCore.Cache cache; - list idxmod; - InstanceHierarchy ih; - case (cache,env,ih,pre,DAE.NAMEMOD(ident = i,mod = m),impl,_) + case DAE.NAMEMOD(ident = i,mod = m) equation - (cache,m_1) = updateMod(cache, env, ih, pre, m, impl, info); + (outCache,m_1) = updateMod(outCache, inEnv, inIH, inPrefix, m, inBoolean, info); then - (cache,{DAE.NAMEMOD(i,m_1)}); - - end match; -end updateSubmod; + DAE.NAMEMOD(i,m_1); + end match for x in inTypesSubModLst); +end updateSubmods; public function elabUntypedMod "This function is used to convert SCode.Mod into Mod, without adding correct type information. Instead, a undefined type will be @@ -868,14 +790,14 @@ protected function compactSubMod2 output SCode.SubMod outMod; output Boolean outFound; algorithm - (outMod, outFound) := matchcontinue(inExistingMod, inNewMod, inModScope, inName) + (outMod, outFound) := match(inExistingMod, inNewMod, inModScope, inName) local String name1, name2; SCode.SubMod submod; case (SCode.NAMEMOD(ident = name1), SCode.NAMEMOD(ident = name2), _, _) - equation - false = stringEqual(name1, name2); + guard + not stringEqual(name1, name2) then (inExistingMod, false); @@ -885,7 +807,7 @@ algorithm then (submod, true); - end matchcontinue; + end match; end compactSubMod2; protected function mergeSubModsInSameScope