diff --git a/DeprecatedStackVm/src/compiler/Compiler.kt b/DeprecatedStackVm/src/compiler/Compiler.kt index 24a29ca2d..b083e0441 100644 --- a/DeprecatedStackVm/src/compiler/Compiler.kt +++ b/DeprecatedStackVm/src/compiler/Compiler.kt @@ -16,7 +16,6 @@ import prog8.vm.RuntimeValue import prog8.vm.stackvm.Syscall import java.io.File import java.nio.file.Path -import java.util.* import kotlin.math.abs diff --git a/DeprecatedStackVm/src/compiler/target/c64/codegen/AsmGen.kt b/DeprecatedStackVm/src/compiler/target/c64/codegen/AsmGen.kt index 96b472263..8dd370824 100644 --- a/DeprecatedStackVm/src/compiler/target/c64/codegen/AsmGen.kt +++ b/DeprecatedStackVm/src/compiler/target/c64/codegen/AsmGen.kt @@ -17,7 +17,6 @@ import prog8.compiler.target.c64.MachineDefinition import prog8.compiler.target.c64.Petscii import prog8.vm.RuntimeValue import java.io.File -import java.util.* import kotlin.math.abs diff --git a/DeprecatedStackVm/src/prog8/vm/stackvm/Program.kt b/DeprecatedStackVm/src/prog8/vm/stackvm/Program.kt index 847a04a53..3ef83e18b 100644 --- a/DeprecatedStackVm/src/prog8/vm/stackvm/Program.kt +++ b/DeprecatedStackVm/src/prog8/vm/stackvm/Program.kt @@ -12,9 +12,9 @@ import prog8.compiler.intermediate.Opcode import prog8.compiler.intermediate.opcodesWithVarArgument import prog8.vm.RuntimeValue import java.io.File -import java.util.* import java.util.regex.Pattern + class Program (val name: String, val program: MutableList, val variables: Map, diff --git a/DeprecatedStackVm/src/prog8/vm/stackvm/StackVm.kt b/DeprecatedStackVm/src/prog8/vm/stackvm/StackVm.kt index e01a5c23a..c58fe1cac 100644 --- a/DeprecatedStackVm/src/prog8/vm/stackvm/StackVm.kt +++ b/DeprecatedStackVm/src/prog8/vm/stackvm/StackVm.kt @@ -12,7 +12,6 @@ import prog8.vm.astvm.BitmapScreenPanel import prog8.vm.astvm.Memory import java.io.File import java.io.PrintStream -import java.util.* import kotlin.math.* diff --git a/compiler/src/prog8/CompilerMain.kt b/compiler/src/prog8/CompilerMain.kt index e5f909ce6..46d3a1ac5 100644 --- a/compiler/src/prog8/CompilerMain.kt +++ b/compiler/src/prog8/CompilerMain.kt @@ -9,7 +9,7 @@ import prog8.vm.astvm.AstVm import java.nio.file.FileSystems import java.nio.file.Path import java.nio.file.StandardWatchEventKinds -import java.util.* +import java.time.LocalDateTime import kotlin.system.exitProcess @@ -67,7 +67,7 @@ private fun compileMain(args: Array) { println(importedFile) importedFile.parent.register(watchservice, StandardWatchEventKinds.ENTRY_MODIFY) } - println("${Date()}: Waiting for file changes.") + println("[${LocalDateTime.now().withNano(0)}] Waiting for file changes.") val event = watchservice.take() for(changed in event.pollEvents()) { val changedPath = changed.context() as Path diff --git a/compiler/src/prog8/ast/expressions/AstExpressions.kt b/compiler/src/prog8/ast/expressions/AstExpressions.kt index 12ded1f53..75b0c9a60 100644 --- a/compiler/src/prog8/ast/expressions/AstExpressions.kt +++ b/compiler/src/prog8/ast/expressions/AstExpressions.kt @@ -13,7 +13,7 @@ import prog8.compiler.target.c64.Petscii import prog8.functions.BuiltinFunctions import prog8.functions.NotConstArgumentException import prog8.functions.builtinFunctionReturnType -import java.util.* +import java.util.Objects import kotlin.math.abs diff --git a/compiler/src/prog8/ast/expressions/InferredTypes.kt b/compiler/src/prog8/ast/expressions/InferredTypes.kt index a18c578a5..d6b3bb312 100644 --- a/compiler/src/prog8/ast/expressions/InferredTypes.kt +++ b/compiler/src/prog8/ast/expressions/InferredTypes.kt @@ -1,7 +1,8 @@ package prog8.ast.expressions +import java.util.Objects import prog8.ast.base.DataType -import java.util.* + object InferredTypes { class InferredType private constructor(val isUnknown: Boolean, val isVoid: Boolean, private var datatype: DataType?) { diff --git a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt index 76ea1f304..4775b57c7 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt @@ -16,7 +16,9 @@ import prog8.functions.BuiltinFunctions import prog8.functions.FunctionSignature import java.math.RoundingMode import java.nio.file.Path -import java.util.* +import java.time.LocalDate +import java.time.LocalDateTime +import java.util.ArrayDeque import kotlin.math.absoluteValue @@ -38,8 +40,8 @@ internal class AsmGen(val program: Program, private val functioncallAsmGen = FunctionCallAsmGen(program, this) private val assignmentAsmGen = AssignmentAsmGen(program, this) private val expressionsAsmGen = ExpressionsAsmGen(program, this) - internal val loopEndLabels = Stack() - internal val loopContinueLabels = Stack() + internal val loopEndLabels = ArrayDeque() + internal val loopContinueLabels = ArrayDeque() internal fun compileToAssembly(optimize: Boolean): AssemblyProgram { assemblyLines.clear() @@ -74,7 +76,7 @@ internal class AsmGen(val program: Program, private fun header() { val ourName = this.javaClass.name out("; 6502 assembly code for '${program.name}'") - out("; generated by $ourName on ${Date()}") + out("; generated by $ourName on ${LocalDateTime.now().withNano(0)}") out("; assembler syntax is for the 64tasm cross-assembler") out("; output options: output=${options.output} launcher=${options.launcher} zp=${options.zeropage}") out("\n.cpu '6502'\n.enc 'none'\n") @@ -90,7 +92,7 @@ internal class AsmGen(val program: Program, throw AssemblyError("BASIC output must have load address $0801") out("; ---- basic program with sys call ----") out("* = ${program.actualLoadAddress.toHex()}") - val year = Calendar.getInstance().get(Calendar.YEAR) + val year = LocalDate.now().year out(" .word (+), $year") out(" .null $9e, format(' %d ', _prog8_entrypoint), $3a, $8f, ' prog8 by idj'") out("+\t.word 0") diff --git a/compiler/src/prog8/vm/RuntimeValue.kt b/compiler/src/prog8/vm/RuntimeValue.kt index 73a5cef22..d6b64c96d 100644 --- a/compiler/src/prog8/vm/RuntimeValue.kt +++ b/compiler/src/prog8/vm/RuntimeValue.kt @@ -8,7 +8,7 @@ import prog8.ast.expressions.NumericLiteralValue import prog8.ast.expressions.StringLiteralValue import prog8.compiler.target.c64.Petscii import prog8.vm.astvm.VmExecutionException -import java.util.* +import java.util.Objects import kotlin.math.abs import kotlin.math.pow diff --git a/compiler/src/prog8/vm/astvm/AstVm.kt b/compiler/src/prog8/vm/astvm/AstVm.kt index 20586baf2..abcb5e37f 100644 --- a/compiler/src/prog8/vm/astvm/AstVm.kt +++ b/compiler/src/prog8/vm/astvm/AstVm.kt @@ -12,7 +12,7 @@ import prog8.compiler.target.c64.Petscii import prog8.vm.* import java.awt.EventQueue import java.io.CharConversionException -import java.util.* +import java.util.ArrayDeque import kotlin.NoSuchElementException import kotlin.concurrent.fixedRateTimer import kotlin.math.* @@ -140,10 +140,10 @@ class AstVm(val program: Program) { var rtcOffset = bootTime private val rnd = Random(0) - private val statusFlagsSave = Stack() - private val registerXsave = Stack() - private val registerYsave = Stack() - private val registerAsave = Stack() + private val statusFlagsSave = ArrayDeque() + private val registerXsave = ArrayDeque() + private val registerYsave = ArrayDeque() + private val registerAsave = ArrayDeque() init { diff --git a/compiler/src/prog8/vm/astvm/ScreenDialog.kt b/compiler/src/prog8/vm/astvm/ScreenDialog.kt index 79546b10d..f3aae4553 100644 --- a/compiler/src/prog8/vm/astvm/ScreenDialog.kt +++ b/compiler/src/prog8/vm/astvm/ScreenDialog.kt @@ -6,7 +6,7 @@ import java.awt.* import java.awt.event.KeyEvent import java.awt.event.KeyListener import java.awt.image.BufferedImage -import java.util.* +import java.util.ArrayDeque import javax.swing.JFrame import javax.swing.JPanel import javax.swing.Timer @@ -18,7 +18,7 @@ class BitmapScreenPanel : KeyListener, JPanel() { private val g2d = image.graphics as Graphics2D private var cursorX: Int=0 private var cursorY: Int=0 - val keyboardBuffer: Deque = LinkedList() + val keyboardBuffer = ArrayDeque() init { val size = Dimension(image.width * SCALING, image.height * SCALING) diff --git a/sim65/src/components/RealTimeClock.kt b/sim65/src/components/RealTimeClock.kt index 7b4178464..95d65c6c2 100644 --- a/sim65/src/components/RealTimeClock.kt +++ b/sim65/src/components/RealTimeClock.kt @@ -1,6 +1,8 @@ package sim65.components -import java.util.* +import java.time.LocalDate +import java.time.LocalTime + /** * A real-time clock (time of day clock). @@ -17,8 +19,6 @@ import java.util.* */ class RealTimeClock(startAddress: Address, endAddress: Address) : MemMappedComponent(startAddress, endAddress) { - val calendar = Calendar.getInstance() - init { require(endAddress - startAddress + 1 == 9) { "rtc needs exactly 9 memory bytes" } } @@ -32,44 +32,29 @@ class RealTimeClock(startAddress: Address, endAddress: Address) : MemMappedCompo } override operator fun get(address: Address): UByte { - when (address - startAddress) { + return when (address - startAddress) { 0 -> { - val year = calendar.get(Calendar.YEAR) - return (year and 255).toShort() + val year = LocalDate.now().year + (year and 255).toShort() } 1 -> { - val year = calendar.get(Calendar.YEAR) - return (year ushr 8).toShort() - } - 2 -> { - val month = calendar.get(Calendar.MONTH) + 1 - return month.toShort() - } - 3 -> { - val day = calendar.get(Calendar.DAY_OF_MONTH) - return day.toShort() - } - 4 -> { - val hour = calendar.get(Calendar.HOUR_OF_DAY) - return hour.toShort() - } - 5 -> { - val minute = calendar.get(Calendar.MINUTE) - return minute.toShort() - } - 6 -> { - val second = calendar.get(Calendar.SECOND) - return second.toShort() + val year = LocalDate.now().year + (year ushr 8).toShort() } + 2 -> LocalDate.now().monthValue.toShort() + 3 -> LocalDate.now().dayOfMonth.toShort() + 4 -> LocalTime.now().hour.toShort() + 5 -> LocalTime.now().minute.toShort() + 6 -> LocalTime.now().second.toShort() 7 -> { - val ms = calendar.get(Calendar.MILLISECOND) - return (ms and 255).toShort() + val ms = LocalTime.now().nano / 1000 + (ms and 255).toShort() } 8 -> { - val ms = calendar.get(Calendar.MILLISECOND) - return (ms ushr 8).toShort() + val ms = LocalTime.now().nano / 1000 + (ms ushr 8).toShort() } - else -> return 0 + else -> 0 } }