- ModuleImporter: deduplicate code

This commit is contained in:
meisl 2021-08-01 15:37:57 +02:00
parent b8fade23de
commit f2cb89a128

View File

@ -38,21 +38,7 @@ class ModuleImporter(private val program: Program,
var logMsg = "importing '${filePath.nameWithoutExtension}' (from $srcPath)"
println(logMsg)
val module = Prog8Parser.parseModule(SourceCode.fromPath(srcPath))
module.program = program
module.linkParents(program.namespace)
program.modules.add(module)
// accept additional imports
val lines = module.statements.toMutableList()
lines.asSequence()
.mapIndexed { i, it -> i to it }
.filter { (it.second as? Directive)?.directive == "%import" }
.forEach { executeImportDirective(it.second as Directive, module) }
module.statements = lines
return module
return importModule(SourceCode.fromPath(srcPath))
}
fun importLibraryModule(name: String): Module? {