From 9bfe8c1bade8f901f844605965bc9b481adaa51d Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 16 Mar 2024 15:55:53 +0800 Subject: [PATCH] some fix --- include/pocketpy/frame.h | 6 +++--- src/frame.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/pocketpy/frame.h b/include/pocketpy/frame.h index 90549026..b413bbec 100644 --- a/include/pocketpy/frame.h +++ b/include/pocketpy/frame.h @@ -11,15 +11,15 @@ namespace pkpy{ // weak reference fast locals struct FastLocals{ // this is a weak reference - const NameDictInt* varnames_inv; + const CodeObject* co; PyObject** a; - int size() const{ return varnames_inv->size();} + int size() const{ return co->varnames.size();} PyObject*& operator[](int i){ return a[i]; } PyObject* operator[](int i) const { return a[i]; } - FastLocals(const CodeObject* co, PyObject** a): varnames_inv(&co->varnames_inv), a(a) {} + FastLocals(const CodeObject* co, PyObject** a): co(co), a(a) {} PyObject** try_get_name(StrName name); NameDict_ to_namedict(); diff --git a/src/frame.cpp b/src/frame.cpp index 38b8c02f..e5b6300b 100644 --- a/src/frame.cpp +++ b/src/frame.cpp @@ -2,14 +2,14 @@ namespace pkpy{ PyObject** FastLocals::try_get_name(StrName name){ - int index = varnames_inv->try_get(name); + int index = co->varnames_inv.try_get(name); if(index == -1) return nullptr; return &a[index]; } NameDict_ FastLocals::to_namedict(){ NameDict_ dict = std::make_shared(); - varnames_inv->apply([&](StrName name, int index){ + co->varnames_inv.apply([&](StrName name, int index){ PyObject* value = a[index]; if(value != PY_NULL) dict->set(name, value); });