mirror of
https://github.com/irmen/prog8.git
synced 2025-01-12 19:29:50 +00:00
fix ast printing of arrays with duplicate elements
This commit is contained in:
parent
03412cacba
commit
fa5479ee5f
@ -21,7 +21,16 @@ fun printAst(root: PtNode, skipLibraries: Boolean, output: (text: String) -> Uni
|
||||
else
|
||||
"&"
|
||||
}
|
||||
is PtArray -> "array len=${node.children.size} ${type(node.type)}"
|
||||
is PtArray -> {
|
||||
val valuelist = node.children.map {
|
||||
when (it) {
|
||||
is PtNumber -> it.number.toString()
|
||||
is PtIdentifier -> it.name
|
||||
else -> "?"
|
||||
}
|
||||
}.joinToString(", ")
|
||||
"array len=${node.children.size} ${type(node.type)} [ $valuelist ]"
|
||||
}
|
||||
is PtArrayIndexer -> "<arrayindexer> ${type(node.type)} ${if(node.splitWords) "[splitwords]" else ""}"
|
||||
is PtBinaryExpression -> "<expr> ${node.operator} ${type(node.type)}"
|
||||
is PtBuiltinFunctionCall -> {
|
||||
|
@ -315,16 +315,16 @@ class AstToSourceTextConverter(val output: (text: String) -> Unit, val program:
|
||||
}
|
||||
|
||||
override fun visit(array: ArrayLiteral) {
|
||||
outputListMembers(array.value.asSequence())
|
||||
outputListMembers(array.value)
|
||||
}
|
||||
|
||||
private fun outputListMembers(array: Sequence<Expression>) {
|
||||
private fun outputListMembers(array: Array<Expression>) {
|
||||
var counter = 0
|
||||
output("[")
|
||||
scopelevel++
|
||||
for (v in array) {
|
||||
for ((idx, v) in array.withIndex()) {
|
||||
v.accept(this)
|
||||
if (v !== array.last())
|
||||
if (idx != array.size-1)
|
||||
output(", ")
|
||||
counter++
|
||||
if (counter > 16) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user