diff --git a/Compiler/FrontEnd/ConnectUtil.mo b/Compiler/FrontEnd/ConnectUtil.mo index 6c165460508..c70f2b2c72d 100644 --- a/Compiler/FrontEnd/ConnectUtil.mo +++ b/Compiler/FrontEnd/ConnectUtil.mo @@ -317,21 +317,22 @@ public function addConnectorVariablesFromDAE input list inVars; input Sets inConnectionSet; input Absyn.Info info; + input DAE.ElementSource inElementSource; output Sets outConnectionSet; algorithm outConnectionSet := - match(inIgnore, inClassState, inPrefix, inVars, inConnectionSet, info) + match(inIgnore, inClassState, inPrefix, inVars, inConnectionSet, info, inElementSource) local Absyn.Path class_path; list streams, flows; Sets cs; // check balance of non expandable connectors! - case (false, ClassInf.CONNECTOR(path = class_path, isExpandable = false), _, _, cs, _) + case (false, ClassInf.CONNECTOR(path = class_path, isExpandable = false), _, _, cs, _, _) equation checkConnectorBalance(inVars, class_path, info); (flows, streams) = getStreamAndFlowVariables(inVars, {}, {}); - cs = List.fold(flows, addFlowVariableFromDAE, cs); + cs = List.fold2(flows, addFlowVariableFromDAE, inElementSource, inPrefix, cs); cs = addStreamFlowAssociations(cs, inPrefix, streams, flows); then cs; @@ -343,14 +344,16 @@ end addConnectorVariablesFromDAE; protected function addFlowVariableFromDAE "Adds a flow variable from the DAE to the sets as an inside flow variable." input DAE.Var inVariable; + input DAE.ElementSource inElementSource; + input Prefix.Prefix inPrefix; input Sets inConnectionSet; output Sets outConnectionSet; protected list crefs; algorithm crefs := daeVarToCrefs(inVariable); - outConnectionSet := List.fold1r(crefs, addInsideFlowVariable, - DAE.emptyElementSource, inConnectionSet); + outConnectionSet := List.fold2r(crefs, addInsideFlowVariable, + inElementSource, inPrefix, inConnectionSet); end addFlowVariableFromDAE; public function isExpandable @@ -656,9 +659,10 @@ protected function addInsideFlowVariable input Connect.Sets inSets; input DAE.ComponentRef inCref; input DAE.ElementSource inSource; + input Prefix.Prefix inPrefix; output Connect.Sets outSets; algorithm - outSets := matchcontinue(inSets, inCref, inSource) + outSets := matchcontinue(inSets, inCref, inSource, inPrefix) local ConnectorElement e; SetTrie sets; @@ -670,17 +674,20 @@ algorithm DAE.ElementSource src; // Check if it exists in the sets already. - case (Connect.SETS(sets = sets), _, _) + case (Connect.SETS(sets = sets), _, _, _) equation _ = setTrieGetElement(inCref, Connect.INSIDE(), sets); then inSets; // Otherwise, add a new set for it. - case (Connect.SETS(sets, sc, c, cc, o), _, DAE.SOURCE(info = info)) + case (Connect.SETS(sets, sc, c, cc, o), _, DAE.SOURCE(info = info), _) equation sc = sc + 1; - src = DAEUtil.addAdditionalComment(inSource, " equation generated by unconnected inside flow, maybe connected later"); + src = DAEUtil.addAdditionalComment(inSource, " add inside flow(" +& + PrefixUtil.printPrefixStr(inPrefix) +& "." +& + ComponentReference.printComponentRefStr(inCref) +& + ")"); e = newElement(inCref, Connect.INSIDE(), Connect.FLOW(), src, sc); sets = setTrieAdd(e, sets); then diff --git a/Compiler/FrontEnd/DAEDump.mo b/Compiler/FrontEnd/DAEDump.mo index 032a2a4b153..46d07ee2a81 100644 --- a/Compiler/FrontEnd/DAEDump.mo +++ b/Compiler/FrontEnd/DAEDump.mo @@ -3940,12 +3940,54 @@ algorithm case (DAE.SOURCE(i, po, iol, ceol, tl, op, cmt)) equation str = cmtListToString(cmt); - str = str +& " /* models: " +& stringDelimitList(List.map(po, withinString), ", ") +& " */"; + str = str +& " /* models: {" +& stringDelimitList(List.map(po, withinString), ", ") +& "}" +& + " connects: {" +& stringDelimitList(connectsStr(ceol), ", ") +& "} */"; then str; end matchcontinue; end getSourceInformationStr; +protected function connectsStr + input list>> inLst; + output list outStr; +algorithm + outstr := matchcontinue(inLst) + local + list>> rest; + list slst; + String str; + DAE.ComponentRef c1, c2; + + case ({}) then {}; + + case ({NONE()}) then {}; + + case ({SOME((c1,c2))}) + equation + str = ComponentReference.printComponentRefStr(c1) +& "," +& + ComponentReference.printComponentRefStr(c2); + str = "connect(" +& str +& ")"; + then + {str}; + + case (SOME((c1,c2))::rest) + equation + str = ComponentReference.printComponentRefStr(c1) +& "," +& + ComponentReference.printComponentRefStr(c2); + str = "connect(" +& str +& ")"; + slst = connectsStr(rest); + then + str::slst; + + case (NONE()::rest) + equation + slst = connectsStr(rest); + then + slst; + + end matchcontinue; +end connectsStr; + protected function withinString input Absyn.Within w; output String str; diff --git a/Compiler/FrontEnd/Inst.mo b/Compiler/FrontEnd/Inst.mo index 78bcaf7a29b..c986395b427 100644 --- a/Compiler/FrontEnd/Inst.mo +++ b/Compiler/FrontEnd/Inst.mo @@ -3261,6 +3261,7 @@ algorithm Option cmt; UnitAbsyn.InstStore store; Option ed; + DAE.ElementSource elementSource; /*// uncomment for debugging case (cache,env,ih,store,mods,pre,csets,ci_state,className,inClassDef6, @@ -3436,7 +3437,8 @@ algorithm // If we are currently instantiating a connector, add all flow variables // in it as inside connectors. zero_dims = instDimsHasZeroDims(inst_dims); - csets1 = ConnectUtil.addConnectorVariablesFromDAE(zero_dims, ci_state1, pre, vars, csets, info); + elementSource = DAEUtil.createElementSource(info, Env.getEnvPath(env4), PrefixUtil.prefixToCrefOpt(pre), NONE(), NONE()); + csets1 = ConnectUtil.addConnectorVariablesFromDAE(zero_dims, ci_state1, pre, vars, csets, info, elementSource); // Reorder the connect equations to have non-expandable connect first: // connect(non_expandable, non_expandable);