arc: cursors for simple for loop variables (#15008)

* arc: cursors for simple for loop variables

* merged devel
This commit is contained in:
Andreas Rumpf 2020-07-17 15:24:36 +02:00 • committed by GitHub
commit d4984e069a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 7 deletions

View file

@ -1,6 +1,6 @@
discard """
output: '''("string here", 80)'''
cmd: '''nim c --gc:arc --expandArc:main --hint:Performance:off $file'''
cmd: '''nim c --gc:arc --expandArc:main --expandArc:sio --hint:Performance:off $file'''
nimout: '''--expandArc: main
var
@ -19,6 +19,24 @@ try:
:tmpD_2]
finally:
`=destroy`(:tmpD_2)
-- end of expandArc ------------------------
--expandArc: sio
block :tmp:
var x_cursor
var f = open("debug.txt", fmRead, 8000)
try:
var res
try:
res = TaintedString(newStringOfCap(80))
block :tmp_1:
while readLine(f, res):
x_cursor = res
echo [x_cursor]
finally:
`=destroy`(res)
finally:
close(f)
-- end of expandArc ------------------------'''
"""
@ -33,3 +51,10 @@ proc main(cond: bool) =
echo x
main(false)
proc sio =
for x in lines("debug.txt"):
echo x
if false:
sio()