Skip to content

Commit

Permalink
NFInst fixes.
Browse files Browse the repository at this point in the history
- Use correct parent in NFInst.modifyExtends.
- Use DAE.T_FUNCTION when converting a function to DAE.

Belonging to [master]:
  - OpenModelica/OMCompiler#2044
  • Loading branch information
perost authored and OpenModelica-Hudson committed Nov 21, 2017
1 parent df577f2 commit ea246de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Compiler/NFFrontEnd/NFFunction.mo
Expand Up @@ -771,13 +771,14 @@ uniontype Function
SCode.Visibility vis;
Boolean par, impr;
DAE.InlineType ity;
DAE.Type ty;
algorithm
vis := SCode.PUBLIC(); // TODO: Use the actual visibility.
par := false; // TODO: Use the actual partial prefix.
impr := fn.attributes.isImpure;
ity := fn.attributes.inline;
daeFn := DAE.FUNCTION(fn.path, defs, Type.toDAE(fn.returnType), vis,
par, impr, ity, DAE.emptyElementSource, NONE());
ty := DAE.T_FUNCTION({}, Type.toDAE(fn.returnType), fn.attributes, fn.path);
daeFn := DAE.FUNCTION(fn.path, defs, ty, vis, par, impr, ity, DAE.emptyElementSource, NONE());
end toDAE;

protected
Expand Down
7 changes: 4 additions & 3 deletions Compiler/NFFrontEnd/NFInst.mo
Expand Up @@ -606,7 +606,7 @@ algorithm
mod := Modifier.merge(cls_mod, mod);

// Apply the modifiers of extends nodes.
ClassTree.mapExtends(cls_tree, function modifyExtends(scope = par));
ClassTree.mapExtends(cls_tree, function modifyExtends(scope = par, parent = par));

// Apply modifier in this scope.
applyModifier(mod, cls_tree, InstNode.name(node));
Expand Down Expand Up @@ -772,6 +772,7 @@ end instImport;
function modifyExtends
input output InstNode extendsNode;
input InstNode scope;
input InstNode parent;
protected
SCode.Element elem;
Absyn.Path basepath;
Expand All @@ -782,12 +783,12 @@ protected
ClassTree cls_tree;
algorithm
cls_tree := Class.classTree(InstNode.getClass(extendsNode));
ClassTree.mapExtends(cls_tree, function modifyExtends(scope = extendsNode));
ClassTree.mapExtends(cls_tree, function modifyExtends(scope = extendsNode, parent = parent));

// Replace the node in the node type with the given scope, so that crefs found
// in this extends are prefixed correctly.
InstNodeType.BASE_CLASS(definition = elem) := InstNode.nodeType(extendsNode);
extendsNode := InstNode.setNodeType(InstNodeType.BASE_CLASS(scope, elem), extendsNode);
extendsNode := InstNode.setNodeType(InstNodeType.BASE_CLASS(parent, elem), extendsNode);

// Create a modifier from the extends.
ext_mod := Modifier.fromElement(elem, InstNode.level(scope) + 1, scope);
Expand Down

0 comments on commit ea246de

Please sign in to comment.