mirror of
https://github.com/irmen/prog8.git
synced 2026-04-19 20:16:51 +00:00
6502 codegen on new Pt-AST.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user