loader: attach mmodule to sourcefile
authorJean Privat <jean@pryen.org>
Wed, 4 Feb 2015 15:15:05 +0000 (22:15 +0700)
committerJean Privat <jean@pryen.org>
Wed, 4 Feb 2015 15:15:05 +0000 (22:15 +0700)
So the associated module can be retrieved from any node

Signed-off-by: Jean Privat <jean@pryen.org>

src/loader.nit

index a046815..57d766c 100644 (file)
@@ -527,6 +527,12 @@ redef class ModelBuilder
                nmodules.add(nmodule)
                self.mmodule2nmodule[mmodule] = nmodule
 
+               var source = nmodule.location.file
+               if source != null then
+                       assert source.mmodule == null
+                       source.mmodule = mmodule
+               end
+
                if decl != null then
                        # Extract documentation
                        var ndoc = decl.n_doc
@@ -673,6 +679,11 @@ redef class MGroup
 
 end
 
+redef class SourceFile
+       # Associated mmodule, once created
+       var mmodule: nullable MModule = null
+end
+
 redef class AStdImport
        # The imported module once determined
        var mmodule: nullable MModule = null