write runtime object bootstrap
This commit is contained in:
@@ -13,32 +13,15 @@
|
||||
|
||||
ArgonObject *BASE_CLASS = NULL;
|
||||
|
||||
void init_base_field() {
|
||||
// add_field(BASE_CLASS, "test", BASE_CLASS);
|
||||
}
|
||||
|
||||
ArgonObject *init_child_argon_object(ArgonObject *cls) {
|
||||
ArgonObject *object = init_argon_class(NULL);
|
||||
object->self = object;
|
||||
object->baseObject = cls;
|
||||
add_field(object, "__call__", NULL);
|
||||
return object;
|
||||
}
|
||||
|
||||
ArgonObject *init_argon_class(char *name) {
|
||||
ArgonObject *new_object() {
|
||||
ArgonObject *object = ar_alloc(sizeof(ArgonObject));
|
||||
object->name = name;
|
||||
object->type = TYPE_OBJECT;
|
||||
object->self = object;
|
||||
object->classObject = ;
|
||||
object->baseObject = BASE_CLASS;
|
||||
object->fields = createHashmap_GC();
|
||||
memset(&object->value, 0, sizeof(object->value));
|
||||
object->dict = createHashmap_GC();
|
||||
add_field(object, "__class__", ARGON_TYPE_TYPE);
|
||||
return object;
|
||||
}
|
||||
|
||||
void add_field(ArgonObject *target, char *name, ArgonObject *object) {
|
||||
hashmap_insert_GC(target->fields,
|
||||
hashmap_insert_GC(target->dict,
|
||||
siphash64_bytes(name, strlen(name), siphash_key), name,
|
||||
object, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user