#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "objs/kite_object.h"
#include "kite_vm.h"
#include "kite_opcodes.h"
Defines | |
#define | KITE_EXECUTE_C |
Typedefs | |
typedef kite_opcode_t *(* | kite_opcode_func_t )(kite_thread_t *, kite_opcode_t *) |
Functions | |
void | kite_vm_call_method (kite_thread_t *thd, kite_object_t *obj, char *name, struct kite_object_t *args, int err) |
void | kite_vm_call_object (kite_thread_t *thd, struct kite_object_t *this, struct kite_object_t *method, struct kite_object_t *args) |
void | kite_vm_call_constructor (kite_thread_t *thd, struct kite_object_t *this, struct kite_object_t *args) |
int | kite_vm_call_operator (kite_thread_t *thd, struct kite_object_t *this, int op, struct kite_object_t *arg, int err) |
void | kite_vm_execute_exception (kite_thread_t *thd, int exit_now) |
void * | kite_vm_execute (void *ptr) |
void | kite_vm_execute_user_method (kite_thread_t *thd, void *pc) |
Variables | |
char * | OPERATOR_STRINGS [] |
char * | OPERATOR_NAME_STRINGS [] |
char * | OPERATOR_METHODS [] |
#define KITE_EXECUTE_C |
typedef kite_opcode_t*(* kite_opcode_func_t)(kite_thread_t *, kite_opcode_t *) |
void kite_vm_call_constructor | ( | kite_thread_t * | thd, | |
struct kite_object_t * | this, | |||
struct kite_object_t * | args | |||
) |
Call constructor on given object.
thd | The current thread. | |
this | The object to operate on. | |
args | A list containing the method arguments to pass in. |
References KITE_FIND_ANY_IN_SYMTAB, kite_list_count(), kite_vm_call_method(), kite_object_t::object_data, kite_object_t::properties, and TRUE.
Referenced by kite_new_instance_with_constructor().
void kite_vm_call_method | ( | kite_thread_t * | thd, | |
struct kite_object_t * | this, | |||
char * | name, | |||
struct kite_object_t * | args, | |||
int | err | |||
) |
Call method on given object.
thd | The current thread. | |
this | The object to operate on. | |
name | The name of the method to call. | |
args | A list containing the method arguments to pass in. | |
err | If 1, throw an exception if the method does not exist. |
References kite_object_t::builtin_data, kite_object_t::inherit_from, kite_dereference_object(), KITE_FIND_METHOD, kite_list_count(), kite_new_exception(), kite_new_list(), kite_new_string(), kite_reference_object(), kite_vm_call_method(), kite_vm_call_object(), kite_vm_call_operator(), kite_object_t::listvalue, kite_object_t::object_data, OP_METHOD_CALL, TRUE, kite_object_t::type, and kite_symtab_t::value.
Referenced by kite_boolean_object(), kite_dereference_and_load(), kite_float_object(), kite_gc_destroy_all(), kite_gc_incremental(), kite_int_object(), kite_string_object(), kite_vm_call_constructor(), kite_vm_call_method(), and kite_vm_call_operator().
void kite_vm_call_object | ( | kite_thread_t * | thd, | |
struct kite_object_t * | this, | |||
struct kite_object_t * | method, | |||
struct kite_object_t * | args | |||
) |
Call passed in method on given object.
thd | The current thread. | |
this | The object to operate on. | |
method | The method to run. | |
args | A list containing the method arguments to pass in. |
References kite_object_t::builtin_data, kite_symtab_t::docstring, FALSE, kite_funccall_info_t::file, kite_thread_t::func_stack, kite_function_t::funcptr, kite_function_t::functype, kite_object_t::funcvalue, kite_symtab_t::global, kite_object_t::inherit_from, kite_destruct_symtab(), kite_pop_stack(), kite_push_stack(), kite_reference_object(), kite_symtab_insert(), kite_top_stack(), kite_vm_execute_user_method(), kite_vm_push, kite_funccall_info_t::last_deref, kite_funccall_info_t::last_deref_obj, kite_symtab_t::left, kite_stack_t::length, kite_funccall_info_t::locals, kite_symtab_t::name, kite_stack_entry_t::obj, kite_object_t::object_data, kite_symtab_t::right, kite_stack_t::stack, kite_funccall_info_t::this, kite_object_t::type, and kite_symtab_t::value.
Referenced by kite_handle_signal(), kite_vm_call_method(), kite_vm_call_operator(), and kite_vm_execute().
int kite_vm_call_operator | ( | kite_thread_t * | thd, | |
struct kite_object_t * | this, | |||
int | op, | |||
struct kite_object_t * | args, | |||
int | err | |||
) |
Call operator on given object.
thd | The current thread. | |
this | The object to operate on. | |
op | The operator to call (see enum kite_operators). | |
args | A list containing the method arguments to pass in. | |
err | If 1, throw an exception if the operator does not exist. |
References kite_object_t::inherit_from, KITE_FIND_ANY_IN_SYMTAB, kite_new_exception(), kite_new_list(), kite_vm_call_method(), kite_vm_call_object(), kite_object_t::object_data, OP_TO_METHOD, OP_TO_STRING, kite_object_t::properties, TRUE, and kite_symtab_t::value.
Referenced by kite_vm_call_method().
void* kite_vm_execute | ( | void * | ptr | ) |
References kite_dereference_object(), kite_new_null(), kite_vm_call_object(), kite_vm_execute_exception(), kite_vm_pop, kite_stack_t::length, kite_thread_t::running_stack, kite_thread_t::start, and TRUE.
Referenced by kite_start_bytecode().
void kite_vm_execute_exception | ( | kite_thread_t * | thd, | |
int | exit_now | |||
) |
void kite_vm_execute_user_method | ( | kite_thread_t * | thd, | |
void * | pc | |||
) |
char* OPERATOR_METHODS[] |
Initial value:
{ "__op_plus__", "__op_minus__", "__op_multiply__", "__op_divide__", "__op_mod__", "__op_unplus__", "__op_unminus__", "__op_assign__", "__op_equals__", "__op_nequals__", "__op_lt__", "__op_gt__", "__op_leq__", "__op_geq__", "__op_and__", "__op_or__", "__op_not__", "__op_xor__", "__op_lshift__", "__op_rshift__", "__op_map__", "__op_reduce__", "__op_array__", "__op_call__", "__op_property__", "__op_number_of_operators__" }
char* OPERATOR_NAME_STRINGS[] |
Initial value:
{ "plus", "minus", "multiply", "divide", "mod", "unplus", "unminus", "assign", "equals", "nequals", "lt", "gt", "leq", "geq", "and", "or", "not", "xor", "lshift", "rshift", "map", "reduce", "array", "call", "property", "number_of_operators" }
char* OPERATOR_STRINGS[] |
Initial value:
{ "+", "-", "*", "/", "%", "unary +", "unary -", "=", "==", "!=", "<", ">", "<=", ">=", "and", "or", "not", "xor", "<<", ">>", "map", "reduce", "[]", "|", ".", NULL, }