Skip to content

Commit

Permalink
[NF] More derived scope fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Mar 27, 2018
1 parent 659bcbc commit b4635bb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFComponent.mo
Expand Up @@ -605,7 +605,7 @@ uniontype Component
function isConnector
input Component component;
output Boolean isConnector =
Class.isConnectorClass(InstNode.getClass(classInstance(component)));
Class.isConnectorClass(InstNode.getDerivedClass(classInstance(component)));
end isConnector;

function isIdentical
Expand Down
5 changes: 3 additions & 2 deletions Compiler/NFFrontEnd/NFInst.mo
Expand Up @@ -750,6 +750,8 @@ algorithm
case Class.DERIVED_CLASS()
algorithm
node := InstNode.replaceClass(cls, node);
updateComponentType(parent, node);

// Merge outer modifiers and attributes.
mod := Modifier.fromElement(InstNode.definition(node), InstNode.level(parent), InstNode.parent(node));
mod := Modifier.merge(outerMod, mod);
Expand All @@ -760,14 +762,13 @@ algorithm
InstNodeType.BASE_CLASS(node, InstNode.definition(cls.baseClass)), cls.baseClass);

// Instantiate the base class and update the nodes.
(base_node, attributes) := instClass(base_node, mod, attributes);
(base_node, attributes) := instClass(base_node, mod, attributes, parent);
cls.baseClass := base_node;
cls.attributes := attributes;

// Update the dimensions and the parent's type with the new class instance.
cls.dims := list(Dimension.setScope(dim, node) for dim in cls.dims);
node := InstNode.updateClass(cls, node);
updateComponentType(parent, node);
then
();

Expand Down
14 changes: 14 additions & 0 deletions Compiler/NFFrontEnd/NFInstNode.mo
Expand Up @@ -537,6 +537,20 @@ uniontype InstNode
end match;
end getClass;

function getDerivedClass
input InstNode node;
output Class cls;
algorithm
cls := match node
local
InstNode parent;

case CLASS_NODE(nodeType = InstNodeType.BASE_CLASS(parent = parent)) then getDerivedClass(parent);
case CLASS_NODE() then Pointer.access(node.cls);
case COMPONENT_NODE() then getDerivedClass(Component.classInstance(Pointer.access(node.component)));
end match;
end getDerivedClass;

function updateClass
input Class cls;
input output InstNode node;
Expand Down

0 comments on commit b4635bb

Please sign in to comment.