From 870c6ea747476618e85a16d1f266867ef0a7f59c Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Mon, 14 Jan 2019 21:31:14 +0100 Subject: [PATCH] stuff --- compiler/src/prog8/ast/AST.kt | 24 +---- compiler/src/prog8/ast/AstChecker.kt | 6 +- .../src/prog8/ast/AstIdentifiersChecker.kt | 15 +-- compiler/src/prog8/compiler/Compiler.kt | 22 +++-- .../intermediate/IntermediateProgram.kt | 7 +- .../src/prog8/compiler/intermediate/Opcode.kt | 1 + .../src/prog8/compiler/target/c64/AsmGen.kt | 4 +- .../prog8/compiler/target/c64/Commodore64.kt | 4 + docs/docs.iml | 4 +- docs/source/conf.py | 1 - examples/assignments.p8 | 6 +- examples/hello.p8 | 2 +- examples/test.p8 | 95 ++++++++++++------- 13 files changed, 109 insertions(+), 82 deletions(-) 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