Take this Ceylon code:
{ for (x in foo) if (bar) for (y in baz) op(x, y) }
The compiler generates an anonymous AbstractIterable
class for this with a chain of boolean
"has thing" methods:
next()
(the only non-boolean
method) callsy()
to get the next element, if possibley()
checks$iterator$2
to request an iterator forbaz
, then gets the next item – if it exists,y
is set, elsey$exhausted$
is set$iterator$2()
checks if thex
iterator isn’t exhausted, if they
iterator exists and if it doesn’t, checks$next$1()
to see if it should generate another iterator$next$1()
checksx()
to see if it should even check the expression, then checks the expression (I abbreviated it below tobar
)x()
checks if the "root" iterator isn’t exhausted, and setsx
in that case
(read
result.java
from bottom to top)