# [MAIN] #default section name

# MMD_EQ ... MMD_STRCMP must be in one block
# see src/multidispatch.c

# INPLACE MMD variant must always be normal op + 1
# NOTE: VTABLE functions that modify their PMC must be marked with :write to
# work properly with the generational GC.

void init() :write
# init must be first for JITed vtable meths
void init_pmc(PMC* initializer) :write
PMC* instantiate(PMC* sig)
void morph(PMC* type) :write
void mark()
void destroy()
PMC* get_namespace()

INTVAL type()

STRING* name()

PMC* clone()
PMC* clone_pmc(PMC* args)

PMC* find_method(STRING* method_name)

[FETCH]
INTVAL get_integer()
INTVAL get_integer_keyed(PMC* key)
INTVAL get_integer_keyed_int(INTVAL key)
INTVAL get_integer_keyed_str(STRING* key)

FLOATVAL get_number()
FLOATVAL get_number_keyed(PMC* key)
FLOATVAL get_number_keyed_int(INTVAL key)
FLOATVAL get_number_keyed_str(STRING* key)

STRING* get_string()
STRING* get_repr()
STRING* get_string_keyed(PMC* key)
STRING* get_string_keyed_int(INTVAL key)
STRING* get_string_keyed_str(STRING* key)

INTVAL get_bool()

PMC* get_pmc()
PMC* get_pmc_keyed(PMC* key)
PMC* get_pmc_keyed_int(INTVAL key)
PMC* get_pmc_keyed_str(STRING* key)

void* get_pointer()
void* get_pointer_keyed(PMC* key)
void* get_pointer_keyed_int(INTVAL key)
void* get_pointer_keyed_str(STRING* key)

[STORE] :write
void set_integer_native(INTVAL value)
void set_integer_keyed(PMC* key, INTVAL value)
void set_integer_keyed_int(INTVAL key, INTVAL value)
void set_integer_keyed_str(STRING* key, INTVAL value)

void set_number_native(FLOATVAL value)
void set_number_keyed(PMC* key, FLOATVAL value)
void set_number_keyed_int(INTVAL key, FLOATVAL value)
void set_number_keyed_str(STRING* key, FLOATVAL value)

void set_string_native(STRING* value)
void assign_string_native(STRING* value)
void set_string_keyed(PMC* key, STRING* value)
void set_string_keyed_int(INTVAL key, STRING* value)
void set_string_keyed_str(STRING* key, STRING* value)

void set_bool(INTVAL value)

void set_pmc(PMC* value)
void assign_pmc(PMC* value)
void set_pmc_keyed(PMC* key, PMC* value)
void set_pmc_keyed_int(INTVAL key, PMC* value)
void set_pmc_keyed_str(STRING* key, PMC* value)

void set_pointer(void* value)
void set_pointer_keyed(PMC* key, void* value)
void set_pointer_keyed_int(INTVAL key, void* value)
void set_pointer_keyed_str(STRING* key, void* value)

[FETCHSIZE]
INTVAL elements()

[POP] :write
INTVAL pop_integer()
FLOATVAL pop_float()
STRING* pop_string()
PMC* pop_pmc()

[PUSH] :write
void push_integer(INTVAL value)
void push_float(FLOATVAL value)
void push_string(STRING* value)
void push_pmc(PMC* value)

[SHIFT] :write
INTVAL shift_integer()
FLOATVAL shift_float()
STRING* shift_string()
PMC* shift_pmc()

[UNSHIFT] :write
void unshift_integer(INTVAL value)
void unshift_float(FLOATVAL value)
void unshift_string(STRING* value)
void unshift_pmc(PMC* value)

## void splice ???

[SPLICE] :write
void splice(PMC* value, INTVAL offset, INTVAL count)

# XXX marking writing here?
[MATH]
PMC* add(PMC* value, PMC* dest)
PMC* add_int(INTVAL value, PMC* dest)
PMC* add_float(FLOATVAL value, PMC* dest)

void i_add(PMC* value) :write
void i_add_int(INTVAL value) :write
void i_add_float(FLOATVAL value) :write

PMC* subtract(PMC* value, PMC* dest)
PMC* subtract_int(INTVAL value, PMC* dest)
PMC* subtract_float(FLOATVAL value, PMC* dest)

void i_subtract(PMC* value) :write
void i_subtract_int(INTVAL value) :write
void i_subtract_float(FLOATVAL value) :write

PMC* multiply(PMC* value, PMC* dest)
PMC* multiply_int(INTVAL value, PMC* dest)
PMC* multiply_float(FLOATVAL value, PMC* dest)

void i_multiply(PMC* value) :write
void i_multiply_int(INTVAL value) :write
void i_multiply_float(FLOATVAL value) :write

PMC* divide(PMC* value, PMC* dest)
PMC* divide_int(INTVAL value, PMC* dest)
PMC* divide_float(FLOATVAL value, PMC* dest)

void i_divide(PMC* value) :write
void i_divide_int(INTVAL value) :write
void i_divide_float(FLOATVAL value) :write

PMC* floor_divide(PMC* value, PMC* dest)
PMC* floor_divide_int(INTVAL value, PMC* dest)
PMC* floor_divide_float(FLOATVAL value, PMC* dest)

void i_floor_divide(PMC* value) :write
void i_floor_divide_int(INTVAL value) :write
void i_floor_divide_float(FLOATVAL value) :write

PMC* modulus(PMC* value, PMC* dest)
PMC* modulus_int(INTVAL value, PMC* dest)
PMC* modulus_float(FLOATVAL value, PMC* dest)

void i_modulus(PMC* value) :write
void i_modulus_int(INTVAL value) :write
void i_modulus_float(FLOATVAL value) :write

void increment() :write
void decrement() :write

PMC* absolute(PMC* dest)
void i_absolute() :write

PMC* neg(PMC* dest)
void i_neg() :write

[CMP]
INTVAL is_equal(PMC* value)
INTVAL is_equal_num(PMC* value)
INTVAL is_equal_string(PMC* value)

INTVAL is_same(PMC* value)

INTVAL cmp(PMC* value)
INTVAL cmp_num(PMC* value)
INTVAL cmp_string(PMC* value)
PMC* cmp_pmc(PMC* value)

[STRING]
PMC* concatenate(PMC* value, PMC* dest)
PMC* concatenate_str(STRING* value, PMC* dest)

void i_concatenate(PMC* value) :write
void i_concatenate_str(STRING* value) :write

PMC* repeat(PMC* value, PMC* dest)
PMC* repeat_int(INTVAL value, PMC* dest)

void i_repeat(PMC* value) :write
void i_repeat_int(INTVAL value) :write

STRING* substr(INTVAL offset, INTVAL length)

[EXISTS]
INTVAL exists_keyed(PMC* key)
INTVAL exists_keyed_int(INTVAL key)
INTVAL exists_keyed_str(STRING* key)

[MAIN]
INTVAL defined()
INTVAL defined_keyed(PMC* key)
INTVAL defined_keyed_int(INTVAL key)
INTVAL defined_keyed_str(STRING* key)

[DELETE] :write
void delete_keyed(PMC* key)
void delete_keyed_int(INTVAL key)
void delete_keyed_str(STRING* key)

[MAIN]
PMC* get_iter()
INTVAL hashvalue()

opcode_t* invoke(void* next)

INTVAL does_pmc(PMC* role)
INTVAL does(STRING* role)

INTVAL isa_pmc(PMC* _class)
INTVAL isa(STRING* _class)

PMC* get_attr_str(STRING* idx)
PMC* get_attr_keyed(PMC* key, STRING* idx)
void set_attr_str(STRING* idx, PMC* value) :write
void set_attr_keyed(PMC* key, STRING* idx, PMC* value) :write

PMC* get_class()

void add_parent(PMC* parent) :write
void remove_parent(PMC* parent) :write

void add_role(PMC* role) :write
void remove_role(PMC* role) :write

void add_attribute(STRING* name, PMC* type) :write
void remove_attribute(STRING* name) :write

void add_method(STRING* method_name, PMC* sub_pmc) :write
void remove_method(STRING* method_name) :write

void add_vtable_override(STRING* vtable_name, PMC* sub_pmc) :write
void remove_vtable_override(STRING* vtable_name) :write

PMC* inspect()
PMC* inspect_str(STRING* what)

void freeze(PMC* info)
void thaw(PMC* info) :write
void thawfinish(PMC* info) :write
void visit(PMC* info)

void init_int(INTVAL initializer) :write
