mirror of
https://github.com/irmen/prog8.git
synced 2024-07-23 00:29:09 +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.")
|
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
|
// 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
|
// always import prog8_lib and math
|
||||||
importer.importLibraryModule(programAst, "math", ICompilationTarget.instance, compilationTargetName)
|
importer.importLibraryModule(programAst, "math", ICompilationTarget.instance, compilationTargetName)
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package prog8.compiler.target
|
package prog8.compiler.target
|
||||||
|
|
||||||
import prog8.ast.IStringEncoding
|
|
||||||
import prog8.ast.Program
|
|
||||||
import prog8.compiler.CompilationOptions
|
import prog8.compiler.CompilationOptions
|
||||||
import prog8.compiler.Zeropage
|
import prog8.compiler.Zeropage
|
||||||
import prog8.parser.ModuleImporter
|
|
||||||
|
|
||||||
|
|
||||||
internal interface IMachineFloat {
|
internal interface IMachineFloat {
|
||||||
@ -34,10 +31,7 @@ internal interface IMachineDefinition {
|
|||||||
fun initializeZeropage(compilerOptions: CompilationOptions)
|
fun initializeZeropage(compilerOptions: CompilationOptions)
|
||||||
fun getFloat(num: Number): IMachineFloat
|
fun getFloat(num: Number): IMachineFloat
|
||||||
|
|
||||||
// TODO don't do the importing here, just return a list of modules to import...:
|
fun importLibs(compilerOptions: CompilationOptions, compilationTargetName: String): List<String>
|
||||||
fun importLibs(compilerOptions: CompilationOptions, importer: ModuleImporter, program: Program,
|
|
||||||
encoder: IStringEncoding, compilationTargetName: String)
|
|
||||||
|
|
||||||
fun launchEmulator(programName: String)
|
fun launchEmulator(programName: String)
|
||||||
fun isRegularRAMaddress(address: Int): Boolean
|
fun isRegularRAMaddress(address: Int): Boolean
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package prog8.compiler.target.c64
|
package prog8.compiler.target.c64
|
||||||
|
|
||||||
import prog8.ast.IStringEncoding
|
|
||||||
import prog8.ast.Program
|
|
||||||
import prog8.compiler.*
|
import prog8.compiler.*
|
||||||
import prog8.compiler.target.CpuType
|
import prog8.compiler.target.CpuType
|
||||||
import prog8.compiler.target.IMachineDefinition
|
import prog8.compiler.target.IMachineDefinition
|
||||||
import prog8.compiler.target.IMachineFloat
|
import prog8.compiler.target.IMachineFloat
|
||||||
import prog8.parser.ModuleImporter
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
@ -31,15 +28,11 @@ internal object C64MachineDefinition: IMachineDefinition {
|
|||||||
|
|
||||||
override fun getFloat(num: Number) = Mflpt5.fromNumber(num)
|
override fun getFloat(num: Number) = Mflpt5.fromNumber(num)
|
||||||
|
|
||||||
override fun importLibs(
|
override fun importLibs(compilerOptions: CompilationOptions,compilationTargetName: String): List<String> {
|
||||||
compilerOptions: CompilationOptions,
|
return if (compilerOptions.launcher == LauncherType.BASIC || compilerOptions.output == OutputType.PRG)
|
||||||
importer: ModuleImporter,
|
listOf("syslib")
|
||||||
program: Program,
|
else
|
||||||
encoder: IStringEncoding,
|
emptyList()
|
||||||
compilationTargetName: String)
|
|
||||||
{
|
|
||||||
if (compilerOptions.launcher == LauncherType.BASIC || compilerOptions.output == OutputType.PRG)
|
|
||||||
importer.importLibraryModule(program, "syslib", encoder, compilationTargetName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun launchEmulator(programName: String) {
|
override fun launchEmulator(programName: String) {
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package prog8.compiler.target.cx16
|
package prog8.compiler.target.cx16
|
||||||
|
|
||||||
import prog8.ast.IStringEncoding
|
|
||||||
import prog8.ast.Program
|
|
||||||
import prog8.compiler.*
|
import prog8.compiler.*
|
||||||
import prog8.compiler.target.CpuType
|
import prog8.compiler.target.CpuType
|
||||||
import prog8.compiler.target.IMachineDefinition
|
import prog8.compiler.target.IMachineDefinition
|
||||||
import prog8.compiler.target.c64.C64MachineDefinition
|
import prog8.compiler.target.c64.C64MachineDefinition
|
||||||
import prog8.parser.ModuleImporter
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
internal object CX16MachineDefinition: IMachineDefinition {
|
internal object CX16MachineDefinition: IMachineDefinition {
|
||||||
@ -28,16 +25,11 @@ internal object CX16MachineDefinition: IMachineDefinition {
|
|||||||
override lateinit var zeropage: Zeropage
|
override lateinit var zeropage: Zeropage
|
||||||
|
|
||||||
override fun getFloat(num: Number) = C64MachineDefinition.Mflpt5.fromNumber(num)
|
override fun getFloat(num: Number) = C64MachineDefinition.Mflpt5.fromNumber(num)
|
||||||
|
override fun importLibs(compilerOptions: CompilationOptions, compilationTargetName: String): List<String> {
|
||||||
override fun importLibs(
|
return if (compilerOptions.launcher == LauncherType.BASIC || compilerOptions.output == OutputType.PRG)
|
||||||
compilerOptions: CompilationOptions,
|
listOf("syslib")
|
||||||
importer: ModuleImporter,
|
else
|
||||||
program: Program,
|
emptyList()
|
||||||
encoder: IStringEncoding,
|
|
||||||
compilationTargetName: String)
|
|
||||||
{
|
|
||||||
if (compilerOptions.launcher == LauncherType.BASIC || compilerOptions.output == OutputType.PRG)
|
|
||||||
importer.importLibraryModule(program, "syslib", encoder, compilationTargetName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun launchEmulator(programName: String) {
|
override fun launchEmulator(programName: String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user