diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 453996abd..e7f997a6d 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -9,6 +9,15 @@
+
+
+
diff --git a/codeGenIntermediate/src/prog8/codegen/intermediate/IRUnusedCodeRemover.kt b/codeGenIntermediate/src/prog8/codegen/intermediate/IRUnusedCodeRemover.kt
index 252871291..affaeea0a 100644
--- a/codeGenIntermediate/src/prog8/codegen/intermediate/IRUnusedCodeRemover.kt
+++ b/codeGenIntermediate/src/prog8/codegen/intermediate/IRUnusedCodeRemover.kt
@@ -168,7 +168,7 @@ class IRUnusedCodeRemover(
it.instructions.forEach { instr ->
if (instr.branchTarget == null)
instr.labelSymbol?.let { label ->
- val chunk = allLabeledChunks[label.substringBeforeLast('.')]
+ val chunk = allLabeledChunks[label] ?: allLabeledChunks[label.substringBeforeLast('.')]
if(chunk!=null)
new+=chunk
else
diff --git a/docs/source/todo.rst b/docs/source/todo.rst
index 36b46e34f..ade38b4fa 100644
--- a/docs/source/todo.rst
+++ b/docs/source/todo.rst
@@ -1,6 +1,8 @@
TODO
====
+make it possible to do indirect jumps in VM? (associate values with labels and if it jumps to a "address value" it looks up the label with that value again?)
+
replace Takes by Http4k in httpCompilerService project. https://github.com/http4k/examples/blob/master/hello-world/README.md
...
@@ -28,6 +30,7 @@ Compiler:
- (need separate step in codegen and IR to write the "golden" variables)
- do we need (array)variable alignment tag instead of block alignment tag? You want to align the data, not the code in the block?
+- VM: implement diskio support (let's start with the basics load, save, delete, rename, status?. no streaming, no directory listing)
- ir: related to the one above: block alignment doesn't translate well to variables in the block (the actual stuff that needs to be aligned in memory) but: need variable alignment tag instead of block alignment tag, really
- ir: proper code gen for the CALLI instruction and that it (optionally) returns a word value that needs to be assigned to a reg
- ir: idea: (but LLVM IR simply keeps the variables, so not a good idea then?...): replace all scalar variables by an allocated register. Keep a table of the variable to register mapping (including the datatype)
diff --git a/examples/test.p8 b/examples/test.p8
index 7cce0475f..7b145a8c3 100644
--- a/examples/test.p8
+++ b/examples/test.p8
@@ -1,54 +1,137 @@
%import textio
-%import math
-%zeropage basicsafe
+%zeropage dontuse
%option no_sysinit
main {
sub start() {
- ubyte @shared pointer
- const uword value = 255
+ uword @shared pointer
+
+; if cx16.r0L>10
+; goto label1
+; if cx16.r0L>11
+; goto label2
+
+ pointer = &label2
+ goto pointer
+
+label1:
+ txt.print("fail\n")
+ return
+
+label2:
+ txt.print("indirect jump ok\n")
+ return
- if pointer>value {
- cx16.r0L++
- }
-; if pointer>50000 {
-; cx16.r0L++
-; }
- txt.bell()
}
}
-/*main222 {
- sub start() {
- str name1 = "name1"
- str name2 = "name2"
- uword[] @split names = [name1, name2, "name3"]
- uword[] addresses = [0,1,2]
- names = [1111,2222,3333]
-
- for cx16.r0 in names {
- txt.print_uw(cx16.r0)
- txt.spc()
- }
- txt.nl()
-
- addresses = names
-
- for cx16.r0 in addresses {
- txt.print_uw(cx16.r0)
- txt.spc()
- }
- txt.nl()
-
- names = [9999,8888,7777]
- names = addresses
- for cx16.r0 in names {
- txt.print_uw(cx16.r0)
- txt.spc()
- }
- txt.nl()
- }
-}*/
+;%import textio
+;%import floats
+;%zeropage dontuse
+;%option no_sysinit
+;
+;main {
+; sub start() {
+; test_bool()
+;; test_byte()
+;; test_ubyte()
+;; test_word()
+;; test_uword()
+;; test_float()
+; }
+;
+; /*
+; tests:
+; - if with only a single goto, direct
+; - if with only a single indirect goto
+; - if without an else block
+; - if with both if and else blocks
+; carthesian product with:
+; - comparison with const zero
+; - comparison with const values
+; - comparison with variable
+; - comparison with array
+; - comparison with expression
+; */
+;
+; sub fail(uword test) {
+; txt.print("failed ")
+; txt.print_uw(test)
+; txt.nl()
+; }
+;
+; sub test_bool() {
+; bool @shared var1, var2
+; uword success = 0
+;
+; single_goto()
+; single_goto_indirect()
+; no_else()
+; ifelse()
+;
+; sub single_goto() {
+; txt.print("bool single_goto\n")
+;test1:
+; var1 = false
+; if var1
+; goto lbl1
+; success++
+; goto test2
+;lbl1:
+; fail(1)
+;
+;test2:
+; var1 = true
+; if var1
+; goto lbl2
+; fail(1)
+; goto test3
+;lbl2: success++
+;
+;test3:
+; if success==2
+; txt.print(" ok\n")
+; else
+; txt.print(" failed\n")
+; }
+;
+; sub single_goto_indirect() {
+; uword pointer
+; txt.print("bool single_goto_indirect\n")
+;test1:
+; var1 = false
+; pointer = &lbl1
+; if var1
+; goto pointer
+; success++
+; goto test2
+;lbl1:
+; fail(1)
+;
+;test2:
+; var1 = true
+; pointer = &lbl2
+; if var1
+; goto pointer
+; fail(1)
+; goto test3
+;lbl2: success++
+;
+;test3:
+; if success==2
+; txt.print(" ok\n")
+; else
+; txt.print(" failed\n")
+; }
+;
+; sub no_else() {
+; }
+;
+; sub ifelse() {
+; }
+; }
+;
+;}