NAME

src/pmc/iterator.pmc - Iterator PMC

DESCRIPTION

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.

SYNOPSIS

default usage

    .local pmc iterator, array, entry
    iterator = iter array
  iter_loop:
    unless iterator, iter_end  # while (more values)
    entry = shift iterator     # get an entry
    ...
    goto iter_loop
  iter_end:

iterate from the end, for arrays

    .local pmc iterator, array, entry
    iterator = iter 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:

iterate over a hash

    .local pmc iterator, hash, key, entry
    iterator = iter hash
  iter_loop:
    unless iterator, iter_end  # while (more values)
    key   = shift iterator     # get the key..
    entry = hash[key]
    ...
    goto iter_loop
  iter_end:

Methods

void init()
Raises an exception. Use init_pmc().
void init_pmc(PMC *initializer)
Initializes the iterator with an aggregate PMC. Defaults iteration mode to iterate from start.
INTVAL get_integer_keyed(PMC *key)
FLOATVAL get_number_keyed(PMC *key)
STRING *get_string_keyed(PMC *key)
PMC *get_pmc_keyed(PMC *key)
Returns the element for *key.
INTVAL exists_keyed(PMC *key)
Returns whether an element for *key exists in the aggregate.
INTVAL defined()
Returns whether the iterator contains an aggregate.
INTVAL defined_keyed(PMC *key)
void set_integer_native(INTVAL value)
Restart iterator