mirror of
https://github.com/irmen/prog8.git
synced 2024-12-23 09:32:43 +00:00
fixed todos in Ast printer
This commit is contained in:
parent
99c29343de
commit
517ea82b99
@ -57,9 +57,20 @@ fun printAst(root: PtNode, skipLibraries: Boolean, output: (text: String) -> Uni
|
|||||||
"???"
|
"???"
|
||||||
}
|
}
|
||||||
is PtAsmSub -> {
|
is PtAsmSub -> {
|
||||||
val params = if (node.parameters.isEmpty()) "" else "...TODO ${node.parameters.size} PARAMS..."
|
val params = node.parameters.map {
|
||||||
|
val register = it.first.registerOrPair
|
||||||
|
val statusflag = it.first.statusflag
|
||||||
|
"${it.second.type} ${it.second.name} @${register ?: statusflag}"
|
||||||
|
}.joinToString(", ")
|
||||||
val clobbers = if (node.clobbers.isEmpty()) "" else "clobbers ${node.clobbers}"
|
val clobbers = if (node.clobbers.isEmpty()) "" else "clobbers ${node.clobbers}"
|
||||||
val returns = if (node.returns.isEmpty()) "" else (if (node.returns.size == 1) "-> ${node.returns[0].second.name.lowercase()}" else "-> ${node.returns.map { it.second.name.lowercase() }}")
|
val returns = if (node.returns.isEmpty()) "" else {
|
||||||
|
"-> ${node.returns.map {
|
||||||
|
val register = it.first.registerOrPair
|
||||||
|
val statusflag = it.first.statusflag
|
||||||
|
"${it.second} @${register ?: statusflag}"}
|
||||||
|
.joinToString(", ")
|
||||||
|
}"
|
||||||
|
}
|
||||||
val str = if (node.inline) "inline " else ""
|
val str = if (node.inline) "inline " else ""
|
||||||
if(node.address==null) {
|
if(node.address==null) {
|
||||||
str + "asmsub ${node.name}($params) $clobbers $returns"
|
str + "asmsub ${node.name}($params) $clobbers $returns"
|
||||||
@ -87,7 +98,7 @@ fun printAst(root: PtNode, skipLibraries: Boolean, output: (text: String) -> Uni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
is PtSub -> {
|
is PtSub -> {
|
||||||
val params = if (node.parameters.isEmpty()) "" else "...TODO ${node.parameters.size} PARAMS..."
|
val params = node.parameters.map { "${it.type} ${it.name}" }.joinToString(", ")
|
||||||
var str = "sub ${node.name}($params) "
|
var str = "sub ${node.name}($params) "
|
||||||
if(node.returntype!=null)
|
if(node.returntype!=null)
|
||||||
str += "-> ${node.returntype.name.lowercase()}"
|
str += "-> ${node.returntype.name.lowercase()}"
|
||||||
|
@ -79,3 +79,7 @@ Other language/syntax features to think about
|
|||||||
- chained comparisons `10<x<20` , `x==y==z` (desugars to `10<x and x<20`, `x==y and y==z`)
|
- chained comparisons `10<x<20` , `x==y==z` (desugars to `10<x and x<20`, `x==y and y==z`)
|
||||||
BUT this needs a new AST node type and rewritten parser rules, because otherwise it changes the semantics
|
BUT this needs a new AST node type and rewritten parser rules, because otherwise it changes the semantics
|
||||||
of existing expressions such as if x<y==0 ...
|
of existing expressions such as if x<y==0 ...
|
||||||
|
- Better idea perhaps is "runtime range objects" the idea would be that "a to b" generates
|
||||||
|
a new kind of "range" value rather than an array (though you can still use it to initialize an array),
|
||||||
|
so you could replace if a <= n <= b with: if n in a to b
|
||||||
|
So this means we should keep the Range Expression alive for much longer.
|
||||||
|
Loading…
Reference in New Issue
Block a user