[pypy-svn] r33480 - in pypy/branch/even-more-config3/pypy: config translator translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Thu Oct 19 20:51:01 CEST 2006


Author: antocuni
Date: Thu Oct 19 20:51:00 2006
New Revision: 33480

Modified:
   pypy/branch/even-more-config3/pypy/config/pypyoption.py
   pypy/branch/even-more-config3/pypy/translator/cli/gencli.py
   pypy/branch/even-more-config3/pypy/translator/cli/ilgenerator.py
   pypy/branch/even-more-config3/pypy/translator/driver.py
Log:
(antocuni, cfbolz)

added cli-trace-calls option to gencli.



Modified: pypy/branch/even-more-config3/pypy/config/pypyoption.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/config/pypyoption.py	(original)
+++ pypy/branch/even-more-config3/pypy/config/pypyoption.py	Thu Oct 19 20:51:00 2006
@@ -182,6 +182,11 @@
             IntOption("inline_threshold", "Threshold when to inline functions",
                       default=1, cmdline=None),
         ]),
+
+        OptionDescription("cli", "GenCLI options", [
+            BoolOption("trace_calls", "Trace function calls", default=False,
+                       cmdline="--cli-trace-calls")
+        ])
     ]),
 ])
 

Modified: pypy/branch/even-more-config3/pypy/translator/cli/gencli.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/translator/cli/gencli.py	(original)
+++ pypy/branch/even-more-config3/pypy/translator/cli/gencli.py	Thu Oct 19 20:51:00 2006
@@ -2,6 +2,9 @@
 import subprocess
 import shutil
 
+from pypy.config.config import Config
+from pypy.config.pypyoption import pypy_optiondescription
+
 from pypy.translator.cli import conftest
 from pypy.translator.cli.ilgenerator import IlasmGenerator
 from pypy.translator.cli.function import Function, log
@@ -22,7 +25,7 @@
 class GenCli(object):
     def __init__(self, tmpdir, translator, entrypoint=None, type_system_class=CTS,
                  opcode_dict=opcodes, name_suffix='.il', function_class=Function,
-                 database_class = LowLevelDatabase, pending_graphs=()):
+                 database_class = LowLevelDatabase, pending_graphs=(), config=None):
         self.tmpdir = tmpdir
         self.translator = translator
         self.entrypoint = entrypoint
@@ -40,6 +43,9 @@
 
         self.tmpfile = tmpdir.join(self.assembly_name + name_suffix)
         self.const_stat = str(tmpdir.join('const_stat'))
+        if config is None:
+            config = Config(pypy_optiondescription)
+        self.config = config
 
     def generate_source(self , asm_class = IlasmGenerator ):
         out = self.tmpfile.open('w')
@@ -47,9 +53,9 @@
             out = Tee(sys.stdout, out)
 
         if USE_STACKOPT:
-            self.ilasm = StackOptGenerator(out, self.assembly_name)
+            self.ilasm = StackOptGenerator(out, self.assembly_name, self.config)
         else:
-            self.ilasm = asm_class(out, self.assembly_name)
+            self.ilasm = asm_class(out, self.assembly_name, self.config)
 
         # TODO: instance methods that are also called as unbound
         # methods are rendered twice, once within the class and once

Modified: pypy/branch/even-more-config3/pypy/translator/cli/ilgenerator.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/translator/cli/ilgenerator.py	(original)
+++ pypy/branch/even-more-config3/pypy/translator/cli/ilgenerator.py	Thu Oct 19 20:51:00 2006
@@ -1,8 +1,6 @@
 from pypy.rpython.lltypesystem.lltype import Signed, Unsigned, Void, Bool, Float
 from pypy.rpython.lltypesystem.lltype import SignedLongLong, UnsignedLongLong
 
-TRACE_CALL = False
-
 class CodeGenerator(object):
     def __init__(self, out, indentstep = 4, startblock = '{', endblock = '}'):
         self._out = out
@@ -38,8 +36,9 @@
     """
     Generate IL code by writing to a file and compiling it with ilasm
     """
-    def __init__(self, outfile, name):
+    def __init__(self, outfile, name, config):
         self.out = outfile
+        self.config = config
         self.code = CodeGenerator(self.out)
         self.code.writeline('.assembly extern mscorlib {}')
         self.code.writeline('.assembly extern pypylib {}')
@@ -114,8 +113,8 @@
         if is_entrypoint:
             self.code.writeline('.entrypoint')
         self.code.writeline('.maxstack 32')
-        self.stderr('start %s' % name, TRACE_CALL and name!='.ctor'
-                    and method_type!='runtime')
+        self.stderr('start %s' % name, self.config.translation.cli.trace_calls
+                    and name!='.ctor' and method_type!='runtime')
 
     def end_function(self):
         self.flush()

Modified: pypy/branch/even-more-config3/pypy/translator/driver.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/translator/driver.py	(original)
+++ pypy/branch/even-more-config3/pypy/translator/driver.py	Thu Oct 19 20:51:00 2006
@@ -497,7 +497,8 @@
         from pypy.tool.udir import udir
 
         entry_point_graph = self.translator.graphs[0]
-        self.gen = GenCli(udir, self.translator, get_entrypoint(entry_point_graph))
+        self.gen = GenCli(udir, self.translator, get_entrypoint(entry_point_graph),
+                          config=self.config)
         filename = self.gen.generate_source()
         self.log.info("Wrote %s" % (filename,))
     task_source_cli = taskdef(task_source_cli, [OOBACKENDOPT, OOTYPE],



More information about the Pypy-commit mailing list