mirror of
https://github.com/irmen/prog8.git
synced 2024-08-22 03:29:07 +00:00
pair
This commit is contained in:
parent
431f2a2088
commit
8af2380a47
@ -15,7 +15,7 @@ internal class BeforeAsmGenerationAstChanger(val program: Program, val errors: E
|
|||||||
private val noModifications = emptyList<IAstModification>()
|
private val noModifications = emptyList<IAstModification>()
|
||||||
|
|
||||||
override fun after(decl: VarDecl, parent: Node): Iterable<IAstModification> {
|
override fun after(decl: VarDecl, parent: Node): Iterable<IAstModification> {
|
||||||
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) {
|
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,
|
// a numeric vardecl without an initial value is initialized with zero,
|
||||||
// unless there's already an assignment below, that initializes the value
|
// 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<IAstModification> {
|
override fun after(scope: AnonymousScope, parent: Node): Iterable<IAstModification> {
|
||||||
val decls = scope.statements.filterIsInstance<VarDecl>()
|
val decls = scope.statements.filterIsInstance<VarDecl>()
|
||||||
subroutineVariables.addAll(decls.map { Pair(it.name, it) })
|
subroutineVariables.addAll(decls.map { it.name to it })
|
||||||
|
|
||||||
val sub = scope.definingSubroutine()
|
val sub = scope.definingSubroutine()
|
||||||
if (sub != null) {
|
if (sub != null) {
|
||||||
|
@ -64,7 +64,7 @@ abstract class Zeropage(protected val options: CompilationOptions) {
|
|||||||
|
|
||||||
private fun makeAllocation(address: Int, size: Int, datatype: DataType, name: String?): Int {
|
private fun makeAllocation(address: Int, size: Int, datatype: DataType, name: String?): Int {
|
||||||
free.removeAll(address until address+size)
|
free.removeAll(address until address+size)
|
||||||
allocations[address] = Pair(name ?: "<unnamed>", datatype)
|
allocations[address] = (name ?: "<unnamed>") to datatype
|
||||||
return address
|
return address
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ internal class AsmGen(private val program: Program,
|
|||||||
errors.handle()
|
errors.handle()
|
||||||
out("${variable.name} = $address\t; auto zp ${variable.datatype}")
|
out("${variable.name} = $address\t; auto zp ${variable.datatype}")
|
||||||
// make sure we add the var to the set of zpvars for this block
|
// 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) {
|
} catch (x: ZeropageDepletedError) {
|
||||||
// leave it as it is.
|
// leave it as it is.
|
||||||
}
|
}
|
||||||
@ -1023,7 +1023,7 @@ $counterVar .byte 0""")
|
|||||||
translate(choice.statements)
|
translate(choice.statements)
|
||||||
out(" jmp $endLabel")
|
out(" jmp $endLabel")
|
||||||
} else {
|
} else {
|
||||||
choiceBlocks.add(Pair(choiceLabel, choice.statements))
|
choiceBlocks.add(choiceLabel to choice.statements)
|
||||||
for (cv in choice.values!!) {
|
for (cv in choice.values!!) {
|
||||||
val value = (cv as NumericLiteralValue).number.toInt()
|
val value = (cv as NumericLiteralValue).number.toInt()
|
||||||
if(conditionDt.typeOrElse(DataType.BYTE) in ByteDatatypes) {
|
if(conditionDt.typeOrElse(DataType.BYTE) in ByteDatatypes) {
|
||||||
|
@ -92,7 +92,7 @@ internal class ModuleImporter {
|
|||||||
// accept additional imports
|
// accept additional imports
|
||||||
val lines = moduleAst.statements.toMutableList()
|
val lines = moduleAst.statements.toMutableList()
|
||||||
lines.asSequence()
|
lines.asSequence()
|
||||||
.mapIndexed { i, it -> Pair(i, it) }
|
.mapIndexed { i, it -> i to it }
|
||||||
.filter { (it.second as? Directive)?.directive == "%import" }
|
.filter { (it.second as? Directive)?.directive == "%import" }
|
||||||
.forEach { executeImportDirective(program, it.second as Directive, modulePath) }
|
.forEach { executeImportDirective(program, it.second as Directive, modulePath) }
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
TODO
|
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 '_'
|
- 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)
|
- 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
|
- see if we can group some errors together for instance the (now single) errors about unidentified symbols
|
||||||
|
Loading…
Reference in New Issue
Block a user