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

Commit 62633fb

Browse files
adrpoOpenModelica-Hudson
authored andcommitted
NF: implement partial support for unqualified imports
1 parent d981c30 commit 62633fb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Compiler/NFFrontEnd/NFImport.mo

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ import System;
7070

7171
public
7272
function addImportsToScope
73+
// adrpo: hm, i don't know if this is correct as imports are not inherited
7374
input list<SCode.Element> imports;
7475
input InstNode currentScope;
7576
input output ClassTree.Tree scope;
7677
protected
7778
Absyn.Import i;
7879
InstNode node, top_scope;
7980
SourceInfo info;
81+
Class cls;
82+
ClassTree.Tree els;
8083
algorithm
8184
if listEmpty(imports) then
8285
return;
@@ -93,17 +96,33 @@ algorithm
9396
case Absyn.NAMED_IMPORT()
9497
algorithm
9598
node := Lookup.lookupClassName(Absyn.FULLYQUALIFIED(i.path), top_scope, info);
99+
// TODO! FIXME! check if there is a local definition with the same name and if prefix of path is a package
100+
// how about importing constants not just classes?!
96101
scope := NFInst.addClassToScope(i.name, ClassTree.Entry.CLASS(node), info, scope);
97102
then
98103
();
99104

100105
case Absyn.QUAL_IMPORT()
101106
algorithm
102107
node := Lookup.lookupClassName(Absyn.FULLYQUALIFIED(i.path), top_scope, info);
108+
// TODO! FIXME! check if there is a local definition with the same name and if prefix of path is a package
109+
// how about importing constants not just classes?!
103110
scope := NFInst.addClassToScope(Absyn.pathLastIdent(i.path), ClassTree.Entry.CLASS(node), info, scope);
104111
then
105112
();
106113

114+
case Absyn.UNQUAL_IMPORT()
115+
algorithm
116+
node := Lookup.lookupClassName(Absyn.FULLYQUALIFIED(i.path), top_scope, info);
117+
node := NFInst.expand(node);
118+
// TODO! FIXME! check that the path is a package!
119+
// how about importing constants not just classes?!
120+
// add all the definitions from node to current scope
121+
// using addInheritedElements here as is basically similar
122+
scope := NFInst.addInheritedElements({node}, scope);
123+
then
124+
();
125+
107126
else
108127
algorithm
109128
print("NFInst.addImportsToScope: IMPLEMENT ME\n");

0 commit comments

Comments
 (0)