annotated some high prio todos

This commit is contained in:
Irmen de Jong 2020-10-17 22:57:54 +02:00
parent fdd91170dc
commit 8f2e166a22
3 changed files with 11 additions and 27 deletions

View File

@ -50,7 +50,7 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
DataType.FLOAT -> assignVariableFloat(assign.target, variable)
DataType.STR -> assignVariableString(assign.target, variable)
in PassByReferenceDatatypes -> {
// TODO what about when the name is a struct? name.firstStructVarName(program.namespace)
// TODO what about when the name is a struct? name.firstStructVarName(program.namespace) ****************************************
assignAddressOf(assign.target, variable)
}
else -> throw AssemblyError("unsupported assignment target type ${assign.target.datatype}")
@ -533,16 +533,14 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
""")
}
TargetStorageKind.ARRAY -> {
// TODO optimize this, but the situation doesn't occur very often
// TODO optimize this (array indexer is just a simple number or variable), but the situation doesn't occur very often ****************************************
// if(target.constArrayIndexValue!=null) {
// TODO("const index ${target.constArrayIndexValue}")
// } else if(target.array!!.arrayspec.index is IdentifierReference) {
// TODO("array[var] ${target.constArrayIndexValue}")
// }
asmgen.out(" lda #<$sourceName | ldy #>$sourceName | jsr floats.push_float")
target.array!!
target.array.indexer.indexNum?.let { asmgen.translateExpression(it) }
target.array.indexer.indexVar?.let { asmgen.translateExpression(it) }
asmgen.translateExpression(target.array!!)
asmgen.out(" lda #<${target.asmVarname} | ldy #>${target.asmVarname} | jsr floats.pop_float_to_indexed_var")
}
TargetStorageKind.MEMORY -> throw AssemblyError("can't assign float to mem byte")
@ -830,15 +828,13 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
throw AssemblyError("no asm gen for assign word $word to memory ${target.memory}")
}
TargetStorageKind.ARRAY -> {
// TODO optimize this, but the situation doesn't occur very often
// TODO optimize this (array indexer is just a simple number or variable), but the situation doesn't occur very often ****************************************
// if(target.constArrayIndexValue!=null) {
// TODO("const index ${target.constArrayIndexValue}")
// } else if(target.array!!.arrayspec.index is IdentifierReference) {
// TODO("array[var] ${target.constArrayIndexValue}")
// }
target.array!!
target.array.indexer.indexNum?.let { asmgen.translateExpression(it) }
target.array.indexer.indexVar?.let { asmgen.translateExpression(it) }
asmgen.translateExpression(target.array!!)
asmgen.out("""
inx
lda P8ESTACK_LO,x
@ -928,12 +924,6 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
""")
}
TargetStorageKind.ARRAY -> {
// TODO optimize this, but the situation doesn't occur very often
// if(target.constArrayIndexValue!=null) {
// TODO("const index ${target.constArrayIndexValue}")
// } else if(target.array!!.arrayspec.index is IdentifierReference) {
// TODO("array[var] ${target.constArrayIndexValue}")
// }
if (target.array!!.indexer.indexNum!=null) {
val indexValue = target.array.indexer.constIndex()!! * DataType.FLOAT.memorySize()
asmgen.out("""
@ -945,6 +935,7 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
sta ${target.asmVarname}+$indexValue+4
""")
} else {
// TODO optimize this (don't use stack eval) as the indexer is only a simple variable ****************************************
asmgen.translateExpression(target.array.indexer.indexVar!!)
asmgen.out("""
lda #<${target.asmVarname}
@ -981,12 +972,6 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
""")
}
TargetStorageKind.ARRAY -> {
// TODO optimize this, but the situation doesn't occur very often
// if(target.constArrayIndexValue!=null) {
// TODO("const index ${target.constArrayIndexValue}")
// } else if(target.array!!.arrayspec.index is IdentifierReference) {
// TODO("array[var] ${target.constArrayIndexValue}")
// }
val arrayVarName = target.asmVarname
if (target.array!!.indexer.indexNum!=null) {
val indexValue = target.array.indexer.constIndex()!! * DataType.FLOAT.memorySize()
@ -1003,6 +988,7 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
sta $arrayVarName+$indexValue+4
""")
} else {
// TODO optimize this (don't use stack eval) as the indexer is only a simple variable ****************************************
asmgen.translateExpression(target.array.indexer.indexVar!!)
asmgen.out("""
lda #<${constFloat}

View File

@ -647,7 +647,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
private fun inplaceModification_word_litval_to_variable(name: String, dt: DataType, operator: String, value: Int) {
when (operator) {
// note: ** (power) operator requires floats.
// TODO use these + and - optimizations in the expressionAsmGenerator as well.
// TODO use these + and - optimizations in the expressionAsmGenerator as well. ****************************************
"+" -> {
when {
value==0 -> {}
@ -720,7 +720,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
if(value.absoluteValue in asmgen.optimizedWordMultiplications) {
asmgen.out(" lda $name | ldy $name+1 | jsr math.mul_word_$value | sta $name | sty $name+1")
} else {
// TODO does this work for signed words? if so the uword/word distinction can be removed altogether
// TODO does this work for signed words? if so the uword/word distinction can be removed altogether ****************************************
asmgen.out("""
lda $name
sta P8ZP_SCRATCH_W1
@ -1168,7 +1168,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
remainderWord()
}
"<<" -> {
asmgen.translateExpression(value) // TODO huh is this okay? wasn't this done above already?
asmgen.translateExpression(value) // TODO huh is this okay? wasn't this done above already? ****************************************
asmgen.out("""
inx
ldy P8ESTACK_LO,x
@ -1180,7 +1180,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
+""")
}
">>" -> {
asmgen.translateExpression(value) // TODO huh is this okay? wasn't this done above already?
asmgen.translateExpression(value) // TODO huh is this okay? wasn't this done above already? *******************************************
if(dt==DataType.UWORD) {
asmgen.out("""
inx

View File

@ -24,8 +24,6 @@ main {
ib = array[3*ib]
ib = array[ib*4]
ib = array[4*ib]
; ib = array[lsb(ib)]
; ib = array[msb(ib)]
testX()
}