This commit is contained in:
blueloveTH 2023-01-09 02:13:53 +08:00
parent 52a51483fb
commit 7ae1928981
4 changed files with 17 additions and 17 deletions

View File

@ -3874,17 +3874,17 @@ public:
return v; return v;
} }
inline void __deref(VM*, PyVar&); inline void try_deref(VM*, PyVar&);
inline PyVar popValue(VM* vm){ inline PyVar popValue(VM* vm){
PyVar value = __pop(); PyVar value = __pop();
__deref(vm, value); try_deref(vm, value);
return value; return value;
} }
inline PyVar topValue(VM* vm){ inline PyVar topValue(VM* vm){
PyVar value = __top(); PyVar value = __top();
__deref(vm, value); try_deref(vm, value);
return value; return value;
} }
@ -3895,7 +3895,7 @@ public:
inline PyVar __topValueN(VM* vm, int n=-1){ inline PyVar __topValueN(VM* vm, int n=-1){
PyVar value = s_data[s_data.size() + n]; PyVar value = s_data[s_data.size() + n];
__deref(vm, value); try_deref(vm, value);
return value; return value;
} }
@ -3935,7 +3935,7 @@ public:
pkpy::ArgList v(n); pkpy::ArgList v(n);
for(int i=n-1; i>=0; i--){ for(int i=n-1; i>=0; i--){
v._index(i) = std::move(s_data[new_size + i]); v._index(i) = std::move(s_data[new_size + i]);
__deref(vm, v._index(i)); try_deref(vm, v._index(i));
} }
s_data.resize(new_size); s_data.resize(new_size);
return v; return v;
@ -4038,7 +4038,7 @@ protected:
if(!items[i]->isType(_tp_ref)) { if(!items[i]->isType(_tp_ref)) {
done = true; done = true;
PyVarList values = items.toList(); PyVarList values = items.toList();
for(int j=i; j<values.size(); j++) frame->__deref(this, values[j]); for(int j=i; j<values.size(); j++) frame->try_deref(this, values[j]);
frame->push(PyTuple(values)); frame->push(PyTuple(values));
break; break;
} }
@ -4223,7 +4223,7 @@ protected:
} break; } break;
case OP_FOR_ITER: case OP_FOR_ITER:
{ {
// __top() must be PyIter, so no need to __deref() // __top() must be PyIter, so no need to try_deref()
auto& it = PyIter_AS_C(frame->__top()); auto& it = PyIter_AS_C(frame->__top());
if(it->hasNext()){ if(it->hasNext()){
PyRef_AS_C(it->var)->set(this, frame, it->next()); PyRef_AS_C(it->var)->set(this, frame, it->next());
@ -5029,7 +5029,7 @@ void TupleRef::del(VM* vm, Frame* frame) const{
} }
/***** Frame's Impl *****/ /***** Frame's Impl *****/
inline void Frame::__deref(VM* vm, PyVar& v){ inline void Frame::try_deref(VM* vm, PyVar& v){
if(v->isType(vm->_tp_ref)) v = vm->PyRef_AS_C(v)->get(vm, this); if(v->isType(vm->_tp_ref)) v = vm->PyRef_AS_C(v)->get(vm, this);
} }

@ -1 +1 @@
Subproject commit f3f4cdf6ceeaad710e1b376ee1f6c739cb48b125 Subproject commit 02647b679b993663b4e1919db6e5e40d45e8ed99

View File

@ -194,17 +194,17 @@ public:
return v; return v;
} }
inline void __deref(VM*, PyVar&); inline void try_deref(VM*, PyVar&);
inline PyVar popValue(VM* vm){ inline PyVar popValue(VM* vm){
PyVar value = __pop(); PyVar value = __pop();
__deref(vm, value); try_deref(vm, value);
return value; return value;
} }
inline PyVar topValue(VM* vm){ inline PyVar topValue(VM* vm){
PyVar value = __top(); PyVar value = __top();
__deref(vm, value); try_deref(vm, value);
return value; return value;
} }
@ -215,7 +215,7 @@ public:
inline PyVar __topValueN(VM* vm, int n=-1){ inline PyVar __topValueN(VM* vm, int n=-1){
PyVar value = s_data[s_data.size() + n]; PyVar value = s_data[s_data.size() + n];
__deref(vm, value); try_deref(vm, value);
return value; return value;
} }
@ -255,7 +255,7 @@ public:
pkpy::ArgList v(n); pkpy::ArgList v(n);
for(int i=n-1; i>=0; i--){ for(int i=n-1; i>=0; i--){
v._index(i) = std::move(s_data[new_size + i]); v._index(i) = std::move(s_data[new_size + i]);
__deref(vm, v._index(i)); try_deref(vm, v._index(i));
} }
s_data.resize(new_size); s_data.resize(new_size);
return v; return v;

View File

@ -87,7 +87,7 @@ protected:
if(!items[i]->isType(_tp_ref)) { if(!items[i]->isType(_tp_ref)) {
done = true; done = true;
PyVarList values = items.toList(); PyVarList values = items.toList();
for(int j=i; j<values.size(); j++) frame->__deref(this, values[j]); for(int j=i; j<values.size(); j++) frame->try_deref(this, values[j]);
frame->push(PyTuple(values)); frame->push(PyTuple(values));
break; break;
} }
@ -272,7 +272,7 @@ protected:
} break; } break;
case OP_FOR_ITER: case OP_FOR_ITER:
{ {
// __top() must be PyIter, so no need to __deref() // __top() must be PyIter, so no need to try_deref()
auto& it = PyIter_AS_C(frame->__top()); auto& it = PyIter_AS_C(frame->__top());
if(it->hasNext()){ if(it->hasNext()){
PyRef_AS_C(it->var)->set(this, frame, it->next()); PyRef_AS_C(it->var)->set(this, frame, it->next());
@ -1078,7 +1078,7 @@ void TupleRef::del(VM* vm, Frame* frame) const{
} }
/***** Frame's Impl *****/ /***** Frame's Impl *****/
inline void Frame::__deref(VM* vm, PyVar& v){ inline void Frame::try_deref(VM* vm, PyVar& v){
if(v->isType(vm->_tp_ref)) v = vm->PyRef_AS_C(v)->get(vm, this); if(v->isType(vm->_tp_ref)) v = vm->PyRef_AS_C(v)->get(vm, this);
} }