Commits

stepahn committed 2990200

removed resizable stack code

Comments (0)

Files changed (3)

js/execution_context.py

         self._variable_environment_ = None
         self._this_binding_ = None
         self._refs_ = [None] * refs_size
-        self._init_stack_(size=stack_size, resize=False)
+        self._init_stack_(stack_size)
 
     def stack_append(self, value):
         self._stack_append(value)
     def __init__(self):
         self._init_stack_()
 
-    def _init_stack_(self, size=1, resize=True):
+    def _init_stack_(self, size=1):
         self._stack_ = [None] * size
         self._stack_pointer_ = 0
-        self._stack_resize_ = resize
 
     def _stack_pointer(self):
         return jit.promote(self._stack_pointer_)
         i = self._stack_pointer()
         len_stack = len(self._stack_)
 
-        assert i >= 0
-        if len_stack <= i and self._stack_resize_ is True:
-            self._stack_ += [None]
-        else:
-            assert len_stack > i
+        assert i >= 0 and len_stack > i
 
         self._stack_[i] = element
         self._stack_pointer_ = i + 1

test/test_stack.py

 import py
-
 from js.utils import StackMixin
 
+
 class Stack(StackMixin):
-    def __init__(self, size, resize = True):
-        self._init_stack_(size, resize)
+    def __init__(self, size):
+        self._init_stack_(size)
 
     def pop(self):
         return self._stack_pop()
     def pop_n(self, n):
         return self._stack_pop_n(n)
 
+
 class TestStack(object):
     def test_stack_push(self):
         s = Stack(99)
         s.append(3)
         assert s.pop() == 3
         assert s._stack_pointer_ == 2
-        assert s._stack_[2] == None
+        assert s._stack_[2] is None
 
         s = Stack(99)
         s.append(1)
         x = s.pop_n(2)
         assert x == [2, 3]
         assert s._stack_pointer_ == 1
-        assert s._stack_[1] == None
-        assert s._stack_[2] == None
+        assert s._stack_[1] is None
+        assert s._stack_[2] is None
 
     def test_stack_no_resize(self):
-        s = Stack(2, False)
+        s = Stack(2)
         s.append(1)
         s.append(1)
-        py.test.raises(AssertionError, s.append,1)
-
-    def test_stack_resize(self):
-        s = Stack(0)
-        s.append(1)
-        s.append(2)
-        s.append(3)
-        assert len(s._stack_) == 3
+        py.test.raises(AssertionError, s.append, 1)