mirror of
https://github.com/irmen/prog8.git
synced 2025-03-08 03:35:29 +00:00
machinedefinition doesn't import system libs itself anymore
This commit is contained in:
parent
2f97aedc3c
commit
ac0b1da3fc
@ -177,7 +177,8 @@ private fun parseImports(filepath: Path, errors: ErrorReporter): Triple<Program,
|
||||
throw ParsingFailedError("${programAst.modules.first().position} BASIC launcher requires output type PRG.")
|
||||
|
||||
// depending on the machine and compiler options we may have to include some libraries
|
||||
ICompilationTarget.instance.machine.importLibs(compilerOptions, importer, programAst, ICompilationTarget.instance, compilationTargetName)
|
||||
for(lib in ICompilationTarget.instance.machine.importLibs(compilerOptions, compilationTargetName))
|
||||
importer.importLibraryModule(programAst, lib, ICompilationTarget.instance, compilationTargetName)
|
||||
|
||||
// always import prog8_lib and math
|
||||
importer.importLibraryModule(programAst, "math", ICompilationTarget.instance, compilationTargetName)
|
||||
|
@ -1,10 +1,7 @@
|
||||
package prog8.compiler.target
|
||||
|
||||
import prog8.ast.IStringEncoding
|
||||
import prog8.ast.Program
|
||||
import prog8.compiler.CompilationOptions
|
||||
import prog8.compiler.Zeropage
|
||||
import prog8.parser.ModuleImporter
|
||||
|
||||
|
||||
internal interface IMachineFloat {
|
||||
@ -34,10 +31,7 @@ internal interface IMachineDefinition {
|
||||
fun initializeZeropage(compilerOptions: CompilationOptions)
|
||||
fun getFloat(num: Number): IMachineFloat
|
||||
|
||||
// TODO don't do the importing here, just return a list of modules to import...:
|
||||
fun importLibs(compilerOptions: CompilationOptions, importer: ModuleImporter, program: Program,
|
||||
encoder: IStringEncoding, compilationTargetName: String)
|
||||
|
||||
fun importLibs(compilerOptions: CompilationOptions, compilationTargetName: String): List<String>
|
||||
fun launchEmulator(programName: String)
|
||||
fun isRegularRAMaddress(address: Int): Boolean
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
package prog8.compiler.target.c64
|
||||
|
||||
import prog8.ast.IStringEncoding
|
||||
import prog8.ast.Program
|
||||
import prog8.compiler.*
|
||||
import prog8.compiler.target.CpuType
|
||||
import prog8.compiler.target.IMachineDefinition
|
||||
import prog8.compiler.target.IMachineFloat
|
||||
import prog8.parser.ModuleImporter
|
||||
import java.io.IOException
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.pow
|
||||
@ -31,15 +28,11 @@ internal object C64MachineDefinition: IMachineDefinition {
|
||||
|
||||
override fun getFloat(num: Number) = Mflpt5.fromNumber(num)
|
||||
|
||||
override fun importLibs(
|
||||
compilerOptions: CompilationOptions,
|
||||
importer: ModuleImporter,
|
||||
program: Program,
|
||||
encoder: IStringEncoding,
|
||||
compilationTargetName: String)
|
||||
{
|
||||
if (compilerOptions.launcher == LauncherType.BASIC || compilerOptions.output == OutputType.PRG)
|
||||
importer.importLibraryModule(program, "syslib", encoder, compilationTargetName)
|
||||
override fun importLibs(compilerOptions: CompilationOptions,compilationTargetName: String): List<String> {
|
||||
return if (compilerOptions.launcher == LauncherType.BASIC || compilerOptions.output == OutputType.PRG)
|
||||
listOf("syslib")
|
||||
else
|
||||
emptyList()
|
||||
}
|
||||
|
||||
override fun launchEmulator(programName: String) {
|
||||
|
@ -1,12 +1,9 @@
|
||||
package prog8.compiler.target.cx16
|
||||
|
||||
import prog8.ast.IStringEncoding
|
||||
import prog8.ast.Program
|
||||
import prog8.compiler.*
|
||||
import prog8.compiler.target.CpuType
|
||||
import prog8.compiler.target.IMachineDefinition
|
||||
import prog8.compiler.target.c64.C64MachineDefinition
|
||||
import prog8.parser.ModuleImporter
|
||||
import java.io.IOException
|
||||
|
||||
internal object CX16MachineDefinition: IMachineDefinition {
|
||||
@ -28,16 +25,11 @@ internal object CX16MachineDefinition: IMachineDefinition {
|
||||
override lateinit var zeropage: Zeropage
|
||||
|
||||
override fun getFloat(num: Number) = C64MachineDefinition.Mflpt5.fromNumber(num)
|
||||
|
||||
override fun importLibs(
|
||||
compilerOptions: CompilationOptions,
|
||||
importer: ModuleImporter,
|
||||
program: Program,
|
||||
encoder: IStringEncoding,
|
||||
compilationTargetName: String)
|
||||
{
|
||||
if (compilerOptions.launcher == LauncherType.BASIC || compilerOptions.output == OutputType.PRG)
|
||||
importer.importLibraryModule(program, "syslib", encoder, compilationTargetName)
|
||||
override fun importLibs(compilerOptions: CompilationOptions, compilationTargetName: String): List<String> {
|
||||
return if (compilerOptions.launcher == LauncherType.BASIC || compilerOptions.output == OutputType.PRG)
|
||||
listOf("syslib")
|
||||
else
|
||||
emptyList()
|
||||
}
|
||||
|
||||
override fun launchEmulator(programName: String) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user