miscdollars.nim 584 B

12345678910111213141516
  1. template toLocation*(result: var string, file: string | cstring, line: int, col: int) =
  2. ## avoids spurious allocations
  3. # Hopefully this can be re-used everywhere so that if a user needs to customize,
  4. # it can be done in a single place.
  5. result.add file
  6. if line > 0:
  7. result.add "("
  8. # simplify this after moving moving `include strmantle` above import assertions`
  9. when declared(addInt): result.addInt line
  10. else: result.add $line
  11. if col > 0:
  12. result.add ", "
  13. when declared(addInt): result.addInt col
  14. else: result.add $col
  15. result.add ")"