summary refs log tree commit diff stats
path: root/compiler/ic/packed_ast.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-01-23 08:06:15 +0100
committerGitHub <noreply@github.com>2021-01-23 08:06:15 +0100
commit8241e55023ee32c9ec0b5443723bbe91f4fe875f (patch)
treed14be71f134b1789db54028704748c4dbed46bfa /compiler/ic/packed_ast.nim
parenteae3bdf8fe554cdd334b8a53de63fd9bf10a7832 (diff)
downloadNim-8241e55023ee32c9ec0b5443723bbe91f4fe875f.tar.gz
IC: next steps (#16729)
* IC: dead code elimination pass
* preparations for a different codegen strategy
* added documentation to the newly written code
* IC: backend code
* IC: backend adjustments
* optimized the compiler a bit
* IC: yet another massive refactoring
* fixes regressions
* cleanups
Diffstat (limited to 'compiler/ic/packed_ast.nim')
-rw-r--r--compiler/ic/packed_ast.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/ic/packed_ast.nim b/compiler/ic/packed_ast.nim
index 708761764..213b21b23 100644
--- a/compiler/ic/packed_ast.nim
+++ b/compiler/ic/packed_ast.nim
@@ -290,6 +290,9 @@ template typ*(n: NodePos): PackedItemId =
 template flags*(n: NodePos): TNodeFlags =
   tree.nodes[n.int].flags
 
+template operand*(n: NodePos): int32 =
+  tree.nodes[n.int].operand
+
 proc span*(tree: PackedTree; pos: int): int {.inline.} =
   if isAtom(tree, pos): 1 else: tree.nodes[pos].operand
 
@@ -451,3 +454,10 @@ when false:
     dest.add nkStrLit, msg, n.info
     copyTree(dest, tree, n)
     patch dest, patchPos
+
+iterator allNodes*(tree: PackedTree): NodePos =
+  var p = 0
+  while p < tree.len:
+    yield NodePos(p)
+    let s = span(tree, p)
+    inc p, s