Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 175a65b

Browse files
adrpoOpenModelica-Hudson
authored andcommitted
new front-end connection handling preparation
- adapt the old front-end with some changes needed for the new front-end - add DAE.CONNECT_EQUATION - use DAE.ConnectorType inside DAE.Attributes.ATTR instead of SCode.ConnectorType
1 parent fdff91a commit 175a65b

File tree

16 files changed

+196
-82
lines changed

16 files changed

+196
-82
lines changed

Compiler/FFrontEnd/FGraph.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ algorithm
556556
SCode.noComment, NONE(), Absyn.dummyInfo);
557557
v = DAE.TYPES_VAR(
558558
name,
559-
DAE.ATTR(SCode.POTENTIAL(), SCode.NON_PARALLEL(), variability, Absyn.BIDIR(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC()),
559+
DAE.ATTR(DAE.NON_CONNECTOR(), SCode.NON_PARALLEL(), variability, Absyn.BIDIR(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC()),
560560
ty,
561561
binding,
562562
constOfForIteratorRange);

Compiler/FFrontEnd/FNode.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ algorithm
606606
nd = FCore.CO(inElement, DAE.NOMOD(), inKind, FCore.VAR_UNTYPED());
607607
i = DAE.TYPES_VAR(
608608
n,
609-
DAE.ATTR(ct,prl,var,dir,io,vis),
609+
DAE.ATTR(DAEUtil.toConnectorTypeNoState(ct),prl,var,dir,io,vis),
610610
DAE.T_UNKNOWN_DEFAULT,
611611
DAE.UNBOUND(),NONE());
612612
then

Compiler/FrontEnd/ConnectUtil.mo

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function addConnection
183183
input Face face1;
184184
input DAE.ComponentRef cref2;
185185
input Face face2;
186-
input SCode.ConnectorType connectorType;
186+
input DAE.ConnectorType connectorType;
187187
input DAE.ElementSource source;
188188
protected
189189
ConnectorElement e1, e2;
@@ -222,7 +222,7 @@ public function addArrayConnection
222222
input DAE.ComponentRef cref2;
223223
input Face face2;
224224
input DAE.ElementSource source;
225-
input SCode.ConnectorType connectorType;
225+
input DAE.ConnectorType connectorType;
226226
protected
227227
list<DAE.ComponentRef> crefs1, crefs2;
228228
DAE.ComponentRef cr2;
@@ -238,13 +238,16 @@ end addArrayConnection;
238238

239239
protected function makeConnectorType
240240
"Creates a connector type from the flow or stream prefix given."
241-
input SCode.ConnectorType connectorType;
241+
input DAE.ConnectorType connectorType;
242242
output ConnectorType ty;
243+
protected
244+
Option<DAE.ComponentRef> flowName;
243245
algorithm
244246
ty := match(connectorType)
245-
case SCode.POTENTIAL() then ConnectorType.EQU();
246-
case SCode.FLOW() then ConnectorType.FLOW();
247-
case SCode.STREAM() then ConnectorType.STREAM(NONE());
247+
case DAE.POTENTIAL() then ConnectorType.EQU();
248+
case DAE.FLOW() then ConnectorType.FLOW();
249+
case DAE.STREAM(flowName) then ConnectorType.STREAM(flowName);
250+
case DAE.NON_CONNECTOR() then ConnectorType.NO_TYPE();
248251
else
249252
algorithm
250253
Error.addMessage(Error.INTERNAL_ERROR,
@@ -381,13 +384,13 @@ protected function getStreamAndFlowVariables
381384
algorithm
382385
for var in variables loop
383386
_ := match var
384-
case DAE.TYPES_VAR(attributes = DAE.ATTR(connectorType = SCode.FLOW()))
387+
case DAE.TYPES_VAR(attributes = DAE.ATTR(connectorType = DAE.FLOW()))
385388
algorithm
386389
flows := var :: flows;
387390
then
388391
();
389392

390-
case DAE.TYPES_VAR(attributes = DAE.ATTR(connectorType = SCode.STREAM()))
393+
case DAE.TYPES_VAR(attributes = DAE.ATTR(connectorType = DAE.STREAM()))
391394
algorithm
392395
streams := var :: streams;
393396
then
@@ -2853,14 +2856,14 @@ algorithm
28532856
else
28542857
_ := match attr
28552858
// A flow variable.
2856-
case DAE.ATTR(connectorType = SCode.FLOW())
2859+
case DAE.ATTR(connectorType = DAE.FLOW())
28572860
algorithm
28582861
flowVars := flowVars + sizeOfType(var.ty);
28592862
then
28602863
();
28612864

28622865
// A stream variable.
2863-
case DAE.ATTR(connectorType = SCode.STREAM())
2866+
case DAE.ATTR(connectorType = DAE.STREAM())
28642867
algorithm
28652868
streamVars := streamVars + sizeOfType(var.ty);
28662869
then

Compiler/FrontEnd/DAE.mo

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import ClassInf;
4747
import SCode;
4848
import Prefix;
4949
import Values;
50+
import Connect;
5051

5152
protected
5253
import DAEDump;
@@ -73,9 +74,12 @@ public uniontype VarKind
7374
end VarKind;
7475

7576
public uniontype ConnectorType
77+
"The type of a connector element."
7678
record POTENTIAL end POTENTIAL;
7779
record FLOW end FLOW;
78-
record STREAM end STREAM;
80+
record STREAM
81+
Option<ComponentRef> associatedFlow;
82+
end STREAM;
7983
record NON_CONNECTOR end NON_CONNECTOR;
8084
end ConnectorType;
8185

@@ -240,6 +244,14 @@ public uniontype Element
240244
ElementSource source "the origin of the component/equation/algorithm" ;
241245
end INITIAL_ARRAY_EQUATION;
242246

247+
record CONNECT_EQUATION "a connect equation"
248+
Element lhsElement;
249+
Connect.Face lhsFace;
250+
Element rhsElement;
251+
Connect.Face rhsFace;
252+
ElementSource source "the origin of the component/equation/algorithm";
253+
end CONNECT_EQUATION;
254+
243255
record COMPLEX_EQUATION "an equation of complex type, e.g. record = func(..)"
244256
Exp lhs;
245257
Exp rhs;
@@ -776,7 +788,7 @@ end Var;
776788
public
777789
uniontype Attributes "- Attributes"
778790
record ATTR
779-
SCode.ConnectorType connectorType "flow, stream or unspecified";
791+
ConnectorType connectorType "flow, stream or unspecified";
780792
SCode.Parallelism parallelism "parallelism";
781793
SCode.Variability variability "variability" ;
782794
Absyn.Direction direction "direction" ;
@@ -786,10 +798,10 @@ uniontype Attributes "- Attributes"
786798
end Attributes;
787799

788800
public
789-
constant Attributes dummyAttrVar = ATTR(SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC());
790-
constant Attributes dummyAttrParam = ATTR(SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.PARAM(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC());
791-
constant Attributes dummyAttrConst = ATTR(SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.CONST(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC());
792-
constant Attributes dummyAttrInput = ATTR(SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC());
801+
constant Attributes dummyAttrVar = ATTR(NON_CONNECTOR(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC());
802+
constant Attributes dummyAttrParam = ATTR(NON_CONNECTOR(), SCode.NON_PARALLEL(), SCode.PARAM(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC());
803+
constant Attributes dummyAttrConst = ATTR(NON_CONNECTOR(), SCode.NON_PARALLEL(), SCode.CONST(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC());
804+
constant Attributes dummyAttrInput = ATTR(NON_CONNECTOR(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT(), Absyn.NOT_INNER_OUTER(), SCode.PUBLIC());
793805

794806
public uniontype BindingSource "where this binding came from: either default binding or start value"
795807
record BINDING_FROM_DEFAULT_VALUE "the binding came from the default value" end BINDING_FROM_DEFAULT_VALUE;

Compiler/FrontEnd/DAEUtil.mo

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,12 +1988,24 @@ public function toConnectorType
19881988
algorithm
19891989
outConnectorType := match(inConnectorType, inState)
19901990
case (SCode.FLOW(), _) then DAE.FLOW();
1991-
case (SCode.STREAM(), _) then DAE.STREAM();
1991+
case (SCode.STREAM(), _) then DAE.STREAM(NONE());
19921992
case (_, ClassInf.CONNECTOR()) then DAE.POTENTIAL();
19931993
else DAE.NON_CONNECTOR();
19941994
end match;
19951995
end toConnectorType;
19961996

1997+
public function toConnectorTypeNoState
1998+
input SCode.ConnectorType scodeConnectorType;
1999+
input Option<DAE.ComponentRef> flowName = NONE();
2000+
output DAE.ConnectorType daeConnectorType;
2001+
algorithm
2002+
daeConnectorType := match scodeConnectorType
2003+
case SCode.FLOW() then DAE.FLOW();
2004+
case SCode.STREAM() then DAE.STREAM(flowName);
2005+
else DAE.POTENTIAL();
2006+
end match;
2007+
end toConnectorTypeNoState;
2008+
19972009
public function toDaeParallelism "Converts scode parallelsim to dae parallelism.
19982010
Prints a warning if parallel variables are used
19992011
in a non-function class."
@@ -5621,7 +5633,7 @@ protected
56215633
algorithm
56225634
SCode.ATTR(connectorType = ct, parallelism = prl, variability = var, direction = dir) := inAttributes;
56235635
SCode.PREFIXES(innerOuter = io, visibility = vis) := inPrefixes;
5624-
outAttributes := DAE.ATTR(ct, prl, var, dir, io, vis);
5636+
outAttributes := DAE.ATTR(toConnectorTypeNoState(ct), prl, var, dir, io, vis);
56255637
end translateSCodeAttrToDAEAttr;
56265638

56275639
public function varName
@@ -5756,7 +5768,7 @@ public function setAttributeDirection
57565768
input DAE.Attributes inAttributes;
57575769
output DAE.Attributes outAttributes;
57585770
protected
5759-
SCode.ConnectorType ct;
5771+
DAE.ConnectorType ct;
57605772
SCode.Parallelism p;
57615773
SCode.Variability var;
57625774
Absyn.InnerOuter io;
@@ -6309,6 +6321,72 @@ algorithm
63096321
(outExp,_) := VarTransform.replaceExp(inExp,replIn,NONE());
63106322
end replaceCompRef;
63116323

6324+
public function connectorTypeStr
6325+
input DAE.ConnectorType connectorType;
6326+
output String string;
6327+
algorithm
6328+
string := match connectorType
6329+
local
6330+
DAE.ComponentRef cref;
6331+
String cref_str;
6332+
6333+
case DAE.POTENTIAL() then "";
6334+
case DAE.FLOW() then "flow";
6335+
case DAE.STREAM(NONE()) then "stream()";
6336+
case DAE.STREAM(SOME(cref))
6337+
algorithm
6338+
cref_str := ComponentReference.printComponentRefStr(cref);
6339+
then
6340+
"stream(" + cref_str + ")";
6341+
else "non connector";
6342+
end match;
6343+
end connectorTypeStr;
6344+
6345+
public function streamBool
6346+
input DAE.ConnectorType inStream;
6347+
output Boolean bStream;
6348+
algorithm
6349+
bStream := match(inStream)
6350+
case DAE.STREAM() then true;
6351+
else false;
6352+
end match;
6353+
end streamBool;
6354+
6355+
public function potentialBool
6356+
input DAE.ConnectorType inConnectorType;
6357+
output Boolean outPotential;
6358+
algorithm
6359+
outPotential := match(inConnectorType)
6360+
case DAE.POTENTIAL() then true;
6361+
else false;
6362+
end match;
6363+
end potentialBool;
6364+
6365+
public function connectorTypeEqual
6366+
input DAE.ConnectorType inConnectorType1;
6367+
input DAE.ConnectorType inConnectorType2;
6368+
output Boolean outEqual;
6369+
algorithm
6370+
outEqual := match(inConnectorType1, inConnectorType2)
6371+
case (DAE.POTENTIAL(), DAE.POTENTIAL()) then true;
6372+
case (DAE.FLOW(), DAE.FLOW()) then true;
6373+
case (DAE.STREAM(_), DAE.STREAM(_)) then true;
6374+
case (DAE.NON_CONNECTOR(), DAE.NON_CONNECTOR()) then true;
6375+
end match;
6376+
end connectorTypeEqual;
6377+
6378+
public function toSCodeConnectorType
6379+
input DAE.ConnectorType daeConnectorType;
6380+
output SCode.ConnectorType scodeConnectorType;
6381+
algorithm
6382+
scodeConnectorType := match daeConnectorType
6383+
case DAE.FLOW() then SCode.FLOW();
6384+
case DAE.STREAM(_) then SCode.STREAM();
6385+
case DAE.POTENTIAL() then SCode.POTENTIAL();
6386+
case DAE.NON_CONNECTOR() then SCode.POTENTIAL();
6387+
end match;
6388+
end toSCodeConnectorType;
6389+
63126390
annotation(__OpenModelica_Interface="frontend");
63136391
end DAEUtil;
63146392

Compiler/FrontEnd/InnerOuter.mo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ algorithm
583583
local
584584
SCode.Variability vt1,vt2;
585585
DAE.Type t1,t2;
586-
SCode.ConnectorType ct;
586+
DAE.ConnectorType ct;
587587
DAE.DAElist dae;
588588
InstHierarchy ih;
589589
Connect.SetTrie sets;
@@ -656,7 +656,7 @@ algorithm
656656
local
657657
SCode.Variability vt1,vt2;
658658
DAE.Type t1,t2;
659-
SCode.ConnectorType ct;
659+
DAE.ConnectorType ct;
660660
DAE.DAElist dae;
661661
InstHierarchy ih;
662662
Connect.SetTrie sets;
@@ -1265,7 +1265,7 @@ algorithm
12651265
DAE.Type ty;
12661266
DAE.Binding binding;
12671267

1268-
SCode.ConnectorType ct;
1268+
DAE.ConnectorType ct;
12691269
SCode.Parallelism parallelism "parallelism";
12701270
SCode.Variability variability "variability" ;
12711271
Absyn.Direction direction "direction" ;

Compiler/FrontEnd/Inst.mo

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4092,7 +4092,7 @@ algorithm
40924092
updatedComps = BaseHashTable.add((cref,0),updatedComps);
40934093
(cache,env2,ih,SOME(updatedComps)) = updateComponentsInEnv2(cache, env, ih, pre, DAE.NOMOD(), crefs_2, ci_state, impl, SOME(updatedComps), SOME(cref));
40944094

4095-
(cache,env_1,ih,updatedComps) = updateComponentInEnv2(cache,env2,cenv,ih,pre,t,n,ad,cl,attr,pf,DAE.ATTR(ct,prl1,var1,dir,io,visibility),info,m,cmod,mods,cref,ci_state,impl,updatedComps);
4095+
(cache,env_1,ih,updatedComps) = updateComponentInEnv2(cache,env2,cenv,ih,pre,t,n,ad,cl,attr,pf,DAE.ATTR(DAEUtil.toConnectorTypeNoState(ct),prl1,var1,dir,io,visibility),info,m,cmod,mods,cref,ci_state,impl,updatedComps);
40964096

40974097
//print("updateComponentInEnv: NEW ENV:\n" + FGraph.printGraphStr(env_1) + "\n");
40984098
then
@@ -4150,7 +4150,7 @@ algorithm
41504150
crefs_2 = InstUtil.removeOptCrefFromCrefs(crefs_2, currentCref);
41514151
updatedComps = BaseHashTable.add((cref,0),updatedComps);
41524152
(cache,env2,ih,SOME(updatedComps)) = updateComponentsInEnv2(cache, env, ih, pre, mods, crefs_2, ci_state, impl, SOME(updatedComps), SOME(cref));
4153-
(cache,env_1,ih,updatedComps) = updateComponentInEnv2(cache,env2,cenv,ih,pre,t,n,ad,cl,attr,pf,DAE.ATTR(ct,prl1,var1,dir,io,visibility),info,m,cmod,mods,cref,ci_state,impl,updatedComps);
4153+
(cache,env_1,ih,updatedComps) = updateComponentInEnv2(cache,env2,cenv,ih,pre,t,n,ad,cl,attr,pf,DAE.ATTR(DAEUtil.toConnectorTypeNoState(ct),prl1,var1,dir,io,visibility),info,m,cmod,mods,cref,ci_state,impl,updatedComps);
41544154
then
41554155
(cache,env_1,ih,SOME(updatedComps));
41564156

@@ -4998,7 +4998,7 @@ algorithm
49984998
io = SCode.prefixesInnerOuter(inPrefixes);
49994999
vis = SCode.prefixesVisibility(inPrefixes);
50005000

5001-
new_var = DAE.TYPES_VAR(n,DAE.ATTR(ct,prl1,var1,dir,io,vis),ty,DAE.UNBOUND(),NONE());
5001+
new_var = DAE.TYPES_VAR(n,DAE.ATTR(DAEUtil.toConnectorTypeNoState(ct),prl1,var1,dir,io,vis),ty,DAE.UNBOUND(),NONE());
50025002
env = FGraph.updateComp(env, new_var, FCore.VAR_TYPED(), compenv);
50035003
ErrorExt.rollBack("Inst.removeSelfReferenceAndUpdate");
50045004
then
@@ -5036,7 +5036,7 @@ algorithm
50365036
io = SCode.prefixesInnerOuter(inPrefixes);
50375037
vis = SCode.prefixesVisibility(inPrefixes);
50385038

5039-
new_var = DAE.TYPES_VAR(n,DAE.ATTR(ct,prl1,var1,dir,io,vis),ty,DAE.UNBOUND(),NONE());
5039+
new_var = DAE.TYPES_VAR(n,DAE.ATTR(DAEUtil.toConnectorTypeNoState(ct),prl1,var1,dir,io,vis),ty,DAE.UNBOUND(),NONE());
50405040
env = FGraph.updateComp(env, new_var, FCore.VAR_TYPED(), compenv);
50415041
ErrorExt.rollBack("Inst.removeSelfReferenceAndUpdate");
50425042
then
@@ -5074,7 +5074,7 @@ algorithm
50745074
io = SCode.prefixesInnerOuter(inPrefixes);
50755075
vis = SCode.prefixesVisibility(inPrefixes);
50765076

5077-
new_var = DAE.TYPES_VAR(n,DAE.ATTR(ct,prl1,var1,dir,io,vis),ty,DAE.UNBOUND(),NONE());
5077+
new_var = DAE.TYPES_VAR(n,DAE.ATTR(DAEUtil.toConnectorTypeNoState(ct),prl1,var1,dir,io,vis),ty,DAE.UNBOUND(),NONE());
50785078
env = FGraph.updateComp(env, new_var, FCore.VAR_TYPED(), compenv);
50795079
ErrorExt.rollBack("Inst.removeSelfReferenceAndUpdate");
50805080
then
@@ -5113,7 +5113,7 @@ algorithm
51135113
io = SCode.prefixesInnerOuter(inPrefixes);
51145114
vis = SCode.prefixesVisibility(inPrefixes);
51155115

5116-
new_var = DAE.TYPES_VAR(n,DAE.ATTR(ct,prl1,var1,dir,io,vis),ty,DAE.UNBOUND(),NONE());
5116+
new_var = DAE.TYPES_VAR(n,DAE.ATTR(DAEUtil.toConnectorTypeNoState(ct),prl1,var1,dir,io,vis),ty,DAE.UNBOUND(),NONE());
51175117
env = FGraph.updateComp(env, new_var, FCore.VAR_TYPED(), compenv);
51185118
ErrorExt.rollBack("Inst.removeSelfReferenceAndUpdate");
51195119
then

Compiler/FrontEnd/InstBinding.mo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ public constant DAE.Type distributionType =
101101
{
102102
DAE.TYPES_VAR(
103103
"name",
104-
DAE.ATTR(SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER(),SCode.PUBLIC()),
104+
DAE.ATTR(DAE.NON_CONNECTOR(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER(),SCode.PUBLIC()),
105105
DAE.T_STRING_DEFAULT,
106106
DAE.UNBOUND(), // binding
107107
NONE()),
108108
DAE.TYPES_VAR(
109109
"params",
110-
DAE.ATTR(SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER(),SCode.PUBLIC()),
110+
DAE.ATTR(DAE.NON_CONNECTOR(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER(),SCode.PUBLIC()),
111111
DAE.T_ARRAY_REAL_NODIM,
112112
DAE.UNBOUND(), // binding
113113
NONE()),
114114
DAE.TYPES_VAR(
115115
"paramNames",
116-
DAE.ATTR(SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER(),SCode.PUBLIC()),
116+
DAE.ATTR(DAE.NON_CONNECTOR(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR(),Absyn.NOT_INNER_OUTER(),SCode.PUBLIC()),
117117
DAE.T_ARRAY_STRING_NODIM,
118118
DAE.UNBOUND(), // binding
119119
NONE())

0 commit comments

Comments
 (0)