Don't return a Values iterator from detach_secondary_results().

Instead, just return the first of the detached values, and provide a
next_secondary_result() method for traversing the list.

This is equivalent to how detach_ebb_args() works, and it allows the
data flow graph to be modified while traversing the list of results.
This commit is contained in:
Jakob Stoklund Olesen
2017-03-15 15:38:47 -07:00
parent 765c866971
commit 89f45a5c82
2 changed files with 31 additions and 15 deletions

View File

@@ -90,10 +90,17 @@ def unwrap_inst(iref, node, fmt):
for d in node.defs[1:]:
fmt.line('let src_{};'.format(d))
with fmt.indented('{', '}'):
fmt.line('let mut vals = dfg.detach_secondary_results(inst);')
for d in node.defs[1:]:
fmt.line('src_{} = vals.next().unwrap();'.format(d))
fmt.line('assert_eq!(vals.next(), None);')
fmt.line(
'src_{} = dfg.detach_secondary_results(inst).unwrap();'
.format(node.defs[1]))
for i in range(2, len(node.defs)):
fmt.line(
'src_{} = dfg.next_secondary_result(src_{})'
'.unwrap();'
.format(node.defs[i], node.defs[i - 1]))
fmt.line(
'assert_eq!(dfg.next_secondary_result(src_{}), None);'
.format(node.defs[-1]))
for d in node.defs[1:]:
if d.has_free_typevar():
fmt.line(