passaux.nim 942 B

12345678910111213141516171819202122232425262728293031323334
  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. import std/objectdollar
  20. proc verboseProcess(context: PPassContext, n: PNode): PNode =
  21. # called from `process` in `processTopLevelStmt`.
  22. result = n
  23. let v = VerboseRef(context)
  24. message(v.config, n.info, hintProcessingStmt, $v.idgen[])
  25. const verbosePass* = makePass(open = verboseOpen, process = verboseProcess)