remove searchParameter() from lookups

it shouldn't be needed to look up subroutine parameters by scoped name
This commit is contained in:
Irmen de Jong 2023-03-04 13:24:33 +01:00
parent 6e9025ebf2
commit b3b380964c
2 changed files with 0 additions and 22 deletions

View File

@ -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
}

View File

@ -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,