mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 23:29:55 +00:00
added codengeration for assigment of array of values to a struct variable (all members at once)
This commit is contained in:
parent
8647a8290e
commit
46fbe01df9
@ -202,7 +202,16 @@ internal class StatementReorderer(val program: Program) : AstWalker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceVar.isArray -> {
|
sourceVar.isArray -> {
|
||||||
TODO("assign struct array $structAssignment")
|
val array = (sourceVar.value as ArrayLiteralValue).value
|
||||||
|
return struct.statements.zip(array).map {
|
||||||
|
val decl = it.first as VarDecl
|
||||||
|
val mangled = mangledStructMemberName(identifierName, decl.name)
|
||||||
|
val targetName = IdentifierReference(listOf(mangled), structAssignment.position)
|
||||||
|
val target = AssignTarget(targetName, null, null, structAssignment.position)
|
||||||
|
val assign = Assignment(target, it.second, structAssignment.position)
|
||||||
|
assign.linkParents(structAssignment)
|
||||||
|
assign
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
throw FatalAstException("can only assign arrays or structs to structs")
|
throw FatalAstException("can only assign arrays or structs to structs")
|
||||||
|
@ -3,8 +3,7 @@ TODO
|
|||||||
====
|
====
|
||||||
|
|
||||||
- get rid of all other TODO's in the code ;-)
|
- get rid of all other TODO's in the code ;-)
|
||||||
- make it possible for array literals to not only contain compile time constants
|
- make it possible for array literals to not only contain compile time constants?
|
||||||
- further optimize assignment codegeneration
|
|
||||||
- implement @stack for asmsub parameters
|
- implement @stack for asmsub parameters
|
||||||
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_'
|
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_'
|
||||||
- option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging)
|
- option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging)
|
||||||
@ -17,7 +16,8 @@ More optimizations
|
|||||||
|
|
||||||
Add more compiler optimizations to the existing ones.
|
Add more compiler optimizations to the existing ones.
|
||||||
|
|
||||||
- more targeted optimizations for assigment asm code, such as the following:
|
- further optimize assignment codegeneration, such as the following:
|
||||||
|
- binexpr splitting (beware self-referencing expressions and asm code ballooning though)
|
||||||
- subroutine calling convention? like: 1 byte arg -> pass in A, 2 bytes -> pass in A+Y, return value likewise.
|
- subroutine calling convention? like: 1 byte arg -> pass in A, 2 bytes -> pass in A+Y, return value likewise.
|
||||||
- can such parameter passing to subroutines be optimized to avoid copying?
|
- can such parameter passing to subroutines be optimized to avoid copying?
|
||||||
- more optimizations on the language AST level
|
- more optimizations on the language AST level
|
||||||
|
@ -20,21 +20,22 @@ main {
|
|||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
txt.print_uwhex(&c1, true)
|
txt.print_ub(c1.red)
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
txt.print_uwhex(&c2, true)
|
txt.print_ub(c1.green)
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
txt.print_uwhex(&c3, true)
|
txt.print_ub(c1.blue)
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
txt.print_uwhex(colors[0], true)
|
|
||||||
txt.chrout('\n')
|
|
||||||
txt.print_uwhex(colors[1], true)
|
|
||||||
txt.chrout('\n')
|
|
||||||
txt.print_uwhex(colors[2], true)
|
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
|
|
||||||
c1 = c2
|
c1 = [99,88,77]
|
||||||
c1 = [11,22,33] ; TODO implement rewrite into individual struct member assignments
|
|
||||||
|
txt.print_ub(c1.red)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.print_ub(c1.green)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.print_ub(c1.blue)
|
||||||
|
txt.chrout('\n')
|
||||||
testX()
|
testX()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user