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

Commit adf0f0d

Browse files
perostOpenModelica-Hudson
authored andcommitted
Fix broken stuff from previous new inst change.
- Fixed cref lookup. - Fixed prefixing of crefs. - Fixed modifier scoping. - Lots of other small fixes.
1 parent a4e7088 commit adf0f0d

File tree

9 files changed

+343
-195
lines changed

9 files changed

+343
-195
lines changed

Compiler/NFFrontEnd/NFBinding.mo

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ encapsulated package NFBinding
3838

3939
public
4040
import DAE;
41+
import NFComponent.Component;
4142
import NFInstNode.InstNode;
4243
import SCode;
4344

@@ -53,15 +54,15 @@ uniontype Binding
5354
Absyn.Exp bindingExp;
5455
SCode.Final finalPrefix;
5556
SCode.Each eachPrefix;
56-
InstNode scope;
57+
Component.Scope scope;
5758
Integer propagatedDims;
5859
SourceInfo info;
5960
end RAW_BINDING;
6061

6162
record UNTYPED_BINDING
6263
Absyn.Exp bindingExp;
6364
Boolean isProcessing;
64-
InstNode scope;
65+
Component.Scope scope;
6566
Integer propagatedDims;
6667
SourceInfo info;
6768
end UNTYPED_BINDING;
@@ -78,7 +79,6 @@ public
7879
input Option<Absyn.Exp> bindingExp;
7980
input SCode.Final finalPrefix;
8081
input SCode.Each eachPrefix;
81-
input InstNode scope;
8282
input Integer dimensions;
8383
input SourceInfo info;
8484
output Binding binding;
@@ -87,10 +87,12 @@ public
8787
local
8888
Absyn.Exp exp;
8989
Integer pd;
90+
Component.Scope scope;
9091

9192
case SOME(exp)
9293
algorithm
9394
pd := if SCode.eachBool(eachPrefix) then -1 else dimensions;
95+
scope := Component.Scope.RELATIVE_COMP(0);
9496
then
9597
RAW_BINDING(exp, finalPrefix, eachPrefix, scope, pd, info);
9698

Compiler/NFFrontEnd/NFComponent.mo

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@
3131

3232
encapsulated package NFComponent
3333

34-
import DAE.Type;
34+
import DAE;
3535
import NFBinding.Binding;
3636
import NFDimension.Dimension;
3737
import NFInstNode.InstNode;
3838
import NFMod.Modifier;
3939
import SCode.Element;
4040

41+
constant Component.Attributes DEFAULT_ATTR =
42+
Component.Attributes.ATTRIBUTES(DAE.VARIABLE(), DAE.BIDIR(), DAE.PUBLIC(), DAE.NON_CONNECTOR());
43+
constant Component.Attributes INPUT_ATTR =
44+
Component.Attributes.ATTRIBUTES(DAE.VARIABLE(), DAE.INPUT(), DAE.PUBLIC(), DAE.NON_CONNECTOR());
45+
constant Component.Scope DEFAULT_SCOPE = Component.Scope.RELATIVE_COMP(0);
46+
4147
uniontype Component
4248
uniontype Attributes
4349
record ATTRIBUTES
@@ -48,6 +54,12 @@ uniontype Component
4854
end ATTRIBUTES;
4955
end Attributes;
5056

57+
uniontype Scope
58+
record RELATIVE_COMP
59+
Integer level;
60+
end RELATIVE_COMP;
61+
end Scope;
62+
5163
record COMPONENT_DEF
5264
Element definition;
5365
Modifier modifier;
@@ -63,7 +75,7 @@ uniontype Component
6375

6476
record TYPED_COMPONENT
6577
InstNode classInst;
66-
Type ty;
78+
DAE.Type ty;
6779
Binding binding;
6880
Component.Attributes attributes;
6981
end TYPED_COMPONENT;
@@ -142,7 +154,7 @@ uniontype Component
142154
local
143155
DAE.Type ty;
144156

145-
case TYPED_COMPONENT(ty = DAE.T_ARRAY(ty = ty))
157+
case TYPED_COMPONENT(ty = DAE.Type.T_ARRAY(ty = ty))
146158
algorithm
147159
component.ty := ty;
148160
then

Compiler/NFFrontEnd/NFComponentNode.mo

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
encapsulated package NFComponentNode
3434

3535
import NFComponent.Component;
36+
import NFInstNode.InstNode;
3637
import NFMod.Modifier;
38+
import NFPrefix.Prefix;
3739
import SCode.Element;
38-
import NFInstNode.InstNode;
3940

4041
uniontype ComponentNode
4142
record COMPONENT_NODE
@@ -106,6 +107,16 @@ uniontype ComponentNode
106107
COMPONENT_NODE(parent = parentNode) := node;
107108
end parent;
108109

110+
function topComponent
111+
input ComponentNode node;
112+
output ComponentNode topComponent;
113+
algorithm
114+
topComponent := match node
115+
case COMPONENT_NODE(parent = EMPTY_NODE()) then node;
116+
case COMPONENT_NODE() then topComponent(node.parent);
117+
end match;
118+
end topComponent;
119+
109120
function setParent
110121
input ComponentNode parent;
111122
input output ComponentNode node;
@@ -161,6 +172,16 @@ uniontype ComponentNode
161172
end match;
162173
end setDefinition;
163174

175+
function info
176+
input ComponentNode node;
177+
output SourceInfo info;
178+
algorithm
179+
info := match node
180+
case COMPONENT_NODE() then SCode.elementInfo(node.definition);
181+
else Absyn.dummyInfo;
182+
end match;
183+
end info;
184+
164185
function clone
165186
input ComponentNode node;
166187
output ComponentNode clone;
@@ -190,6 +211,23 @@ uniontype ComponentNode
190211
();
191212
end match;
192213
end apply;
214+
215+
function instPrefix
216+
input ComponentNode node;
217+
input output Prefix prefix = Prefix.NO_PREFIX();
218+
algorithm
219+
prefix := match node
220+
case COMPONENT_NODE(parent = EMPTY_NODE()) then prefix;
221+
222+
case COMPONENT_NODE()
223+
algorithm
224+
prefix := Prefix.add(node.name, {}, DAE.T_UNKNOWN_DEFAULT, prefix);
225+
then
226+
instPrefix(node.parent, prefix);
227+
228+
else prefix;
229+
end match;
230+
end instPrefix;
193231
end ComponentNode;
194232

195233
annotation(__OpenModelica_Interface="frontend");

0 commit comments

Comments
 (0)