Can't yield item from ValueRef iterator.
See original GitHub issueStore instruction in llvm ir. i would like to get second operand. “<pointer>” by using next function. but how many use next. it always return first operand. python for clause works. but next function doesn’t work.
I did something wrong? my test code like this.
def applyConstraint(instruction: llvm.ValueRef):
	if instruction.opcode == 'store':
		print(instruction.operands.next())
		print(instruction.operands.next())
		for i in instruction.operands:
			print(i)
Issue Analytics
- State:
 - Created 3 years ago
 - Comments:6 (3 by maintainers)
 
Top Results From Across the Web
Why can't iterator methods take either 'ref' or 'out' parameters?
C# iterators are state machines internally. Every time you yield return something, the place where you left off should be saved along with ......
Read more >yield statement - provide the next element in an iterator
Use the yield statement in iterators to provide the next value or signal the end of an iteration.
Read more >C#: IEnumerable, yield return, and lazy evaluation
An iterator is a method that uses the yield return keywords. yield return is ... First() to try to find a specific item...
Read more >Python Yield - What does the yield keyword do? | ML+
Adding yield keyword to a function will make the function return a ... You can then iterate through the generator to extract items....
Read more >Python Yield vs Return - Initial Commit
An iterator in Python is an object to which you can apply the __next__() method to and iterate through it. We can turn...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I appreciate your answer!
Thanks for the details - I can now see the issue. When you call
instruction.operands.next(),instruction.operandsgives you a new_OperandsIterator- so when you callnext()on it, you get the first operand. When you then doinstruction.operands.next()on the following line,instruction.operandsgives a new_OperandsIteratoragain, so callingnext()on it gives you the first operand again.Your code:
written using
next()instead could look like this to accomplish what you were originally trying to do:With your
simple2.llfile, this gives me the output: