From ae45ce517ef86844854cbe5ad9794527490881ae Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 3 Apr 2022 17:33:50 +0200 Subject: [PATCH] cleanups --- .../src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt | 2 +- .../src/prog8/codegen/experimental/AstToXmlConverter.kt | 2 +- codeOptimizers/src/prog8/optimizer/StatementOptimizer.kt | 1 - compiler/src/prog8/compiler/Compiler.kt | 2 +- .../src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt | 1 - compiler/src/prog8/compiler/astprocessing/SymbolTableMaker.kt | 1 - compilerAst/src/prog8/ast/expressions/AstExpressions.kt | 3 +-- docs/source/syntaxreference.rst | 1 + docs/source/targetsystem.rst | 1 + virtualmachine/src/prog8/vm/GraphicsWindow.kt | 2 +- 10 files changed, 7 insertions(+), 9 deletions(-) diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt index f820b1b8a..641056fa7 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt @@ -56,7 +56,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, ident } } - val argExpressions = mutableListOf(argExpression); + val argExpressions = mutableListOf(argExpression) val fcall = BuiltinFunctionCall(IdentifierReference(listOf(name), Position.DUMMY), argExpressions, Position.DUMMY) fcall.linkParents(scope) translateFunctioncall(fcall, func, discardResult = false, resultToStack = false, null) diff --git a/codeGenExperimental/src/prog8/codegen/experimental/AstToXmlConverter.kt b/codeGenExperimental/src/prog8/codegen/experimental/AstToXmlConverter.kt index 2c75663f6..0514ca363 100644 --- a/codeGenExperimental/src/prog8/codegen/experimental/AstToXmlConverter.kt +++ b/codeGenExperimental/src/prog8/codegen/experimental/AstToXmlConverter.kt @@ -612,7 +612,7 @@ class AstToXmlConverter(internal val program: PtProgram, } if(asmSub.clobbers.isNotEmpty()) { xml.elt("clobbers") - xml.attr("registers", asmSub.clobbers.map {it.name}.joinToString(",")) + xml.attr("registers", asmSub.clobbers.joinToString(",") { it.name }) xml.endElt() } if(asmSub.retvalRegisters.isNotEmpty()) { diff --git a/codeOptimizers/src/prog8/optimizer/StatementOptimizer.kt b/codeOptimizers/src/prog8/optimizer/StatementOptimizer.kt index b00952757..e61ee6815 100644 --- a/codeOptimizers/src/prog8/optimizer/StatementOptimizer.kt +++ b/codeOptimizers/src/prog8/optimizer/StatementOptimizer.kt @@ -7,7 +7,6 @@ import prog8.ast.walk.AstWalker import prog8.ast.walk.IAstModification import prog8.code.core.* import prog8.code.target.VMTarget -import prog8.code.target.virtual.VirtualMachineDefinition import kotlin.math.floor diff --git a/compiler/src/prog8/compiler/Compiler.kt b/compiler/src/prog8/compiler/Compiler.kt index ae03fc38d..53fb90418 100644 --- a/compiler/src/prog8/compiler/Compiler.kt +++ b/compiler/src/prog8/compiler/Compiler.kt @@ -265,7 +265,7 @@ fun determineCompilationOptions(program: Program, compTarget: ICompilationTarget .flatMap { (it as Directive).args }.toSet() val floatsEnabled = allOptions.any { it.name == "enable_floats" } val noSysInit = allOptions.any { it.name == "no_sysinit" } - var zpType: ZeropageType = + val zpType: ZeropageType = if (zpoption == null) if (floatsEnabled) ZeropageType.FLOATSAFE else ZeropageType.KERNALSAFE else diff --git a/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt b/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt index 35494a45b..8e1f03d36 100644 --- a/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt +++ b/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt @@ -7,7 +7,6 @@ import prog8.ast.statements.* import prog8.ast.walk.AstWalker import prog8.ast.walk.IAstModification import prog8.ast.walk.IAstVisitor -import prog8.code.ast.PtIdentifier import prog8.code.core.* import prog8.code.target.VMTarget diff --git a/compiler/src/prog8/compiler/astprocessing/SymbolTableMaker.kt b/compiler/src/prog8/compiler/astprocessing/SymbolTableMaker.kt index 8b8b75b58..651eb4e6d 100644 --- a/compiler/src/prog8/compiler/astprocessing/SymbolTableMaker.kt +++ b/compiler/src/prog8/compiler/astprocessing/SymbolTableMaker.kt @@ -7,7 +7,6 @@ import prog8.ast.statements.* import prog8.ast.walk.IAstVisitor import prog8.code.* import prog8.code.core.ArrayDatatypes -import prog8.code.core.ElementToArrayTypes import prog8.code.core.Position import java.util.* diff --git a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt index 8a7263ff0..f09191b6e 100644 --- a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt +++ b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt @@ -987,8 +987,7 @@ class FunctionCallExpression(override var target: IdentifierReference, // multiple return values. Can occur for asmsub routines. If there is exactly one register return value, take that. val registerReturns = stmt.asmReturnvaluesRegisters.filter {it.registerOrPair != null } if(registerReturns.size==1) { - val reg = registerReturns.single().registerOrPair!! - return when(reg) { + return when(registerReturns.single().registerOrPair!!) { RegisterOrPair.A, RegisterOrPair.X, RegisterOrPair.Y -> InferredTypes.InferredType.known(DataType.UBYTE) diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index de67d2188..264e98e8a 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -855,3 +855,4 @@ case you have to use { } to enclose them:: } else -> txt.print("don't know") } + diff --git a/docs/source/targetsystem.rst b/docs/source/targetsystem.rst index 3bf10abbe..c38758357 100644 --- a/docs/source/targetsystem.rst +++ b/docs/source/targetsystem.rst @@ -155,3 +155,4 @@ And for the Commander X16:: cx16.set_irq(uword handler_address, boolean useKernal) ; vsync irq cx16.set_rasterirq(uword handler_address, uword rasterline) ; note: disables kernal irq handler! sys.wait() won't work anymore cx16.restore_irq() ; set everything back to the systems default irq handler + diff --git a/virtualmachine/src/prog8/vm/GraphicsWindow.kt b/virtualmachine/src/prog8/vm/GraphicsWindow.kt index 17d10ee7a..d81830170 100644 --- a/virtualmachine/src/prog8/vm/GraphicsWindow.kt +++ b/virtualmachine/src/prog8/vm/GraphicsWindow.kt @@ -34,7 +34,7 @@ class GraphicsWindow(val pixelWidth: Int, val pixelHeight: Int, val pixelScaling contentPane.background = Color.BLACK isResizable = false isLocationByPlatform = true - defaultCloseOperation = JFrame.EXIT_ON_CLOSE + defaultCloseOperation = EXIT_ON_CLOSE image = graphicsConfiguration.createCompatibleImage(pixelWidth, pixelHeight, Transparency.OPAQUE) contentPane.add(BitmapScreenPanel(image, pixelScaling), BorderLayout.CENTER) pack()