Commits

Brian Kearns  committed 5f4b6b6

cleanups in rpython.translator

  • Participants
  • Parent commits c154acb

Comments (0)

Files changed (25)

File rpython/translator/backendopt/escape.py

             return NotImplemented
         return VarState(self.get_creationpoint(op.result, "malloc_varsize", op))
 
-    def op_keepalive(self, op, state):
-        return None
-
     def op_cast_pointer(self, op, state):
         return state
 

File rpython/translator/backendopt/mallocprediction.py

                     STRUCT)._obj.destructor_funcptr
                 if destr_ptr:
                     continue
-            except (ValueError, AttributeError), e:
+            except (ValueError, AttributeError):
                 pass
             varstate = adi.getstate(op.result)
             assert len(varstate.creation_points) == 1

File rpython/translator/backendopt/mallocv.py

 from rpython.flowspace.model import Variable, Constant, Block, Link
-from rpython.flowspace.model import SpaceOperation, FunctionGraph, copygraph
+from rpython.flowspace.model import SpaceOperation, copygraph
 from rpython.flowspace.model import checkgraph
 from rpython.flowspace.model import c_last_exception
 from rpython.translator.backendopt.support import log

File rpython/translator/backendopt/tailrecursion.py

-from rpython.translator.simplify import get_graph
 from rpython.flowspace.model import mkentrymap, checkgraph
 
 # this transformation is very academical -- I had too much time

File rpython/translator/c/extfunc.py

         def _RPyListOfString_New(length=lltype.Signed):
             return LIST_OF_STR.ll_newlist(length)
 
-        def _RPyListOfString_New(length=lltype.Signed):
-            return LIST_OF_STR.ll_newlist(length)
-
         def _RPyListOfString_SetItem(l=p,
                                     index=lltype.Signed,
                                     newstring=lltype.Ptr(STR)):

File rpython/translator/c/funcgen.py

                         for op in self.gen_link(link):
                             yield '\t' + op
                         # 'break;' not needed, as gen_link ends in a 'goto'
-                        
                     # Emit default case
                     yield 'default:'
                     if defaultlink is None:
 
     # the C preprocessor cannot handle operations taking a variable number
     # of arguments, so here are Python methods that do it
-    
+
     def OP_NEWLIST(self, op):
         args = [self.expr(v) for v in op.args]
         r = self.expr(op.result)

File rpython/translator/c/node.py

 from rpython.rtyper.lltypesystem.lltype import (Struct, Array, FixedSizeArray,
     FuncType, typeOf, GcStruct, GcArray, RttiStruct, ContainerType, parentlink,
-    Ptr, Void, OpaqueType, Float, RuntimeTypeInfo, getRuntimeTypeInfo, Char,
+    Void, OpaqueType, Float, RuntimeTypeInfo, getRuntimeTypeInfo, Char,
     _subarray)
 from rpython.rtyper.lltypesystem import llmemory, llgroup
 from rpython.translator.c.funcgen import FunctionCodeGenerator
 from rpython.translator.c.primitive import PrimitiveType, name_signed
 from rpython.rlib import exports
 from rpython.rlib.rfloat import isfinite, isinf
-from rpython.rlib.rstackovf import _StackOverflow
 from rpython.translator.c import extfunc
-from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from py.builtin import BaseException
 
 def needs_gcheader(T):
     if not isinstance(T, ContainerType):
             return 'RPyItem(%s, %s)' % (baseexpr, indexexpr)
 
     def definition(self):
-        gcpolicy = self.db.gcpolicy
         yield 'struct %s {' % self.name
         for fname, typename in self.gcfields:
             yield '\t' + cdecl(typename, fname) + ';'
 
     def initializationexpr(self, decoration=''):
         T = self.getTYPE()
-        defnode = self.db.gettypedefnode(T)
         yield '{'
         if needs_gcheader(T):
             gc_init = self.db.gcpolicy.array_gcheader_initdata(self)
     def initializationexpr(self, decoration=''):
         T = self.getTYPE()
         assert self.typename == self.implementationtypename  # not var-sized
-        is_empty = True
         yield '{'
         # _names == ['item0', 'item1', ...]
         for j, name in enumerate(T._names):

File rpython/translator/driver.py

             for func, inputtypes in self.secondary_entrypoints:
                 if inputtypes == Ellipsis:
                     continue
-                rettype = annotator.build_types(func, inputtypes, False)
+                annotator.build_types(func, inputtypes, False)
 
         if self.entry_point:
             s = annotator.build_types(self.entry_point, self.inputtypes)

File rpython/translator/exceptiontransform.py

 from rpython.translator.simplify import join_blocks, cleanup_graph
 from rpython.translator.unsimplify import copyvar, varoftype
 from rpython.translator.unsimplify import insert_empty_block, split_block
-from rpython.translator.backendopt import canraise, inline, support, removenoops
+from rpython.translator.backendopt import canraise, inline
 from rpython.flowspace.model import Block, Constant, Variable, Link, \
-    c_last_exception, SpaceOperation, checkgraph, FunctionGraph, mkentrymap
+    c_last_exception, SpaceOperation, FunctionGraph, mkentrymap
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rtyper.ootypesystem import ootype
 from rpython.rtyper.lltypesystem import lloperation
 from rpython.rtyper import rtyper
-from rpython.rtyper import rclass
 from rpython.rtyper.rmodel import inputconst
 from rpython.rlib.rarithmetic import r_uint, r_longlong, r_ulonglong
 from rpython.rlib.rarithmetic import r_singlefloat
             evalue = rpyexc_fetch_value()
             rpyexc_clear()
             return evalue
-        
+
         def rpyexc_restore_exception(evalue):
             if evalue:
                 exc_data.exc_type = rclass.ll_inst_type(evalue)
 
         # XXX: does alloc_shortcut make sense also for ootype?
         if alloc_shortcut:
-            T = spaceop.result.concretetype
             var_no_exc = self.gen_nonnull(spaceop.result, llops)
         else:
             v_exc_type = self.gen_getfield('exc_type', llops)
             var_no_exc = self.gen_isnull(v_exc_type, llops)
 
         block.operations.extend(llops)
-        
+
         block.exitswitch = var_no_exc
         #exception occurred case
         b = Block([])

File rpython/translator/gensupp.py

 Another name could be genEric, but well...
 """
 
-import sys
-
 def uniquemodulename(name, SEEN={}):
     # never reuse the same module name within a Python session!
     i = 0

File rpython/translator/goal/_test_thread.py

-import thread, time
+import thread
 
 class MonitorList(list):
     def append(self, obj):

File rpython/translator/goal/bpnn.py

 
 # __________  Entry point for stand-alone builds __________
 
-import time
-
 def entry_point(argv):
     if len(argv) > 1:
         N = int(argv[1])

File rpython/translator/goal/gcbench.py

 #               - No attempt to measure variation with object size
 #               - Results are sensitive to locking cost, but we dont
 #                 check for proper locking
-import os, time
+import time
 
 USAGE = """gcbench [num_repetitions] [--depths=N,N,N..] [--threads=N]"""
 ENABLE_THREADS = True

File rpython/translator/goal/query.py

 # functions to query information out of the translator and annotator from the debug prompt of translate
 import types
-import re
 
 import rpython.annotator.model as annmodel
 import rpython.flowspace.model as flowmodel
     return "%s -> %s" % (
         ', '.join(map(hbinding, g.getargs())),
         hbinding(g.getreturnvar()))
-    
+
 class Found(Exception):
     pass
 

File rpython/translator/goal/targetgcbench.py

-import os, sys
 from rpython.translator.goal import gcbench
 
 # _____ Define and setup target ___

File rpython/translator/goal/targetpushpop.py

 actually implementing argv of the executable.
 """
 
-import os, sys
-
 # __________  Entry point  __________
 
 class A(object):

File rpython/translator/goal/targetvarsized.py

-import os, sys
+import os
 #from rpython.translator.goal import richards
 
 modfilename = os.path.join(os.path.dirname(__file__), 'richards.py')

File rpython/translator/platform/__init__.py

 
 import py, os, sys
 
-from rpython.tool.ansi_print import ansi_log
 from rpython.tool.runsubprocess import run_subprocess as _run_subprocess
 from rpython.tool.udir import udir
 

File rpython/translator/platform/arm.py

-import py, os
 from rpython.translator.platform.linux import Linux
 from rpython.translator.platform.posix import _run_subprocess, GnuMakefile
 from rpython.translator.platform import ExecutionResult, log
-from rpython.tool.udir import udir
 from os import getenv
 
 SB2 = getenv('SB2')

File rpython/translator/platform/darwin.py

 """Support for OS X."""
 
-import os
-
 from rpython.translator.platform import posix
 
 class Darwin(posix.BasePosix):
         return (list(self.shared_only)
                 + ['-dynamiclib', '-undefined', 'dynamic_lookup']
                 + args)
-    
+
     def _include_dirs_for_libffi(self):
         return ['/usr/include/ffi']
 

File rpython/translator/simplify.py

 """
 
 import py
+
 from rpython.flowspace import operation
-from rpython.flowspace.model import (SpaceOperation, Variable, Constant, Block,
-                                      Link, c_last_exception, checkgraph,
-                                      mkentrymap)
+from rpython.flowspace.model import (SpaceOperation, Variable, Constant,
+                                     c_last_exception, checkgraph, mkentrymap)
 from rpython.rlib import rarithmetic
 from rpython.translator import unsimplify
 from rpython.translator.backendopt import ssa
     Return an object which is supposed to have attributes such as graph and
     _callable
     """
-    if hasattr(func, '_obj'): 
+    if hasattr(func, '_obj'):
         return func._obj # lltypesystem
     else:
         return func # ootypesystem
                     pending.append(prevvar)
 
     flow_read_var_backward(read_vars)
-    
+
     for block in blocks:
 
         # look for removable operations whose result is never used
                 elif op.opname == 'simple_call': 
                     # XXX we want to have a more effective and safe 
                     # way to check if this operation has side effects
-                    # ... 
+                    # ...
                     if op.args and isinstance(op.args[0], Constant):
                         func = op.args[0].value
                         try:
                 break
         else:
             raise AssertionError("lost 'iter' operation")
-        vlength = Variable('maxlength')
         vlist2 = Variable(vlist)
         chint = Constant({'maxlength': True})
         iterblock.operations += [
     eliminate_empty_blocks(graph)
     join_blocks(graph)
     remove_identical_vars(graph)
-    checkgraph(graph)    
-    
+    checkgraph(graph)

File rpython/translator/tool/graphpage.py

-import inspect, types
 from rpython.flowspace.model import Block, Link, FunctionGraph
 from rpython.flowspace.model import safe_iterblocks, safe_iterlinks
-from rpython.translator.tool.make_dot import DotGen, make_dot, make_dot_graphs
+from rpython.translator.tool.make_dot import DotGen, make_dot_graphs
 from rpython.annotator.model import SomePBC
 from rpython.annotator.description import MethodDesc
 from rpython.annotator.classdef import ClassDef
             label += "\\n" + self.createlink(info.origin, 'Originated at')
         if caused_by is not None:
             label += '\\n' + self.createlink(caused_by)
-        
+
         dotgen.emit_node('0', shape="box", color="red", label=label)
         for n, (data, caused_by) in zip(range(len(history)), history):
             label = nottoowide(data)
         return 'class_hierarchy'
 
     def do_compute(self, dotgen):
-        translator = self.translator
-
         # show the class hierarchy
         self.compute_class_hieararchy(dotgen)
 

File rpython/translator/tool/lltracker.py

 """
 
 import sys, os
-import gc
 from rpython.rtyper.lltypesystem import lltype, llmemory
 from rpython.memory.gcheader import header2obj
 from rpython.translator.tool.reftracker import BaseRefTrackerPage, MARKER
 
 
 class LLRefTrackerPage(BaseRefTrackerPage):
-
     def compute(self, objectlist, size_gc_header):
         self.size_gc_header = size_gc_header
         return BaseRefTrackerPage.compute(self, objectlist)
                                                      with_header=False):
                     yield fmt % (name,), value
             if gcobjptr:
-                GCT = lltype.typeOf(gcobjptr)
                 if self.size_gc_header is not None:
                     for sub in self.enum_content(gcobjptr._obj,
                                                  with_header=False):

File rpython/translator/transform.py

 completed.
 """
 
-import types
 from rpython.flowspace.model import SpaceOperation
 from rpython.flowspace.model import Variable, Constant, Link
 from rpython.flowspace.model import c_last_exception, checkgraph
 from rpython.annotator import model as annmodel
-from rpython.rlib.rstack import stack_check
 from rpython.rtyper.lltypesystem import lltype
 
 def checkgraphs(self, blocks):

File rpython/translator/translator.py

 translation-related code.  It can be used for interactive testing of the
 translator; see pypy/bin/translatorshell.py.
 """
-import os, sys, types, copy
+import sys
+import types
 
 from rpython.translator import simplify
 from rpython.flowspace.model import FunctionGraph, checkgraph, Block
 from rpython.flowspace.objspace import build_flow
 from rpython.tool.ansi_print import ansi_log
 from rpython.tool.sourcetools import nice_repr_for_func
-from rpython.config.translationoption import get_combined_translation_config
 from rpython.config.translationoption import get_platform
+
 import py
 log = py.log.Producer("flowgraph")
 py.log.setconsumer("flowgraph", ansi_log)