mirror of
https://github.com/irmen/prog8.git
synced 2026-04-20 11:17:01 +00:00
added first implementation of RPN 6502 codegen - all via stackeval still
This commit is contained in:
@@ -265,7 +265,7 @@ class PtRpn(type: DataType, position: Position): PtExpression(type, position) {
|
||||
return Pair(maxDepths, numPushes)
|
||||
}
|
||||
|
||||
fun finalOperator(): String? = (children.last() as? PtRpnOperator)?.operator
|
||||
fun finalOperator() = children.last() as? PtRpnOperator
|
||||
fun finalFirstOperand() = children[children.size-3]
|
||||
fun finalSecondOperand() = children[children.size-2]
|
||||
}
|
||||
@@ -273,9 +273,6 @@ class PtRpn(type: DataType, position: Position): PtExpression(type, position) {
|
||||
class PtRpnOperator(val operator: String, val type: DataType, val operand1Type: DataType, val operand2Type: DataType, position: Position): PtNode(position) {
|
||||
init {
|
||||
// NOTE: For now, we require that the types of the operands are the same size as the output type of the operator node.
|
||||
require(operand1Type equalsSize operand2Type) {
|
||||
"operand type size(s) differ: $operand1Type $operand2Type oper: $operator"
|
||||
}
|
||||
if(operator !in ComparisonOperators) {
|
||||
require(type equalsSize operand1Type && type equalsSize operand2Type) {
|
||||
"operand type size(s) differ from operator result type $type: $operand1Type $operand2Type oper: $operator"
|
||||
@@ -342,6 +339,8 @@ class PtNumber(type: DataType, val number: Double, position: Position) : PtExpre
|
||||
}
|
||||
|
||||
operator fun compareTo(other: PtNumber): Int = number.compareTo(other.number)
|
||||
|
||||
override fun toString() = "PtNumber:$type:$number"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ class PtForLoop(position: Position) : PtNode(position) {
|
||||
|
||||
|
||||
class PtIfElse(position: Position) : PtNode(position) {
|
||||
val condition: PtNode
|
||||
get() = children[0]
|
||||
val condition: PtExpression // either PtRpn or PtBinaryExpression
|
||||
get() = children[0] as PtExpression
|
||||
val ifScope: PtNodeGroup
|
||||
get() = children[1] as PtNodeGroup
|
||||
val elseScope: PtNodeGroup
|
||||
|
||||
Reference in New Issue
Block a user