mirror of
https://github.com/irmen/prog8.git
synced 2025-11-01 06:16:15 +00:00
fix bug: VM MULR float error, another pointer dependency checker error
This commit is contained in:
@@ -1707,7 +1707,7 @@ main {
|
|||||||
errors.errors[1] shouldContain "assigning this value to struct instance not supported"
|
errors.errors[1] shouldContain "assigning this value to struct instance not supported"
|
||||||
}
|
}
|
||||||
|
|
||||||
test("pointer variable usage detection in other block") {
|
test("pointer variable usage detection in other block 1") {
|
||||||
val src="""
|
val src="""
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
@@ -1723,4 +1723,80 @@ other {
|
|||||||
compileText(VMTarget(), true, src, outputDir, writeAssembly = false) shouldNotBe null
|
compileText(VMTarget(), true, src, outputDir, writeAssembly = false) shouldNotBe null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("pointer variable usage detection in other block 2") {
|
||||||
|
val src="""
|
||||||
|
main {
|
||||||
|
sub start() {
|
||||||
|
other.func.variable^^ += 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
other {
|
||||||
|
sub func() {
|
||||||
|
^^ubyte variable
|
||||||
|
}
|
||||||
|
}"""
|
||||||
|
compileText(VMTarget(), false, src, outputDir, writeAssembly = false) shouldNotBe null
|
||||||
|
compileText(VMTarget(), true, src, outputDir, writeAssembly = false) shouldNotBe null
|
||||||
|
}
|
||||||
|
|
||||||
|
test("float ptr inplace operations") {
|
||||||
|
val src="""
|
||||||
|
%option enable_floats
|
||||||
|
|
||||||
|
main {
|
||||||
|
^^float g_floats
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
^^float l_floats
|
||||||
|
|
||||||
|
f_add()
|
||||||
|
f_sub()
|
||||||
|
f_mul()
|
||||||
|
f_div()
|
||||||
|
|
||||||
|
sub f_add() {
|
||||||
|
l_floats^^ += 3.0
|
||||||
|
g_floats^^ += 3.0
|
||||||
|
other.g_floats^^ += 3.0
|
||||||
|
other.func.l_floats^^ += 3.0
|
||||||
|
}
|
||||||
|
|
||||||
|
sub f_sub() {
|
||||||
|
l_floats^^ -= 3.0
|
||||||
|
g_floats^^ -= 3.0
|
||||||
|
other.g_floats^^ -= 3.0
|
||||||
|
other.func.l_floats^^ -= 3.0
|
||||||
|
}
|
||||||
|
|
||||||
|
sub f_mul() {
|
||||||
|
l_floats^^ *= 3.0
|
||||||
|
g_floats^^ *= 3.0
|
||||||
|
other.g_floats^^ *= 3.0
|
||||||
|
other.func.l_floats^^ *= 3.0
|
||||||
|
}
|
||||||
|
|
||||||
|
sub f_div() {
|
||||||
|
l_floats^^ /= 3.0
|
||||||
|
g_floats^^ /= 3.0
|
||||||
|
other.g_floats^^ /= 3.0
|
||||||
|
other.func.l_floats^^ /= 3.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
other {
|
||||||
|
%option force_output
|
||||||
|
|
||||||
|
^^float g_floats
|
||||||
|
|
||||||
|
sub func() {
|
||||||
|
^^float l_floats
|
||||||
|
}
|
||||||
|
}"""
|
||||||
|
compileText(VMTarget(), false, src, outputDir) shouldNotBe null
|
||||||
|
//compileText(C64Target(), false, src, outputDir) shouldNotBe null
|
||||||
|
//compileText(Cx16Target(), false, src, outputDir) shouldNotBe null
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -172,6 +172,9 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
|||||||
if(variable is VarDecl) {
|
if(variable is VarDecl) {
|
||||||
allIdentifiersAndTargets.add(IdentifierReference(listOf(variable.name), variable.position) to variable)
|
allIdentifiersAndTargets.add(IdentifierReference(listOf(variable.name), variable.position) to variable)
|
||||||
}
|
}
|
||||||
|
else if(variable is Subroutine) {
|
||||||
|
notCalledButReferenced += variable
|
||||||
|
}
|
||||||
chain.removeLastOrNull()
|
chain.removeLastOrNull()
|
||||||
}
|
}
|
||||||
super.visit(deref)
|
super.visit(deref)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
|
|
||||||
STRUCTS and TYPED POINTERS
|
STRUCTS and TYPED POINTERS
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,52 @@
|
|||||||
|
%option enable_floats
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
^^float g_floats
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
other.bptr^^ = true
|
^^float l_floats
|
||||||
; other.bptr = 2222
|
|
||||||
;cx16.r0bL = other.bptr^^
|
f_add()
|
||||||
|
f_sub()
|
||||||
|
f_mul()
|
||||||
|
f_div()
|
||||||
|
|
||||||
|
sub f_add() {
|
||||||
|
l_floats^^ += 3.0
|
||||||
|
g_floats^^ += 3.0
|
||||||
|
other.g_floats^^ += 3.0
|
||||||
|
other.func.l_floats^^ += 3.0
|
||||||
|
}
|
||||||
|
|
||||||
|
sub f_sub() {
|
||||||
|
l_floats^^ -= 3.0
|
||||||
|
g_floats^^ -= 3.0
|
||||||
|
other.g_floats^^ -= 3.0
|
||||||
|
other.func.l_floats^^ -= 3.0
|
||||||
|
}
|
||||||
|
|
||||||
|
sub f_mul() {
|
||||||
|
l_floats^^ *= 3.0
|
||||||
|
g_floats^^ *= 3.0
|
||||||
|
other.g_floats^^ *= 3.0
|
||||||
|
other.func.l_floats^^ *= 3.0
|
||||||
|
}
|
||||||
|
|
||||||
|
sub f_div() {
|
||||||
|
l_floats^^ /= 3.0
|
||||||
|
g_floats^^ /= 3.0
|
||||||
|
other.g_floats^^ /= 3.0
|
||||||
|
other.func.l_floats^^ /= 3.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
other {
|
other {
|
||||||
^^bool bptr
|
%option force_output
|
||||||
|
|
||||||
|
^^float g_floats
|
||||||
|
|
||||||
|
sub func() {
|
||||||
|
^^float l_floats
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -679,15 +679,15 @@ val instructionFormats = mutableMapOf(
|
|||||||
Opcode.SUBR to InstructionFormat.from("BW,<>r1,<r2 | F,<>fr1,<fr2"),
|
Opcode.SUBR to InstructionFormat.from("BW,<>r1,<r2 | F,<>fr1,<fr2"),
|
||||||
Opcode.SUB to InstructionFormat.from("BW,<>r1,<i | F,<>fr1,<i"),
|
Opcode.SUB to InstructionFormat.from("BW,<>r1,<i | F,<>fr1,<i"),
|
||||||
Opcode.SUBM to InstructionFormat.from("BW,<r1,<>a | F,<fr1,<>a"),
|
Opcode.SUBM to InstructionFormat.from("BW,<r1,<>a | F,<fr1,<>a"),
|
||||||
Opcode.MULR to InstructionFormat.from("BW,<>r1,<r2"),
|
Opcode.MULR to InstructionFormat.from("BW,<>r1,<r2 | F,<>fr1,<fr2"),
|
||||||
Opcode.MUL to InstructionFormat.from("BW,<>r1,<i"),
|
Opcode.MUL to InstructionFormat.from("BW,<>r1,<i | F,<>fr1,<i"),
|
||||||
Opcode.MULM to InstructionFormat.from("BW,<r1,<>a"),
|
Opcode.MULM to InstructionFormat.from("BW,<r1,<>a | F,<fr1,<>a"),
|
||||||
Opcode.MULSR to InstructionFormat.from("BW,<>r1,<r2 | F,<>fr1,<fr2"),
|
Opcode.MULSR to InstructionFormat.from("BW,<>r1,<r2 | F,<>fr1,<fr2"),
|
||||||
Opcode.MULS to InstructionFormat.from("BW,<>r1,<i | F,<>fr1,<i"),
|
Opcode.MULS to InstructionFormat.from("BW,<>r1,<i | F,<>fr1,<i"),
|
||||||
Opcode.MULSM to InstructionFormat.from("BW,<r1,<>a | F,<fr1,<>a"),
|
Opcode.MULSM to InstructionFormat.from("BW,<r1,<>a | F,<fr1,<>a"),
|
||||||
Opcode.DIVR to InstructionFormat.from("BW,<>r1,<r2"),
|
Opcode.DIVR to InstructionFormat.from("BW,<>r1,<r2 | F,<>fr1,<fr2"),
|
||||||
Opcode.DIV to InstructionFormat.from("BW,<>r1,<i"),
|
Opcode.DIV to InstructionFormat.from("BW,<>r1,<i | F,<>fr1,<i"),
|
||||||
Opcode.DIVM to InstructionFormat.from("BW,<r1,<>a"),
|
Opcode.DIVM to InstructionFormat.from("BW,<r1,<>a | F,<fr1,<>a"),
|
||||||
Opcode.DIVSR to InstructionFormat.from("BW,<>r1,<r2 | F,<>fr1,<fr2"),
|
Opcode.DIVSR to InstructionFormat.from("BW,<>r1,<r2 | F,<>fr1,<fr2"),
|
||||||
Opcode.DIVS to InstructionFormat.from("BW,<>r1,<i | F,<>fr1,<i"),
|
Opcode.DIVS to InstructionFormat.from("BW,<>r1,<i | F,<>fr1,<i"),
|
||||||
Opcode.DIVSM to InstructionFormat.from("BW,<r1,<>a | F,<fr1,<>a"),
|
Opcode.DIVSM to InstructionFormat.from("BW,<r1,<>a | F,<fr1,<>a"),
|
||||||
|
|||||||
Reference in New Issue
Block a user