mirror of
https://github.com/irmen/prog8.git
synced 2024-11-18 19:12:44 +00:00
got rid of old getScopedSymbolNameForTarget routine
This commit is contained in:
parent
58d9c46a9b
commit
42fe052f9f
@ -522,13 +522,15 @@ class AsmGen(private val program: Program,
|
||||
val targetScope = target.definingSubroutine
|
||||
val identScope = identifier.definingSubroutine
|
||||
return if (targetScope !== identScope) {
|
||||
val scopedName = getScopedSymbolNameForTarget(identifier.nameInSource.last(), target)
|
||||
val scopedName = (target as INamedStatement).scopedName
|
||||
if (target is Label) {
|
||||
// make labels locally scoped in the asm. Is slightly problematic, see GitHub issue #62
|
||||
val last = scopedName.removeLast()
|
||||
scopedName.add("_$last")
|
||||
val newName = scopedName.dropLast(1) + ("_${scopedName.last()}")
|
||||
fixNameSymbols(newName.joinToString("."))
|
||||
}
|
||||
else {
|
||||
fixNameSymbols(scopedName.joinToString("."))
|
||||
}
|
||||
fixNameSymbols(scopedName.joinToString("."))
|
||||
} else {
|
||||
if (target is Label) {
|
||||
// make labels locally scoped in the asm. Is slightly problematic, see GitHub issue #62
|
||||
@ -546,19 +548,6 @@ class AsmGen(private val program: Program,
|
||||
fun asmVariableName(identifier: IdentifierReference) =
|
||||
fixNameSymbols(identifier.nameInSource.joinToString("."))
|
||||
|
||||
// TODO use INamedStatement.scopedName
|
||||
private fun getScopedSymbolNameForTarget(actualName: String, target: Statement): MutableList<String> {
|
||||
val scopedName = mutableListOf(actualName)
|
||||
var node: Node = target
|
||||
while (node !is Block) {
|
||||
node = node.parent
|
||||
if(node is INameScope) {
|
||||
scopedName.add(0, node.name)
|
||||
}
|
||||
}
|
||||
return scopedName
|
||||
}
|
||||
|
||||
internal fun asmSymbolName(regs: RegisterOrPair): String =
|
||||
if (regs in Cx16VirtualRegisters)
|
||||
"cx16." + regs.toString().lowercase()
|
||||
|
@ -29,7 +29,7 @@ sealed class Statement : Node {
|
||||
abstract fun accept(visitor: IAstVisitor)
|
||||
abstract fun accept(visitor: AstWalker, parent: Node)
|
||||
|
||||
` fun nextSibling(): Statement? {
|
||||
fun nextSibling(): Statement? {
|
||||
val statements = (parent as? IStatementContainer)?.statements ?: return null
|
||||
val nextIdx = statements.indexOfFirst { it===this } + 1
|
||||
return if(nextIdx < statements.size)
|
||||
|
Loading…
Reference in New Issue
Block a user