Commits

David Schneider committed 7727925

Replace calls to atom contructor with factory method calls

Comments (0)

Files changed (4)

prolog/builtin/atomconstruction.py

         if self.i < len(self.r) + 1:
             fcont, heap = self.prepare_more_solutions(fcont, heap)
             oldstate = heap.branch()
-            self.var1.unify(term.Atom(self.r[:self.i]), heap)
-            self.var2.unify(term.Atom(self.r[self.i:]), heap)
+            self.var1.unify(term.Callable.build(self.r[:self.i]), heap)
+            self.var2.unify(term.Callable.build(self.r[self.i:]), heap)
             return self.nextcont, fcont, heap
         raise error.UnificationFailed()
 
             if r.endswith(s2):
                 stop = len(r) - len(s2)
                 assert stop > 0
-                a1.unify(term.Atom(r[:stop]), heap)
+                a1.unify(term.Callable.build(r[:stop]), heap)
             else:
                 raise error.UnificationFailed()
     else:
         if isinstance(a2, term.Var):
             r = helper.convert_to_str(result)
             if r.startswith(s1):
-                a2.unify(term.Atom(r[len(s1):]), heap)
+                a2.unify(term.Callable.build(r[len(s1):]), heap)
             else:
                 raise error.UnificationFailed()
         else:
             s2 = helper.convert_to_str(a2)
-            result.unify(term.Atom(s1 + s2), heap)
+            result.unify(term.Callable.build(s1 + s2), heap)
     return scont, fcont, heap
 
 @expose_builtin("atom_length", unwrap_spec = ["atom", "obj"])
                     before.unify(term.Number(b), heap)
                     after.unify(term.Number(len(s) - l - b), heap)
                     length.unify(term.Number(l), heap)
-                    sub.unify(term.Atom(s[b:b + l]), heap)
+                    sub.unify(term.Callable.build(s[b:b + l]), heap)
                     result = continuation.call(engine, choice_point=True)
                     heap.discard(oldstate)
                     return result
                 before.unify(term.Number(b), heap)
                 after.unify(term.Number(a), heap)
                 length.unify(term.Number(l), heap)
-                sub.unify(term.Atom(s[b:b + l]), heap)
+                sub.unify(term.Callable.build(s[b:b + l]), heap)
                 result = continuation.call(engine, choice_point=True)
                 heap.discard(oldstate)
                 return result

prolog/builtin/parseraccess.py

                 try:
                     precedence.unify(term.Number(prec), heap)
                     typ.unify(term.Callable.build(form), heap)
-                    name.unify(term.Atom(op), heap)
+                    name.unify(term.Callable.build(op), heap)
                     return continuation.call(engine, choice_point=True)
                 except error.UnificationFailed:
                     heap.revert(oldstate)

prolog/builtin/termconstruction.py

         functor.unify(t, heap)
         arity.unify(term.Number(0), heap)
     elif isinstance(t, term.Term):
-        functor.unify(term.Atom(t.name()), heap)
+        functor.unify(term.Callable.build(t.name()), heap)
         arity.unify(term.Number(t.argument_count()), heap)
     elif isinstance(t, term.Var):
         if isinstance(functor, term.Var):
 def impl_univ(engine, heap, first, second):
     if not isinstance(first, term.Var):
         if isinstance(first, term.Term):
-            l = [term.Atom(first.name())] + first.arguments()
+            l = [term.Callable.build(first.name())] + first.arguments()
         else:
             l = [first]
         u1 = helper.wrap_list(l)

prolog/interpreter/test/test_callable_interface.py

 def test_atom_get_signature():
     r = atom.get_prolog_signature() 
     r.name() == '/'
-    r._args[0] == Atom('a')
+    r._args[0] == Callable.build('a')
     r._args[1] == Number(0)
 
 def test_atom_get_arguments():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.