[pypy-svn] r13541 - pypy/dist/pypy/rpython

tismer at codespeak.net tismer at codespeak.net
Fri Jun 17 16:28:22 CEST 2005


Author: tismer
Date: Fri Jun 17 16:28:21 2005
New Revision: 13541

Modified:
   pypy/dist/pypy/rpython/llinterp.py
Log:
removed trailing spaces.

It would be nice if everybody would check
editor settings if possible? Space lines
between python functions are quite usual,
but there we many single spaces at line ends
all over the place. ???

Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py	(original)
+++ pypy/dist/pypy/rpython/llinterp.py	Fri Jun 17 16:28:21 2005
@@ -1,34 +1,34 @@
-from pypy.rpython.lltype import * 
+from pypy.rpython.lltype import *
 from pypy.rpython.lltype import _ptr
 from pypy.translator.translator import Translator
 from pypy.tool.sourcetools import compile2
 from pypy.objspace.flow.model import Constant, Variable, last_exception
 import py
 
-log = py.log.Producer('llinterp') 
+log = py.log.Producer('llinterp')
 
 class LLException(Exception):
     pass
 
-class LLInterpreter(object): 
-    """ low level interpreter working with concrete values. """ 
+class LLInterpreter(object):
+    """ low level interpreter working with concrete values. """
 
-    def __init__(self, flowgraphs, typer): 
-        self.flowgraphs = flowgraphs 
+    def __init__(self, flowgraphs, typer):
+        self.flowgraphs = flowgraphs
         self.bindings = {}
         self.typer = typer
 
     # _______________________________________________________
-    # variable setters/getters helpers 
-    
-    def fillvars(self, block, values): 
-        vars = block.inputargs 
+    # variable setters/getters helpers
+
+    def fillvars(self, block, values):
+        vars = block.inputargs
         assert len(vars) == len(values), (
                    "block %s received %d args, expected %d" % (
                     block, len(values), len(vars)))
-        for var, val in zip(vars, values): 
-            self.setvar(var, val) 
-        
+        for var, val in zip(vars, values):
+            self.setvar(var, val)
+
     def setvar(self, var, val):
         if var.concretetype != Void:
             assert var.concretetype == typeOf(val)
@@ -39,18 +39,18 @@
         if isinstance(var, Variable):
             self.setvar(var, val)
 
-    def getval(self, varorconst): 
-        try: 
+    def getval(self, varorconst):
+        try:
             return varorconst.value
-        except AttributeError: 
+        except AttributeError:
             return self.bindings[varorconst]
 
     # _______________________________________________________
-    # other helpers 
-    def getoperationhandler(self, opname): 
-        try: 
-            return getattr(self, 'op_' + opname) 
-        except AttributeError: 
+    # other helpers
+    def getoperationhandler(self, opname):
+        try:
+            return getattr(self, 'op_' + opname)
+        except AttributeError:
             g = globals()
             assert opname in g, (
                     "cannot handle operation %r yet" %(opname,))
@@ -64,18 +64,18 @@
         graph = self.flowgraphs[func]
         return self.eval_graph(graph,args)
 
-    def eval_graph(self, graph, args=()): 
+    def eval_graph(self, graph, args=()):
         log.graph("evaluating", graph.name)
         nextblock = graph.startblock
-        while 1: 
-            self.fillvars(nextblock, args) 
+        while 1:
+            self.fillvars(nextblock, args)
             nextblock, args = self.eval_block(nextblock)
             if nextblock is None:
                 return args
 
-    def eval_block(self, block): 
-        """ return (nextblock, values) tuple. If nextblock 
-            is None, values is the concrete return value. 
+    def eval_block(self, block):
+        """ return (nextblock, values) tuple. If nextblock
+            is None, values is the concrete return value.
         """
         catch_exception = block.exitswitch == Constant(last_exception)
         e = None
@@ -87,7 +87,7 @@
             if not (catch_exception and op is block.operations[-1]):
                 raise
 
-        # determine nextblock and/or return value 
+        # determine nextblock and/or return value
         if len(block.exits) == 0:
             # return block
             if len(block.inputargs) == 2:
@@ -98,9 +98,9 @@
                 # watch out, these are _ptr's
                 raise LLException(etype, evalue)
             resultvar, = block.getvariables()
-            result = self.getval(resultvar) 
-            log.operation("returning", result) 
-            return None, result 
+            result = self.getval(resultvar)
+            log.operation("returning", result)
+            return None, result
         elif block.exitswitch is None:
             # single-exit block
             assert len(block.exits) == 1
@@ -119,37 +119,37 @@
                 else:
                     # no handler found, pass on
                     raise e
-        else: 
+        else:
             index = self.getval(block.exitswitch)
             link = block.exits[index]
         return link.target, [self.getval(x) for x in link.args]
-    
-    def eval_operation(self, operation): 
-        log.operation("considering", operation) 
-        ophandler = self.getoperationhandler(operation.opname) 
+
+    def eval_operation(self, operation):
+        log.operation("considering", operation)
+        ophandler = self.getoperationhandler(operation.opname)
         vals = [self.getval(x) for x in operation.args]
         # if these special cases pile up, do something better here
         if operation.opname == 'cast_pointer':
             vals.insert(0, operation.result.concretetype)
-        retval = ophandler(*vals) 
+        retval = ophandler(*vals)
         self.setvar(operation.result, retval)
 
     # __________________________________________________________
-    # misc LL operation implementations 
+    # misc LL operation implementations
 
-    def op_same_as(self, x): 
+    def op_same_as(self, x):
         return x
 
-    def op_setfield(self, obj, fieldname, fieldvalue): 
+    def op_setfield(self, obj, fieldname, fieldvalue):
         # obj should be pointer
         setattr(obj, fieldname, fieldvalue)
-        
+
     def op_getarrayitem(self,array,index):
         return array[index]
-    
+
     def op_setarrayitem(self,array,index,item):
         array[index] = item
-        
+
     def op_direct_call(self, f, *args):
         if hasattr(f._obj, 'graph'):
             return self.eval_graph(f._obj.graph, args)
@@ -157,7 +157,7 @@
 
     def op_malloc(self, obj):
         return malloc(obj)
-    
+
     def op_getfield(self, obj, field):
         # assert: obj should be pointer
         result = getattr(obj, field)
@@ -186,38 +186,38 @@
     def op_getarraysize(self,array):
         #print array,type(array),dir(array)
         return len(array)
-    
+
     def op_cast_pointer(self, tp, obj):
         # well, actually this is what's now in the globals.
         return cast_pointer(tp, obj)
 # __________________________________________________________
-# primitive operations 
-from pypy.objspace.flow.operation import FunctionByName 
+# primitive operations
+from pypy.objspace.flow.operation import FunctionByName
 opimpls = FunctionByName.copy()
-opimpls['is_true'] = bool 
+opimpls['is_true'] = bool
 
-for typ in (float, int): 
+for typ in (float, int):
     typname = typ.__name__
-    for opname in ('add', 'sub', 'mul', 'div', 'gt', 'lt', 
-                   'ge', 'ne', 'le', 'eq'): 
-        assert opname in opimpls 
+    for opname in ('add', 'sub', 'mul', 'div', 'gt', 'lt',
+                   'ge', 'ne', 'le', 'eq'):
+        assert opname in opimpls
         exec py.code.Source("""
-            def %(typname)s_%(opname)s(x, y): 
+            def %(typname)s_%(opname)s(x, y):
                 assert isinstance(x, %(typname)s)
                 assert isinstance(y, %(typname)s)
                 func = opimpls[%(opname)r]
-                return func(x, y) 
+                return func(x, y)
         """ % locals()).compile()
-    for opname in 'is_true',: 
-        assert opname in opimpls 
+    for opname in 'is_true',:
+        assert opname in opimpls
         exec py.code.Source("""
-            def %(typname)s_%(opname)s(x): 
+            def %(typname)s_%(opname)s(x):
                 assert isinstance(x, %(typname)s)
                 func = opimpls[%(opname)r]
-                return func(x) 
+                return func(x)
         """ % locals()).compile()
 
 # by default we route all logging messages to nothingness
-# e.g. tests can then switch on logging to get more help 
-# for failing tests 
-py.log.setconsumer('llinterp', None) 
+# e.g. tests can then switch on logging to get more help
+# for failing tests
+py.log.setconsumer('llinterp', None)



More information about the Pypy-commit mailing list