From 8af2380a47f42def15b0c14e2b2048c7df514b13 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 1 Nov 2020 18:00:20 +0100 Subject: [PATCH] pair --- compiler/src/prog8/compiler/BeforeAsmGenerationAstChanger.kt | 4 ++-- compiler/src/prog8/compiler/Zeropage.kt | 2 +- compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt | 4 ++-- compiler/src/prog8/parser/ModuleParsing.kt | 2 +- docs/source/todo.rst | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/src/prog8/compiler/BeforeAsmGenerationAstChanger.kt b/compiler/src/prog8/compiler/BeforeAsmGenerationAstChanger.kt index 8a76f8245..49604c8ba 100644 --- a/compiler/src/prog8/compiler/BeforeAsmGenerationAstChanger.kt +++ b/compiler/src/prog8/compiler/BeforeAsmGenerationAstChanger.kt @@ -15,7 +15,7 @@ internal class BeforeAsmGenerationAstChanger(val program: Program, val errors: E private val noModifications = emptyList() override fun after(decl: VarDecl, parent: Node): Iterable { - subroutineVariables.add(Pair(decl.name, decl)) + subroutineVariables.add(decl.name to decl) if (decl.value == null && !decl.autogeneratedDontRemove && decl.type == VarDeclType.VAR && decl.datatype in NumericDatatypes) { // a numeric vardecl without an initial value is initialized with zero, // unless there's already an assignment below, that initializes the value @@ -74,7 +74,7 @@ internal class BeforeAsmGenerationAstChanger(val program: Program, val errors: E override fun after(scope: AnonymousScope, parent: Node): Iterable { val decls = scope.statements.filterIsInstance() - subroutineVariables.addAll(decls.map { Pair(it.name, it) }) + subroutineVariables.addAll(decls.map { it.name to it }) val sub = scope.definingSubroutine() if (sub != null) { diff --git a/compiler/src/prog8/compiler/Zeropage.kt b/compiler/src/prog8/compiler/Zeropage.kt index dbfb9b3c6..cbc8b278b 100644 --- a/compiler/src/prog8/compiler/Zeropage.kt +++ b/compiler/src/prog8/compiler/Zeropage.kt @@ -64,7 +64,7 @@ abstract class Zeropage(protected val options: CompilationOptions) { private fun makeAllocation(address: Int, size: Int, datatype: DataType, name: String?): Int { free.removeAll(address until address+size) - allocations[address] = Pair(name ?: "", datatype) + allocations[address] = (name ?: "") to datatype return address } diff --git a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt index 941ce9bb8..9d162d751 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt @@ -258,7 +258,7 @@ internal class AsmGen(private val program: Program, errors.handle() out("${variable.name} = $address\t; auto zp ${variable.datatype}") // make sure we add the var to the set of zpvars for this block - allocatedZeropageVariables[fullName] = Pair(address, variable.datatype) + allocatedZeropageVariables[fullName] = address to variable.datatype } catch (x: ZeropageDepletedError) { // leave it as it is. } @@ -1023,7 +1023,7 @@ $counterVar .byte 0""") translate(choice.statements) out(" jmp $endLabel") } else { - choiceBlocks.add(Pair(choiceLabel, choice.statements)) + choiceBlocks.add(choiceLabel to choice.statements) for (cv in choice.values!!) { val value = (cv as NumericLiteralValue).number.toInt() if(conditionDt.typeOrElse(DataType.BYTE) in ByteDatatypes) { diff --git a/compiler/src/prog8/parser/ModuleParsing.kt b/compiler/src/prog8/parser/ModuleParsing.kt index 5f4ea026c..dbf845fc0 100644 --- a/compiler/src/prog8/parser/ModuleParsing.kt +++ b/compiler/src/prog8/parser/ModuleParsing.kt @@ -92,7 +92,7 @@ internal class ModuleImporter { // accept additional imports val lines = moduleAst.statements.toMutableList() lines.asSequence() - .mapIndexed { i, it -> Pair(i, it) } + .mapIndexed { i, it -> i to it } .filter { (it.second as? Directive)?.directive == "%import" } .forEach { executeImportDirective(program, it.second as Directive, modulePath) } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 1e1671ed8..323b7265c 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,7 +2,7 @@ TODO ==== -- calling convention for builtin functions no longer via stack but via statically allocated vars inside the subroutine proc (just as normal subroutines) +- calling convention for builtin functions no longer via stack but via registers or statically allocated vars inside the subroutine proc (like normal subroutines) - make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_' - option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging) - see if we can group some errors together for instance the (now single) errors about unidentified symbols