[pypy-svn] r17989 - in pypy/dist/pypy/translator: goal tool tool/pygame

pedronis at codespeak.net pedronis at codespeak.net
Fri Sep 30 00:38:38 CEST 2005


Author: pedronis
Date: Fri Sep 30 00:38:35 2005
New Revision: 17989

Modified:
   pypy/dist/pypy/translator/goal/driver.py
   pypy/dist/pypy/translator/goal/translate_pypy_new.py
   pypy/dist/pypy/translator/tool/pdbplus.py
   pypy/dist/pypy/translator/tool/pygame/server.py
Log:
recomposed the translate_pypy_new puzzle

still do to:
- renable forking
- finish: print -> logging
- display options
- some more polish



Modified: pypy/dist/pypy/translator/goal/driver.py
==============================================================================
--- pypy/dist/pypy/translator/goal/driver.py	(original)
+++ pypy/dist/pypy/translator/goal/driver.py	Fri Sep 30 00:38:35 2005
@@ -26,7 +26,7 @@
 class TranslationDriver(SimpleTaskEngine):
 
     def __init__(self, translator, inputtypes, policy=None, options=None,
-                 runner=None, disable=[]):
+                 runner=None, disable=[], default_goal = None):
         SimpleTaskEngine.__init__(self)
 
         self.translator = translator
@@ -45,12 +45,54 @@
         self.options = options
         self.standalone = standalone
 
-        if runner is None:
+        if runner is None and not standalone:
             def runner(f):
                 f()
         self.runner = runner
 
         self.done = {}
+        
+        maybe_skip = {}
+        def add_maybe_skip(goal):
+            if goal in maybe_skip:
+                return
+            maybe_skip[goal] = True
+            for depending in self._depending_on(goal):
+                add_maybe_skip(depending)
+
+        for goal in self.backend_select_goals(disable):
+            add_maybe_skip(goal)
+        self.maybe_skip = maybe_skip.keys()
+
+        if default_goal:
+            default_goal, = self.backend_select_goals([default_goal])
+            if default_goal in self.maybe_skip:
+                default_goal = None
+        
+        self.default_goal = default_goal
+
+        # expose tasks
+        def expose_task(task):
+            backend_goal, = self.backend_select_goals([task])
+            def proc():
+                self.proceed(backend_goal)
+            setattr(self, task, proc)
+
+        for task in ('annotate', 'rtype', 'backopt', 'source', 'compile', 'run'):
+            expose_task(task)
+            
+    def backend_select_goals(self, goals):
+        backend = self.options.backend
+        assert backend
+        l = []
+        for goal in goals:
+            if goal in self.tasks:
+                l.append(goal)
+            else:
+                goal = "%s_%s" % (goal, backend)
+                assert goal in self.tasks
+                l.append(goal)
+        return l
 
     def info(self, msg):
         print msg
@@ -86,11 +128,11 @@
     #
     task_rtype = taskdef(task_rtype, ['annotate'], "RTyping")
 
-    def task_backendoptimisations(self):
+    def task_backopt(self):
         opt = self.options
         self.translator.backend_optimizations(ssa_form=opt.backend != 'llvm')
     #
-    task_backendoptimisations = taskdef(task_backendoptimisations, 
+    task_backopt = taskdef(task_backopt, 
                                         ['rtype'], "Back-end optimisations") 
 
     def task_source_c(self):  # xxx messy
@@ -113,7 +155,7 @@
         self.cbuilder = cbuilder
     #
     task_source_c = taskdef(task_source_c, 
-                            ['?backendoptimisations', '?rtype', '?annotate'], 
+                            ['?backopt', '?rtype', '?annotate'], 
                             "Generating c source")
 
     def task_compile_c(self): # xxx messy
@@ -122,10 +164,10 @@
 
         if self.standalone:
             self.c_entryp = cbuilder.executable_name
+            self.info("written: %s" % (c_entryp,))
         else:
             cbuilder.import_module()    
             self.c_entryp = cbuilder.get_entry_point()
-        #print 'Written %s.' % (c_entryp,)
     #
     task_compile_c = taskdef(task_compile_c, ['source_c'], "Compiling c source")
 
@@ -152,21 +194,21 @@
         raise NotImplementedError, "llinterpret" # xxx
     #
     task_llinterpret = taskdef(task_llinterpret, 
-                               ['?backendoptimisations', 'rtype'], 
+                               ['?backopt', 'rtype'], 
                                "LLInterpeting")
 
     def task_source_llvm(self):
         raise NotImplementedError, "source_llvm" # xxx
     #
     task_source_llvm = taskdef(task_source_llvm, 
-                               ['backendoptimisations', 'rtype'], 
+                               ['backopt', 'rtype'], 
                                "Generating llvm source")
 
     def task_compile_llvm(self):
         raise NotImplementedError, "compile_llvm" # xxx
     #
     task_compile_llvm = taskdef(task_compile_llvm, 
-                                ['backendoptimisations', 'rtype'], 
+                                ['backopt', 'rtype'], 
                                 "Compiling llvm source")
 
     def task_run_llvm(self):
@@ -175,50 +217,49 @@
     task_run_llvm = taskdef(task_run_llvm, ['compile_llvm'], 
                             "Running compiled llvm source")
 
-    def proceed(self, goal):
-        self._execute([goal])
-
-    def __getattr__(self, name): # xxx
-        if name in self.tasks:
-            def proceed_with_task():
-                self.proceed(name)
-            return proceed_with_task
-        raise AttribueError, name
-
-    def from_targetspec(targetspec_dic, options=None, args=None):
+    def proceed(self, goals):
+        if not goals:
+            if self.default_goal:
+                goals = [self.default_goal]
+            else:
+                self.info("nothing to do")
+                return
+        elif isinstance(goals, str):
+            goals = [goals]
+        goals = self.backend_select_goals(goals)
+        self._execute(goals, task_skip = self.maybe_skip)
+
+    def from_targetspec(targetspec_dic, options=None, args=None, empty_translator=None, 
+                        disable=[],
+                        default_goal=None):
         if args is None:
             args = []
         if options is None:
             options = DEFAULT_OPTIONS.copy()
             
         target = targetspec_dic['target']        
-        spec = target(options, arg)
+        spec = target(options, args)
         try:
             entry_point, inputtypes, policy = spec
         except ValueError:
             entry_point, inputtypes = spec
             policy = None
 
-        translator = Translator(entry_point, verbose=True, simplifying=True)
+        if empty_translator:
+            # re-initialize it
+            empty_translator.__init__(entry_point, verbose=True, simplifying=True)
+            translator = empty_translator
+        else:
+            translator = Translator(entry_point, verbose=True, simplifying=True)
             
         driver = TranslationDriver(translator, inputtypes,
-                                   policy, options, targetspec_dic['run'])
+                                   policy, options, targetspec_dic.get('run'),
+                                   disable=disable,
+                                   default_goal = default_goal)
 
-        return translation
+        return driver
 
     from_targetspec = staticmethod(from_targetspec)
-        
-
-# xxx reorg/move around
-
-def load_target(targetspec):
-    if not targetspec.endswith('.py'):
-        targetspec += '.py'
-    targetspec_dic = {}
-    sys.path.insert(0, os.path.dirname(targetspec))
-    #xxx print 
-    execfile(targetspec, targetspec_dic)
-    return targetspec_dic
 
 
 # __________ helpers

Modified: pypy/dist/pypy/translator/goal/translate_pypy_new.py
==============================================================================
--- pypy/dist/pypy/translator/goal/translate_pypy_new.py	(original)
+++ pypy/dist/pypy/translator/goal/translate_pypy_new.py	Fri Sep 30 00:38:35 2005
@@ -4,8 +4,11 @@
 
     See below
 """
+import sys, os
+
 import autopath 
 
+
 # dict are not ordered, cheat with #_xyz keys and bunchiter
 def OPT(*args):
     return args
@@ -22,7 +25,6 @@
 
 opts = {
 
-
     '0_Annotation': {
     '0_annotate': [OPT(('-a', '--annotate'), "Annotate", GOAL),
                  OPT(('--no-annotate',), "Don't annotate", SKIP_GOAL)],
@@ -40,7 +42,6 @@
                  OPT(('--no-backopt',), "Don't do backend optimisations", SKIP_GOAL)],
     },
 
-
     '3_Code generation options': {
     '0_source': [OPT(('-s', '--source'), "Generate source code", GOAL),
                OPT(('--no-source',), "Don't generate source code", SKIP_GOAL)],
@@ -60,13 +61,11 @@
     '_run': [OPT(('-r', '--run'), "Run compiled code", GOAL),
             OPT(('--no-run',), "Don't run compiled code", SKIP_GOAL)],
     },
-
     
     '6_General&other options': {
     '0_batch': [OPT(('--batch',), "Don't run interactive helpers", True)],
     '1_lowmem': [OPT(('--lowmem',), "Target should try to save memory", True)],
 
-
     '2_huge': [OPT(('--huge',), "Threshold in the number of functions after which only a local call graph and not a full one is displayed", int)],
 
     '3_text': [OPT(('--text',), "Don't start the pygame viewer", True)], 
@@ -92,13 +91,6 @@
     'default_goals': ['annotate', 'rtype', 'backopt', 'source', 'compile'],
     'skipped_goals': ['run'],
     
-##     'annotate': True,
-##     'rtype': True,
-##     'backopt': True,
-##     'source': True,
-##     'compile': True,
-##     'run': False,
-    
     'lowmem': False,
     
     'debug': False,
@@ -144,9 +136,18 @@
     if enable:
         parser.values.goals = parser.values.goals + [goal]
     else:
-        parser.values.goals = parser.values.skipped_goals + [goal]
+        parser.values.skipped_goals = parser.values.skipped_goals + [goal]
 
-def parse_options():
+def load_target(targetspec):
+    if not targetspec.endswith('.py'):
+        targetspec += '.py'
+    targetspec_dic = {}
+    sys.path.insert(0, os.path.dirname(targetspec))
+    #xxx print 
+    execfile(targetspec, targetspec_dic)
+    return targetspec_dic
+
+def parse_options_and_load_target():
     opt_parser = optparse.OptionParser(prog="translate_pypy",
                                        formatter=OptHelpFormatter())
     for group_name, grp_opts in bunchiter(opts):
@@ -173,6 +174,7 @@
                     opt_setup['type'] = 'string'
 
                 grp.add_option(*names, **opt_setup)
+
     opt_parser.set_defaults(**defaults)
 
     options, args = opt_parser.parse_args()
@@ -186,368 +188,76 @@
             options.targetspec = arg
         elif os.path.isfile(arg) and arg.endswith('.py'):
             options.targetspec = arg[:-3]        
+
+    targespec_dic = load_target(options.targetspec)
     
-    return options, args
+    return targespec_dic, options, args
 
 def main():
-    options, args = parse_options()
-
-    print options, args
-
-if __name__ == '__main__':
-    main()
+    targetspec_dic, options, args = parse_options_and_load_target()
 
-#  
-## """
-## Command-line options for translate_pypy:
-
-##     See below
-## """
-
-## opts = {
-##     'Annotation':[
-##         ['-m', '--lowmem', 'Try to save memory', [True,False], False],
-##         ['-n', '--no_annotations', "Don't infer annotations", [True,False], False],
-##         ['-d', '--debug', 'record debug information', [True,False], False],
-##         ['-i', '--insist', "Dont't stop on first error", [True,False], True]], 
-            
-##     'Specialization':[
-##         ['-t', '--specialize', "Don't specialize", [True,False], True]],
-            
-##     'Backend optimisation': [
-##         ['-o', '--optimize', "Don't optimize (should have different name)", 
-##                                                              [True,False], True ]],
-                    
-##     'Process options':[
-##         ['-f', '--fork', 
-##                "(UNIX) Create restartable checkpoint after annotation [,specialization]",
-##                             [['fork1','fork2']], [] ],
-##         ['-l', '--load', "load translator from file", [str], ''],
-##         ['-s', '--save', "save translator to file", [str], '']], 
-        
-##     'Codegeneration options':[
-##         ['-g', '--gc', 'Garbage collector', ['ref', 'boehm','none'], 'boehm'], 
-##         ['-b', '--backend', 'Backend selector', ['c','llvm'],'c'], 
-##         ['-w', '--gencode', "Don't generate code", [True,False], True], 
-##         ['-c', '--compile', "Don't compile generated code", [True,False], True]], 
-            
-##     'Compilation options':[],
+    from pypy.translator import translator
+    from pypy.translator.goal import driver
+    from pypy.translator.tool.pdbplus import PdbPlusShow
+    from pypy.translator.tool.graphserver import run_async_server
+
+    t = translator.Translator()
+
+    if options.graphserve:
+        serv_start, serv_show, serv_stop, serv_cleanup = run_async_server(t, options.graphserve)
+        def server_setup():
+            return serv_start, serv_show, serv_stop, serv_cleanup
+    else:
+        def server_setup():
+            from pypy.translator.tool.pygame.server import run_translator_server
+            return run_translator_server(t, options)
+
+    pdb_plus_show = PdbPlusShow(t) # need a translator to support extended commands
+
+    def debug(got_error):
+        tb = None
+        if got_error:
+            import traceback
+            exc, val, tb = sys.exc_info()
+            print >> sys.stderr
+            traceback.print_exception(exc, val, tb)
+            print >> sys.stderr
             
-##     'Run options':[
-##         ['-r', '--run', "Don't run the compiled code", [True,False], True], 
-##         ['-x', '--batch', "Dont run interactive helpers", [True,False], False]],
-##     'Pygame options':[
-##         ['-p', '--pygame', "Dont run pygame", [True,False], True], 
-##         ['-H', '--huge',
-##            "Threshold in the number of functions after which only a local call graph and not a full one is displayed", [int], 0 ]]}
-           
-## import autopath, sys, os
-
-## if '-use-snapshot' in sys.argv:
-##     # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-##     basedir = autopath.this_dir
-
-##     pypy_translation_snapshot_dir = os.path.join(basedir, 'pypy-translation-snapshot')
-
-##     if not os.path.isdir(pypy_translation_snapshot_dir):
-##         print """
-##     Translation will be performed on a specific revision of PyPy which lives on
-##     a branch. This needs to be checked out into translator/goal with:
-
-##     svn co http://codespeak.net/svn/pypy/branch/pypy-translation-snapshot
-##     """[1:]
-##         sys.exit(2)
-
-##     # override imports from pypy head with imports from pypy-translation-snapshot
-##     import pypy
-##     pypy.__path__.insert(0, pypy_translation_snapshot_dir)
-
-##     # complement imports from pypy.objspace (from pypy-translation-snapshot)
-##     # with pypy head objspace/
-##     import pypy.objspace
-##     pypy.objspace.__path__.append(os.path.join(autopath.pypydir, 'objspace'))
-
-##     print "imports redirected to pypy-translation-snapshot."
-
-##     # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
-
-## import threading, pdb
-
-## from pypy.translator.translator import Translator
-## from pypy.annotation import model as annmodel
-## from pypy.annotation import listdef
-## from pypy.annotation.policy import AnnotatorPolicy
-## from pypy.translator.pickle.main import load, save
-## # catch TyperError to allow for post-mortem dump
-## from pypy.rpython.error import TyperError
-
-## from pypy.translator.goal import query
-
-## # XXX this tries to make compiling faster
-## from pypy.translator.tool import cbuild
-## cbuild.enable_fast_compilation()
-## from pypy.translator.tool.util import update_usession_dir
-## from pypy.translator.tool.util import assert_rpython_mostly_not_imported, mkexename
-
-## annmodel.DEBUG = False
-
-
-
-## # __________  Main  __________
-
-## def sanity_check_annotation(t):
-##     irreg = query.qoutput(query.check_exceptblocks_qgen(t))
-##     if not irreg:
-##         print "++ All exceptblocks seem sane"
-
-##     lost = query.qoutput(query.check_methods_qgen(t))
-##     assert not lost, "lost methods, something gone wrong with the annotation of method defs"
-##     print "++ No lost method defs"
-
-##     so = query.qoutput(query.polluted_qgen(t))
-##     tot = len(t.flowgraphs)
-##     percent = int(tot and (100.0*so / tot) or 0)
-##     print "-- someobjectness %2d (%d of %d functions polluted by SomeObjects)" % (percent, so, tot)
-
-## def analyse(t, inputtypes):
-
-##     standalone = inputtypes is None
-##     if standalone:
-##         ldef = listdef.ListDef(None, annmodel.SomeString())
-##         inputtypes = [annmodel.SomeList(ldef)]
-    
-##     if not cmd_line_opt.no_annotations:
-##         print 'Annotating...'
-##         print 'with policy: %s.%s' % (policy.__class__.__module__, policy.__class__.__name__) 
-##         a = t.annotate(inputtypes, policy=policy)
-##         sanity_check_annotation(t)
-
-##     if a: #and not options['-no-s']:
-##         print 'Simplifying...'
-##         a.simplify()
-##         if 'fork1' in cmd_line_opt.fork:
-##             from pypy.translator.goal import unixcheckpoint
-##             assert_rpython_mostly_not_imported() 
-##             unixcheckpoint.restartable_point(auto='run')
-##     if a and cmd_line_opt.specialize:
-##         print 'Specializing...'
-##         t.specialize(dont_simplify_again=True,
-##                      crash_on_first_typeerror=not cmd_line_opt.insist)
-##     if cmd_line_opt.optimize:
-##         print 'Back-end optimizations...'
-##         t.backend_optimizations(ssa_form=cmd_line_opt.backend != 'llvm')
-##     if a and 'fork2' in cmd_line_opt.fork:
-##         from pypy.translator.goal import unixcheckpoint
-##         unixcheckpoint.restartable_point(auto='run')
-##     if a:
-##         t.frozen = True   # cannot freeze if we don't have annotations
-##     return  standalone
-
-## # graph servers
-
-## serv_start, serv_show, serv_stop, serv_cleanup = None, None, None, None
-
-## if __name__ == '__main__':
+            block = getattr(val, '__annotator_block', None)
+            if block:
+                print '-'*60
+                t.about(block)
+                print '-'*60
+            print
+        else:
+            print '-'*60
+            print 'Done.'
+            print
+
+        if options.batch:
+            print >>sys.stderr, "batch mode, not calling interactive helpers"
+            return
+
+        pdb_plus_show.start(tb, server_setup, graphic=not options.text)
+
+    try:
+        drv = driver.TranslationDriver.from_targetspec(targetspec_dic, options, args,
+                                                      empty_translator=t,
+                                                      disable=options.skipped_goals,
+                                                      default_goal='compile')
+        pdb_plus_show.expose({'drv': drv})
 
-##     targetspec = 'targetpypystandalone'
-##     listen_port = None
-    
-##     def debug(got_error):
-##         from pypy.translator.tool.pdbplus import PdbPlusShow
+        goals = options.goals
+        drv.proceed(goals)
         
-##         pdb_plus_show = PdbPlusShow(t) # need a translator to support extended commands
+    except SystemExit:
+        raise
+    except:
+        debug(True)
+        raise SystemExit(1)
+    else:
+        debug(False)
 
-##         tb = None
-##         if got_error:
-##             import traceback
-##             exc, val, tb = sys.exc_info()
-##             print >> sys.stderr
-##             traceback.print_exception(exc, val, tb)
-##             print >> sys.stderr
-
-##             block = getattr(val, '__annotator_block', None)
-##             if block:
-##                 print '-'*60
-##                 t.about(block)
-##                 print '-'*60
-##             print
-##         else:
-##             print '-'*60
-##             print 'Done.'
-##             print
-
-##         if cmd_line_opt.batch:
-##             print >>sys.stderr, "batch mode, not calling interactive helpers"
-##             return
-
-##         def server_setup():
-##             if serv_start:
-##                 return serv_start, serv_show, serv_stop, serv_cleanup
-##             else:
-##                 from pypy.translator.tool.pygame.server import run_translator_server
-##                 return run_translator_server(t, entry_point, cmd_line_opt)
-
-##         pdb_plus_show.start(tb, server_setup, graphic=cmd_line_opt.pygame)
-
-
-##     from optparse import OptionParser
-##     parser = OptionParser()
-##     for group in opts:
-##         for option in opts[group]:
-##             if option[-1] in [True,False]:
-##                 if option[-1] == True: 
-##                     action = "store_false"
-##                 else:
-##                     action = "store_true"
-##                 parser.add_option(option[0],option[1], default=option[-1], 
-##                 dest=option[1].lstrip('--'), help=option[2], action=action)
-##             elif type(option[-2][0]) == list:
-##                 parser.add_option(option[0],option[1], default=option[-1], 
-##                 dest=option[1].lstrip('--'), help=option[2], action="append")
-##             else:
-##                 parser.add_option(option[0],option[1], default=option[-1], 
-##                 dest=option[1].lstrip('--'), help=option[2])
-    
-##     (cmd_line_opt, args) = parser.parse_args()
-##     argiter = iter(args) #sys.argv[1:])
-##     for arg in argiter:
-##         try:
-##             listen_port = int(arg)
-##         except ValueError:
-##             if os.path.isfile(arg+'.py'):
-##                 assert not os.path.isfile(arg), (
-##                     "ambiguous file naming, please rename %s" % arg)
-##                 targetspec = arg
-##             elif os.path.isfile(arg) and arg.endswith('.py'):
-##                 targetspec = arg[:-3]
-##     t = None
-##     options = {}
-##     for opt in parser.option_list[1:]:
-##         options[opt.dest] = getattr(cmd_line_opt,opt.dest)
-##         if options.get('gc') == 'boehm':
-##             options['-boehm'] = True
-## ##    if options['-tcc']:
-## ##        os.environ['PYPY_CC'] = 'tcc -shared -o "%s.so" "%s.c"'
-##     if cmd_line_opt.debug:
-##         annmodel.DEBUG = True
-##     try:
-##         err = None
-##         if cmd_line_opt.load:
-##             loaded_dic = load(cmd_line_opt.load)
-##             t = loaded_dic['trans']
-##             entry_point = t.entrypoint
-##             inputtypes = loaded_dic['inputtypes']
-##             targetspec_dic = loaded_dic['targetspec_dic']
-##             targetspec = loaded_dic['targetspec']
-##             old_options = loaded_dic['options']
-##             for name in 'no_a specialize optimize'.split():
-##                 # if one of these options has not been set, before,
-##                 # then the action has been done and must be prevented, now.
-##                 if not old_options[name]:
-##                     if options[name]:
-##                         print 'option %s is implied by the load' % name
-##                     options[name] = True
-##             print "continuing Analysis as defined by %s, loaded from %s" %(
-##                 targetspec, cmd_line_opt.loadname)
-##             targetspec_dic['target'] = None
-##         else:
-##             targetspec_dic = {}
-##             sys.path.insert(0, os.path.dirname(targetspec))
-##             execfile(targetspec+'.py', targetspec_dic)
-##             print "Analysing target as defined by %s" % targetspec
-##             if targetspec_dic.get('options', None):
-##                 targetspec_dic['options'].update(options)
-##                 options = targetspec_dic['options']
-##                 print options,targetspec_dic['options']
-##         print 'options in effect:'
-##         optnames = options.keys()
-##         optnames.sort()
-##         for name in optnames: 
-##             print '   %25s: %s' %(name, options[name])
-
-##         policy = AnnotatorPolicy()
-##         target = targetspec_dic['target']
-##         if target:
-##             spec = target(cmd_line_opt, []) # xxx rest args
-##             try:
-##                 entry_point, inputtypes, policy = spec
-##             except ValueError:
-##                 entry_point, inputtypes = spec
-##             t = Translator(entry_point, verbose=True, simplifying=True)
-##             a = None
-##         else:
-##             # otherwise we have been loaded
-##             a = t.annotator
-##             t.frozen = False
-##         if listen_port:
-##             from pypy.translator.tool.graphserver import run_async_server
-##             serv_start, serv_show, serv_stop, serv_cleanup = run_async_server(t, listen_port)
-##         try:
-##             standalone = analyse(t, inputtypes)
-##         except TyperError:
-##             err = sys.exc_info()
-##         print '-'*60
-##         if cmd_line_opt.save:
-##             print 'saving state to %s' % cmd_line_opt.save
-##             if err:
-##                 print '*** this save is done after errors occured ***'
-##             save(t, cmd_line_opt.save,
-##                  trans=t,
-##                  inputtypes=inputtypes,
-##                  targetspec=targetspec,
-##                  targetspec_dic=targetspec_dic,
-##                  options=options,
-##                  )
-##         if err:
-##             raise err[0], err[1], err[2]
-##         if cmd_line_opt.backend == 'c': #XXX probably better to supply gcpolicy as string to the backends
-##             gcpolicy = None
-##             if cmd_line_opt.gc =='boehm':
-##                 from pypy.translator.c import gc
-##                 gcpolicy = gc.BoehmGcPolicy
-##             if cmd_line_opt.gc == 'none':
-##                 from pypy.translator.c import gc
-##                 gcpolicy = gc.NoneGcPolicy
-##         elif cmd_line_opt.backend == 'llvm':
-##             gcpolicy = cmd_line_opt.gc
-
-##         if cmd_line_opt.backend == 'llinterpret':
-##             def interpret():
-##                 import py
-##                 from pypy.rpython.llinterp import LLInterpreter
-##                 py.log.setconsumer("llinterp operation", None)    
-##                 interp = LLInterpreter(t.flowgraphs, t.rtyper)
-##                 interp.eval_function(entry_point,
-##                                      targetspec_dic['get_llinterp_args']())
-##             interpret()
-##         elif not cmd_line_opt.gencode:
-##             print 'Not generating C code.'
-##         else:
-##             print 'Generating %s %s code...' %(cmd_line_opt.compile and "and compiling" or "",cmd_line_opt.backend)
-##             keywords = {'really_compile' : cmd_line_opt.compile, 
-##                         'standalone' : standalone, 
-##                         'gcpolicy' : gcpolicy}
-##             c_entry_point = t.compile(cmd_line_opt.backend, **keywords)
-                             
-##             if standalone: # xxx fragile and messy
-##                 import shutil
-##                 exename = mkexename(c_entry_point)
-##                 newexename = mkexename('./pypy-' + cmd_line_opt.backend)
-##                 shutil.copy(exename, newexename)
-##                 c_entry_point = newexename
-##             update_usession_dir()
-##             print 'Written %s.' % (c_entry_point,)
-##             if cmd_line_opt.run:
-##                 print 'Running!'
-##                 if standalone:
-##                     os.system(c_entry_point)
-##                 else:
-##                     targetspec_dic['run'](c_entry_point)
-##     except SystemExit:
-##         raise
-##     except:
-##         if t: debug(True)
-##         raise SystemExit(1)
-##     else:
-##         if t: debug(False)
+
+if __name__ == '__main__':
+    main()

Modified: pypy/dist/pypy/translator/tool/pdbplus.py
==============================================================================
--- pypy/dist/pypy/translator/tool/pdbplus.py	(original)
+++ pypy/dist/pypy/translator/tool/pdbplus.py	Fri Sep 30 00:38:35 2005
@@ -8,6 +8,7 @@
     def __init__(self, translator):
         pdb.Pdb.__init__(self)
         self.translator = translator
+        self.exposed = {}
 
     def post_mortem(self, t):
         self.reset()
@@ -15,6 +16,9 @@
             t = t.tb_next
         self.interaction(t.tb_frame, t)        
 
+    def expose(self, d):
+        self.exposed.update(d)
+
     show = None
 
     def install_show(self, show):
@@ -360,6 +364,8 @@
             fn, args = self.post_mortem, (tb,)
         try:
             t = self.translator # define enviroments, xxx more stuff
+            exec ""
+            locals().update(self.exposed)
             fn(*args)
             pass # for debugger to land
         except pdb.bdb.BdbQuit:

Modified: pypy/dist/pypy/translator/tool/pygame/server.py
==============================================================================
--- pypy/dist/pypy/translator/tool/pygame/server.py	(original)
+++ pypy/dist/pypy/translator/tool/pygame/server.py	Fri Sep 30 00:38:35 2005
@@ -1,5 +1,5 @@
 
-def run_translator_server(t, entry_point, options):
+def run_translator_server(t, options):
     from pypy.translator.tool import graphpage
     import pygame
     from pypy.translator.tool.pygame.graphclient import get_layout



More information about the Pypy-commit mailing list