|
|
@@ -112,46 +112,60 @@ template<> inline void gc_mark<Function>(Function& t){
|
|
|
t._closure._gc_mark();
|
|
|
}
|
|
|
|
|
|
-struct ValueStack {
|
|
|
- PyObject** _begin;
|
|
|
- PyObject** _sp;
|
|
|
-
|
|
|
- ValueStack(int n=16): _begin((PyObject**)pool128.alloc(n * sizeof(void*))), _sp(_begin) { }
|
|
|
-
|
|
|
- PyObject*& top(){ return _sp[-1]; }
|
|
|
- PyObject* top() const { return _sp[-1]; }
|
|
|
- PyObject*& second(){ return _sp[-2]; }
|
|
|
- PyObject* second() const { return _sp[-2]; }
|
|
|
- PyObject*& peek(int n){ return _sp[-n]; }
|
|
|
- PyObject* peek(int n) const { return _sp[-n]; }
|
|
|
- void push(PyObject* v){ *_sp++ = v; }
|
|
|
- void pop(){ --_sp; }
|
|
|
- PyObject* popx(){ return *--_sp; }
|
|
|
- ArgsView view(int n){ return ArgsView(_sp-n, _sp); }
|
|
|
- void shrink(int n){ _sp -= n; }
|
|
|
- int size() const { return _sp - _begin; }
|
|
|
- bool empty() const { return _sp == _begin; }
|
|
|
- PyObject** begin() const { return _begin; }
|
|
|
- PyObject** end() const { return _sp; }
|
|
|
- void resize(int n) { _sp = _begin + n; }
|
|
|
-
|
|
|
- ValueStack(ValueStack&& other) noexcept{
|
|
|
- _begin = other._begin;
|
|
|
- _sp = other._sp;
|
|
|
- other._begin = nullptr;
|
|
|
- }
|
|
|
-
|
|
|
- ValueStack& operator=(ValueStack&& other) noexcept{
|
|
|
- if(_begin != nullptr) pool128.dealloc(_begin);
|
|
|
- _begin = other._begin;
|
|
|
- _sp = other._sp;
|
|
|
- other._begin = nullptr;
|
|
|
- return *this;
|
|
|
- }
|
|
|
-
|
|
|
- ~ValueStack(){ if(_begin!=nullptr) pool128.dealloc(_begin); }
|
|
|
+struct ValueStack: pod_vector<PyObject*> {
|
|
|
+ PyObject*& top(){ return back(); }
|
|
|
+ PyObject* top() const { return back(); }
|
|
|
+ PyObject*& second(){ return (*this)[size()-2]; }
|
|
|
+ PyObject* second() const { return (*this)[size()-2]; }
|
|
|
+ PyObject*& peek(int n){ return (*this)[size()-n]; }
|
|
|
+ PyObject* peek(int n) const { return (*this)[size()-n]; }
|
|
|
+ void push(PyObject* v){ push_back(v); }
|
|
|
+ void pop(){ pop_back(); }
|
|
|
+ PyObject* popx(){ return popx_back(); }
|
|
|
+ ArgsView view(int n){ return ArgsView(end()-n, end()); }
|
|
|
+ void shrink(int n){ resize(size() - n); }
|
|
|
};
|
|
|
|
|
|
+// struct ValueStack {
|
|
|
+// PyObject** _begin;
|
|
|
+// PyObject** _sp;
|
|
|
+
|
|
|
+// ValueStack(int n=16): _begin((PyObject**)pool128.alloc(n * sizeof(void*))), _sp(_begin) { }
|
|
|
+
|
|
|
+// PyObject*& top(){ return _sp[-1]; }
|
|
|
+// PyObject* top() const { return _sp[-1]; }
|
|
|
+// PyObject*& second(){ return _sp[-2]; }
|
|
|
+// PyObject* second() const { return _sp[-2]; }
|
|
|
+// PyObject*& peek(int n){ return _sp[-n]; }
|
|
|
+// PyObject* peek(int n) const { return _sp[-n]; }
|
|
|
+// void push(PyObject* v){ *_sp++ = v; }
|
|
|
+// void pop(){ --_sp; }
|
|
|
+// PyObject* popx(){ return *--_sp; }
|
|
|
+// ArgsView view(int n){ return ArgsView(_sp-n, _sp); }
|
|
|
+// void shrink(int n){ _sp -= n; }
|
|
|
+// int size() const { return _sp - _begin; }
|
|
|
+// bool empty() const { return _sp == _begin; }
|
|
|
+// PyObject** begin() const { return _begin; }
|
|
|
+// PyObject** end() const { return _sp; }
|
|
|
+// void resize(int n) { _sp = _begin + n; }
|
|
|
+
|
|
|
+// ValueStack(ValueStack&& other) noexcept{
|
|
|
+// _begin = other._begin;
|
|
|
+// _sp = other._sp;
|
|
|
+// other._begin = nullptr;
|
|
|
+// }
|
|
|
+
|
|
|
+// ValueStack& operator=(ValueStack&& other) noexcept{
|
|
|
+// if(_begin != nullptr) pool128.dealloc(_begin);
|
|
|
+// _begin = other._begin;
|
|
|
+// _sp = other._sp;
|
|
|
+// other._begin = nullptr;
|
|
|
+// return *this;
|
|
|
+// }
|
|
|
+
|
|
|
+// ~ValueStack(){ if(_begin!=nullptr) pool128.dealloc(_begin); }
|
|
|
+// };
|
|
|
+
|
|
|
struct Frame {
|
|
|
int _ip = -1;
|
|
|
int _next_ip = 0;
|