mirror of
https://github.com/irmen/prog8.git
synced 2025-01-10 20:30:23 +00:00
fix position of @shared in array var declarations so that the order is now type[] @shared
This commit is contained in:
parent
3cf9b9d9a5
commit
77c2b2b326
@ -519,13 +519,18 @@ internal class AstChecker(private val program: Program,
|
|||||||
err("const modifier can only be used on numeric types (byte, word, float)")
|
err("const modifier can only be used on numeric types (byte, word, float)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @zp can only occur on integers
|
||||||
|
if(decl.datatype !in IntegerDatatypes) {
|
||||||
|
if(decl.zeropage==ZeropageWish.PREFER_ZEROPAGE)
|
||||||
|
errors.warn("this datatype can't be placed in zeropage", decl.position)
|
||||||
|
if(decl.zeropage==ZeropageWish.REQUIRE_ZEROPAGE)
|
||||||
|
errors.err("this datatype can't be placed in zeropage", decl.position)
|
||||||
|
}
|
||||||
|
|
||||||
// FLOATS enabled?
|
// FLOATS enabled?
|
||||||
if(!compilerOptions.floats && decl.datatype.oneOf(DataType.FLOAT, DataType.ARRAY_F) && decl.type!= VarDeclType.MEMORY)
|
if(!compilerOptions.floats && decl.datatype.oneOf(DataType.FLOAT, DataType.ARRAY_F) && decl.type!= VarDeclType.MEMORY)
|
||||||
err("floating point used, but that is not enabled via options")
|
err("floating point used, but that is not enabled via options")
|
||||||
|
|
||||||
if(decl.datatype == DataType.FLOAT && (decl.zeropage==ZeropageWish.REQUIRE_ZEROPAGE || decl.zeropage==ZeropageWish.PREFER_ZEROPAGE))
|
|
||||||
errors.warn("floating point values won't be placed in Zeropage due to size constraints", decl.position)
|
|
||||||
|
|
||||||
// ARRAY without size specifier MUST have an iterable initializer value
|
// ARRAY without size specifier MUST have an iterable initializer value
|
||||||
if(decl.isArray && decl.arraysize==null) {
|
if(decl.isArray && decl.arraysize==null) {
|
||||||
if(decl.type== VarDeclType.MEMORY)
|
if(decl.type== VarDeclType.MEMORY)
|
||||||
|
@ -21,7 +21,7 @@ import prog8tests.helpers.DummyStringEncoder
|
|||||||
import prog8tests.helpers.ErrorReporterForTests
|
import prog8tests.helpers.ErrorReporterForTests
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
class AsmGenSymbolsTests: StringSpec({
|
class TestAsmGenSymbols: StringSpec({
|
||||||
fun createTestProgram(): Program {
|
fun createTestProgram(): Program {
|
||||||
/*
|
/*
|
||||||
main {
|
main {
|
32
compiler/test/codegeneration/TestVariables.kt
Normal file
32
compiler/test/codegeneration/TestVariables.kt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package prog8tests.codegeneration
|
||||||
|
|
||||||
|
import io.kotest.core.spec.style.FunSpec
|
||||||
|
import io.kotest.matchers.shouldBe
|
||||||
|
import io.kotest.matchers.string.shouldContain
|
||||||
|
import prog8.compiler.target.C64Target
|
||||||
|
import prog8tests.helpers.ErrorReporterForTests
|
||||||
|
import prog8tests.helpers.assertSuccess
|
||||||
|
import prog8tests.helpers.compileText
|
||||||
|
|
||||||
|
|
||||||
|
class TestVariables: FunSpec({
|
||||||
|
|
||||||
|
test("shared variables without refs not removed for inlined asm") {
|
||||||
|
val text = """
|
||||||
|
main {
|
||||||
|
sub start() {
|
||||||
|
ubyte[] @shared array = [1,2,3,4]
|
||||||
|
str @shared name = "test"
|
||||||
|
ubyte @shared bytevar = 0
|
||||||
|
|
||||||
|
%asm {{
|
||||||
|
lda array
|
||||||
|
lda name
|
||||||
|
lda bytevar
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
compileText(C64Target, true, text, writeAssembly = true).assertSuccess()
|
||||||
|
}
|
||||||
|
})
|
@ -3,6 +3,10 @@ TODO
|
|||||||
|
|
||||||
For next compiler release (7.6)
|
For next compiler release (7.6)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
why does the following use a intermediate return value and not just A?
|
||||||
|
sub pushing_start() -> ubyte {
|
||||||
|
return joy_info & 16
|
||||||
|
}
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,49 +1,16 @@
|
|||||||
%import textio
|
%option enable_floats
|
||||||
%import floats
|
|
||||||
%zeropage basicsafe
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
ubyte xx = 0
|
ubyte[] @shared @zp array = [1,2,3,4]
|
||||||
|
str @shared @zp name = "test"
|
||||||
|
ubyte @shared @zp bytevar = 0
|
||||||
|
float @shared @zp fl
|
||||||
|
|
||||||
singleparamb(123)
|
%asm {{
|
||||||
singleparamb(123)
|
lda array
|
||||||
singleparamw(-9999)
|
lda name
|
||||||
singleparamw(-9999)
|
lda bytevar
|
||||||
doubleparamb(xx+111,-99)
|
}}
|
||||||
doubleparamb(xx+111,-99)
|
|
||||||
doubleparamw(xx+8888,-9999)
|
|
||||||
doubleparamw(xx+8888,-9999)
|
|
||||||
singleparamf(1.23456)
|
|
||||||
singleparamf(1.23456)
|
|
||||||
}
|
|
||||||
|
|
||||||
sub singleparamb(ubyte bb) {
|
|
||||||
txt.print_ub(bb)
|
|
||||||
txt.nl()
|
|
||||||
}
|
|
||||||
|
|
||||||
sub doubleparamb(ubyte bb, byte bs) {
|
|
||||||
txt.print_ub(bb)
|
|
||||||
txt.spc()
|
|
||||||
txt.print_b(bs)
|
|
||||||
txt.nl()
|
|
||||||
}
|
|
||||||
|
|
||||||
sub singleparamw(word ww) {
|
|
||||||
txt.print_w(ww)
|
|
||||||
txt.nl()
|
|
||||||
}
|
|
||||||
|
|
||||||
sub doubleparamw(uword uw, word ww) {
|
|
||||||
txt.print_uw(uw)
|
|
||||||
txt.spc()
|
|
||||||
txt.print_w(ww)
|
|
||||||
txt.nl()
|
|
||||||
}
|
|
||||||
|
|
||||||
sub singleparamf(float ff) {
|
|
||||||
floats.print_f(ff)
|
|
||||||
txt.nl()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ directive :
|
|||||||
|
|
||||||
directivearg : stringliteral | identifier | integerliteral ;
|
directivearg : stringliteral | identifier | integerliteral ;
|
||||||
|
|
||||||
vardecl: datatype SHARED? ZEROPAGE? (arrayindex | ARRAYSIG) ? varname=identifier ;
|
vardecl: datatype (arrayindex | ARRAYSIG)? SHARED? ZEROPAGE? varname=identifier ;
|
||||||
|
|
||||||
varinitializer : vardecl '=' expression ;
|
varinitializer : vardecl '=' expression ;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user