diff --git a/compiler/src/prog8/ast/AST.kt b/compiler/src/prog8/ast/AST.kt index 88c04a838..4af598419 100644 --- a/compiler/src/prog8/ast/AST.kt +++ b/compiler/src/prog8/ast/AST.kt @@ -347,7 +347,7 @@ interface IFunctionCall { interface INameScope { val name: String val position: Position - var statements: MutableList + val statements: MutableList val parent: Node fun linkParents(parent: Node) @@ -376,17 +376,16 @@ interface INameScope { } fun getLabelOrVariable(name: String): IStatement? { + // TODO this call is relatively slow.... cache it? make statement list non-mutable and update the cache when it is explicitly updated? for (stmt in statements) { - if (stmt is Label && stmt.name==name) return stmt if (stmt is VarDecl && stmt.name==name) return stmt + else if (stmt is Label && stmt.name==name) return stmt } return null } - fun allLabelsAndVariables(): Map { - val labelsAndVars = statements.filterIsInstance