passaux.nim 917 B

1234567891011121314151617181920212223242526272829303132
  1. #
  2. #
  3. # The Nim Compiler
  4. # (c) Copyright 2012 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. ## implements some little helper passes
  10. import
  11. ast, passes, msgs, options, lineinfos
  12. from modulegraphs import ModuleGraph, PPassContext
  13. type
  14. VerboseRef = ref object of PPassContext
  15. config: ConfigRef
  16. proc verboseOpen(graph: ModuleGraph; s: PSym; idgen: IdGenerator): PPassContext =
  17. # xxx consider either removing this or keeping for documentation for how to add a pass
  18. result = VerboseRef(config: graph.config, idgen: idgen)
  19. proc verboseProcess(context: PPassContext, n: PNode): PNode =
  20. # called from `process` in `processTopLevelStmt`.
  21. result = n
  22. let v = VerboseRef(context)
  23. message(v.config, n.info, hintProcessingStmt, $v.idgen[])
  24. const verbosePass* = makePass(open = verboseOpen, process = verboseProcess)