mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
015c994c02
commit
614abcdeea
@ -60,9 +60,6 @@ goto *OP_LABELS[byte.op];
|
||||
__NEXT_STEP:;
|
||||
#if DEBUG_CEVAL_STEP
|
||||
_log_s_data();
|
||||
#endif
|
||||
#if DEBUG_CEVAL_STEP_MIN
|
||||
std::cout << OP_NAMES[byte.op] << std::endl;
|
||||
#endif
|
||||
switch (byte.op)
|
||||
{
|
||||
@ -113,7 +110,7 @@ __NEXT_STEP:;
|
||||
heap._auto_collect();
|
||||
_name = StrName(byte.arg);
|
||||
_0 = frame->_locals.try_get(_name);
|
||||
if(_0 != nullptr) { PUSH(_0); DISPATCH(); }
|
||||
if(_0 != PY_NULL) { PUSH(_0); DISPATCH(); }
|
||||
_0 = frame->f_closure_try_get(_name);
|
||||
if(_0 != nullptr) { PUSH(_0); DISPATCH(); }
|
||||
_0 = frame->f_globals().try_get(_name);
|
||||
|
@ -36,7 +36,6 @@
|
||||
#define DEBUG_EXTRA_CHECK 0
|
||||
#define DEBUG_DIS_EXEC 0
|
||||
#define DEBUG_CEVAL_STEP 0
|
||||
#define DEBUG_CEVAL_STEP_MIN 0
|
||||
#define DEBUG_FULL_EXCEPTION 0
|
||||
#define DEBUG_MEMORY_POOL 0
|
||||
#define DEBUG_NO_MEMORY_POOL 0
|
||||
@ -71,7 +70,7 @@
|
||||
#define PK_ENABLE_COMPUTED_GOTO 1
|
||||
#define UNREACHABLE() __builtin_unreachable()
|
||||
|
||||
#if DEBUG_CEVAL_STEP || DEBUG_CEVAL_STEP_MIN
|
||||
#if DEBUG_CEVAL_STEP
|
||||
#undef PK_ENABLE_COMPUTED_GOTO
|
||||
#endif
|
||||
|
||||
|
@ -49,10 +49,11 @@ struct FastLocals{
|
||||
|
||||
NameDict_ to_namedict(){
|
||||
NameDict_ dict = make_sp<NameDict>();
|
||||
// TODO: optimize this
|
||||
// NameDict.items() is expensive
|
||||
// TODO: optimize this, NameDict.items() is expensive
|
||||
for(auto& kv: varnames_inv->items()){
|
||||
dict->set(kv.first, a[kv.second]);
|
||||
PyObject* value = a[kv.second];
|
||||
if(value == PY_NULL) continue;
|
||||
dict->set(kv.first, value);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
8
tests/42_closure_ex.py
Normal file
8
tests/42_closure_ex.py
Normal file
@ -0,0 +1,8 @@
|
||||
def f(n):
|
||||
def g(x):
|
||||
if x==n:
|
||||
return n
|
||||
return g(x+1)
|
||||
return g(0)
|
||||
|
||||
assert f(10) == 10
|
Loading…
x
Reference in New Issue
Block a user