attempt to fix Windows path issue with "library:" prefixes in AsmGen

This commit is contained in:
Irmen de Jong 2021-10-16 14:50:08 +02:00
parent aea364e43d
commit 9626c5dead
2 changed files with 3 additions and 4 deletions

View File

@ -375,7 +375,7 @@ fun printAst(programAst: Program) {
println()
}
internal fun loadAsmIncludeFile(filename: String, sourcePath: Path): Result<String, NoSuchFileException> {
internal fun loadAsmIncludeFile(filename: String, source: SourceCode): Result<String, NoSuchFileException> {
return if (filename.startsWith(libraryFilePrefix)) {
return runCatching {
val stream = object {}.javaClass.getResourceAsStream("/prog8lib/${filename.substring(libraryFilePrefix.length)}") // TODO handle via SourceCode
@ -383,7 +383,7 @@ internal fun loadAsmIncludeFile(filename: String, sourcePath: Path): Result<Stri
}.mapError { NoSuchFileException(File(filename)) }
} else {
// first try in the isSameAs folder as where the containing file was imported from
val sib = sourcePath.resolveSibling(filename)
val sib = Path(source.pathString()).resolveSibling(filename)
if (sib.toFile().isFile)
Ok(sib.toFile().readText())

View File

@ -1328,8 +1328,7 @@ $repeatLabel lda $counterVar
val includedName = stmt.args[0].str!!
if(stmt.definingModule.source is SourceCode.Generated)
TODO("%asminclude inside non-library, non-filesystem module")
val sourcePath = Path(stmt.definingModule.source.pathString())
loadAsmIncludeFile(includedName, sourcePath).fold(
loadAsmIncludeFile(includedName, stmt.definingModule.source).fold(
success = { assemblyLines.add(it.trimEnd().trimStart('\n')) },
failure = { errors.err(it.toString(), stmt.position) }
)