blueloveTH 1 год назад
Родитель
Сommit
c95c93499a
2 измененных файлов с 6 добавлено и 10 удалено
  1. 1 6
      include/pocketpy/common/vector.hpp
  2. 5 4
      src/compiler/compiler.cpp

+ 1 - 6
include/pocketpy/common/vector.hpp

@@ -224,6 +224,7 @@ struct vector {
         int n = end - begin;
         reserve(_size + n);
         uninitialized_copy_n(begin, n, _data + _size);
+        _size += n;
     }
 
     void insert(const T* it, const T& t) {
@@ -308,12 +309,6 @@ struct small_vector {
 
     [[nodiscard]] T* end() const { return _end; }
 
-    [[nodiscard]] T* rbegin() const { return _end - 1; }
-
-    [[nodiscard]] T* rend() const { return _begin - 1; }
-
-    [[nodiscard]] T& front() const { return *begin(); }
-
     [[nodiscard]] T& back() const { return *(end() - 1); }
 
     [[nodiscard]] T& operator[] (int index) { return _begin[index]; }

+ 5 - 4
src/compiler/compiler.cpp

@@ -1005,12 +1005,13 @@ void Compiler::consume_type_hints() {
 
 void Compiler::_add_decorators(const Expr_vector& decorators) {
     // [obj]
-    for(auto it = decorators.rbegin(); it != decorators.rend(); ++it) {
-        (*it)->emit_(ctx());                                // [obj, f]
-        ctx()->emit_(OP_ROT_TWO, BC_NOARG, (*it)->line);    // [f, obj]
+    for(int i=decorators.size()-1; i>=0; i--) {
+        int line = decorators[i]->line;
+        decorators[i]->emit_(ctx());                        // [obj, f]
+        ctx()->emit_(OP_ROT_TWO, BC_NOARG, line);           // [f, obj]
         ctx()->emit_(OP_LOAD_NULL, BC_NOARG, BC_KEEPLINE);  // [f, obj, NULL]
         ctx()->emit_(OP_ROT_TWO, BC_NOARG, BC_KEEPLINE);    // [obj, NULL, f]
-        ctx()->emit_(OP_CALL, 1, (*it)->line);              // [obj]
+        ctx()->emit_(OP_CALL, 1, line);                     // [obj]
     }
 }