#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <dlfcn.h>
#include "kite_object.h"
#include "kite_gc.h"
Defines | |
#define | NULL_OBJECT "System.null" |
#define | INTEGER_OBJECT "System.integer" |
#define | FLOAT_OBJECT "System.float" |
#define | STRING_OBJECT "System.string" |
#define | LIST_OBJECT "System.list" |
#define | METHOD_OBJECT "System.method" |
#define | BOOLEAN_OBJECT "System.boolean" |
Functions | |
kite_object_t * | kite_new_null (kite_thread_t *thd) |
kite_object_t * | kite_new_integer (kite_thread_t *thd, long val) |
kite_object_t * | kite_new_float (kite_thread_t *thd, double val) |
kite_object_t * | kite_new_string (kite_thread_t *thd, char *str) |
kite_object_t * | kite_new_string_with_length (kite_thread_t *thd, char *str, int len) |
kite_object_t * | kite_new_ident (kite_thread_t *thd, char *str) |
kite_object_t * | kite_new_list (kite_thread_t *thd) |
kite_object_t * | kite_new_boolean (kite_thread_t *thd, int val) |
kite_object_t * | kite_new_method_compiled (kite_thread_t *thd, kite_compiled_func_t ptr, int numargs) |
kite_object_t * | kite_new_method_compiled_with_docs (kite_thread_t *thd, kite_compiled_func_t ptr, char *doc, int numargs,...) |
kite_object_t * | kite_new_method_bytecode (kite_thread_t *thd, struct kite_opcode_t *ptr, int numargs) |
kite_object_t * | kite_new_method_bytecode_with_docs (kite_thread_t *thd, struct kite_opcode_t *ptr, char *doc, int numargs,...) |
kite_object_t * | kite_new_class (kite_thread_t *thd, kite_object_t *inherits, char *name) |
kite_object_t * | kite_new_instance (kite_thread_t *thd, kite_object_t *class) |
kite_object_t * | kite_new_instance_with_constructor (kite_thread_t *thd, kite_object_t *class, kite_object_t *args) |
kite_object_t * | kite_new_exception (kite_thread_t *thd, char *name, char *msg) |
void | kite_free_instruction_list (kite_thread_t *thd, struct kite_opcode_t *opc) |
void | kite_destruct_object_nofree (kite_thread_t *thd, kite_object_t **obj, int r) |
void | kite_finalize_object (void *obj, void *cd) |
void | kite_destruct_object (kite_thread_t *thd, kite_object_t **obj, int r) |
#define BOOLEAN_OBJECT "System.boolean" |
Referenced by kite_new_boolean().
#define FLOAT_OBJECT "System.float" |
Referenced by kite_new_float().
#define INTEGER_OBJECT "System.integer" |
Referenced by kite_new_integer().
#define LIST_OBJECT "System.list" |
Referenced by kite_new_list().
#define METHOD_OBJECT "System.method" |
Referenced by kite_new_method_bytecode(), and kite_new_method_compiled().
#define NULL_OBJECT "System.null" |
Referenced by kite_new_null().
#define STRING_OBJECT "System.string" |
Referenced by kite_new_string(), and kite_new_string_with_length().
void kite_destruct_object | ( | kite_thread_t * | , | |
kite_object_t ** | , | |||
int | ||||
) |
Destroy object.
References kite_destruct_object_nofree().
Referenced by kite_finalize_object(), and kite_gc_destroy_all().
void kite_destruct_object_nofree | ( | kite_thread_t * | , | |
kite_object_t ** | , | |||
int | ||||
) |
Destroy object.
References kite_object_t::builtin_data, kite_object_t::docstring, kite_function_t::funcptr, kite_function_t::functype, kite_object_t::funcvalue, kite_object_t::inherit_from, kite_dereference_object(), kite_destruct_symtab(), kite_free_instruction_list(), kite_list_remove(), kite_object_t::listvalue, kite_object_t::name, OBJ_BOOLEAN, OBJ_CLASS, OBJ_FLOAT, OBJ_IDENT, OBJ_INSTANCE, OBJ_INTEGER, OBJ_LIST, OBJ_METHOD, OBJ_STRING, kite_object_t::object_data, kite_object_t::properties, kite_object_t::stringvalue, and kite_object_t::type.
Referenced by kite_destruct_object(), and kite_gc_incremental().
void kite_finalize_object | ( | void * | , | |
void * | ||||
) |
Destroy object.
References kite_destruct_object().
Referenced by kite_new_class(), and kite_new_instance().
void kite_free_instruction_list | ( | kite_thread_t * | thd, | |
struct kite_opcode_t * | opc | |||
) |
Referenced by kite_destruct_object_nofree().
kite_object_t* kite_new_boolean | ( | kite_thread_t * | thd, | |
int | val | |||
) |
Create a new boolean object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References BOOLEAN_OBJECT, FALSE, kite_dereference_and_load(), kite_reference_object(), and TRUE.
Referenced by kite_boolean_object().
kite_object_t* kite_new_class | ( | kite_thread_t * | thd, | |
kite_object_t * | parent, | |||
char * | name | |||
) |
Create a new Kite class.
thd | The associated thread for this object. | |
parent | The class that this inherits from. | |
name | The new class' name. |
References kite_object_t::builtin_data, FALSE, kite_function_t::funcptr, kite_object_t::funcvalue, kite_object_t::inherit_from, kite_finalize_object(), kite_gc_incremental(), kite_list_add_end(), kite_reference_object(), kite_object_t::name, kite_object_t::object_data, and kite_object_t::type.
Referenced by kite_dereference_and_load(), and kite_new_ident().
kite_object_t* kite_new_exception | ( | kite_thread_t * | thd, | |
char * | name, | |||
char * | message | |||
) |
Create a new exception object.
thd | The thread to associate the exception with. | |
name | The fully-qualified name of the exception (e.g. System.exceptions.FileError) | |
message | The message to associate with the given exception. |
References kite_dereference_and_load(), kite_dereference_object(), kite_list_object(), kite_new_instance_with_constructor(), and kite_new_string().
Referenced by kite_dereference_and_load(), kite_vm_call_method(), and kite_vm_call_operator().
kite_object_t* kite_new_float | ( | kite_thread_t * | thd, | |
double | val | |||
) |
Create a new floating-point object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References FLOAT_OBJECT, and kite_dereference_and_load().
Referenced by kite_float_object().
kite_object_t* kite_new_ident | ( | kite_thread_t * | thd, | |
char * | val | |||
) |
Create a new identifier object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References kite_object_t::builtin_data, kite_symtab_t::global, KITE_FIND_ANY_IN_SYMTAB, kite_new_class(), kite_new_symtab(), kite_symtab_insert(), kite_symtab_t::name, kite_object_t::stringvalue, kite_object_t::type, and kite_symtab_t::value.
Referenced by kite_new_method_bytecode_with_docs(), and kite_new_method_compiled_with_docs().
kite_object_t* kite_new_instance | ( | kite_thread_t * | thd, | |
kite_object_t * | parent | |||
) |
Create a new Kite instance (without initialization)
thd | The associated thread for this object. | |
parent | The class that this instance is associated with. |
References kite_object_t::inherit_from, kite_finalize_object(), kite_gc_incremental(), kite_list_add_end(), kite_reference_object(), kite_object_t::name, kite_object_t::object_data, and kite_object_t::type.
Referenced by kite_new_instance_with_constructor(), kite_new_list(), kite_new_method_bytecode(), kite_new_method_compiled(), kite_new_null(), kite_new_string(), and kite_new_string_with_length().
kite_object_t* kite_new_instance_with_constructor | ( | kite_thread_t * | thd, | |
kite_object_t * | parent, | |||
kite_object_t * | args | |||
) |
Create a new Kite instance (with initialization)
thd | The associated thread for this object. | |
parent | The class that this instance is associated with. | |
args | A list specifying arguments to pass to the constructor. |
References kite_new_instance(), and kite_vm_call_constructor().
Referenced by kite_new_exception().
kite_object_t* kite_new_integer | ( | kite_thread_t * | thd, | |
long | val | |||
) |
Create a new integer object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References INTEGER_OBJECT, and kite_dereference_and_load().
Referenced by kite_handle_signal(), and kite_int_object().
kite_object_t* kite_new_list | ( | kite_thread_t * | thd | ) |
Create a new empty list object.
thd | The associated thread for the object. |
References kite_object_t::builtin_data, kite_dereference_and_load(), kite_new_instance(), LIST_OBJECT, kite_object_t::listvalue, and kite_object_t::type.
Referenced by kite_append_list(), kite_boolean_object(), kite_dereference_and_load(), kite_float_object(), kite_gc_destroy_all(), kite_gc_incremental(), kite_handle_signal(), kite_int_object(), kite_list_object(), kite_new_method_bytecode_with_docs(), kite_new_method_compiled_with_docs(), kite_string_object(), kite_vm_call_method(), and kite_vm_call_operator().
kite_object_t* kite_new_method_bytecode | ( | kite_thread_t * | thd, | |
struct kite_opcode_t * | func, | |||
int | numargs | |||
) |
Create a new method object (based on Kite bytecode).
thd | The associated thread for the object. | |
func | The C function that this method refers to. | |
numargs | The number of arguments this method should take in Kite code. |
References kite_object_t::builtin_data, kite_function_t::funcptr, kite_function_t::functype, kite_object_t::funcvalue, kite_dereference_and_load(), kite_new_instance(), METHOD_OBJECT, kite_function_t::numargs, and kite_object_t::type.
Referenced by kite_new_method_bytecode_with_docs().
kite_object_t* kite_new_method_bytecode_with_docs | ( | kite_thread_t * | thd, | |
struct kite_opcode_t * | func, | |||
char * | desc, | |||
int | numargs, | |||
... | ||||
) |
Create a new method object with documentation strings (based on Kite bytecode).
thd | The associated thread for the object. | |
func | The bytecode that this method refers to. | |
desc | The method's description. | |
numargs | The number of arguments this method should take in Kite code. | |
argname | (for each argument) The name of the argument. | |
argdesc | (for each argument) The description of the argument. |
References kite_append_list(), kite_new_ident(), kite_new_list(), kite_new_method_bytecode(), kite_set_arginfo(), and kite_set_docstring().
kite_object_t* kite_new_method_compiled | ( | kite_thread_t * | thd, | |
kite_compiled_func_t | func, | |||
int | numargs | |||
) |
Create a new method object (based on C-compiled code).
thd | The associated thread for the object. | |
func | The C function that this method refers to. | |
numargs | The number of arguments this method should take in Kite code. |
References kite_object_t::builtin_data, kite_function_t::funcptr, kite_function_t::functype, kite_object_t::funcvalue, kite_dereference_and_load(), kite_new_instance(), METHOD_OBJECT, kite_function_t::numargs, and kite_object_t::type.
Referenced by kite_new_method_compiled_with_docs().
kite_object_t* kite_new_method_compiled_with_docs | ( | kite_thread_t * | thd, | |
kite_compiled_func_t | func, | |||
char * | desc, | |||
int | numargs, | |||
... | ||||
) |
Create a new method object with documentation strings (based on C-compiled code).
thd | The associated thread for the object. | |
func | The C function that this method refers to. | |
desc | The method's description. | |
numargs | The number of arguments this method should take in Kite code. | |
argname | (for each argument) The name of the argument. | |
argdesc | (for each argument) The description of the argument. |
References kite_append_list(), kite_new_ident(), kite_new_list(), kite_new_method_compiled(), kite_set_arginfo(), and kite_set_docstring().
kite_object_t* kite_new_null | ( | kite_thread_t * | thd | ) |
Create a new null object.
thd | The associated thread for the object. |
References kite_dereference_and_load(), kite_new_instance(), kite_reference_object(), NULL_OBJECT, and kite_object_t::type.
Referenced by kite_handle_signal().
kite_object_t* kite_new_string | ( | kite_thread_t * | thd, | |
char * | val | |||
) |
Create a new string object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References kite_object_t::builtin_data, kite_dereference_and_load(), kite_new_instance(), STRING_OBJECT, kite_object_t::stringvalue, and kite_object_t::type.
Referenced by kite_new_exception(), kite_object_name(), kite_string_object(), and kite_vm_call_method().
kite_object_t* kite_new_string_with_length | ( | kite_thread_t * | thd, | |
char * | val, | |||
int | length | |||
) |
Create a new string object (with given length).
thd | The associated thread for the object. | |
val | The value to associate with the object. | |
length | The length of the string. |
References kite_object_t::builtin_data, kite_dereference_and_load(), KITE_GET_STRING_VALUE, kite_new_instance(), STRING_OBJECT, kite_object_t::stringvalue, and kite_object_t::type.