Commits

Carl Friedrich Bolz  committed d29789b

make rpython

  • Participants
  • Parent commits e497a06
  • Branches compress-terms2

Comments (0)

Files changed (2)

File prolog/interpreter/shape.py

     def get_shape(self):
         return jit.promote(self.shape)
 
+    def set_shape(self, shape):
+        self.shape = shape
+
     def get_storage(self, i):
         return self.storage[i]
 
     def size_storage(self):
         return self.get_shape().num_storage_vars()
 
+    def set_full_storage(self, storage):
+        self.storage = storage
+
     # _____________________________________________________________________
     # callable interface
 
         assert newsize == new_shape.num_storage_vars()
         newstorage = [None] * newsize
         for i in range(index):
-            newstorage[i] = self.storage[i]
+            newstorage[i] = self.get_storage(i)
         for i in range(obj.size_storage()):
             child = newstorage[i + index] = obj.get_storage(i)
             if isinstance(child, term.VarInTerm):
 
         offset = obj.size_storage() - 1
         for i in range(index + 1, self.size_storage()):
-            child = newstorage[i + offset] = self.storage[i]
+            child = newstorage[i + offset] = self.get_storage(i)
             if isinstance(child, term.VarInTerm) and child.parent is self:
                 assert isinstance(self, ShapedCallableMutable)
                 indicator = child.indicator
                 if (isinstance(indicator, term.VarInTermIndex) and
                         indicator.index == i):
                     child.indicator = term.VarInTermIndex.build(i + offset)
-        self.storage = newstorage
-        self.shape = new_shape
+        self.set_full_storage(newstorage)
+        self.set_shape(new_shape)
         return self
 
     def replace_child(self, index, obj):

File prolog/jittest/interpjit.py

         nrev([],[]).
         nrev([X|Y],Z) :- nrev(Y,Z1),
                          app(Z1,[X],Z).
+        reverse([], L, L).
+        reverse([H|T], L, O) :-
+            reverse(T, [H | L], O).
 
         run(X) :- solve([X]).
         solve([]).
         """
         )
 
-        t1 = parse_query_term("app([1, 2, 3, 4, 5, 6], [8, 9], X), X == [1, 2, 3, 4, 5, 6, 8, 9].")
+        t1 = parse_query_term("app([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [8, 9], X), X == [1, 2, 3, 4, 5, 6, 8, 9].")
         #t2 = parse_query_term("loop_when(100).")
         t2 = parse_query_term("freeze_list(15, T).")
-        t3 = parse_query_term("nrev([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], X), X == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1].")
+        t3 = parse_query_term("reverse([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [], X), X == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].")
         t4 = parse_query_term("run(app([1, 2, 3, 4, 5, 6, 7], [8, 9], X)), X == [1, 2, 3, 4, 5, 6, 7, 8, 9].")
         t5 = parse_query_term("map(add1, [1, 2, 3, 4, 5, 6, 7], X), X == [2, 3, 4, 5, 6, 7, 8].")
         t6 = parse_query_term("partition([6, 6, 6, 6, 6, 6, 66, 3, 6, 1, 2, 6, 8, 9, 0,4, 2, 5, 1, 106, 3, 6, 1, 2, 6, 8, 9, 0,4, 2, 5, 1, 10, 3, 6, 1, 2, 6, 8, 9, 0,4, 2, 5, 1, 10], 5, X, Y).")
         # XXX
         #interp_w(2)
 
-        self.meta_interp(interp_w, [2], listcomp=True, backendopt=True,
+        self.meta_interp(interp_w, [1], listcomp=True, backendopt=True,
                          listops=True)
         #self.meta_interp(interp_w, [3], listcomp=True,
         #                 listops=True)