1. Carl Friedrich Bolz
  2. Pyrolog

Commits

Carl Friedrich Bolz  committed f3c7543

random stuff in my work dir

  • Participants
  • Parent commits 88b2dea
  • Branches rip-out-varinterm

Comments (0)

Files changed (3)

File prolog/interpreter/heap.py

View file
  • Ignore whitespace
         return result
 
     def newvar_in_term(self, parent, index):
+        return self.newvar() # disable VarInTerm
         from prolog.interpreter.term import VarInTerm
         result = VarInTerm(parent, index)
         result.created_after_choice_point = self

File prolog/interpreter/shape.py

View file
  • Ignore whitespace
 
     def resolve(self, shaped_callable, index):
         result = unerase(shaped_callable.get_raw_storage(index))
-        # XXX use new JIT interface here instead
-        assert isinstance(result, term.Atom)
+        jit.record_known_class(result, term.Atom)
         return result
 
     def write(self, shaped_callable, i, val):
         for i in range(self.size_storage()):
             child = self.get_storage(i)
             y = 0
-            if isinstance(child, term.VarInTerm):
+            # XXX adapt to missing VarInTerms
+            if 0:#isinstance(child, term.VarInTerm):
                 parent = child.parent
                 shape = parent.get_shape()
                 indicator = child.indicator
         storage = [None] * self.size_storage()
         result = ShapedCallableMutable(self.get_shape(), storage)
         newinstance = False
-        needmutable = False
         i = 0
         for i in range(self.size_storage()):
             arg = self.get_storage(i)
             cloned = arg.copy_standardize_apart_as_child_of(heap, env, result, i)
             newinstance = newinstance | (isinstance(arg, term.NumberedVar) or cloned is not arg)
-            needmutable = needmutable | isinstance(cloned, term.VarInTerm)
             result.set_storage(i, cloned)
         if newinstance:
-            if not needmutable:
-                result = result._make_immutable()
+            result = result._make_immutable()
             return result.compress()
         else:
             return self
             for i in range(obj.size_storage()):
                 child = obj.get_storage(i)
                 # XXX whew, subtle logic here
-                if isinstance(child, term.VarInTerm):
+                if 0: #isinstance(child, term.VarInTerm):
                     deref = child.getbinding()
                     if deref is None:
                         self = self._make_mutable()
 
     def move_child(self, index, newindex, old_shape):
         child = self.get_storage_using_shape(index, old_shape)
-        if isinstance(child, term.VarInTerm):
+        if 0:#isinstance(child, term.VarInTerm):
             child = child.move(self, index, newindex)
             self.set_storage(newindex, child)
         else:

File prolog/interpreter/test/test_shape.py

View file
  • Ignore whitespace
     assert c1.get_full_storage() == [b, nil, a]
 
 def test_replace_child_fixup_varinterm_at_end():
+    py.test.skip("VarInTerms are gone")
     h = heap.Heap()
     sig = signature.Signature.getsignature(".", 3)
     build = shape.SharingShape
 
 
 def test_replace_child_fixup_varinterm_from_replacement():
+    py.test.skip("VarInTerms are gone")
     h = heap.Heap()
     sig = signature.Signature.getsignature(".", 3)
     build = shape.SharingShape
     for i in range(100):
         env = assert_true("loop(10, X).", e)
     res = env['X']
-    assert [obj.num for obj in unwrap_list(res)] == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
-    assert len(res.get_full_storage()) == shape.SHAPED_CALLABLE_SIZE
+    assert [obj.binding.num for obj in unwrap_list(res)] == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
+    #assert len(res.get_full_storage()) == shape.SHAPED_CALLABLE_SIZE
 
     for i in range(10):
         env = assert_true("loop(100, Y), append(Y, Y, X).", e)
     res = env['X']
-    l = [obj.num for obj in unwrap_list(res)]
+    l = [obj.binding.num for obj in unwrap_list(res)]
     assert l == range(99, -1, -1) * 2
     res = env['X']
-    assert len(res.get_full_storage()) == shape.SHAPED_CALLABLE_SIZE
+    #assert len(res.get_full_storage()) == shape.SHAPED_CALLABLE_SIZE
 
     for i in range(10):
         env = assert_true("loop(100, Y), reverse(Y, [], X).", e)
     res = env['Y']
-    assert len(res.get_full_storage()) == shape.SHAPED_CALLABLE_SIZE
+    #assert len(res.get_full_storage()) == shape.SHAPED_CALLABLE_SIZE
     res = env['X']
-    l = [obj.num for obj in unwrap_list(res)]
+    l = [obj.binding.num for obj in unwrap_list(res)]
     assert l == range(100)
     res = env['X']
     assert len(res.get_full_storage()) == shape.SHAPED_CALLABLE_SIZE