NAME ^

classes/hash.pmc - Hash PMC

DESCRIPTION ^

These are the vtable functions for the Hash PMC.

Functions ^

*/

#include "parrot/parrot.h"

/* These are set in class_init */ static PMC* intret;

/*

static PMC *get_integer_pmc(Interp *interpreter, INTVAL base_type )

Lookup the PMC type which is used for storing native integers.

TODO: PMCs extending Hash should probably register themselves.

static PMC *get_none_pmc(Interp *interpreter, INTVAL base_type )

As PerlUndef and None are singleton PMCs, it is probably cheap to call pmc_new.

TODO: PMCs extending Hash should probably register themselves.

static PMC *get_number_pmc(Interp *interpreter, INTVAL base_type )

Lookup the PMC type which is used for floating point numbers.

TODO: PMCs extending Hash should probably register themselves.

static PMC *get_string_pmc(Interp *interpreter, INTVAL base_type )

Lookup the PMC type which is used for storing strings.

TODO: PMCs extending Hash should probably register themselves.

static STRING *make_hash_key(Interp *interpreter, PMC *key)

Returns a Parrot string for *key.

void class_init()

Class initialization. Allocates the memory for the hash. Sets up some global variables.

void *invoke(void *next)

Pythonic object constructor. SELF is a Hash Class object. Return a new dict object according to 2.1. Built-in Functions.

void init()

Initializes the instance. Creates a global Undef if it doesn't already exist.

void mark()

Marks the hash as live.

INTVAL type_keyed_str(STRING *key)

Returns the type of the element for *key.

INTVAL type_keyed (PMC *key)

Returns the type of the element for *key.

PMC *clone()

Creates and returns a clone of the hash.

INTVAL get_integer()

Returns the size of the hash.

INTVAL get_integer_keyed_str(STRING *key)

INTVAL get_integer_keyed_int(INTVAL key)

INTVAL get_integer_keyed(PMC *key)

Returns the integer value for the element at *key.

FLOATVAL get_number_keyed_str(STRING *key)

FLOATVAL get_number_keyed_int(INTVAL key)

FLOATVAL get_number_keyed(PMC *key)

Returns the floating-point value for the element at *key.

STRING *get_string()

Returns a string representation of the hash, showing its class name and memory address.

For Python returns its repr.

STRING *get_string_keyed_str(STRING *key)

STRING *get_string_keyed_int(INTVAL key)

STRING *get_string_keyed(PMC *key)

Returns the string value for the element at *key.

INTVAL get_bool()

Returns true if the hash size is not zero.

INTVAL elements()

Returns the number of elements in the hash.

PMC *get_pmc_keyed_str(STRING *key)

PMC *get_pmc_keyed_int(INTVAL key)

PMC *get_pmc_keyed(PMC *key)

Returns the PMC value for the element at *key.

INTVAL is_same(PMC *other)

Returns whether the hash is the same as *other.

void set_integer_keyed(PMC *key, INTVAL value)

void set_integer_keyed_str(STRING *key, INTVAL value)

void set_number_keyed (PMC *key, FLOATVAL value)

void set_number_keyed_str(STRING *key, FLOATVAL value)

Sets value as the value for *key.

void set_string_keyed(PMC *key, STRING *value)

void set_string_keyed_str(STRING *key, STRING *value)

void set_pmc_keyed(PMC *dest_key, PMC *value)

void set_pmc_keyed_str(STRING *key, PMC *value)

Sets *value as the value for *key.

INTVAL is_equal(PMC *value)

The == operation.

Check if two hashes hold the same keys and values.

INTVAL exists_keyed_str(STRING *key)

INTVAL exists_keyed(PMC *key)

Returns whether a key *key exists in the hash.

INTVAL defined_keyed_str(STRING *key)

INTVAL defined_keyed(PMC *key)

Returns whether the value for *key is defined.

void delete_keyed_str(STRING *key)

void delete_keyed(PMC *key)

Deletes the element associated with *key.

PMC *slice (PMC *key)

Return a new iterator for the slice PMC key

void visit(visit_info *info)

Used during archiving to visit the elements in the hash.

void freeze(visit_info *info)

Used to archive the hash.

void thaw(visit_info *info)

Used to unarchive the hash.

SEE ALSO ^

docs/pdds/pdd08_keys.pod.

POD ERRORS ^

Hey! The above document had some coding errors, which are explained below:

Around line 15:

You can't have =items (as at line 27) unless the first thing after the =over is an =item


parrot