Skip to content

Commit

Permalink
Fix broken stuff from previous new inst change.
Browse files Browse the repository at this point in the history
- Fixed cref lookup.
- Fixed prefixing of crefs.
- Fixed modifier scoping.
- Lots of other small fixes.
  • Loading branch information
perost authored and OpenModelica-Hudson committed Nov 15, 2016
1 parent a4e7088 commit adf0f0d
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 195 deletions.
8 changes: 5 additions & 3 deletions Compiler/NFFrontEnd/NFBinding.mo
Expand Up @@ -38,6 +38,7 @@ encapsulated package NFBinding

public
import DAE;
import NFComponent.Component;
import NFInstNode.InstNode;
import SCode;

Expand All @@ -53,15 +54,15 @@ uniontype Binding
Absyn.Exp bindingExp;
SCode.Final finalPrefix;
SCode.Each eachPrefix;
InstNode scope;
Component.Scope scope;
Integer propagatedDims;
SourceInfo info;
end RAW_BINDING;

record UNTYPED_BINDING
Absyn.Exp bindingExp;
Boolean isProcessing;
InstNode scope;
Component.Scope scope;
Integer propagatedDims;
SourceInfo info;
end UNTYPED_BINDING;
Expand All @@ -78,7 +79,6 @@ public
input Option<Absyn.Exp> bindingExp;
input SCode.Final finalPrefix;
input SCode.Each eachPrefix;
input InstNode scope;
input Integer dimensions;
input SourceInfo info;
output Binding binding;
Expand All @@ -87,10 +87,12 @@ public
local
Absyn.Exp exp;
Integer pd;
Component.Scope scope;

case SOME(exp)
algorithm
pd := if SCode.eachBool(eachPrefix) then -1 else dimensions;
scope := Component.Scope.RELATIVE_COMP(0);
then
RAW_BINDING(exp, finalPrefix, eachPrefix, scope, pd, info);

Expand Down
18 changes: 15 additions & 3 deletions Compiler/NFFrontEnd/NFComponent.mo
Expand Up @@ -31,13 +31,19 @@

encapsulated package NFComponent

import DAE.Type;
import DAE;
import NFBinding.Binding;
import NFDimension.Dimension;
import NFInstNode.InstNode;
import NFMod.Modifier;
import SCode.Element;

constant Component.Attributes DEFAULT_ATTR =
Component.Attributes.ATTRIBUTES(DAE.VARIABLE(), DAE.BIDIR(), DAE.PUBLIC(), DAE.NON_CONNECTOR());
constant Component.Attributes INPUT_ATTR =
Component.Attributes.ATTRIBUTES(DAE.VARIABLE(), DAE.INPUT(), DAE.PUBLIC(), DAE.NON_CONNECTOR());
constant Component.Scope DEFAULT_SCOPE = Component.Scope.RELATIVE_COMP(0);

uniontype Component
uniontype Attributes
record ATTRIBUTES
Expand All @@ -48,6 +54,12 @@ uniontype Component
end ATTRIBUTES;
end Attributes;

uniontype Scope
record RELATIVE_COMP
Integer level;
end RELATIVE_COMP;
end Scope;

record COMPONENT_DEF
Element definition;
Modifier modifier;
Expand All @@ -63,7 +75,7 @@ uniontype Component

record TYPED_COMPONENT
InstNode classInst;
Type ty;
DAE.Type ty;
Binding binding;
Component.Attributes attributes;
end TYPED_COMPONENT;
Expand Down Expand Up @@ -142,7 +154,7 @@ uniontype Component
local
DAE.Type ty;

case TYPED_COMPONENT(ty = DAE.T_ARRAY(ty = ty))
case TYPED_COMPONENT(ty = DAE.Type.T_ARRAY(ty = ty))
algorithm
component.ty := ty;
then
Expand Down
40 changes: 39 additions & 1 deletion Compiler/NFFrontEnd/NFComponentNode.mo
Expand Up @@ -33,9 +33,10 @@
encapsulated package NFComponentNode

import NFComponent.Component;
import NFInstNode.InstNode;
import NFMod.Modifier;
import NFPrefix.Prefix;
import SCode.Element;
import NFInstNode.InstNode;

uniontype ComponentNode
record COMPONENT_NODE
Expand Down Expand Up @@ -106,6 +107,16 @@ uniontype ComponentNode
COMPONENT_NODE(parent = parentNode) := node;
end parent;

function topComponent
input ComponentNode node;
output ComponentNode topComponent;
algorithm
topComponent := match node
case COMPONENT_NODE(parent = EMPTY_NODE()) then node;
case COMPONENT_NODE() then topComponent(node.parent);
end match;
end topComponent;

function setParent
input ComponentNode parent;
input output ComponentNode node;
Expand Down Expand Up @@ -161,6 +172,16 @@ uniontype ComponentNode
end match;
end setDefinition;

function info
input ComponentNode node;
output SourceInfo info;
algorithm
info := match node
case COMPONENT_NODE() then SCode.elementInfo(node.definition);
else Absyn.dummyInfo;
end match;
end info;

function clone
input ComponentNode node;
output ComponentNode clone;
Expand Down Expand Up @@ -190,6 +211,23 @@ uniontype ComponentNode
();
end match;
end apply;

function instPrefix
input ComponentNode node;
input output Prefix prefix = Prefix.NO_PREFIX();
algorithm
prefix := match node
case COMPONENT_NODE(parent = EMPTY_NODE()) then prefix;

case COMPONENT_NODE()
algorithm
prefix := Prefix.add(node.name, {}, DAE.T_UNKNOWN_DEFAULT, prefix);
then
instPrefix(node.parent, prefix);

else prefix;
end match;
end instPrefix;
end ComponentNode;

annotation(__OpenModelica_Interface="frontend");
Expand Down

0 comments on commit adf0f0d

Please sign in to comment.