[pypy-svn] r42248 - in pypy/dist/pypy/lang/prolog: builtin interpreter

cfbolz at codespeak.net cfbolz at codespeak.net
Sun Apr 22 22:57:41 CEST 2007


Author: cfbolz
Date: Sun Apr 22 22:57:41 2007
New Revision: 42248

Modified:
   pypy/dist/pypy/lang/prolog/builtin/allsolution.py
   pypy/dist/pypy/lang/prolog/builtin/parseraccess.py
   pypy/dist/pypy/lang/prolog/interpreter/error.py
   pypy/dist/pypy/lang/prolog/interpreter/helper.py
Log:
use Atom.newatom to construct Atoms that can be expected to be used more than
once to get caching.


Modified: pypy/dist/pypy/lang/prolog/builtin/allsolution.py
==============================================================================
--- pypy/dist/pypy/lang/prolog/builtin/allsolution.py	(original)
+++ pypy/dist/pypy/lang/prolog/builtin/allsolution.py	Sun Apr 22 22:57:41 2007
@@ -22,7 +22,7 @@
         engine.call(goal, collector)
     except error.UnificationFailed:
         engine.heap.revert(oldstate)
-    result = term.Atom("[]")
+    result = term.Atom.newatom("[]")
     for i in range(len(collector.found) - 1, -1, -1):
         copy = collector.found[i]
         d = {}

Modified: pypy/dist/pypy/lang/prolog/builtin/parseraccess.py
==============================================================================
--- pypy/dist/pypy/lang/prolog/builtin/parseraccess.py	(original)
+++ pypy/dist/pypy/lang/prolog/builtin/parseraccess.py	Sun Apr 22 22:57:41 2007
@@ -12,7 +12,7 @@
                 oldstate = engine.heap.branch()
                 try:
                     precedence.unify(term.Number(prec), engine.heap)
-                    typ.unify(term.Atom(form), engine.heap)
+                    typ.unify(term.Atom.newatom(form), engine.heap)
                     name.unify(term.Atom(op), engine.heap)
                     return continuation.call(engine)
                 except error.UnificationFailed:

Modified: pypy/dist/pypy/lang/prolog/interpreter/error.py
==============================================================================
--- pypy/dist/pypy/lang/prolog/interpreter/error.py	(original)
+++ pypy/dist/pypy/lang/prolog/interpreter/error.py	Sun Apr 22 22:57:41 2007
@@ -29,7 +29,7 @@
 
 def throw_instantiation_error():
     from pypy.lang.prolog.interpreter import term
-    raise CatchableError(term.Atom("instantiation_error"))
+    raise CatchableError(term.Atom.newatom("instantiation_error"))
 
 def throw_type_error(valid_type, obj):
     from pypy.lang.prolog.interpreter import term
@@ -39,7 +39,7 @@
     # number, predicate_indicator, variable
     from pypy.lang.prolog.interpreter import term
     raise CatchableError(
-        term.Term("type_error", [term.Atom(valid_type), obj]))
+        term.Term("type_error", [term.Atom.newatom(valid_type), obj]))
 
 def throw_domain_error(valid_domain, obj):
     from pypy.lang.prolog.interpreter import term
@@ -50,14 +50,14 @@
     # stream, stream_option, stream_or_alias, stream_position,
     # stream_property, write_option
     raise CatchableError(
-        term.Term("domain_error", [term.Atom(valid_domain), obj]))
+        term.Term("domain_error", [term.Atom.newatom(valid_domain), obj]))
 
 def throw_existence_error(object_type, obj):
     from pypy.lang.prolog.interpreter import term
     # valid types are:
     # procedure, source_sink, stream
     raise CatchableError(
-        term.Term("existence_error", [term.Atom(object_type), obj]))
+        term.Term("existence_error", [term.Atom.newatom(object_type), obj]))
 
 def throw_permission_error(operation, permission_type, obj):
     from pypy.lang.prolog.interpreter import term
@@ -68,6 +68,6 @@
     # binary_stream, flag, operator, past_end_of_stream, private_procedure,
     # static_procedure, source_sink, stream, text_stream. 
     raise CatchableError(
-        term.Term("permission_error", [term.Atom(operation),
-                                       term.Atom(permission_type),
+        term.Term("permission_error", [term.Atom.newatom(operation),
+                                       term.Atom.newatom(permission_type),
                                        obj]))

Modified: pypy/dist/pypy/lang/prolog/interpreter/helper.py
==============================================================================
--- pypy/dist/pypy/lang/prolog/interpreter/helper.py	(original)
+++ pypy/dist/pypy/lang/prolog/interpreter/helper.py	Sun Apr 22 22:57:41 2007
@@ -1,10 +1,10 @@
-""" Helper functions for dealing with prolog lists"""
+""" Helper functions for dealing with prolog terms"""
 
 from pypy.lang.prolog.interpreter import term
 from pypy.lang.prolog.interpreter import error
 
 def wrap_list(python_list):
-    curr = term.Atom("[]")
+    curr = term.Atom.newatom("[]")
     for i in range(len(python_list) - 1, -1, -1):
         curr = term.Term(".", [python_list[i], curr])
     return curr



More information about the Pypy-commit mailing list