mirror of
https://github.com/irmen/prog8.git
synced 2024-12-17 16:29:50 +00:00
target machine config tweak and fix possible compiler crash on wrong type name
This commit is contained in:
parent
d70b8303b1
commit
c080fbe59a
@ -13,6 +13,7 @@ interface IMachineDefinition {
|
||||
val FLOAT_MAX_NEGATIVE: Double
|
||||
val FLOAT_MAX_POSITIVE: Double
|
||||
val FLOAT_MEM_SIZE: Int
|
||||
val STARTUP_CODE_RESERVED_SIZE: UInt // this is here, so that certain compiler targets are able to tune this
|
||||
val PROGRAM_LOAD_ADDRESS : UInt
|
||||
val PROGRAM_MEMTOP_ADDRESS: UInt
|
||||
val BSSHIGHRAM_START: UInt
|
||||
|
@ -11,6 +11,7 @@ class AtariMachineDefinition: IMachineDefinition {
|
||||
override val FLOAT_MAX_POSITIVE = 9.999999999e97
|
||||
override val FLOAT_MAX_NEGATIVE = -9.999999999e97
|
||||
override val FLOAT_MEM_SIZE = 6
|
||||
override val STARTUP_CODE_RESERVED_SIZE = 20u
|
||||
override val PROGRAM_LOAD_ADDRESS = 0x2000u
|
||||
override val PROGRAM_MEMTOP_ADDRESS = 0xffffu // TODO what's memtop?
|
||||
|
||||
|
@ -13,6 +13,7 @@ class C128MachineDefinition: IMachineDefinition {
|
||||
override val FLOAT_MAX_POSITIVE = Mflpt5.FLOAT_MAX_POSITIVE
|
||||
override val FLOAT_MAX_NEGATIVE = Mflpt5.FLOAT_MAX_NEGATIVE
|
||||
override val FLOAT_MEM_SIZE = Mflpt5.FLOAT_MEM_SIZE
|
||||
override val STARTUP_CODE_RESERVED_SIZE = 20u
|
||||
override val PROGRAM_LOAD_ADDRESS = 0x1c01u
|
||||
override val PROGRAM_MEMTOP_ADDRESS = 0xff00u
|
||||
|
||||
|
@ -14,6 +14,7 @@ class C64MachineDefinition: IMachineDefinition {
|
||||
override val FLOAT_MAX_POSITIVE = Mflpt5.FLOAT_MAX_POSITIVE
|
||||
override val FLOAT_MAX_NEGATIVE = Mflpt5.FLOAT_MAX_NEGATIVE
|
||||
override val FLOAT_MEM_SIZE = Mflpt5.FLOAT_MEM_SIZE
|
||||
override val STARTUP_CODE_RESERVED_SIZE = 20u
|
||||
override val PROGRAM_LOAD_ADDRESS = 0x0801u
|
||||
override val PROGRAM_MEMTOP_ADDRESS = 0xcfe0u // $a000 if floats are used
|
||||
// note that at $cfe0-$cfff are the 16 'virtual registers' R0-R15
|
||||
|
@ -13,6 +13,7 @@ class CX16MachineDefinition: IMachineDefinition {
|
||||
override val FLOAT_MAX_POSITIVE = Mflpt5.FLOAT_MAX_POSITIVE
|
||||
override val FLOAT_MAX_NEGATIVE = Mflpt5.FLOAT_MAX_NEGATIVE
|
||||
override val FLOAT_MEM_SIZE = Mflpt5.FLOAT_MEM_SIZE
|
||||
override val STARTUP_CODE_RESERVED_SIZE = 20u
|
||||
override val PROGRAM_LOAD_ADDRESS = 0x0801u
|
||||
override val PROGRAM_MEMTOP_ADDRESS = 0x9f00u
|
||||
|
||||
|
@ -11,6 +11,7 @@ class Neo6502MachineDefinition: IMachineDefinition {
|
||||
override val FLOAT_MAX_POSITIVE = 9.999999999e97
|
||||
override val FLOAT_MAX_NEGATIVE = -9.999999999e97
|
||||
override val FLOAT_MEM_SIZE = 6
|
||||
override val STARTUP_CODE_RESERVED_SIZE = 20u
|
||||
override val PROGRAM_LOAD_ADDRESS = 0x0800u
|
||||
override val PROGRAM_MEMTOP_ADDRESS = 0xfc00u // kernal starts here
|
||||
|
||||
|
@ -13,6 +13,7 @@ class PETMachineDefinition: IMachineDefinition {
|
||||
override val FLOAT_MAX_POSITIVE = Mflpt5.FLOAT_MAX_POSITIVE
|
||||
override val FLOAT_MAX_NEGATIVE = Mflpt5.FLOAT_MAX_NEGATIVE
|
||||
override val FLOAT_MEM_SIZE = Mflpt5.FLOAT_MEM_SIZE
|
||||
override val STARTUP_CODE_RESERVED_SIZE = 20u
|
||||
override val PROGRAM_LOAD_ADDRESS = 0x0401u
|
||||
override val PROGRAM_MEMTOP_ADDRESS = 0x8000u
|
||||
|
||||
|
@ -13,6 +13,7 @@ class VirtualMachineDefinition: IMachineDefinition {
|
||||
override val FLOAT_MAX_POSITIVE = Float.MAX_VALUE.toDouble()
|
||||
override val FLOAT_MAX_NEGATIVE = -Float.MAX_VALUE.toDouble()
|
||||
override val FLOAT_MEM_SIZE = 8 // 64-bits double
|
||||
override val STARTUP_CODE_RESERVED_SIZE = 0u // not actually used
|
||||
override val PROGRAM_LOAD_ADDRESS = 0u // not actually used
|
||||
override val PROGRAM_MEMTOP_ADDRESS = 0xffffu // not actually used
|
||||
|
||||
|
@ -283,8 +283,9 @@ internal class AstChecker(private val program: Program,
|
||||
if (addr > 65535u)
|
||||
errors.err("block address must be valid integer 0..\$ffff", block.position)
|
||||
if(compilerOptions.loadAddress!=0u) {
|
||||
if (addr < compilerOptions.loadAddress + 20u)
|
||||
errors.err("block address must be at least program load address + 20 (to allow for startup logic)", block.position)
|
||||
val gapsize = compilerOptions.compTarget.machine.STARTUP_CODE_RESERVED_SIZE
|
||||
if (addr < compilerOptions.loadAddress + gapsize)
|
||||
errors.err("block address must be at least program load address + $gapsize (to allow for startup logic)", block.position)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,13 @@ private fun AugassignmentContext.toAst(): Assignment {
|
||||
return Assignment(assign_target().toAst(), expression, AssignmentOrigin.USERCODE, toPosition())
|
||||
}
|
||||
|
||||
private fun DatatypeContext.toAst() = DataType.valueOf(text.uppercase())
|
||||
private fun DatatypeContext.toAst(): DataType {
|
||||
try {
|
||||
return DataType.valueOf(text.uppercase())
|
||||
} catch (_: IllegalArgumentException) {
|
||||
return DataType.UNDEFINED
|
||||
}
|
||||
}
|
||||
|
||||
private fun ArrayindexContext.toAst() : ArrayIndex =
|
||||
ArrayIndex(expression().toAst(), toPosition())
|
||||
|
@ -1182,7 +1182,12 @@ data class IdentifierReference(val nameInSource: List<String>, override val posi
|
||||
|
||||
override fun inferType(program: Program): InferredTypes.InferredType {
|
||||
return when (val targetStmt = targetStatement(program)) {
|
||||
is VarDecl -> InferredTypes.knownFor(targetStmt.datatype)
|
||||
is VarDecl -> {
|
||||
if(targetStmt.datatype==DataType.UNDEFINED)
|
||||
InferredTypes.unknown()
|
||||
else
|
||||
InferredTypes.knownFor(targetStmt.datatype)
|
||||
}
|
||||
else -> InferredTypes.InferredType.unknown()
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
|
||||
- make "block address must be at least program load address + 20 (to allow for startup logic)" more flexible; the 20 should be a constant in the compilation target
|
||||
|
||||
...
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
%option no_sysinit
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
main $0810 {
|
||||
sub start() {
|
||||
ubyte sprite
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user