parrotcode: Iterator PMC | |
Contents | PMCs |
src/pmc/iterator.pmc - Iterator PMC
These are the vtable functions for the Iterator base class. Iterators are used in combination with other classes(mainly aggregates) to visit all entries in that aggregate.
.local pmc iterator, array, entry
iterator = new 'Iterator', array
iter_loop:
unless iterator, iter_end # while (more values)
entry = shift iterator # get an entry
...
goto iter_loop
iter_end:
The new
can alteratively be written as:
iterator = iter array
.local pmc iterator, array, entry
iterator = new 'Iterator', array
iterator = .ITERATE_FROM_END
iter_loop:
unless iterator, iter_end # while (more values)
entry = pop iterator # get an entry
...
goto iter_loop
iter_end:
.local pmc iterator, hash, key, entry
iterator = new 'Iterator', hash
iter_loop:
unless iterator, iter_end # while (more values)
key = shift iterator # get the key..
entry = hash[key]
...
goto iter_loop
iter_end:
void init()
init_pmc()
.void init_pmc(PMC *initializer)
void mark()
PMC *clone()
INTVAL get_integer()
STRING *get_string()
INTVAL get_integer_keyed(PMC *key)
INTVAL get_integer_keyed_int(INTVAL idx)
FLOATVAL get_number_keyed(PMC *key)
FLOATVAL get_number_keyed_int(INTVAL idx)
STRING *get_string_keyed(PMC *key)
STRING *get_string_keyed_int(INTVAL idx)
INTVAL get_bool()
-1
.INTVAL elements()
PMC *get_pmc_keyed(PMC *key)
*key
.PMC *get_pmc_keyed_int(INTVAL key)
key
.void set_integer_native(INTVAL value)
value
must be one of ITERATE_FROM_START ... Iterate from start
ITERATE_FROM_START_KEYS ... OrderedHash by keys
ITERATE_FROM_END ... Arrays and PerlString only
INTVAL pop_integer()
FLOATVAL pop_float()
STRING *pop_string()
PMC *pop_pmc()
INTVAL shift_integer()
opcode_t *invoke(void *next)
FLOATVAL shift_float()
STRING *shift_string()
PMC *shift_pmc()
INTVAL exists_keyed(PMC *key)
*key
exists in the aggregate.INTVAL exists_keyed_int(INTVAL idx)
idx
exists in the aggregate.INTVAL defined()
INTVAL defined_keyed(PMC *key)
INTVAL defined_keyed_int(INTVAL key)
defined_keyed(key)
on the aggregate.INTVAL type_keyed(PMC *key)
type_keyed(key)
on the aggregate.INTVAL type_keyed_int(PMC *idx)
type_keyed(key)
on the aggregate.
|