Skip to content

Commit

Permalink
- merged latest modifications from branches/MathCoreOSMC
Browse files Browse the repository at this point in the history
Revision: 4385
Author: bjozac
Date: 11:48:50, den 23 oktober 2009
Message:
Added support for un-connected arrays of connectors
a.b_connector[:].c 
This did not generate zero equations for flow variables. 
----
Modified : /branches/MathCoreOSMC/Compiler/Connect.mo
Modified : /branches/MathCoreOSMC/Compiler/Env.mo



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4391 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Oct 25, 2009
1 parent 125f8d4 commit a0b6f70
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Compiler/Connect.mo
Expand Up @@ -1087,7 +1087,7 @@ algorithm
vars = listAppend(v1, listAppend(v2,v3));
*/

//print("Outside connectors, v1: " +& Util.stringDelimitList(Util.listMap(v1,Exp.printComponentRefStr),", ") +& "\n");
//print("\n Outside connectors, v1: " +& Util.stringDelimitList(Util.listMap(v1,Exp.printComponentRefStr),", ") +& "\n");
//print(" Inside connectors, v2: " +& Util.stringDelimitList(Util.listMap(v2,Exp.printComponentRefStr),", ") +& "\n");

vars = listAppend(v1, v2);
Expand Down
48 changes: 47 additions & 1 deletion Compiler/Env.mo
Expand Up @@ -1596,14 +1596,35 @@ algorithm
equation
lst1 = localInsideConnectorFlowvars3(xs, oid);
(_,false) = Inst.innerOuterBooleans(io);
//lst2 = Types.flowVariables(vars, Exp.CREF_QUAL(oid,Exp.COMPLEX(name,{},ClassInf.CONNECTOR(name)),{},Exp.CREF_IDENT(id,Exp.COMPLEX(name,{},ClassInf.CONNECTOR(name)),{})));
// We set type unknown for inside connectors for the check of "unconnected connectors".
lst2 = Types.flowVariables(vars, Exp.CREF_QUAL(oid,Exp.COMPLEX(name,{},ClassInf.UNKNOWN("unk")),{},
Exp.CREF_IDENT(id,Exp.COMPLEX(name,{},
ClassInf.CONNECTOR(name,isExpandable)),{})));
res = listAppend(lst1, lst2);
then
res;
case ((Types.VAR(name = id,attributes=Types.ATTR(innerOuter=io),type_ = (tmpty as (Types.T_ARRAY(ad,_),_))) :: xs),oid)
local
Types.ArrayDim ad;
list<Integer> adims;
list<Types.Var> tvars;
Types.Type tmpty,flatArrayType;
list<list<Exp.Subscript>> indexSubscriptLists;
Exp.ComponentRef connectorRef;
Boolean isExpandable;

equation
((flatArrayType as (Types.T_COMPLEX(ClassInf.CONNECTOR(string = name, isExpandable=isExpandable),tvars,_,_),_)),adims) = Types.flattenArrayType(tmpty);
(_,false) = Inst.innerOuterBooleans(io);
true = Types.isComplexConnector(flatArrayType);
indexSubscriptLists = createSubs(adims);
lst1 = localInsideConnectorFlowvars3_2(tvars, id, indexSubscriptLists);
connectorRef = Exp.CREF_QUAL(oid,Exp.COMPLEX(name,{},ClassInf.UNKNOWN("unk")),{},
Exp.CREF_IDENT(id,Exp.COMPLEX(name,{},ClassInf.CONNECTOR(name,isExpandable)),{}));
lst1 = localInsideConnectorFlowvars3_3(tvars,connectorRef,indexSubscriptLists);
//print(" Array refs: " +& Util.stringDelimitList(Util.listMap(lst1,Exp.printComponentRefStr),", ") +& "\n");
then lst1;

case ((_ :: xs),oid)
equation
res = localInsideConnectorFlowvars3(xs, oid);
Expand All @@ -1612,6 +1633,31 @@ algorithm
end matchcontinue;
end localInsideConnectorFlowvars3;

protected function localInsideConnectorFlowvars3_3 "
Author BZ, 2009-10
Helper function for localInsideConnectorFlowvars3, handles the case with inside array connectors
"
input list<Types.Var> connectorSubs;
input Exp.ComponentRef baseRef;
input list<list<Exp.Subscript>> ssubs;
output list<Exp.ComponentRef> outRefs;
algorithm outRefs := matchcontinue(connectorSubs,baseRef,ssubs)
local
list<Exp.Subscript> s;
list<Exp.ComponentRef> lst1,lst2;
case({},_,_) then {};
case(_,_,{}) then {};
case(connectorSubs,baseRef,s::ssubs)
equation
lst1 = localInsideConnectorFlowvars3_3(connectorSubs,baseRef,ssubs);
baseRef = Exp.subscriptCref(baseRef,s);
lst2 = Types.flowVariables(connectorSubs, baseRef);
outRefs = listAppend(lst1,lst2);
then
outRefs;
end matchcontinue;
end localInsideConnectorFlowvars3_3;

protected function localInsideConnectorFlowvars3_2 "
Author: BZ, 2009-05
Extract vars from complex types.
Expand Down

0 comments on commit a0b6f70

Please sign in to comment.