mirror of
https://github.com/irmen/prog8.git
synced 2024-09-07 19:54:26 +00:00
fix @requirezp in astToSource. Fix sometimes allocating zeropage variables in normal ram.
This commit is contained in:
parent
0e87db9eb7
commit
4bf4771f08
@ -494,7 +494,9 @@ class AsmGen(private val program: Program,
|
||||
val vars = statements.asSequence()
|
||||
.filterIsInstance<VarDecl>()
|
||||
.filter {
|
||||
it.type==VarDeclType.VAR && zeropage.allocatedZeropageVariable(it.scopedName)==null
|
||||
it.type==VarDeclType.VAR
|
||||
&& it.zeropage!=ZeropageWish.REQUIRE_ZEROPAGE
|
||||
&& zeropage.allocatedZeropageVariable(it.scopedName)==null
|
||||
}
|
||||
|
||||
vars.filter { it.datatype == DataType.STR && shouldActuallyOutputStringVar(it) }
|
||||
@ -504,6 +506,7 @@ class AsmGen(private val program: Program,
|
||||
val blockname = inBlock?.name
|
||||
|
||||
vars.filter{ it.datatype != DataType.STR }.sortedBy { it.datatype }.forEach {
|
||||
require(it.zeropage!=ZeropageWish.REQUIRE_ZEROPAGE)
|
||||
if(!isZpVar(it.scopedName)) {
|
||||
if(blockname!="prog8_lib" || !it.name.startsWith("P8ZP_SCRATCH_")) // the "hooks" to the temp vars are not generated as new variables
|
||||
vardecl2asm(it)
|
||||
|
@ -122,7 +122,9 @@ class AstToSourceTextConverter(val output: (text: String) -> Unit, val program:
|
||||
if(decl.isArray)
|
||||
output("]")
|
||||
|
||||
if(decl.zeropage == ZeropageWish.REQUIRE_ZEROPAGE || decl.zeropage==ZeropageWish.PREFER_ZEROPAGE)
|
||||
if(decl.zeropage == ZeropageWish.REQUIRE_ZEROPAGE)
|
||||
output(" @requirezp")
|
||||
else if(decl.zeropage == ZeropageWish.PREFER_ZEROPAGE)
|
||||
output(" @zp")
|
||||
if(decl.sharedWithAsm)
|
||||
output(" @shared")
|
||||
|
@ -861,7 +861,8 @@ data class IdentifierReference(val nameInSource: List<String>, override val posi
|
||||
fun targetVarDecl(program: Program): VarDecl? = targetStatement(program) as? VarDecl
|
||||
fun targetSubroutine(program: Program): Subroutine? = targetStatement(program) as? Subroutine
|
||||
|
||||
override fun equals(other: Any?) = other is IdentifierReference && other.nameInSource==nameInSource // NOTE: only compare by the name, not the position!
|
||||
// TODO equality also includes position, compare nameInSource explicitly if you only want name equality
|
||||
override fun equals(other: Any?) = other is IdentifierReference && other.nameInSource==nameInSource
|
||||
override fun hashCode() = nameInSource.hashCode()
|
||||
|
||||
override fun linkParents(parent: Node) {
|
||||
|
@ -16,7 +16,7 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
val importedBy = mutableMapOf<Module, Set<Module>>().withDefault { setOf() }
|
||||
val calls = mutableMapOf<Subroutine, Set<Subroutine>>().withDefault { setOf() }
|
||||
val calledBy = mutableMapOf<Subroutine, Set<Node>>().withDefault { setOf() }
|
||||
private val allIdentifiersAndTargets = mutableMapOf<Pair<IdentifierReference, Position>, Statement>()
|
||||
private val allIdentifiersAndTargets = mutableMapOf<Pair<IdentifierReference, Position>, Statement>() // note: identifier+location as key, because currently identifier equality is only on name
|
||||
private val allAssemblyNodes = mutableListOf<InlineAssembly>()
|
||||
|
||||
init {
|
||||
|
@ -38,6 +38,7 @@ Blocked by an official Commander-x16 r39 release
|
||||
|
||||
Future Things and Ideas
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- IdentifierReference: fix equality to also include position. CallGraph can then also only store IdentifierRef instead of pair(ident, position) as keys.
|
||||
- Fix: don't report as recursion if code assign address of its own subroutine to something, rather than calling it
|
||||
- allow "xxx" * constexpr (where constexpr is not a number literal, now gives expression error not same type)
|
||||
- can we promise a left-to-right function call argument evaluation? without sacrificing performance
|
||||
|
@ -1,22 +1,14 @@
|
||||
%import textio
|
||||
%import floats
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
ubyte[4] @shared @requirezp arr1 = [1,2,3,4]
|
||||
uword[2] @shared @requirezp arr2 = [111,222]
|
||||
float[2] @shared @requirezp arr3 = [1.111, 2.222]
|
||||
; TODO why allocated not cleaned????
|
||||
ubyte[255] @shared @requirezp arr1
|
||||
uword[100] @shared @requirezp arr2
|
||||
sub start() {
|
||||
txt.print_ub(arr1[3])
|
||||
txt.spc()
|
||||
txt.print_uw(arr2[1])
|
||||
txt.spc()
|
||||
floats.print_f(arr3[1])
|
||||
repeat {
|
||||
; txt.print_ub(arr1[3])
|
||||
; txt.spc()
|
||||
; txt.print_uw(arr2[1])
|
||||
; txt.spc()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sprites {
|
||||
word[3] sprites_x = [111,222,333]
|
||||
word[3] sprites_y = [666,777,888]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user