mirror of
https://github.com/irmen/prog8.git
synced 2024-12-23 09:32:43 +00:00
remove searchParameter() from lookups
it shouldn't be needed to look up subroutine parameters by scoped name
This commit is contained in:
parent
6e9025ebf2
commit
b3b380964c
@ -76,9 +76,6 @@ interface IStatementContainer {
|
||||
fun isNotEmpty(): Boolean = statements.isNotEmpty()
|
||||
|
||||
fun searchSymbol(name: String): Statement? {
|
||||
if(this is Subroutine && isAsmSubroutine)
|
||||
return searchParameter(name)
|
||||
|
||||
// this is called quite a lot and could perhaps be optimized a bit more,
|
||||
// but adding a memoization cache didn't make much of a practical runtime difference...
|
||||
for (stmt in statements) {
|
||||
@ -139,9 +136,6 @@ interface IStatementContainer {
|
||||
}
|
||||
}
|
||||
|
||||
if(this is Subroutine && !isAsmSubroutine)
|
||||
return searchParameter(name)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
@ -720,22 +720,6 @@ class Subroutine(override val name: String,
|
||||
override fun accept(visitor: AstWalker, parent: Node) = visitor.visit(this, parent)
|
||||
override fun toString() =
|
||||
"Subroutine(name=$name, parameters=$parameters, returntypes=$returntypes, ${statements.size} statements, address=$asmAddress)"
|
||||
|
||||
// code to provide the ability to reference asmsub parameters via qualified name:
|
||||
private val asmParamsDecls = mutableMapOf<String, VarDecl>()
|
||||
|
||||
fun searchParameter(name: String): VarDecl? {
|
||||
// TODO can we get rid of this routine? it makes temporary vardecls...
|
||||
val existingDecl = asmParamsDecls[name]
|
||||
if(existingDecl!=null)
|
||||
return existingDecl
|
||||
|
||||
val param = parameters.firstOrNull {it.name==name} ?: return null
|
||||
val decl = VarDecl.fromParameter(param)
|
||||
decl.linkParents(this)
|
||||
asmParamsDecls[name] = decl
|
||||
return decl
|
||||
}
|
||||
}
|
||||
|
||||
open class SubroutineParameter(val name: String,
|
||||
|
Loading…
Reference in New Issue
Block a user