summary refs log tree commit diff stats
path: root/compiler/passaux.nim
blob: 68b7832489bb03cd4cb88c9aeef28764cd4fae3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
#
#           The Nim Compiler
#        (c) Copyright 2012 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

## implements some little helper passes

import
  ast, passes, msgs, options, lineinfos

from modulegraphs import ModuleGraph, PPassContext

type
  VerboseRef = ref object of PPassContext
    config: ConfigRef

proc verboseOpen(graph: ModuleGraph; s: PSym; idgen: IdGenerator): PPassContext =
  # xxx consider either removing this or keeping for documentation for how to add a pass
  result = VerboseRef(config: graph.config, idgen: idgen)

proc verboseProcess(context: PPassContext, n: PNode): PNode =
  # called from `process` in `processTopLevelStmt`.
  result = n
  let v = VerboseRef(context)
  message(v.config, n.info, hintProcessingStmt, $v.idgen[])

const verbosePass* = makePass(open = verboseOpen, process = verboseProcess)