allow Python-style negative array indexing to count from the end

This commit is contained in:
Irmen de Jong
2023-12-23 16:37:28 +01:00
parent ad9eaeafeb
commit 4cd9bb8f99
7 changed files with 42 additions and 16 deletions
@@ -170,7 +170,7 @@ internal class ExpressionGen(private val codeGen: IRCodeGen) {
if(arrayIx.usesPointerVariable) {
if(eltSize!=1)
throw AssemblyError("non-array var indexing requires bytes dt")
if(arrayIx.index.type!=DataType.UBYTE)
if(arrayIx.index.type !in ByteDatatypes)
throw AssemblyError("non-array var indexing requires bytes index")
val tr = translateExpression(arrayIx.index)
addToResult(result, tr, tr.resultReg, -1)