[pypy-svn] r17905 - in pypy/dist/pypy: rpython tool
pedronis at codespeak.net
pedronis at codespeak.net
Tue Sep 27 16:40:20 CEST 2005
Author: pedronis
Date: Tue Sep 27 16:40:18 2005
New Revision: 17905
Modified:
pypy/dist/pypy/rpython/rbool.py
pypy/dist/pypy/rpython/rfloat.py
pypy/dist/pypy/rpython/rint.py
pypy/dist/pypy/rpython/rmodel.py
pypy/dist/pypy/rpython/rtyper.py
pypy/dist/pypy/tool/ansi_print.py
Log:
convert print in rtyper to use logging
Modified: pypy/dist/pypy/rpython/rbool.py
==============================================================================
--- pypy/dist/pypy/rpython/rbool.py (original)
+++ pypy/dist/pypy/rpython/rbool.py Tue Sep 27 16:40:18 2005
@@ -3,10 +3,9 @@
from pypy.rpython.lltype import Signed, Unsigned, Bool, Float, pyobjectptr
from pypy.rpython.rmodel import Repr, TyperError, IntegerRepr, BoolRepr
from pypy.rpython.robject import PyObjRepr, pyobj_repr
+from pypy.rpython.rmodel import log
-debug = False
-
class __extend__(annmodel.SomeBool):
def rtyper_makerepr(self, rtyper):
return bool_repr
@@ -44,10 +43,10 @@
class __extend__(pairtype(BoolRepr, IntegerRepr)):
def convert_from_to((r_from, r_to), v, llops):
if r_from.lowleveltype == Bool and r_to.lowleveltype == Unsigned:
- if debug: print 'explicit cast_bool_to_uint'
+ log.debug('explicit cast_bool_to_uint')
return llops.genop('cast_bool_to_uint', [v], resulttype=Unsigned)
if r_from.lowleveltype == Bool and r_to.lowleveltype == Signed:
- if debug: print 'explicit cast_bool_to_int'
+ log.debug('explicit cast_bool_to_int')
return llops.genop('cast_bool_to_int', [v], resulttype=Signed)
return NotImplemented
Modified: pypy/dist/pypy/rpython/rfloat.py
==============================================================================
--- pypy/dist/pypy/rpython/rfloat.py (original)
+++ pypy/dist/pypy/rpython/rfloat.py Tue Sep 27 16:40:18 2005
@@ -8,8 +8,8 @@
from pypy.rpython.rstr import STR
from pypy.rpython.lltype import functionptr, FuncType, malloc
from pypy.rpython import rstr
+from pypy.rpython.rmodel import log
-debug = False
class __extend__(annmodel.SomeFloat):
def rtyper_makerepr(self, rtyper):
@@ -166,17 +166,17 @@
class __extend__(pairtype(IntegerRepr, FloatRepr)):
def convert_from_to((r_from, r_to), v, llops):
if r_from.lowleveltype == Unsigned and r_to.lowleveltype == Float:
- if debug: print 'explicit cast_uint_to_float'
+ log.debug('explicit cast_uint_to_float')
return llops.genop('cast_uint_to_float', [v], resulttype=Float)
if r_from.lowleveltype == Signed and r_to.lowleveltype == Float:
- if debug: print 'explicit cast_int_to_float'
+ log.debug('explicit cast_int_to_float')
return llops.genop('cast_int_to_float', [v], resulttype=Float)
return NotImplemented
class __extend__(pairtype(BoolRepr, FloatRepr)):
def convert_from_to((r_from, r_to), v, llops):
if r_from.lowleveltype == Bool and r_to.lowleveltype == Float:
- if debug: print 'explicit cast_bool_to_float'
+ log.debug('explicit cast_bool_to_float')
return llops.genop('cast_bool_to_float', [v], resulttype=Float)
return NotImplemented
Modified: pypy/dist/pypy/rpython/rint.py
==============================================================================
--- pypy/dist/pypy/rpython/rint.py (original)
+++ pypy/dist/pypy/rpython/rint.py Tue Sep 27 16:40:18 2005
@@ -7,10 +7,9 @@
inputconst
from pypy.rpython.robject import PyObjRepr, pyobj_repr
from pypy.rpython.rarithmetic import intmask, r_uint
+from pypy.rpython.rmodel import log
-debug = False
-
class __extend__(annmodel.SomeInteger):
def rtyper_makerepr(self, rtyper):
if self.unsigned:
@@ -29,10 +28,10 @@
def convert_from_to((r_from, r_to), v, llops):
if r_from.lowleveltype == Signed and r_to.lowleveltype == Unsigned:
- if debug: print 'explicit cast_int_to_uint'
+ log.debug('explicit cast_int_to_uint')
return llops.genop('cast_int_to_uint', [v], resulttype=Unsigned)
if r_from.lowleveltype == Unsigned and r_to.lowleveltype == Signed:
- if debug: print 'explicit cast_uint_to_int'
+ log.debug('explicit cast_uint_to_int')
return llops.genop('cast_uint_to_int', [v], resulttype=Signed)
return NotImplemented
Modified: pypy/dist/pypy/rpython/rmodel.py
==============================================================================
--- pypy/dist/pypy/rpython/rmodel.py (original)
+++ pypy/dist/pypy/rpython/rmodel.py Tue Sep 27 16:40:18 2005
@@ -4,7 +4,6 @@
from pypy.rpython.lltype import Void, Bool, Float, Signed, Char, UniChar
from pypy.rpython.lltype import typeOf, LowLevelType, Ptr, PyObject
from pypy.rpython.lltype import FuncType, functionptr, cast_ptr_to_int
-from pypy.tool.ansi_print import ansi_print
from pypy.rpython.error import TyperError, MissingRTypeOperation
# initialization states for Repr instances
@@ -322,12 +321,24 @@
_callable = getattr(graphfunc, '_specializedversionof_', graphfunc)
return functionptr(FT, graphfunc.func_name, graph = graph, _callable = _callable)
-def warning(msg):
- ansi_print("*** WARNING: %s" % (msg,), esc="31") # RED
-
-
def needsgc(classdef, nogc=False):
if classdef is None:
return not nogc
else:
return getattr(classdef.cls, '_alloc_flavor_', 'gc').startswith('gc')
+
+# logging/warning
+
+import py
+from pypy.tool.ansi_print import ansi_log
+
+log = py.log.Producer("rtyper")
+py.log.setconsumer("rtyper", ansi_log)
+#py.log.setconsumer("rtyper translating", None)
+#py.log.setconsumer("rtyper debug", None)
+
+def warning(msg):
+ log.WARNING(msg)
+
+
+
Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py (original)
+++ pypy/dist/pypy/rpython/rtyper.py Tue Sep 27 16:40:18 2005
@@ -31,8 +31,7 @@
from pypy.rpython.annlowlevel import annotate_lowlevel_helper
from pypy.rpython.exceptiondata import ExceptionData
-log = py.log.Producer("rtyper")
-py.log.setconsumer("rtyper", None)
+from pypy.rpython.rmodel import log
class RPythonTyper:
@@ -58,9 +57,7 @@
try:
self.seed = int(os.getenv('RTYPERSEED'))
s = 'Using %d as seed for block shuffling' % self.seed
- print '*' * len(s)
- print s
- print '*' * len(s)
+ log.info(s)
except:
self.seed = 0
self.order = None
@@ -69,9 +66,7 @@
order_module = RTYPERORDER.split(',')[0]
self.order = __import__(order_module, {}, {}, ['*']).order
s = 'Using %s.%s for order' % (self.order.__module__, self.order.__name__)
- print '*' * len(s)
- print s
- print '*' * len(s)
+ log.info(s)
self.crash_on_first_typeerror = True
def add_pendingsetup(self, repr):
@@ -157,20 +152,20 @@
error_report = " but %d errors" % self.typererror_count
else:
error_report = ''
- print 'specializing: %d / %d blocks (%d%%)%s' % (
- n, total, 100 * n // total, error_report)
+ log.event('specializing: %d / %d blocks (%d%%)%s' % (
+ n, total, 100 * n // total, error_report))
# make sure all reprs so far have had their setup() called
self.call_all_setups()
if self.typererrors:
- self.dump_typererrors()
+ self.dump_typererrors(to_log=True)
raise TyperError("there were %d error" % len(self.typererrors))
# make sure that the return variables of all graphs are concretetype'd
for graph in self.annotator.translator.flowgraphs.values():
v = graph.getreturnvar()
self.setconcretetype(v)
- def dump_typererrors(self, num=None, minimize=True):
+ def dump_typererrors(self, num=None, minimize=True, to_log=False):
c = 0
bc = 0
for err in self.typererrors[:num]:
@@ -184,11 +179,19 @@
func = "(%s:%s)" %(func.__module__ or '?', func.__name__)
else:
func = "(?:?)"
- print "TyperError-%d: %s" % (c, func)
- print str(err)
- print ""
- if bc:
- print "(minimized %d errors away for this dump)" % (bc,)
+ errmsg = ("TyperError-%d: %s" % (c, func) +
+ str(err) +
+ "\n")
+ if to_log:
+ log.ERROR(errmsg)
+ else:
+ print errmsg
+ if bc:
+ minmsg = "(minimized %d errors away for this dump)" % (bc,)
+ if to_log:
+ log.ERROR(minmsg)
+ else:
+ print minmsg
def call_all_setups(self):
# make sure all reprs so far have had their setup() called
Modified: pypy/dist/pypy/tool/ansi_print.py
==============================================================================
--- pypy/dist/pypy/tool/ansi_print.py (original)
+++ pypy/dist/pypy/tool/ansi_print.py Tue Sep 27 16:40:18 2005
@@ -29,6 +29,7 @@
'WARNING': ((31,), False),
'event': ((1,), True),
'ERROR': ((1, 31), False),
+ 'info': ((32,), False),
}
def __init__(self, kw_to_color={}, file=None):
More information about the Pypy-commit
mailing list