mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some fix
This commit is contained in:
parent
63e869df0c
commit
9bfe8c1bad
@ -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();
|
||||
|
@ -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<NameDict>();
|
||||
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);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user