mirror of
https://github.com/irmen/prog8.git
synced 2025-02-27 03:29:22 +00:00
code style
This commit is contained in:
parent
25d80f4df1
commit
83639c2535
@ -39,7 +39,7 @@ internal object C64MachineDefinition: IMachineDefinition {
|
|||||||
for(emulator in listOf("x64sc", "x64")) {
|
for(emulator in listOf("x64sc", "x64")) {
|
||||||
println("\nStarting C-64 emulator $emulator...")
|
println("\nStarting C-64 emulator $emulator...")
|
||||||
val cmdline = listOf(emulator, "-silent", "-moncommands", "$programName.vice-mon-list",
|
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 processb = ProcessBuilder(cmdline).inheritIO()
|
||||||
val process: Process
|
val process: Process
|
||||||
try {
|
try {
|
||||||
|
@ -27,7 +27,11 @@ internal class StatementOptimizer(private val program: Program,
|
|||||||
|
|
||||||
override fun after(subroutine: Subroutine, parent: Node): Iterable<IAstModification> {
|
override fun after(subroutine: Subroutine, parent: Node): Iterable<IAstModification> {
|
||||||
for(returnvar in subsThatNeedReturnVariable) {
|
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)
|
returnvar.first.statements.add(0, decl)
|
||||||
}
|
}
|
||||||
subsThatNeedReturnVariable.clear()
|
subsThatNeedReturnVariable.clear()
|
||||||
|
@ -293,8 +293,7 @@ class Program(val name: String,
|
|||||||
)
|
)
|
||||||
internedStringsBlock.statements.add(decl)
|
internedStringsBlock.statements.add(decl)
|
||||||
decl.linkParents(internedStringsBlock)
|
decl.linkParents(internedStringsBlock)
|
||||||
val scopedName = listOf(internedStringsModuleName, decl.name)
|
return listOf(internedStringsModuleName, decl.name)
|
||||||
return scopedName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val key = Pair(string.value, string.altEncoding)
|
val key = Pair(string.value, string.altEncoding)
|
||||||
|
@ -537,7 +537,7 @@ class InlineAssembly(val assembly: String, override val position: Position) : St
|
|||||||
|
|
||||||
class AnonymousScope(override var statements: MutableList<Statement>,
|
class AnonymousScope(override var statements: MutableList<Statement>,
|
||||||
override val position: Position) : INameScope, Statement() {
|
override val position: Position) : INameScope, Statement() {
|
||||||
override val name: String
|
override val name: String = "<anon-$sequenceNumber>"
|
||||||
override lateinit var parent: Node
|
override lateinit var parent: Node
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -545,7 +545,7 @@ class AnonymousScope(override var statements: MutableList<Statement>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
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++
|
sequenceNumber++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ abstract class AstWalker {
|
|||||||
fun applyModifications(): Int {
|
fun applyModifications(): Int {
|
||||||
// check if there are double removes, keep only the last one
|
// check if there are double removes, keep only the last one
|
||||||
val removals = modifications.filter { it.first is IAstModification.Remove }
|
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 }
|
val doubles = removals.groupBy { (it.first as IAstModification.Remove).node }.filter { it.value.size>1 }
|
||||||
doubles.forEach {
|
doubles.forEach {
|
||||||
for(doubleRemove in it.value.dropLast(1)) {
|
for(doubleRemove in it.value.dropLast(1)) {
|
||||||
|
@ -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)
|
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 {
|
fun importModule(filePath: Path): Module {
|
||||||
print("importing '${moduleName(filePath.fileName)}'")
|
print("importing '${moduleName(filePath.fileName)}'")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user