NAME

src/pmc/slice.pmc - Slice PMC

DESCRIPTION

These are the vtable functions for the slice PMC class.

A Slice PMC isa Key PMC, holding a chain of start and/or end values for slice ranges. Private flags define the meaning of the values:

  [ s .. e ]    s .. KEY_start_slice_FLAG; e .. KEY_end_slice_FLAG
  [ x,     ]    KEY_start_slice_FLAG | KEY_end_slice_FLAG
  [  .. e  ]    KEY_inf_slice_FLAG   | KEY_end_slice_FLAG
  [ s ..   ]    KEY_start_slice_FLAG | KEY_inf_slice_FLAG

Infinite ranges are currently implemented for Array and PerlString only.

Run

  $ parrot -d2000 slice.pasm

to see slice constant flags.

During initialization above key chain gets converted to parrot_range_t structures.

Methods

INTVAL get_integer()
Get the next integer key from the current slice range.
STRING *get_string()
Get the next string key from the current slice range.
PMC *slice(PMC *key)
PMC *get_iter()
A slice can serve as its own iterator, yielding values [start .. end-1]. This is used for implementing Pythons xrange()
PMC *nextkey_keyed(PMC *agg, INTVAL what)
Prepare slice PMC SELF for iteration over the passed aggregate or advance to next position in the range, depending on what.