mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
1e89045f82
commit
07d8a520bf
@ -598,7 +598,6 @@ __NEXT_STEP:;
|
||||
TOP()->attr().set(_name, _0);
|
||||
DISPATCH();
|
||||
/*****************************************/
|
||||
// TODO: using "goto" inside with block may cause __exit__ not called
|
||||
TARGET(WITH_ENTER)
|
||||
call_method(POPX(), __enter__);
|
||||
DISPATCH();
|
||||
|
@ -497,7 +497,7 @@ struct CompExpr: Expr{
|
||||
ctx->emit(OP_FOR_ITER, BC_NOARG, BC_KEEPLINE);
|
||||
bool ok = vars->emit_store(ctx);
|
||||
// this error occurs in `vars` instead of this line, but...nevermind
|
||||
if(!ok) FATAL_ERROR(); // TODO: raise a SyntaxError instead
|
||||
PK_ASSERT(ok); // TODO: raise a SyntaxError instead
|
||||
if(cond){
|
||||
cond->emit(ctx);
|
||||
int patch = ctx->emit(OP_POP_JUMP_IF_FALSE, BC_NOARG, BC_KEEPLINE);
|
||||
|
10
src/frame.h
10
src/frame.h
@ -49,12 +49,10 @@ struct FastLocals{
|
||||
|
||||
NameDict_ to_namedict(){
|
||||
NameDict_ dict = make_sp<NameDict>();
|
||||
// TODO: optimize this, NameDict.items() is expensive
|
||||
for(auto& kv: varnames_inv->items()){
|
||||
PyObject* value = a[kv.second];
|
||||
if(value == PY_NULL) continue;
|
||||
dict->set(kv.first, value);
|
||||
}
|
||||
varnames_inv->apply([&](StrName name, int index){
|
||||
PyObject* value = a[index];
|
||||
if(value != PY_NULL) dict->set(name, value);
|
||||
});
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
@ -182,6 +182,14 @@ while(!_items[i].first.empty()) { \
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename __Func>
|
||||
void apply(__Func func) const {
|
||||
for(uint16_t i=0; i<_capacity; i++){
|
||||
if(_items[i].first.empty()) continue;
|
||||
func(_items[i].first, _items[i].second);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<StrName> keys() const {
|
||||
std::vector<StrName> v;
|
||||
for(uint16_t i=0; i<_capacity; i++){
|
||||
|
Loading…
x
Reference in New Issue
Block a user