mirror of
https://github.com/irmen/prog8.git
synced 2024-08-20 21:29:18 +00:00
fixed ast to source for structs
This commit is contained in:
parent
4372de1e7e
commit
96ef7ba55d
@ -85,7 +85,7 @@ class AstToSourceCode(val output: (text: String) -> Unit, val program: Program):
|
||||
DataType.ARRAY_W -> "word["
|
||||
DataType.ARRAY_F -> "float["
|
||||
DataType.STRUCT -> "" // the name of the struct is enough
|
||||
else -> "?????2"
|
||||
else -> "?????"
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +113,10 @@ class AstToSourceCode(val output: (text: String) -> Unit, val program: Program):
|
||||
VarDeclType.CONST -> output("const ")
|
||||
VarDeclType.MEMORY -> output("&")
|
||||
}
|
||||
output(decl.struct?.name ?: "")
|
||||
|
||||
if(decl.datatype==DataType.STRUCT && decl.struct!=null)
|
||||
output(decl.struct!!.name)
|
||||
|
||||
output(datatypeString(decl.datatype))
|
||||
if(decl.arraysize!=null) {
|
||||
decl.arraysize!!.index.accept(this)
|
||||
|
@ -5,23 +5,36 @@
|
||||
|
||||
main {
|
||||
|
||||
str[] names = ["aap", "noot", "mies", "vuur"]
|
||||
uword[] names3 = ["aap", "noot", "mies", "vuur"]
|
||||
ubyte[] values = [11,22,33,44]
|
||||
uword[] arrays = [names, names3, values]
|
||||
|
||||
struct Color {
|
||||
ubyte red
|
||||
ubyte green
|
||||
ubyte blue
|
||||
}
|
||||
|
||||
Color c1 = [11,22,33] ; TODO fix crash
|
||||
Color c2 = [11,22,33] ; TODO fix crash
|
||||
Color c3 = [11,22,33] ; TODO fix crash
|
||||
; uword[] colors = [ c1, c2, c3]
|
||||
; Color c1 = [11,22,33] ; TODO fix crash
|
||||
; Color c2 = [11,22,33] ; TODO fix crash
|
||||
; Color c3 = [11,22,33] ; TODO fix crash
|
||||
; uword[] colors = [ c1, c2, c3] ; TODO should contain pointers to (the first element) of each struct
|
||||
|
||||
|
||||
str[] names = ["aap", "noot", "mies", "vuur"]
|
||||
uword[] names3 = ["aap", "noot", "mies", "vuur"]
|
||||
ubyte[] values = [11,22,33,44]
|
||||
uword[] arrays = [names, names3, values]
|
||||
|
||||
|
||||
sub start() {
|
||||
Color c1 = [11,22,33]
|
||||
Color c2 = [11,22,33]
|
||||
Color c3 = [11,22,33]
|
||||
uword[] colors = [ c1, c2, c3] ; TODO should contain pointers to (the first element) of each struct
|
||||
|
||||
c1.red = 100
|
||||
c1.green = 100
|
||||
c1.blue = 100
|
||||
; c1 = [11,22,33] ; TODO rewrite into individual struct member assignments
|
||||
|
||||
|
||||
uword s
|
||||
for s in names {
|
||||
txt.print(s)
|
||||
@ -35,7 +48,7 @@ main {
|
||||
txt.chrout('\n')
|
||||
|
||||
repeat {
|
||||
txt.print(names3[rnd()&3]) ; TODO doesn't show correct names? only shows 'aap' and 'noot' works fine if idx in separate var
|
||||
txt.print(names3[rnd()&3])
|
||||
txt.chrout(' ')
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user