write runtime object bootstrap

This commit is contained in:
2025-08-03 01:48:41 +01:00
parent a7d7ded803
commit 417d66faf3
15 changed files with 69 additions and 91 deletions

View File

@@ -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);
}