Added top down (using module name) resolution to the grand resolver

parser_exception_before
Tristan B. V. Kildaire 2021-03-31 21:15:28 +02:00
parent ab5ee58055
commit c5f45e6a36
3 changed files with 35 additions and 8 deletions

View File

@ -23,6 +23,11 @@ public final class TypeChecker
/* The name resolver */
private Resolver resolver;
public Module getModule()
{
return modulle;
}
this(Module modulle)
{
this.modulle = modulle;

View File

@ -93,6 +93,8 @@ public final class Resolver
* If no dot
*
* Try and find `name` within c
*
* TODO: WOn't resolve a module
*/
if(path.length == 1)
{
@ -154,6 +156,19 @@ public final class Resolver
else
{
/* TODO: Bug is we will never find top container */
/* Check if the name of root is that of Module */
if(cmp(typeChecker.getModule().getName(), path[0]) == 0)
{
/* Root ourselves relative to the Module */
/* TODO: Don't serch for myModule class and ooga within */
/**
* TODO: Although the above should be impossible when we set usable names
* and make sure module name cannot be sed anywhere
*/
/* TODO: Even if it could be because of this check it would be ignored */
/* TODO: This is what we want, but to avoid confusion we shouldn't allow the use of that name */
return resolveBest(typeChecker.getModule(), name);
}
Entity entityFound = resolveUp(c, path[0]);

View File

@ -39,13 +39,7 @@ class X : myModule.ooga
}
class myModule
{
class ooga
{
}
}
class K : myModule.ooga
{
@ -54,7 +48,10 @@ class X : myModule.ooga
class D : X.Y
{
class Fok : myModule.ooga
{
}
}
class F : Shekshi.G.F {}
@ -148,6 +145,16 @@ class Them
}
class naai : testClass.test3.llllll.fokfok
{
}
class baai : myModule.testClass.test3.llllll.fokfok
{
}
}
}