code style

This commit is contained in:
Irmen de Jong 2021-05-13 01:00:19 +02:00
parent 25d80f4df1
commit 83639c2535
6 changed files with 14 additions and 8 deletions

View File

@ -39,7 +39,7 @@ internal object C64MachineDefinition: IMachineDefinition {
for(emulator in listOf("x64sc", "x64")) {
println("\nStarting C-64 emulator $emulator...")
val cmdline = listOf(emulator, "-silent", "-moncommands", "$programName.vice-mon-list",
"-autostartprgmode", "1", "-autostart-warp", "-autostart", programName + ".prg")
"-autostartprgmode", "1", "-autostart-warp", "-autostart", "$programName.prg")
val processb = ProcessBuilder(cmdline).inheritIO()
val process: Process
try {

View File

@ -27,7 +27,11 @@ internal class StatementOptimizer(private val program: Program,
override fun after(subroutine: Subroutine, parent: Node): Iterable<IAstModification> {
for(returnvar in subsThatNeedReturnVariable) {
val decl = VarDecl(VarDeclType.VAR, returnvar.second, ZeropageWish.DONTCARE, null, retvarName, null, false, true, returnvar.third)
val decl = VarDecl(VarDeclType.VAR, returnvar.second, ZeropageWish.DONTCARE, null, retvarName, null,
isArray = false,
autogeneratedDontRemove = true,
position = returnvar.third
)
returnvar.first.statements.add(0, decl)
}
subsThatNeedReturnVariable.clear()

View File

@ -293,8 +293,7 @@ class Program(val name: String,
)
internedStringsBlock.statements.add(decl)
decl.linkParents(internedStringsBlock)
val scopedName = listOf(internedStringsModuleName, decl.name)
return scopedName
return listOf(internedStringsModuleName, decl.name)
}
val key = Pair(string.value, string.altEncoding)

View File

@ -537,7 +537,7 @@ class InlineAssembly(val assembly: String, override val position: Position) : St
class AnonymousScope(override var statements: MutableList<Statement>,
override val position: Position) : INameScope, Statement() {
override val name: String
override val name: String = "<anon-$sequenceNumber>"
override lateinit var parent: Node
companion object {
@ -545,7 +545,7 @@ class AnonymousScope(override var statements: MutableList<Statement>,
}
init {
name = "<anon-$sequenceNumber>" // make sure it's an invalid soruce code identifier so user source code can never produce it
// make sure it's an invalid soruce code identifier so user source code can never produce it
sequenceNumber++
}

View File

@ -175,7 +175,7 @@ abstract class AstWalker {
fun applyModifications(): Int {
// check if there are double removes, keep only the last one
val removals = modifications.filter { it.first is IAstModification.Remove }
if(removals.size>0) {
if(removals.isNotEmpty()) {
val doubles = removals.groupBy { (it.first as IAstModification.Remove).node }.filter { it.value.size>1 }
doubles.forEach {
for(doubleRemove in it.value.dropLast(1)) {

View File

@ -25,7 +25,10 @@ fun moduleName(fileName: Path) = fileName.toString().substringBeforeLast('.')
internal fun pathFrom(stringPath: String, vararg rest: String): Path = FileSystems.getDefault().getPath(stringPath, *rest)
class ModuleImporter(val program: Program, val encoder: IStringEncoding, val compilationTargetName: String, val libdirs: List<String>) {
class ModuleImporter(private val program: Program,
private val encoder: IStringEncoding,
private val compilationTargetName: String,
private val libdirs: List<String>) {
fun importModule(filePath: Path): Module {
print("importing '${moduleName(filePath.fileName)}'")