From a21765a9ca314c624cd9968ef22e109da8754c81 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 5 Jun 2025 19:57:14 +0800 Subject: [PATCH] backup --- src/interpreter/ceval.c | 6 +++--- src/interpreter/vm.c | 6 +++--- src/modules/pickle.c | 4 ++-- src/public/modules.c | 6 +++--- src/public/py_mappingproxy.c | 2 +- src/public/stack_ops.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/interpreter/ceval.c b/src/interpreter/ceval.c index eaafc958..0921392f 100644 --- a/src/interpreter/ceval.c +++ b/src/interpreter/ceval.c @@ -902,7 +902,7 @@ FrameResult VM__run_top_frame(VM* self) { case OP_POP_IMPORT_STAR: { // [module] NameDict* dict = PyObject__dict(TOP()->_obj); - py_Ref all = NameDict__try_get(dict, __all__); + py_ItemRef all = NameDict__try_get(dict, __all__); if(all) { py_TValue* p; int length = pk_arrayview(all, &p); @@ -912,7 +912,7 @@ FrameResult VM__run_top_frame(VM* self) { } for(int i = 0; i < length; i++) { py_Name name = py_namev(py_tosv(p + i)); - py_Ref value = NameDict__try_get(dict, name); + py_ItemRef value = NameDict__try_get(dict, name); if(value == NULL) { ImportError("cannot import name '%n'", name); goto __ERROR; @@ -921,7 +921,7 @@ FrameResult VM__run_top_frame(VM* self) { } } } else { - for(int i = 0; i < dict->length; i++) { + for(int i = 0; i < dict->capacity; i++) { NameDict_KV* kv = &dict->items[i]; if(kv->key == NULL) continue; c11_sv name = py_name2sv(kv->key); diff --git a/src/interpreter/vm.c b/src/interpreter/vm.c index 3afe0c70..bc6ba8ad 100644 --- a/src/interpreter/vm.c +++ b/src/interpreter/vm.c @@ -678,9 +678,9 @@ void ManagedHeap__mark(ManagedHeap* self) { for(int i = 0; i < obj->slots; i++) pk__mark_value(p + i); } else if(obj->slots == -1) { - NameDict* namedict = PyObject__dict(obj); - for(int i = 0; i < namedict->length; i++) { - NameDict_KV* kv = &namedict->items[i]; + NameDict* dict = PyObject__dict(obj); + for(int i = 0; i < dict->capacity; i++) { + NameDict_KV* kv = &dict->items[i]; if(kv->key == NULL) continue; pk__mark_value(&kv->value); } diff --git a/src/modules/pickle.c b/src/modules/pickle.c index 8752a09a..b9e2e6e3 100644 --- a/src/modules/pickle.c +++ b/src/modules/pickle.c @@ -374,7 +374,7 @@ static bool pkl__write_object(PickleObject* buf, py_TValue* obj) { } if(ti->is_python) { NameDict* dict = PyObject__dict(obj->_obj); - for(int i = dict->length - 1; i >= 0; i--) { + for(int i = dict->capacity - 1; i >= 0; i--) { NameDict_KV* kv = &dict->items[i]; if(kv->key == NULL) continue; if(!pkl__write_object(buf, &kv->value)) return false; @@ -383,7 +383,7 @@ static bool pkl__write_object(PickleObject* buf, py_TValue* obj) { pkl__emit_int(buf, obj->type); buf->used_types[obj->type] = true; pkl__emit_int(buf, dict->length); - for(int i = 0; i < dict->length; i++) { + for(int i = 0; i < dict->capacity; i++) { NameDict_KV* kv = &dict->items[i]; if(kv->key == NULL) continue; c11_sv field = py_name2sv(kv->key); diff --git a/src/public/modules.c b/src/public/modules.c index 05a2a0ed..14c1431d 100644 --- a/src/public/modules.c +++ b/src/public/modules.c @@ -764,9 +764,9 @@ void function__gc_mark(void* ud, c11_vector* p_stack) { Function* func = ud; if(func->globals) pk__mark_value(func->globals); if(func->closure) { - NameDict* namedict = func->closure; - for(int i = 0; i < namedict->length; i++) { - NameDict_KV* kv = &namedict->items[i]; + NameDict* dict = func->closure; + for(int i = 0; i < dict->capacity; i++) { + NameDict_KV* kv = &dict->items[i]; if(kv->key == NULL) continue; pk__mark_value(&kv->value); } diff --git a/src/public/py_mappingproxy.c b/src/public/py_mappingproxy.c index 51903051..ff747244 100644 --- a/src/public/py_mappingproxy.c +++ b/src/public/py_mappingproxy.c @@ -52,7 +52,7 @@ static bool namedict_items(int argc, py_Ref argv) { py_Ref object = py_getslot(argv, 0); NameDict* dict = PyObject__dict(object->_obj); py_newlist(py_retval()); - for(int i = 0; i < dict->length; i++) { + for(int i = 0; i < dict->capacity; i++) { py_Ref slot = py_list_emplace(py_retval()); py_Ref p = py_newtuple(slot, 2); NameDict_KV* kv = &dict->items[i]; diff --git a/src/public/stack_ops.c b/src/public/stack_ops.c index c621b80a..db34c0a6 100644 --- a/src/public/stack_ops.c +++ b/src/public/stack_ops.c @@ -26,7 +26,7 @@ py_ItemRef py_emplacedict(py_Ref self, py_Name name) { bool py_applydict(py_Ref self, bool (*f)(py_Name, py_Ref, void*), void* ctx) { assert(self && self->is_ptr); NameDict* dict = PyObject__dict(self->_obj); - for(int i = 0; i < dict->length; i++) { + for(int i = 0; i < dict->capacity; i++) { NameDict_KV* kv = &dict->items[i]; if(kv->key == NULL) continue; bool ok = f(kv->key, &kv->value, ctx);