6502 codegen on new Pt-AST.

This commit is contained in:
Irmen de Jong
2023-01-04 22:55:05 +01:00
parent 6ee270d9d8
commit 5e8f767642
23 changed files with 1351 additions and 1452 deletions
@@ -43,6 +43,10 @@ sealed class PtExpression(val type: DataType, position: Position) : PtNode(posit
else -> false
}
}
infix fun isSameAs(target: PtAssignTarget): Boolean {
TODO()
}
}
class PtAddressOf(position: Position) : PtExpression(DataType.UWORD, position) {
@@ -66,6 +70,8 @@ class PtArray(type: DataType, position: Position): PtExpression(type, position)
return false
return type==other.type && children == other.children
}
val size: Int = children.size
}
@@ -141,6 +147,11 @@ class PtMemoryByte(position: Position) : PtExpression(DataType.UBYTE, position)
class PtNumber(type: DataType, val number: Double, position: Position) : PtExpression(type, position) {
companion object {
fun fromBoolean(bool: Boolean, position: Position): PtNumber =
PtNumber(DataType.UBYTE, if(bool) 1.0 else 0.0, position)
}
init {
if(type==DataType.BOOL)
throw IllegalArgumentException("bool should have become ubyte @$position")
+4 -2
View File
@@ -3,6 +3,8 @@ package prog8.code.ast
import prog8.code.core.*
interface IPtSubroutine
class PtAsmSub(
name: String,
val address: UInt?,
@@ -12,7 +14,7 @@ class PtAsmSub(
val retvalRegisters: List<RegisterOrStatusflag>,
val inline: Boolean,
position: Position
) : PtNamedNode(name, position) {
) : PtNamedNode(name, position), IPtSubroutine {
override fun printProperties() {
print("$name inline=$inline")
}
@@ -25,7 +27,7 @@ class PtSub(
val returntype: DataType?,
val inline: Boolean,
position: Position
) : PtNamedNode(name, position) {
) : PtNamedNode(name, position), IPtSubroutine {
override fun printProperties() {
print(name)
}