topt_cursor.nim 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. discard """
  2. output: '''("string here", 80)'''
  3. cmd: '''nim c --gc:arc --expandArc:main --expandArc:sio --hint:Performance:off $file'''
  4. nimout: '''--expandArc: main
  5. var
  6. :tmpD
  7. :tmpD_1
  8. :tmpD_2
  9. try:
  10. var x_cursor = ("hi", 5)
  11. x_cursor = if cond:
  12. :tmpD = ("different", 54)
  13. :tmpD else:
  14. :tmpD_1 = ("string here", 80)
  15. :tmpD_1
  16. echo [
  17. :tmpD_2 = `$`(x_cursor)
  18. :tmpD_2]
  19. finally:
  20. `=destroy`(:tmpD_2)
  21. -- end of expandArc ------------------------
  22. --expandArc: sio
  23. block :tmp:
  24. var x_cursor
  25. var f = open("debug.txt", fmRead, 8000)
  26. try:
  27. var res
  28. try:
  29. res = TaintedString(newStringOfCap(80))
  30. block :tmp_1:
  31. while readLine(f, res):
  32. x_cursor = res
  33. echo [x_cursor]
  34. finally:
  35. `=destroy`(res)
  36. finally:
  37. close(f)
  38. -- end of expandArc ------------------------'''
  39. """
  40. proc main(cond: bool) =
  41. var x = ("hi", 5) # goal: computed as cursor
  42. x = if cond:
  43. ("different", 54)
  44. else:
  45. ("string here", 80)
  46. echo x
  47. main(false)
  48. proc sio =
  49. for x in lines("debug.txt"):
  50. echo x
  51. if false:
  52. sio()