[pypy-svn] r12460 - in pypy/dist: demo goal pypy/bin pypy/documentation pypy/interpreter pypy/interpreter/test pypy/objspace pypy/translator pypy/translator/goal

arigo at codespeak.net arigo at codespeak.net
Wed May 18 19:15:26 CEST 2005


Author: arigo
Date: Wed May 18 19:15:26 2005
New Revision: 12460

Added:
   pypy/dist/demo/   (props changed)
      - copied from r12444, pypy/dist/goal/
   pypy/dist/demo/bpnn.py   (contents, props changed)
   pypy/dist/demo/fibonacci.py   (contents, props changed)
   pypy/dist/demo/sharedref.py
      - copied, changed from r12455, user/arigo/hack/pypy-hack/sharedref.py
   pypy/dist/pypy/bin/   (props changed)
   pypy/dist/pypy/bin/autopath.py
      - copied unchanged from r12444, pypy/dist/pypy/interpreter/autopath.py
   pypy/dist/pypy/bin/py.py
      - copied, changed from r12444, pypy/dist/pypy/interpreter/py.py
   pypy/dist/pypy/bin/translator.py   (contents, props changed)
      - copied, changed from r12451, pypy/dist/pypy/translator/translator.py
   pypy/dist/pypy/translator/goal/
      - copied from r12444, pypy/dist/goal/
Removed:
   pypy/dist/demo/app_example.py
   pypy/dist/demo/app_main.py
   pypy/dist/demo/buildcache.py
   pypy/dist/demo/buildcache2.py
   pypy/dist/demo/compiler-hack.py
   pypy/dist/demo/dis-pregoal.py
   pypy/dist/demo/gadfly-demo.py
   pypy/dist/demo/hello_world.py
   pypy/dist/demo/objectspace-reconstruct.py
   pypy/dist/demo/pydoc-goal.py
   pypy/dist/demo/pydoc-pregoal.py
   pypy/dist/demo/stringcomp.py
   pypy/dist/demo/targetpypy.py
   pypy/dist/demo/targetpypy0.py
   pypy/dist/demo/targetpypy1.py
   pypy/dist/demo/targetpypymain.py
   pypy/dist/demo/targetrpystone.py
   pypy/dist/demo/targetrpystone2.py
   pypy/dist/demo/translate_pypy.py
   pypy/dist/goal/
   pypy/dist/pypy/interpreter/py.py
   pypy/dist/pypy/translator/goal/buildcache.py
   pypy/dist/pypy/translator/goal/compiler-hack.py
   pypy/dist/pypy/translator/goal/dis-goal.py
   pypy/dist/pypy/translator/goal/dis-pregoal.py
   pypy/dist/pypy/translator/goal/foodbill.py
   pypy/dist/pypy/translator/goal/gadfly-demo.py
   pypy/dist/pypy/translator/goal/hello_world.py
   pypy/dist/pypy/translator/goal/http-and-html.py
   pypy/dist/pypy/translator/goal/objectspace-reconstruct.py
   pypy/dist/pypy/translator/goal/pydoc-goal.py
   pypy/dist/pypy/translator/goal/pydoc-pregoal.py
   pypy/dist/pypy/translator/goal/stringcomp.py
Modified:
   pypy/dist/demo/dis-goal.py
   pypy/dist/demo/foodbill.py
   pypy/dist/demo/http-and-html.py
   pypy/dist/pypy/documentation/objspace.txt
   pypy/dist/pypy/interpreter/test/test_py.py
   pypy/dist/pypy/objspace/thunk.py
   pypy/dist/pypy/translator/goal/translate_pypy.py   (contents, props changed)
   pypy/dist/pypy/translator/translator.py
Log:
issue47 in-progress

New official entry points into PyPy:
A    dist/pypy/bin/py.py
A    dist/pypy/bin/translator.py
D    pypy/interpreter/py.py

translate_pypy and associated files have been moved:
A    dist/pypy/translator/goal
D    dist/goal

There is a new directory for demo material, where I kept some of the examples
of the old goal directory and commented them:
RM   dist/demo
M    dist/demo/foodbill.py
M    dist/demo/dis-goal.py
M    dist/demo/http-and-html.py

There are three new demos too.  Two about the thunk object space and one
showing a nicely annotated and translated piece of code (from the Psyco tests,
originally by Neil Schemenauer):
AM   demo/bpnn.py
A    demo/sharedref.py
AM   demo/fibonacci.py


Deleted: /pypy/dist/goal/app_example.py
==============================================================================
--- /pypy/dist/goal/app_example.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,3 +0,0 @@
-print '--- beginning of app_example.py ---'
-print 6*7
-print '--- end of app_example.py ---'

Deleted: /pypy/dist/goal/app_main.py
==============================================================================
--- /pypy/dist/goal/app_main.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,24 +0,0 @@
-# App-level version of py.py.
-# XXX very incomplete!  Blindly runs the file named as first argument.
-# No option checking, no interactive console, no fancy hooks.
-
-def entry_point(argv):
-    import sys
-    sys.executable = argv[0]
-    sys.argv = argv[1:]
-
-    mainmodule = type(sys)('__main__')
-    sys.modules['__main__'] = mainmodule
-
-    try:
-        execfile(sys.argv[0], mainmodule.__dict__)
-    except:
-        sys.excepthook(*sys.exc_info())
-        return 1
-    else:
-        return 0
-
-if __name__ == '__main__':
-    # debugging only
-    import sys
-    sys.exit(entry_point(sys.argv))

Added: pypy/dist/demo/bpnn.py
==============================================================================
--- (empty file)
+++ pypy/dist/demo/bpnn.py	Wed May 18 19:15:26 2005
@@ -0,0 +1,200 @@
+#!/usr/bin/python
+"""
+    Translator Demo
+
+    Run this file -- over regular Python! -- to analyse and type-annotate
+    the functions and class defined in this module, starting from the
+    entry point function demo().
+
+    Requires Pygame.
+"""
+# Back-Propagation Neural Networks
+# 
+# Written in Python.  See http://www.python.org/
+#
+# Neil Schemenauer <nascheme at enme.ucalgary.ca>
+#
+# Modifications to the original (Armin Rigo):
+#   * import random from PyPy's lib, which is Python 2.2's plain
+#     Python implementation
+#   * use sys.stdout.write() instead of print statements for now
+#   * starts the Translator instead of the demo by default.
+
+import sys
+import math
+
+# XXX the Translator needs the plain Python version of random.py:
+import autopath; from pypy.lib import random
+
+
+random.seed(0)
+
+# calculate a random number where:  a <= rand < b
+def rand(a, b):
+    return (b-a)*random.random() + a
+
+# Make a matrix (we could use NumPy to speed this up)
+def makeMatrix(I, J, fill=0.0):
+    m = []
+    for i in range(I):
+        m.append([fill]*J)
+    return m
+
+class NN:
+    
+    def __init__(self, ni, nh, no):
+        # number of input, hidden, and output nodes
+        self.ni = ni + 1 # +1 for bias node
+        self.nh = nh
+        self.no = no
+
+        # activations for nodes
+        self.ai = [1.0]*self.ni
+        self.ah = [1.0]*self.nh
+        self.ao = [1.0]*self.no
+        
+        # create weights
+        self.wi = makeMatrix(self.ni, self.nh)
+        self.wo = makeMatrix(self.nh, self.no)
+        # set them to random vaules
+        for i in range(self.ni):
+            for j in range(self.nh):
+                self.wi[i][j] = rand(-2.0, 2.0)
+        for j in range(self.nh):
+            for k in range(self.no):
+                self.wo[j][k] = rand(-2.0, 2.0)
+
+        # last change in weights for momentum   
+        self.ci = makeMatrix(self.ni, self.nh)
+        self.co = makeMatrix(self.nh, self.no)
+
+    def update(self, inputs):
+        if len(inputs) != self.ni-1:
+            raise ValueError, 'wrong number of inputs'
+
+        # input activations
+        for i in range(self.ni-1):
+            #self.ai[i] = 1.0/(1.0+math.exp(-inputs[i]))
+            self.ai[i] = inputs[i]
+
+        # hidden activations
+        for j in range(self.nh):
+            sum = 0.0
+            for i in range(self.ni):
+                sum = sum + self.ai[i] * self.wi[i][j]
+            self.ah[j] = 1.0/(1.0+math.exp(-sum))
+
+        # output activations
+        for k in range(self.no):
+            sum = 0.0
+            for j in range(self.nh):
+                sum = sum + self.ah[j] * self.wo[j][k]
+            self.ao[k] = 1.0/(1.0+math.exp(-sum))
+
+        return self.ao[:]
+
+
+    def backPropagate(self, targets, N, M):
+        if len(targets) != self.no:
+            raise ValueError, 'wrong number of target values'
+
+        # calculate error terms for output
+        output_deltas = [0.0] * self.no
+        for k in range(self.no):
+            ao = self.ao[k]
+            output_deltas[k] = ao*(1-ao)*(targets[k]-ao)
+
+        # calculate error terms for hidden
+        hidden_deltas = [0.0] * self.nh
+        for j in range(self.nh):
+            sum = 0.0
+            for k in range(self.no):
+                sum = sum + output_deltas[k]*self.wo[j][k]
+            hidden_deltas[j] = self.ah[j]*(1-self.ah[j])*sum
+
+        # update output weights
+        for j in range(self.nh):
+            for k in range(self.no):
+                change = output_deltas[k]*self.ah[j]
+                self.wo[j][k] = self.wo[j][k] + N*change + M*self.co[j][k]
+                self.co[j][k] = change
+                #print N*change, M*self.co[j][k]
+
+        # update input weights
+        for i in range(self.ni):
+            for j in range(self.nh):
+                change = hidden_deltas[j]*self.ai[i]
+                self.wi[i][j] = self.wi[i][j] + N*change + M*self.ci[i][j]
+                self.ci[i][j] = change
+
+        # calculate error
+        error = 0.0
+        for k in range(len(targets)):
+            error = error + 0.5*(targets[k]-self.ao[k])**2
+        return error
+
+
+    def test(self, patterns):
+        for p in patterns:
+            print_('%s -> %s' % (p[0], self.update(p[0])))
+
+    def weights(self):
+        print_('Input weights:')
+        for i in range(self.ni):
+            print_(self.wi[i])
+        print_()
+        print_('Output weights:')
+        for j in range(self.nh):
+            print_(self.wo[j])
+
+    def train(self, patterns, iterations=2000, N=0.5, M=0.1):
+        # N: learning rate
+        # M: momentum factor
+        for i in xrange(iterations):
+            error = 0.0
+            for p in patterns:
+                inputs = p[0]
+                targets = p[1]
+                self.update(inputs)
+                error = error + self.backPropagate(targets, N, M)
+            if i % 100 == 0:
+                print_('error %-14f' % error)
+
+def print_(s):
+    sys.stdout.write(s+'\n')
+
+
+def demo():
+    # Teach network XOR function
+    pat = [
+        [[0,0], [0]],
+        [[0,1], [1]],
+        [[1,0], [1]],
+        [[1,1], [0]]
+    ]
+
+    # create a network with two input, two hidden, and two output nodes
+    n = NN(2, 3, 1)
+    # train it with some patterns
+    n.train(pat, 2000)
+    # test it
+    n.test(pat)
+
+
+
+if __name__ == '__main__':
+    #demo()
+
+    print 'Loading...'
+    from pypy.translator.translator import Translator
+    t = Translator(demo)
+    print 'Annotating...'
+    a = t.annotate([])
+    a.simplify()
+    #a.specialize()
+    print 'Displaying the call graph and the class hierarchy.'
+    t.viewcg()
+    print 'Compiling...'
+    f = t.ccompile()
+    print 'Running...'
+    f()

Deleted: /pypy/dist/goal/buildcache.py
==============================================================================
--- /pypy/dist/goal/buildcache.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,56 +0,0 @@
-from pypy.tool import option, autopath, testit
-from pypy.interpreter import gateway 
-import os
-
-#######################################################
-def app_triggerall():
-    import sys, types # , exceptions
-    k = 42
-    def gen():
-        yield k
-        #yield (k, 1.0, 4L, [''], {}, unicode, Ellipsis) 
-        try:
-            raise ValueError
-        except ValueError: 
-            x = sys.exc_info()
-        try:
-            raise x[0], x[1], x[2]
-        except ValueError:
-            pass
-            
-    #gen.func_code.co_name
-    str({'co_name': ('f',)}), str(object.__init__.im_func.func_code)
-    #"for %r" % ({'x': gen}) 
-    "%02d %04f %05g %05s <%s> %r" % (1, 2.25, 2.25, 2.25, [1,2], {'x': gen})
-    for x in gen():
-        pass
-
-def app_triggerexec():
-    exec "i=3"
-    
-gateway.importall(globals())   # app_xxx() -> xxx()
-
-#######################################################
-from pypy.objspace.std import stdtypedef
-    
-def buildcache(space): 
-    print "triggering cache build for %r" % space 
-    triggerall(space) 
-    triggerexec(space)
-    #testit.main(os.path.join(autopath.pypydir, 'objspace', 'std'))
-    #Cache.freeze()
-    #space._typecache = frozendict(space._typecache) 
-    #space._faketypecache = frozendict(space._faketypecache) 
-    #space._gatewaycache = frozendict(space._gatewaycache) 
-    #space = option.objspace('std')
-    #buildcache(space)
-    #for x in  stdtypedef._temp:
-    #    x.cache_table = frozendict(x.cache_table)
-    print "cache build finished, caches are 'frozen' now"
-
-if __name__ == '__main__': 
-    space = option.objspace('std') 
-    buildcache(space) 
-    #testit.main(autopath.pypydir)
-
-    testit.main(os.path.join(autopath.pypydir)) # , 'objspace', 'std'))

Deleted: /pypy/dist/goal/buildcache2.py
==============================================================================
--- /pypy/dist/goal/buildcache2.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,54 +0,0 @@
-
-def buildcache(space):
-    from pypy.interpreter.typedef import interptypes
-    
-    space.builtin.getdict()
-    print "*builtin*"
-    w_dic = space.builtin.w_dict
-    #print space.unwrap(space.call_method(w_dic,"keys"))
-    
-
-    space.sys.getdict()
-    print "*sys*"
-    w_dic = space.sys.w_dict
-    #print space.unwrap(space.call_method(w_dic,"keys"))
-
-    # others
-    w_modules = space.sys.get('modules')
-    def getmodule(name):
-        return space.getitem(w_modules, space.wrap(name))
-
-    getmodule('parser').getdict()
-    print "*parser*"
-
-    for typedef in interptypes:
-        w_typ = space.gettypeobject(typedef)
-        w_typ.getdict()
-        print "*%s*" % typedef.name
-        
-    for typedef in space.model.pythontypes:
-        w_typ = getattr(space, 'w_' + typedef.name)
-        w_typ.getdict()
-
-        print "*%s*" % typedef.name
-        #print w_typ.dict_w.keys()
-
-    space.builtin.get('file').getdict()
-
-    space.appexec([],"""():
-    try:
-       raise ValueError
-    except ValueError:
-       pass
-    exec 'pass'    
-""")
-    # freeze caches?
-    print "cache build finished"
-
-if __name__ == '__main__':
-    import autopath    
-    from pypy.objspace.std.objspace import StdObjSpace
-
-    space = StdObjSpace()
-
-    buildcache(space)

Deleted: /pypy/dist/goal/compiler-hack.py
==============================================================================
--- /pypy/dist/goal/compiler-hack.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,6 +0,0 @@
-import compiler
-c = compiler.compile('a=1', '', 'exec')
-import dis
-dis.dis(c)
-exec c
-print a

Modified: pypy/dist/demo/dis-goal.py
==============================================================================
--- pypy/dist/goal/dis-goal.py	(original)
+++ pypy/dist/demo/dis-goal.py	Wed May 18 19:15:26 2005
@@ -1,2 +1,7 @@
+"""
+An old-time classical example, and one of our first goals.
+To run on top of PyPy.
+"""
+
 import dis
 dis.dis(dis.dis)

Deleted: /pypy/dist/goal/dis-pregoal.py
==============================================================================
--- /pypy/dist/goal/dis-pregoal.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,2 +0,0 @@
-import dis
-dis.disassemble(dis.dis.func_code)

Added: pypy/dist/demo/fibonacci.py
==============================================================================
--- (empty file)
+++ pypy/dist/demo/fibonacci.py	Wed May 18 19:15:26 2005
@@ -0,0 +1,43 @@
+"""
+Thunk (a.k.a. lazy objects) in PyPy.
+To run on top of the thunk object space with the following command-line:
+
+    py.py -o thunk thunk-demo.py
+
+This is a typical Functional Programming Languages demo, computing the
+Fibonacci sequence by using an infinite lazy linked list.
+"""
+
+try:
+    thunk    # only available in 'py.py -o thunk'
+except NameError:
+    print __doc__
+    raise SystemExit(2)
+
+# ____________________________________________________________
+
+
+class ListNode:
+    def __init__(self, head, tail):
+        self.head = head   # the first element of the list
+        self.tail = tail   # the sublist of all remaining elements
+
+
+def add_lists(list1, list2):
+    """Compute the linked-list equivalent of the Python expression
+          [a+b for (a,b) in zip(list1,list2)]
+    """
+    return ListNode(list1.head + list2.head,
+                    thunk(add_lists, list1.tail, list2.tail))
+
+
+# 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
+Fibonacci = ListNode(1, ListNode(1, None))
+Fibonacci.tail.tail = thunk(add_lists, Fibonacci, Fibonacci.tail)
+
+
+if __name__ == '__main__':
+    node = Fibonacci
+    while True:
+        print node.head
+        node = node.tail

Modified: pypy/dist/demo/foodbill.py
==============================================================================
--- pypy/dist/goal/foodbill.py	(original)
+++ pypy/dist/demo/foodbill.py	Wed May 18 19:15:26 2005
@@ -1,3 +1,8 @@
+"""
+Of historical interest: we computed the food bill of our first Gothenburg
+sprint with PyPy :-)
+"""
+
 slips=[(1, 'Kals MatMarkn', 6150, 'Chutney for Curry', 'dinner Saturday'),
        (2, 'Kals MatMarkn', 32000, 'Spaghetti, Beer', 'dinner Monday'),
        (2, 'Kals MatMarkn', -810, 'Deposit on Beer Bottles', 'various'),

Deleted: /pypy/dist/goal/gadfly-demo.py
==============================================================================
--- /pypy/dist/goal/gadfly-demo.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,23 +0,0 @@
-import os
-os.mkdir('db')
-
-import gadfly
-connection = gadfly.gadfly()
-connection.startup('test', 'db')
-cursor = connection.cursor()
-
-def print_and_execute(cursor, operation):
-    print operation
-    cursor.execute(operation)
-
-print_and_execute(cursor, "CREATE TABLE pypy(py varchar)")
-print_and_execute(cursor, "INSERT INTO pypy(py) VALUES ('py')")
-print_and_execute(cursor, "SELECT * FROM pypy")
-for row in cursor.fetchall():
-    print row
-
-connection.commit()
-connection.close()
-
-import shutil
-shutil.rmtree('db')

Deleted: /pypy/dist/goal/hello_world.py
==============================================================================
--- /pypy/dist/goal/hello_world.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,2 +0,0 @@
-aStr = 'hello world'
-print len(aStr)

Modified: pypy/dist/demo/http-and-html.py
==============================================================================
--- pypy/dist/goal/http-and-html.py	(original)
+++ pypy/dist/demo/http-and-html.py	Wed May 18 19:15:26 2005
@@ -1,3 +1,11 @@
+"""
+    Standard Library usage demo.
+    Uses urllib and htmllib to download and parse a web page.
+
+    The purpose of this demo is to remind and show that almost all
+    pure-Python modules of the Standard Library work just fine.
+"""
+
 url = 'http://www.python.org/'
 html = 'python.html'
 import urllib

Deleted: /pypy/dist/goal/objectspace-reconstruct.py
==============================================================================
--- /pypy/dist/goal/objectspace-reconstruct.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,163 +0,0 @@
-
-def __getattribute__(w_obj,w_name):
-  name = space.unwrap(w_name)
-  w_descr = space.lookup(w_obj, name)
-  if w_descr is not None:
-     if space.is_data_descr(w_descr):
-         return space.get(w_descr,w_obj,space.type(w_obj))
-  w_dict = space.getdict(w_obj)
-  if w_dict is not None:
-     try:
-       return space.getitem(w_dict,w_name)
-     except OperationError, e:
-       if not e.match(space,space.w_KeyError):
-         raise
-  if w_descr is not None:
-     return space.get(w_descr,w_obj,space.wrap(type))
-  raise OperationError(space.w_AttributeError,w_name)
-
-def space.getattr(w_obj,w_name):
-   w_descr = space.lookup(w_obj, '__getattribute__')
-   try:
-     return space.get_and_call_function(w_descr, w_obj, w_name)
-   except: # AttributeError
-     w_descr = space.lookup(w_obj, '__getattr__')
-     if w_descr is None:
-       raise
-     return space.get_and_call_function(w_descr, w_obj, w_name)
-
-def space.get(w_obj,w_name):
-   w_descr = space.lookup(w_obj, '__get__')
-   if w_descr is not None:
-     return space.get_and_call(w_descr, w_obj, space.newtuple([w_name]))
-   else:
-     return w_obj
-
-def space.call(w_obj, w_args, w_kwargs):
-   w_descr = space.lookup(w_obj, '__call__')
-   if w_descr is None:
-     raise OperationError(space.w_TypeError, space.wrap('...'))
-   return space.get_and_call(w_descr, w_obj, w_args, w_kwargs)
-
-
-class BaseObjSpace:
-  def get_and_call(self, w_descr, w_obj, w_args, w_kwargs):
-    if isinstance(w_descr, W_Function):
-      args_w = space.unpacktuple(w_args)
-      return w_descr.func.call(space.newtuple([w_obj]+args_w),w_kwargs)
-    else:
-      w_bound = space.get(w_descr,w_obj,space.gettype(w_obj))
-      return space.call(w_bound, w_args, w_kwargs)
-
-class Wrappable:
-    def __wrap__(self, space):
-        return self
-
-class Function(Wrappable):
-    TypeDef = Type("function", [], {
-        '__call__' : app_descr_function_call,
-        'func_code' : Property(func_code_getter) 
-        })
-
-class BuiltinType:
-    def __init__(self, name, bases, rawdict):
-        self.name = name 
-        self.bases = bases 
-        self.rawdict = rawdict
-        self.mro = []
-
-class W_Function:
-    def __init__(self, space, func):
-        self.func = func
-        self.space = space
-
-    def gettype(self):
-        space = self.space
-        try:
-            return space.FunctionType 
-        except AttributeError:
-            space.FunctionType = f = Type(space, [space.ObjectType]) 
-            f.dict_w['__call__'] = space.wrap(app_descr_function_call)
-            func_code_property = Property(func_code_getter)
-            f.dict_w['func_code'] = space.wrap(func_code_property) 
-            return f 
-
-class StdObjectSpace:
-    def lookup(space, w_obj, name):
-        typ = space._gettype(w_obj)
-        return space.wrap(typ.lookup(name))
-
-    def type(space,w_obj):
-        return space.wrap(space._gettype(w_obj))
-
-    def _gettype
-        try:
-            return space._types[w_obj.__class__]
-        except KeyError:
-            typ = space.buildtype(w_obj.TypeDef) 
-            space._types[w_obj.__class__] = typ
-            return typ
-
-    def buildtype(space, typedef):
-        typ = Type(w_
-        for name, value 
-
-    def wrap(space, obj):
-        
-        assert self.space == space 
-        return W_Type(space, self)
-
-def trivspace.lookup(space, w_obj, name):
-    if isinstance(w_obj, Wrappable):
-        for basedef in w_obj.TypeDef.mro():
-            if name in basedef.rawdict:
-                return space.wrap(basedef.rawdict[name])
-        return None 
-    else:
-        for cls in w_obj.__class__.__mro__:
-            if name in cls.__dict__:
-                return cls.__dict__[name]
-        return None
-
-
-def func_code_getter(space,w_func):
-    return space.wrap(w_func.func.code)
-
-def object___class__(space,w_obj):
-    return space.type(w_obj)
-
-def descr_function_call(space, w_func, w_args, w_kwds): 
-    return w_func.func.call(w_args, w_kwds)
-app_descr_function_call = gateway.interp2app(descr_function_call) 
-
-
-
-
-class Property:
-    def __init__(self, fget, fset=None, fdel=None, doc=None):
-        self.fget = fget
-        self.fset = fset
-        self.fdel = fdel
-        self.doc = doc
-    def __wrap__(self, space):
-        return W_Property(space, self)
-
-class W_Property(...Wrapped):
-    def __init__(self, space, property):
-        self.space = space
-        self.property = property
-    def gettype(self):
-        space = self.space
-        try:
-            return space.PropertyType
-        except AttributeError:
-            space.PropertyType = t = Type(space, "builtin-property", [])
-            t.dict_w["__get__"] = space.wrap(app_descr_property_get)
-            return t
-
-def descr_property_get(space, w_property, w_obj, w_ignored):
-    return w_property.property.fget(space, w_obj)
-
-app_descr_property_get = gateway.interp2app(descr_property_get)
-
-

Deleted: /pypy/dist/goal/pydoc-goal.py
==============================================================================
--- /pypy/dist/goal/pydoc-goal.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,2 +0,0 @@
-import pydoc
-pydoc.help(pydoc)

Deleted: /pypy/dist/goal/pydoc-pregoal.py
==============================================================================
--- /pypy/dist/goal/pydoc-pregoal.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1 +0,0 @@
-import pydoc

Copied: pypy/dist/demo/sharedref.py (from r12455, user/arigo/hack/pypy-hack/sharedref.py)
==============================================================================
--- user/arigo/hack/pypy-hack/sharedref.py	(original)
+++ pypy/dist/demo/sharedref.py	Wed May 18 19:15:26 2005
@@ -156,7 +156,14 @@
     print 'Ok'
     return Channel(s, False)
 
+
 if __name__ == '__main__':
+    try:
+        thunk, become    # only available in 'py.py -o thunk'
+    except NameError:
+        print __doc__
+        raise SystemExit(2)
+
     channels = []
     for a in sys.argv[1:]:
         try:

Deleted: /pypy/dist/goal/stringcomp.py
==============================================================================
--- /pypy/dist/goal/stringcomp.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,17 +0,0 @@
-
-### a trivial program to test strings, lists, functions and methods ###
-
-def addstr(s1,s2):
-    return s1 + s2
-
-str = "an interesting string"
-str2 = 'another::string::xxx::y:aa'
-str3 = addstr(str,str2)
-arr = []
-for word in str.split():
-    if word in str2.split('::'):
-        arr.append(word)
-print ''.join(arr)
-print "str + str2 = ", str3
-
-

Deleted: /pypy/dist/goal/targetpypy.py
==============================================================================
--- /pypy/dist/goal/targetpypy.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,32 +0,0 @@
-import buildcache2
-from pypy.objspace.std.objspace import StdObjSpace, W_Object
-from pypy.objspace.std.intobject import W_IntObject
-
-# __________  Entry point  __________
-
-def entry_point():
-    w_a = W_IntObject(space, -6)
-    w_b = W_IntObject(space, -7)
-    return space.mul(w_a, w_b)
-
-# _____ Define and setup target ___
-
-def target():
-    global space
-    # disable translation of the whole of classobjinterp.py
-    StdObjSpace.setup_old_style_classes = lambda self: None
-    space = StdObjSpace()
-    # call cache filling code
-    buildcache2.buildcache(space)    
-    # further call the entry_point once to trigger building remaining
-    # caches (as far as analyzing the entry_point is concerned)
-    entry_point()
-
-    return entry_point, []
-
-# _____ Run translated _____
-def run(c_entry_point):
-    w_result = c_entry_point()
-    print w_result
-    print w_result.intval
-    assert w_result.intval == 42

Deleted: /pypy/dist/goal/targetpypy0.py
==============================================================================
--- /pypy/dist/goal/targetpypy0.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,33 +0,0 @@
-from pypy.objspace import dummy
-from pypy.interpreter.pycode import PyCode
-
-# __________  Entry point  __________
-
-def entry_point(code, w_loc):
-    code2 = PyCode(space)
-    code2 = code2._from_code(code)
-    code2.exec_code(space, space.wrap({}), w_loc)
-
-# _____ Define and setup target _____
-
-def target():
-    global space
-    space = dummy.DummyObjSpace()
-
-    from pypy.interpreter import pycode
-
-    pycode.setup_frame_classes()
-
-    from pypy.interpreter import pyopcode
-
-    # cheat
-    space._gatewaycache.content[pyopcode.app] =  space.newdict([])
-
-    return entry_point,[object, dummy.W_Obj]
-
-# _____ Run translated _____
-
-def run(c_entry_point):
-    w_result = c_entry_point(compile("a+b","<stuff>","eval"),dummy.W_Obj())
-    print w_result
-

Deleted: /pypy/dist/goal/targetpypy1.py
==============================================================================
--- /pypy/dist/goal/targetpypy1.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,75 +0,0 @@
-from pypy.objspace.std.objspace import StdObjSpace, W_Object
-from pypy.objspace.std.intobject import W_IntObject
-from pypy.objspace.std import stdtypedef
-
-# __________  Entry point  __________
-
-operations = "mul add sub div mod lshift rshift floordiv truediv ".split()
-
-def entry_point():
-    w_a = W_IntObject(space, -7)
-    w_b = W_IntObject(space, 6)
-    results_w = [mmentrypoints[op](space, w_a, w_b) for op in operations]
-    return [space.unwrap(each) for each in resuls_w]
-
-# flatten the above code, to get a nicer look
-def make_flat_code():
-    g = globals()
-    # make globals constants from the operations
-    code = """def entry_point():
-    import sys
-    w_a = W_IntObject(space, -7)
-    # -sys.maxint-1 crashes: genc problem with OP_SUB and int constant
-    # when implementing lshift_Long_Long and rshift__Long_Long
-    w_b = W_IntObject(space,  6)
-    results_w = []
-    append = results_w.append
-"""
-    for op in operations:
-        g["op_%s" % op] = mmentrypoints[op]
-        line = "    append(op_%s(space, w_a, w_b))" % op
-        code += line + '\n'
-    code += "    return [space.unwrap(each) for each in results_w]\n"
-    print code
-    exec code in g
-    
-# _____ Define and setup target _____
-def target():
-    global space, mmentrypoints
-    # disable translation of the whole of classobjinterp.py
-    StdObjSpace.setup_old_style_classes = lambda self: None
-    space = StdObjSpace()
-    # call cache filling code *not* needed here
-
-    # ------------------------------------------------------------
-    mmentrypoints = {}
-    for name in operations:
-        mm = getattr(space.MM, name)
-        exprargs, expr, miniglobals, fallback = (
-            mm.install_not_sliced(space.model.typeorder, baked_perform_call=False))
-        func = stdtypedef.make_perform_trampoline('__mm_'+name,
-                                                  exprargs, expr, miniglobals,
-                                                  mm)
-        mmentrypoints[name] = func
-    # ------------------------------------------------------------
-
-    # further call the entry_point once to trigger building remaining
-    # caches (as far as analyzing the entry_point is concerned)
-    make_flat_code()
-    entry_point()
-
-    return entry_point, []
-
-# _____ Run translated _____
-
-def run(c_entry_point):
-    res = c_entry_point()
-    print res
-    import operator
-    assert res == [getattr(operator, name)(-7, 6) for name in operations]
-
-if __name__ == "__main__":
-    # just run it without translation
-    target()
-    run(entry_point)
-    
\ No newline at end of file

Deleted: /pypy/dist/goal/targetpypymain.py
==============================================================================
--- /pypy/dist/goal/targetpypymain.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,45 +0,0 @@
-import os, sys
-from pypy.objspace.std.objspace import StdObjSpace
-from pypy.annotation.model import *
-from pypy.annotation.listdef import ListDef
-from pypy.interpreter import gateway
-
-# WARNING: this requires the annotator.
-# There is no easy way to build all caches manually,
-# but the annotator can do it for us for free.
-
-this_dir = os.path.dirname(sys.argv[0])
-
-# __________  Entry point  __________
-
-def entry_point(argv):
-    w_argv = space.newlist([space.wrap(s) for s in argv])
-    w_exitcode = space.call(w_entry_point, w_argv)
-    return space.int_w(w_exitcode)
-
-# _____ Define and setup target ___
-
-def target():
-    global space, w_entry_point
-    # disable translation of the whole of classobjinterp.py
-    StdObjSpace.setup_old_style_classes = lambda self: None
-    # disable geninterp for now -- we have faaar toooo much interp-level code
-    # for the poor translator already
-    gateway.ApplevelClass.use_geninterp = False
-
-    space = StdObjSpace()
-
-    # manually imports app_main.py
-    filename = os.path.join(this_dir, 'app_main.py')
-    w_dict = space.newdict([])
-    space.exec_(open(filename).read(), w_dict, w_dict)
-    w_entry_point = space.getitem(w_dict, space.wrap('entry_point'))
-
-    s_list_of_strings = SomeList(ListDef(None, SomeString()))
-    return entry_point, [s_list_of_strings]
-
-# _____ Run translated _____
-def run(c_entry_point):
-    argv = [os.path.join(this_dir, 'app_example.py')]
-    exitcode = c_entry_point(argv)
-    assert exitcode == 0

Deleted: /pypy/dist/goal/targetrpystone.py
==============================================================================
--- /pypy/dist/goal/targetrpystone.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,36 +0,0 @@
-import buildcache2
-from pypy.objspace.std.objspace import StdObjSpace
-from pypy.translator.test import rpystone
-
-# __________  Entry point  __________
-
-LOOPS = 150000
-
-# rpystone.setslow(False)
-
-def entry_point():
-    rpystone.entrypoint(LOOPS)
-    
-# _____ Define and setup target _____
-def target():
-    global space, mmentrypoints
-    space = StdObjSpace()
-
-    # ------------------------------------------------------------
-
-    return entry_point, []
-
-# _____ Run translated _____
-
-def run(c_entry_point):
-    res_w = c_entry_point()
-    print res_w
-    print "CPython:"
-    rpystone.entrypoint(50000)
-
-if __name__ == "__main__":
-    # just run it without translation
-    LOOPS = 50000
-    target()
-    run(entry_point)
-    
\ No newline at end of file

Deleted: /pypy/dist/goal/targetrpystone2.py
==============================================================================
--- /pypy/dist/goal/targetrpystone2.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,36 +0,0 @@
-import buildcache2
-from pypy.objspace.std.objspace import StdObjSpace
-from pypy.translator.test import rpystone
-
-# __________  Entry point  __________
-
-LOOPS = 1000000
-
-rpystone.setslow(False)
-
-def entry_point():
-    rpystone.entrypoint(LOOPS)
-    
-# _____ Define and setup target _____
-def target():
-    global space, mmentrypoints
-    space = StdObjSpace()
-
-    # ------------------------------------------------------------
-
-    return entry_point, []
-
-# _____ Run translated _____
-
-def run(c_entry_point):
-    res_w = c_entry_point()
-    print res_w
-    print "CPython:"
-    rpystone.entrypoint(50000)
-
-if __name__ == "__main__":
-    # just run it without translation
-    LOOPS = 50000
-    target()
-    run(entry_point)
-    
\ No newline at end of file

Deleted: /pypy/dist/goal/translate_pypy.py
==============================================================================
--- /pypy/dist/goal/translate_pypy.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,434 +0,0 @@
-#
-#  
-#
-"""
-Command-line options for translate_pypy:
-
-   port       Listen on the given port number for connexions
-                  (see pypy/translator/tool/pygame/graphclient.py)
-   targetspec
-              targetspec.py is a python file defining
-              what is the translation target and setting things up for it,
-              it should have a target function returning an entry_point ...;
-              defaults to targetpypy. The .py suffix is optional.
-   -text      Don't start the Pygame viewer
-   -no-a      Don't infer annotations, just translate everything
-   -no-s      Don't simplify the graph after annotation
-   -no-t      Don't type-specialize the graph operations with the C typer
-   -no-c      Don't generate the C code
-   -c         Generate the C code, but don't compile it
-   -o         Generate and compile the C code, but don't run it
-   -no-mark-some-objects
-              Do not mark functions that have SomeObject in their signature.
-   -tcc       Equivalent to the envvar PYPY_CC='tcc -shared -o "%s.so" "%s.c"'
-                  -- http://fabrice.bellard.free.fr/tcc/
-   -no-d      Disable recording of debugging information
-   -huge=%    Threshold in the number of functions after which only a local call
-              graph and not a full one is displayed
-"""
-import autopath, sys, threading, pdb, os
-
-from pypy.translator.translator import Translator
-from pypy.translator.ann_override import pypy_overrides
-from pypy.annotation import model as annmodel
-from pypy.tool.cache import Cache
-from pypy.annotation.model import SomeObject
-from pypy.tool.udir import udir 
-from pypy.tool.ansi_print import ansi_print
-
-
-# XXX this tries to make compiling faster
-from pypy.translator.tool import buildpyxmodule
-buildpyxmodule.enable_fast_compilation()
-
-
-
-
-# __________  Main  __________
-
-def analyse(target):
-    global t, entry_point
-
-    entry_point, inputtypes = target()
-
-    t = Translator(entry_point, verbose=True, simplifying=True)
-    if listen_port:
-        run_async_server()
-    if not options['-no-a']:
-        try:
-            a = t.annotate(inputtypes, overrides=pypy_overrides)
-        finally:
-            worstblocks_topten(t.annotator)
-        if not options['-no-s']:
-            a.simplify()
-        if not options['-no-t']:
-            a.specialize()
-        t.frozen = True   # cannot freeze if we don't have annotations
-        if not options['-no-mark-some-objects']:
-            options['-no-mark-some-objects'] = True # Do not do this again
-            find_someobjects(t)
-
-
-def find_someobjects(translator, quiet=False):
-    """Find all functions in that have SomeObject in their signature."""
-    annotator = translator.annotator
-    if not annotator:
-        return # no annotations available
-
-    translator.highlight_functions = {}
-
-    def is_someobject(var):
-        try:
-            return annotator.binding(var).__class__ == SomeObject
-        except KeyError:
-            return False
-
-    def short_binding(var):
-        try:
-            binding = annotator.binding(var)
-        except KeyError:
-            return "?"
-        if binding.is_constant():
-            return 'const %s' % binding.__class__.__name__
-        else:
-            return binding.__class__.__name__
-
-    header = True
-    items = [(graph.name, func, graph)
-             for func, graph in translator.flowgraphs.items()]
-    items.sort()
-    num = someobjnum = 0
-    for graphname, func, graph in items:
-        unknown_input_args = len(filter(is_someobject, graph.getargs()))
-        unknown_return_value = is_someobject(graph.getreturnvar())
-        if unknown_input_args or unknown_return_value:
-            someobjnum += 1
-            translator.highlight_functions[func] = True
-            if not quiet:
-                if header:
-                    header = False
-                    print "=" * 70
-                    print "Functions that have SomeObject in their signature"
-                    print "=" * 70
-                print ("%(name)s(%(args)s) -> %(result)s\n"
-                       "%(filename)s:%(lineno)s\n"
-                       % {'name': graph.name,
-                          'filename': func.func_globals.get('__name__', '?'),
-                          'lineno': func.func_code.co_firstlineno,
-                          'args': ', '.join(map(short_binding,
-                                                graph.getargs())),
-                          'result': short_binding(graph.getreturnvar())})
-        num += 1
-    if not quiet:
-        print "=" * 70
-        percent = int(num and (100.0*someobjnum / num) or 0)
-        print "someobjectness: %2d percent" % (percent)
-        print "(%d out of %d functions get or return SomeObjects" % (
-            someobjnum, num) 
-        print "=" * 70
-
-
-def update_usession_dir(stabledir = udir.dirpath('usession')): 
-    from py import path 
-    try:
-        if stabledir.check(dir=1): 
-            for x in udir.visit(path.checker(file=1)): 
-                target = stabledir.join(x.relto(udir)) 
-                if target.check():
-                    target.remove()
-                else:
-                    target.dirpath().ensure(dir=1) 
-                try:
-                    target.mklinkto(x) 
-                except path.Invalid: 
-                    x.copy(target) 
-    except path.Invalid: 
-        print "ignored: couldn't link or copy to %s" % stabledir 
-
-def run_in_thread(fn, args, cleanup=None, cleanup_args=()):
-    def _run_in_thread():
-        fn(*args)
-        if cleanup is not None:
-            cleanup(*cleanup_args)
-    return threading.Thread(target=_run_in_thread, args=())
-
-def run_async_server():
-    from pypy.translator.tool import graphpage, graphserver
-    homepage = graphpage.TranslatorPage(t)
-    graphserver.run_server(homepage, port=listen_port, background=True)
-    options['-text'] = True
-
-def worstblocks_topten(ann, n=10):
-    h = [(count, block) for block, count in ann.reflowcounter.iteritems()]
-    h.sort()
-    print
-    ansi_print(',-----------------------  Top %d Most Reflown Blocks  -----------------------.' % n, 36)
-    for i in range(n):
-        if not h:
-            break
-        count, block = h.pop()
-        ansi_print('                                                      #%3d: reflown %d times  |' % (i+1, count), 36)
-        about(block)
-    ansi_print("`----------------------------------------------------------------------------'", 36)
-    print
-
-
-if __name__ == '__main__':
-
-    targetspec = 'targetpypy'
-    huge = 100
-
-    options = {'-text': False,
-               '-no-c': False,
-               '-c':    False,
-               '-o':    False,
-               '-no-mark-some-objects': False,
-               '-no-a': False,
-               '-no-s': False,
-               '-no-t': False,
-               '-tcc':  False,
-               '-no-d': False,
-               }
-    listen_port = None
-    for arg in sys.argv[1:]:
-        if arg in ('-h', '--help'):
-            print __doc__.strip()
-            sys.exit()
-        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]
-            elif arg.startswith('-huge='):
-                huge = int(arg[6:])
-            else:                
-                assert arg in options, "unknown option %r" % (arg,)
-                options[arg] = True
-    if options['-tcc']:
-        os.environ['PYPY_CC'] = 'tcc -shared -o "%s.so" "%s.c"'
-    if options['-no-d']:
-        annmodel.DEBUG = False
-
-    def about(x):
-        """ interactive debugging helper """
-        from pypy.objspace.flow.model import Block, flatten
-        if isinstance(x, Block):
-            for func, graph in t.flowgraphs.items():
-                if x in flatten(graph):
-                    funcname = func.func_name
-                    cls = getattr(func, 'class_', None)
-                    if cls:
-                        funcname = '%s.%s' % (cls.__name__, funcname)
-                    print '%s is a %s in the graph of %s' % (x,
-                                x.__class__.__name__, funcname)
-                    print 'at %s:%d' % (func.func_globals.get('__name__', '?'),
-                                        func.func_code.co_firstlineno)
-                    break
-            else:
-                print '%s is a %s at some unknown location' % (x,
-                                x.__class__.__name__)
-            print 'containing the following operations:'
-            for op in x.operations:
-                print op
-            print '--end--'
-            return
-        print "don't know about", x
-
-    def run_server():
-        from pypy.translator.tool import graphpage
-        from pypy.translator.tool.pygame.graphclient import get_layout
-        from pypy.translator.tool.pygame.graphdisplay import GraphDisplay
-        import pygame
-
-        if not options['-no-mark-some-objects']:
-            find_someobjects(t, quiet=True)
-
-        if len(t.functions) <= huge:
-            page = graphpage.TranslatorPage(t)
-        else:
-            page = graphpage.LocalizedCallGraphPage(t, entry_point)
-
-        display = GraphDisplay(get_layout(page))
-        async_quit = display.async_quit
-        def show(page):
-            display.async_cmd(layout=get_layout(page))
-        return display.run, show, async_quit, pygame.quit
-
-    class PdbPlusShow(pdb.Pdb):
-
-        def post_mortem(self, t):
-            self.reset()
-            while t.tb_next is not None:
-                t = t.tb_next
-            self.interaction(t.tb_frame, t)        
-
-        show = None
-
-        def _show(self, page):
-            if not self.show:
-                print "*** No display"
-                return
-            self.show(page)
-
-        def _importobj(self, fullname):
-            obj = None
-            name = ''
-            for comp in fullname.split('.'):
-                name += comp
-                obj = getattr(obj, comp, None)
-                if obj is None:
-                    try:
-                        obj = __import__(name, {}, {}, ['*'])
-                    except ImportError:
-                        raise NameError
-                name += '.'
-            return obj
-
-        TRYPREFIXES = ['','pypy.','pypy.objspace.','pypy.interpreter.', 'pypy.objspace.std.' ]
-
-        def _getobj(self, name):
-            if '.' in name:
-                for pfx in self.TRYPREFIXES:
-                    try:
-                        return self._importobj(pfx+name)
-                    except NameError:
-                        pass
-            try:
-                return self._getval(name)
-            except (NameError, AttributeError, LookupError):
-                print "*** Not found:", name
-            return None
-
-        def do_showg(self, arg):
-            """showg obj
-show graph for obj, obj can be an expression or a dotted name
-(in which case prefixing with some packages in pypy is tried (see help pypyprefixes)).
-if obj is a function or method, the localized call graph is shown;
-if obj is a class or ClassDef the class definition graph is shown"""            
-            from pypy.annotation.classdef import ClassDef
-            from pypy.translator.tool import graphpage            
-            obj = self._getobj(arg)
-            if obj is None:
-                return
-            if hasattr(obj, 'im_func'):
-                obj = obj.im_func
-            if obj in t.flowgraphs:
-                page = graphpage.LocalizedCallGraphPage(t, obj)
-            elif obj in getattr(t.annotator, 'getuserclasses', lambda: {})():
-                page = graphpage.ClassDefPage(t, t.annotator.getuserclasses()[obj])
-            elif isinstance(obj, ClassDef):
-                page = graphpage.ClassDefPage(t, obj)
-            else:
-                print "*** Nothing to do"
-                return
-            self._show(page)
-
-        def do_flowg(self, arg):
-            """callg obj
-show flow graph for function obj, obj can be an expression or a dotted name
-(in which case prefixing with some packages in pypy is tried (see help pypyprefixes))"""            
-            import types
-            from pypy.translator.tool import graphpage                        
-            obj = self._getobj(arg)
-            if obj is None:
-                return
-            if hasattr(obj, 'im_func'):
-                obj = obj.im_func
-            if not isinstance(obj, types.FunctionType):
-                print "*** Not a function"
-                return
-            self._show(graphpage.FlowGraphPage(t, [obj]))
-
-        def do_callg(self, arg):
-            """callg obj
-show localized call-graph for function obj, obj can be an expression or a dotted name
-(in which case prefixing with some packages in pypy is tried (see help pypyprefixes))"""
-            import types
-            from pypy.translator.tool import graphpage                        
-            obj = self._getobj(arg)
-            if obj is None:
-                return
-            if hasattr(obj, 'im_func'):
-                obj = obj.im_func
-            if not isinstance(obj, types.FunctionType):
-                print "*** Not a function"
-                return
-            self._show(graphpage.LocalizedCallGraphPage(t, obj))
-
-        def do_classhier(self, arg):
-            """classhier
-show class hierarchy graph"""
-            from pypy.translator.tool import graphpage           
-            self._show(graphpage.ClassHierarchyPage(t))
-
-        def help_graphs(self):
-            print "graph commands are: showg, flowg, callg, classhier"
-
-        def help_pypyprefixes(self):
-            print "these prefixes are tried for dotted names in graph commands:"
-            print self.TRYPREFIXES
-
-    def debug(got_error):
-        pdb_plus_show = PdbPlusShow()
-        
-        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
-                about(block)
-                print '-'*60
-
-            print >> sys.stderr
-            func, args = pdb_plus_show.post_mortem, (tb,)
-        else:
-            print '-'*60
-            print 'Done.'
-            print
-            func, args = pdb_plus_show.set_trace, ()
-        if options['-text']:
-            func(*args)
-        else:
-            start, show, stop, cleanup = run_server()
-            pdb_plus_show.show = show
-            debugger = run_in_thread(func, args, stop)
-            debugger.start()
-            start()
-            debugger.join()
-            cleanup()
-
-    try:
-        targetspec_dic = {}
-        sys.path.insert(0, os.path.dirname(targetspec))
-        execfile(targetspec+'.py',targetspec_dic)
-        print "Analysing target as defined by %s" % targetspec
-        analyse(targetspec_dic['target'])
-        print '-'*60
-        if options['-no-c']:
-            print 'Not generating C code.'
-        elif options['-c']:
-            print 'Generating C code without compiling it...'
-            filename = t.ccompile(really_compile=False)
-            update_usession_dir()
-            print 'Written %s.' % (filename,)
-        else:
-            print 'Generating and compiling C code...'
-            c_entry_point = t.ccompile()
-            update_usession_dir()
-            if not options['-o']:
-                print 'Running!'
-                targetspec_dic['run'](c_entry_point)
-    except:
-        debug(True)
-    else:
-        debug(False)
-    

Copied: pypy/dist/pypy/bin/py.py (from r12444, pypy/dist/pypy/interpreter/py.py)
==============================================================================
--- pypy/dist/pypy/interpreter/py.py	(original)
+++ pypy/dist/pypy/bin/py.py	Wed May 18 19:15:26 2005
@@ -1,5 +1,11 @@
 #!/usr/bin/env python 
 
+"""Main entry point into the PyPy interpreter.  For a list of options, type
+
+      py.py --help
+
+"""
+
 try:
     import autopath
 except ImportError:

Copied: pypy/dist/pypy/bin/translator.py (from r12451, pypy/dist/pypy/translator/translator.py)
==============================================================================
--- pypy/dist/pypy/translator/translator.py	(original)
+++ pypy/dist/pypy/bin/translator.py	Wed May 18 19:15:26 2005
@@ -1,9 +1,9 @@
+#!/usr/bin/env python 
+
 """PyPy Translator Frontend
 
 Glue script putting together the various pieces of the translator.
-Can be used for interactive testing of the translator. Run as:
-
-    python -i translator.py
+Can be used for interactive testing of the translator.
 
 Example:
 
@@ -32,294 +32,11 @@
 """
 
 import autopath, os, sys
-
-from pypy.objspace.flow.model import *
-from pypy.annotation.model import *
-from pypy.translator.annrpython import RPythonAnnotator
-from pypy.translator.simplify import simplify_graph
-from pypy.translator.genpyrex import GenPyrex
-from pypy.translator.gencl import GenCL
-from pypy.translator.genc.genc import GenC
-from pypy.translator.gensupp import uniquemodulename
-from pypy.translator.tool.buildpyxmodule import make_module_from_pyxstring
-from pypy.translator.tool.buildpyxmodule import make_module_from_c
-from pypy.objspace.flow import FlowObjSpace
-
-
-class Translator:
-
-    def __init__(self, func=None, verbose=False, simplifying=True,
-                 builtins_can_raise_exceptions=False,
-                 do_imports_immediately=True):
-        self.entrypoint = func
-        self.verbose = verbose
-        self.simplifying = simplifying
-        self.builtins_can_raise_exceptions = builtins_can_raise_exceptions
-        self.do_imports_immediately = do_imports_immediately
-        self.clear()
-
-    def clear(self):
-        """Clear all annotations and all flow graphs."""
-        self.annotator = None
-        self.flowgraphs = {}  # {function: graph}
-        self.functions = []   # the keys of self.flowgraphs, in creation order
-        self.callgraph = {}   # {opaque_tag: (caller, callee)}
-        self.frozen = False   # when frozen, no more flowgraphs can be generated
-        self.concretetypes = {}  # see getconcretetype()
-        self.ctlist = []         #  "
-        if self.entrypoint:
-            self.getflowgraph()
-
-    def getflowgraph(self, func=None, called_by=None, call_tag=None):
-        """Get the flow graph for a function (default: the entry point)."""
-        func = func or self.entrypoint
-        try:
-            graph = self.flowgraphs[func]
-        except KeyError:
-            if self.verbose:
-                print 'getflowgraph (%s:%d) %s' % (
-                    func.func_globals.get('__name__', '?'),
-                    func.func_code.co_firstlineno,
-                    func.__name__),
-                sys.stdout.flush()
-            assert not self.frozen
-            space = FlowObjSpace()
-            space.builtins_can_raise_exceptions = self.builtins_can_raise_exceptions
-            space.do_imports_immediately = self.do_imports_immediately
-            graph = space.build_flow(func)
-            if self.simplifying:
-                simplify_graph(graph, self.simplifying)
-            if self.verbose:
-                print
-            self.flowgraphs[func] = graph
-            self.functions.append(func)
-            try:
-                import inspect
-                graph.func = func
-                graph.source = inspect.getsource(func)
-            except IOError:
-                pass  # e.g. when func is defined interactively
-        if called_by:
-            self.callgraph[called_by, func, call_tag] = called_by, func
-        return graph
-
-    def gv(self, func=None):
-        """Shows the control flow graph for a function (default: all)
-        -- requires 'dot' and 'gv'."""
-        import os
-        from pypy.translator.tool.make_dot import make_dot, make_dot_graphs
-        if func is None:
-            # show the graph of *all* functions at the same time
-            graphs = []
-            for func in self.functions:
-                graph = self.getflowgraph(func)
-                graphs.append((graph.name, graph))
-            dest = make_dot_graphs(self.entrypoint.__name__, graphs)
-        else:
-            graph = self.getflowgraph(func)
-            dest = make_dot(graph.name, graph)
-        os.system('gv %s' % str(dest))
-
-    def view(self, *functions):
-        """Shows the control flow graph with annotations if computed.
-        Requires 'dot' and pygame."""
-        from pypy.translator.tool.graphpage import FlowGraphPage
-        FlowGraphPage(self).display()
-
-    def viewcg(self):
-        """Shows the whole call graph and the class hierarchy, based on
-        the computed annotations."""
-        from pypy.translator.tool.graphpage import TranslatorPage
-        TranslatorPage(self).display()
-
-    def simplify(self, func=None, passes=True):
-        """Simplifies the control flow graph (default: for all functions)."""
-        if func is None:
-            for func in self.flowgraphs.keys():
-                self.simplify(func)
-        else:
-            graph = self.getflowgraph(func)
-            simplify_graph(graph, passes)
-            
-    def annotate(self, input_args_types, func=None, overrides={}):
-        """annotate(self, input_arg_types[, func]) -> Annotator
-
-        Provides type information of arguments. Returns annotator.
-        """
-        func = func or self.entrypoint
-        if self.annotator is None:
-            self.annotator = RPythonAnnotator(self, overrides=overrides)
-        graph = self.getflowgraph(func)
-        self.annotator.build_types(graph, input_args_types, func)
-        return self.annotator
-
-    def checkgraphs(self):
-        for graph in self.flowgraphs.itervalues():
-            checkgraph(graph)
-
-    def source(self, func=None):
-        """Returns original Python source.
-        
-        Returns <interactive> for functions written while the
-        interactive session.
-        """
-        func = func or self.entrypoint
-        graph = self.getflowgraph(func)
-        return getattr(graph, 'source', '<interactive>')
-
-    def pyrex(self, input_arg_types=None, func=None):
-        """pyrex(self[, input_arg_types][, func]) -> Pyrex translation
-
-        Returns Pyrex translation. If input_arg_types is provided,
-        returns type annotated translation. Subsequent calls are
-        not affected by this.
-        """
-        return self.generatecode(GenPyrex, input_arg_types, func)
-
-    def cl(self, input_arg_types=None, func=None):
-        """cl(self[, input_arg_types][, func]) -> Common Lisp translation
-        
-        Returns Common Lisp translation. If input_arg_types is provided,
-        returns type annotated translation. Subsequent calls are
-        not affected by this.
-        """
-        return self.generatecode(GenCL, input_arg_types, func)
-
-    def c(self):
-        """c(self) -> C (CPython) translation
-        
-        Returns C (CPython) translation.
-        """
-        from StringIO import StringIO 
-        out = StringIO()
-        genc = GenC(out, self)
-        return out.getvalue()
-
-    def llvm(self):
-        """llvm(self) -> LLVM translation
-        
-        Returns LLVM translation.
-        """
-        from pypy.translator.llvm import genllvm
-        if self.annotator is None:
-            raise genllvm.CompileError, "function has to be annotated."
-        gen = genllvm.LLVMGenerator(self)
-        return str(gen)
-    
-    def generatecode(self, gencls, input_arg_types, func):
-        if input_arg_types is None:
-            ann = self.annotator
-        else:
-            ann = RPythonAnnotator(self)
-        if func is None:
-            codes = [self.generatecode1(gencls, input_arg_types,
-                                        self.entrypoint, ann)]
-            for func in self.functions:
-                if func is not self.entrypoint:
-                    code = self.generatecode1(gencls, None, func, ann,
-                                              public=False)
-                    codes.append(code)
-        else:
-            codes = [self.generatecode1(gencls, input_arg_types, func, ann)]
-        code = self.generateglobaldecl(gencls, func, ann)
-        if code:
-            codes.insert(0, code)
-        return '\n\n#_________________\n\n'.join(codes)
-
-    def generatecode1(self, gencls, input_arg_types, func, ann, public=True):
-        graph = self.getflowgraph(func)
-        g = gencls(graph)
-        g.by_the_way_the_function_was = func   # XXX
-        if input_arg_types is not None:
-            ann.build_types(graph, input_arg_types, func)
-        if ann is not None:
-            g.setannotator(ann)
-        return g.emitcode(public)
-
-    def generateglobaldecl(self, gencls, func, ann):
-        graph = self.getflowgraph(func)
-        g = gencls(graph)
-        if ann is not None:
-            g.setannotator(ann)
-        return g.globaldeclarations()
-
-    def compile(self):
-        """Returns compiled function, compiled using Pyrex.
-        """
-        from pypy.tool.udir import udir
-        name = self.entrypoint.func_name
-        pyxcode = self.pyrex()
-        mod = make_module_from_pyxstring(name, udir, pyxcode)
-        return getattr(mod, name)
-
-    def ccompile(self, really_compile=True):
-        """Returns compiled function, compiled using the C generator.
-        """
-        from pypy.tool.udir import udir
-        if self.annotator is not None:
-            self.frozen = True
-        name = uniquemodulename(self.entrypoint.func_name)
-        cfile = udir.join('%s.c' % name)
-        f = cfile.open('w')
-        f2 = udir.join('%s-init.py' % name).open('w+')
-        GenC(f, self, name, f2=f2)
-        f2.close()
-        f.close()
-        if not really_compile:
-            return cfile
-        mod = make_module_from_c(cfile,
-            include_dirs=[os.path.join(autopath.this_dir, 'genc')])
-        self.concretetypes.clear()
-        return getattr(mod, self.entrypoint.func_name)
-
-    def llvmcompile(self, optimize=True):
-        """llvmcompile(self, optimize=True) -> LLVM translation
-        
-        Returns LLVM translation with or without optimization.
-        """
-        from pypy.translator.llvm import genllvm
-        if self.annotator is None:
-            raise genllvm.CompileError, "function has to be annotated."
-        gen = genllvm.LLVMGenerator(self)
-        return gen.compile(optimize)
-
-    def call(self, *args):
-        """Calls underlying Python function."""
-        return self.entrypoint(*args)
-
-    def dis(self, func=None):
-        """Disassembles underlying Python function to bytecodes."""
-        from dis import dis
-        dis(func or self.entrypoint)
-
-##    def consider_call(self, ann, func, args):
-##        graph = self.getflowgraph(func)
-##        ann.addpendingblock(graph.startblock, args)
-##        result_var = graph.getreturnvar()
-##        try:
-##            return ann.binding(result_var)
-##        except KeyError:
-##            # typical case for the 1st call, because addpendingblock() did
-##            # not actually start the analysis of the called function yet.
-##            return impossiblevalue
-
-    def getconcretetype(self, cls, *args):
-        "DEPRECATED.  To be removed"
-        # Return a (cached) 'concrete type' object attached to this translator.
-        # Concrete types are what is put in the 'concretetype' attribute of
-        # the Variables and Constants of the flow graphs by typer.py to guide
-        # the code generators.
-        try:
-            return self.concretetypes[cls, args]
-        except KeyError:
-            result = self.concretetypes[cls, args] = cls(self, *args)
-            self.ctlist.append(result)
-            return result
+from pypy.translator.translator import Translator
 
 
 if __name__ == '__main__':
     from pypy.translator.test import snippet as test
-    import sys
     if (os.getcwd() not in sys.path and
         os.path.curdir not in sys.path):
         sys.path.insert(0, os.getcwd())

Modified: pypy/dist/pypy/documentation/objspace.txt
==============================================================================
--- pypy/dist/pypy/documentation/objspace.txt	(original)
+++ pypy/dist/pypy/documentation/objspace.txt	Wed May 18 19:15:26 2005
@@ -213,7 +213,7 @@
 
 Example usage::
 
-    $ python interpreter/py.py -o thunk
+    $ py.py -o thunk
     >>>> def f():
     ...     print 'computing...'
     ...     return 6*7

Deleted: /pypy/dist/pypy/interpreter/py.py
==============================================================================
--- /pypy/dist/pypy/interpreter/py.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,183 +0,0 @@
-#!/usr/bin/env python 
-
-try:
-    import autopath
-except ImportError:
-    pass
-
-from pypy.tool.getpy import py
-#py.magic.invoke(compile=1)
-
-from pypy.tool import option
-from pypy.tool.optik import make_option
-from pypy.interpreter import main, interactive, error
-import os, sys
-import time
-
-class Options(option.Options):
-    verbose = os.getenv('PYPY_TB')
-    interactive = 0
-    command = []
-    completer = False
-
-def get_main_options():
-    options = option.get_standard_options()
-
-    options.append(make_option(
-        '-v', action='store_true', dest='verbose',
-        help='show verbose interpreter-level traceback'))
-
-    options.append(make_option(
-        '-C', action='store_true', dest='completer',
-        help='use readline commandline completer'))
-
-    options.append(make_option(
-        '-i', action="store_true", dest="interactive",
-        help="inspect interactively after running script"))
-
-    options.append(make_option(
-        '-O', action="store_true", dest="optimize",
-        help="dummy optimization flag for compatibility with C Python"))
-
-    def command_callback(option, opt, value, parser):
-        parser.values.command = parser.rargs[:]
-        parser.rargs[:] = []
-        
-    options.append(make_option(
-        '-c', action="callback",
-        callback=command_callback,
-        help="program passed in as CMD (terminates option list)"))
-        
-    return options
-
-def main_(argv=None):
-    starttime = time.time() 
-    args = option.process_options(get_main_options(), Options, argv[1:])
-    if Options.verbose:
-        error.RECORD_INTERPLEVEL_TRACEBACK = True
-
-    # create the object space
-    space = option.objspace()
-    space._starttime = starttime
-    assert 'pypy.tool.udir' not in sys.modules, (
-        "running py.py should not import pypy.tool.udir, which is\n"
-        "only for testing or translating purposes.")
-    space.setitem(space.sys.w_dict,space.wrap('executable'),space.wrap(argv[0]))
-
-    # store the command-line arguments into sys.argv
-    go_interactive = Options.interactive
-    banner = ''
-    exit_status = 0
-    if Options.command:
-        args = ['-c'] + Options.command[1:]
-    for arg in args:
-        space.call_method(space.sys.get('argv'), 'append', space.wrap(arg))
-
-    # load the source of the program given as command-line argument
-    if Options.command:
-        def doit():
-            main.run_string(Options.command[0], space=space)
-    elif args:
-        def doit():
-            main.run_file(args[0], space=space)
-    else:
-        def doit():
-            pass
-        space.call_method(space.sys.get('argv'), 'append', space.wrap(''))
-        go_interactive = 1
-        banner = None
-
-    try:
-        # compile and run it
-        if not main.run_toplevel(space, doit, verbose=Options.verbose):
-            exit_status = 1
-
-        # start the interactive console
-        if go_interactive:
-            con = interactive.PyPyConsole(space, verbose=Options.verbose,
-                                                 completer=Options.completer)
-            if banner == '':
-                banner = '%s / %s'%(con.__class__.__name__,
-                                    repr(space))
-            con.interact(banner)
-            exit_status = 0
-    finally:
-        # call the sys.exitfunc()
-        w_exitfunc = space.sys.getdictvalue(space, 'exitfunc')
-        if w_exitfunc is not None:
-            def doit():
-                space.call_function(w_exitfunc)
-            main.run_toplevel(space, doit, verbose=Options.verbose)
-
-    return exit_status
-
-##def main_(argv=None):
-##    starttime = time.time() 
-##    from pypy.tool import tb_server
-##    args = option.process_options(get_main_options(), Options, argv[1:])
-##    space = None
-##    exit_status = 1   # until proven otherwise
-##                      # XXX should review what CPython's policy is for
-##                      # the exit status code
-##    try:
-##        space = option.objspace()
-##        space._starttime = starttime
-##        assert 'pypy.tool.udir' not in sys.modules, (
-##            "running py.py should not import pypy.tool.udir, which is\n"
-##            "only for testing or translating purposes.")
-##        go_interactive = Options.interactive
-##        if Options.verbose:
-##            error.RECORD_INTERPLEVEL_TRACEBACK = True
-##        banner = ''
-##        space.setitem(space.sys.w_dict,space.wrap('executable'),space.wrap(argv[0]))
-##        if Options.command:
-##            args = ['-c'] + Options.command[1:]
-##        for arg in args:
-##            space.call_method(space.sys.get('argv'), 'append', space.wrap(arg))
-##        try:
-##            if Options.command:
-##                main.run_string(Options.command[0], '<string>', space)
-##            elif args:
-##                main.run_file(args[0], space)
-##            else:
-##                space.call_method(space.sys.get('argv'), 'append', space.wrap(''))
-##                go_interactive = 1
-##                banner = None
-##            exit_status = 0
-##        except error.OperationError, operationerr:
-##            if Options.verbose:
-##                operationerr.print_detailed_traceback(space)
-##            else:
-##                operationerr.print_application_traceback(space)
-##        if go_interactive:
-##            con = interactive.PyPyConsole(space, verbose=Options.verbose, completer=Options.completer)
-##            if banner == '':
-##                banner = '%s / %s'%(con.__class__.__name__,
-##                                    repr(space))
-##            con.interact(banner)
-##    except:
-##        exc_type, value, tb = sys.exc_info()
-##        sys.last_type = exc_type
-##        sys.last_value = value
-##        sys.last_traceback = tb
-##        if issubclass(exc_type, SystemExit):
-##            pass   # don't print tracebacks for SystemExit
-##        elif isinstance(value, error.OperationError):
-##            value.print_detailed_traceback(space=space)
-##        else:
-##            sys.excepthook(exc_type, value, tb)
-##        tb_server.wait_until_interrupt()
-##        exit_status = 1
-            
-##    tb_server.stop()
-##    return exit_status
-
-if __name__ == '__main__':
-    try:
-        import readline
-    except:
-        pass
-    if hasattr(sys, 'setrecursionlimit'):
-        # for running "python -i py.py -Si -- py.py -Si" 
-        sys.setrecursionlimit(3000)
-    sys.exit(main_(sys.argv))

Modified: pypy/dist/pypy/interpreter/test/test_py.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_py.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_py.py	Wed May 18 19:15:26 2005
@@ -1,10 +1,10 @@
 
-import pypy.interpreter.py
+import autopath
 from pypy.tool.udir import udir
 import py
 import sys
 
-pypypath = str(py.path.local(pypy.interpreter.py.__file__).new(basename='py.py'))
+pypypath = str(py.path.local(autopath.pypydir).join('bin', 'py.py'))
 
 def test_executable():
     """Ensures sys.executable points to the py.py script"""

Modified: pypy/dist/pypy/objspace/thunk.py
==============================================================================
--- pypy/dist/pypy/objspace/thunk.py	(original)
+++ pypy/dist/pypy/objspace/thunk.py	Wed May 18 19:15:26 2005
@@ -1,6 +1,6 @@
 """Example usage:
 
-    $ python interpreter/py.py -o thunk
+    $ py.py -o thunk
     >>> def f():
     ...     print 'computing...'
     ...     return 6*7

Deleted: /pypy/dist/goal/buildcache.py
==============================================================================
--- /pypy/dist/goal/buildcache.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,56 +0,0 @@
-from pypy.tool import option, autopath, testit
-from pypy.interpreter import gateway 
-import os
-
-#######################################################
-def app_triggerall():
-    import sys, types # , exceptions
-    k = 42
-    def gen():
-        yield k
-        #yield (k, 1.0, 4L, [''], {}, unicode, Ellipsis) 
-        try:
-            raise ValueError
-        except ValueError: 
-            x = sys.exc_info()
-        try:
-            raise x[0], x[1], x[2]
-        except ValueError:
-            pass
-            
-    #gen.func_code.co_name
-    str({'co_name': ('f',)}), str(object.__init__.im_func.func_code)
-    #"for %r" % ({'x': gen}) 
-    "%02d %04f %05g %05s <%s> %r" % (1, 2.25, 2.25, 2.25, [1,2], {'x': gen})
-    for x in gen():
-        pass
-
-def app_triggerexec():
-    exec "i=3"
-    
-gateway.importall(globals())   # app_xxx() -> xxx()
-
-#######################################################
-from pypy.objspace.std import stdtypedef
-    
-def buildcache(space): 
-    print "triggering cache build for %r" % space 
-    triggerall(space) 
-    triggerexec(space)
-    #testit.main(os.path.join(autopath.pypydir, 'objspace', 'std'))
-    #Cache.freeze()
-    #space._typecache = frozendict(space._typecache) 
-    #space._faketypecache = frozendict(space._faketypecache) 
-    #space._gatewaycache = frozendict(space._gatewaycache) 
-    #space = option.objspace('std')
-    #buildcache(space)
-    #for x in  stdtypedef._temp:
-    #    x.cache_table = frozendict(x.cache_table)
-    print "cache build finished, caches are 'frozen' now"
-
-if __name__ == '__main__': 
-    space = option.objspace('std') 
-    buildcache(space) 
-    #testit.main(autopath.pypydir)
-
-    testit.main(os.path.join(autopath.pypydir)) # , 'objspace', 'std'))

Deleted: /pypy/dist/goal/compiler-hack.py
==============================================================================
--- /pypy/dist/goal/compiler-hack.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,6 +0,0 @@
-import compiler
-c = compiler.compile('a=1', '', 'exec')
-import dis
-dis.dis(c)
-exec c
-print a

Deleted: /pypy/dist/goal/dis-goal.py
==============================================================================
--- /pypy/dist/goal/dis-goal.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,2 +0,0 @@
-import dis
-dis.dis(dis.dis)

Deleted: /pypy/dist/goal/dis-pregoal.py
==============================================================================
--- /pypy/dist/goal/dis-pregoal.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,2 +0,0 @@
-import dis
-dis.disassemble(dis.dis.func_code)

Deleted: /pypy/dist/goal/foodbill.py
==============================================================================
--- /pypy/dist/goal/foodbill.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,54 +0,0 @@
-slips=[(1, 'Kals MatMarkn', 6150, 'Chutney for Curry', 'dinner Saturday'),
-       (2, 'Kals MatMarkn', 32000, 'Spaghetti, Beer', 'dinner Monday'),
-       (2, 'Kals MatMarkn', -810, 'Deposit on Beer Bottles', 'various'),
-       (3, 'Fram', 7700, 'Rice and Curry Spice', 'dinner Saturday'),
-       (4, 'Kals MatMarkn', 25000, 'Alcohol-Free Beer, sundries', 'various'),
-       (4, 'Kals MatMarkn', -1570, "Michael's toothpaste", 'none'),
-       (4, 'Kals MatMarkn', -1690, "Laura's toothpaste", 'none'),
-       (4, 'Kals MatMarkn', -720, 'Deposit on Beer Bottles', 'various'),
-       (4, 'Kals MatMarkn', -60, 'Deposit on another Beer Bottle', 'various'),
-       (5, 'Kals MatMarkn', 26750, 'lunch bread meat cheese', 'lunch Monday'),
-       (6, 'Kals MatMarkn', 15950, 'various', 'dinner Tuesday and Thursday'),
-       (7, 'Kals MatMarkn', 3650, 'Drottningsylt, etc.', 'dinner Thursday'),
-       (8, 'Kals MatMarkn', 26150, 'Chicken and Mushroom Sauce', 'dinner Wed'),
-       (8, 'Kals MatMarkn', -2490, 'Jacob and Laura -- juice', 'dinner Wed'),
-       (8, 'Kals MatMarkn', -2990, "Chicken we didn't cook", 'dinner Wednesday'),
-       (9, 'Kals MatMarkn', 1380, 'fruit for Curry', 'dinner Saturday'),
-       (9, 'Kals MatMarkn', 1380, 'fruit for Curry', 'dinner Saturday'),
-       (10, 'Kals MatMarkn', 26900, 'Jansons Frestelse', 'dinner Sunday'),
-       (10, 'Kals MatMarkn', -540, 'Deposit on Beer Bottles', 'dinner Sunday'),
-       (11, 'Kals MatMarkn', 22650, 'lunch bread meat cheese', 'lunch Thursday'),
-       (11, 'Kals MatMarkn', -2190, 'Jacob and Laura -- juice', 'lunch Thursday'),
-       (11, 'Kals MatMarkn', -2790, 'Jacob and Laura -- cereal', 'lunch Thurs'),
-       (11, 'Kals MatMarkn', -760, 'Jacob and Laura -- milk', 'lunch Thursday'),
-       (12, 'Kals MatMarkn', 18850, 'lunch bread meat cheese', 'lunch Friday'),
-       (13, 'Kals MatMarkn', 18850, 'lunch bread meat cheese', 'guestimate Sun'),
-       (14, 'Kals MatMarkn', 18850, 'lunch bread meat cheese', 'guestimate Tues'),
-       (15, 'Kals MatMarkn', 20000, 'lunch bread meat cheese', 'guestimate Wed'),
-       (16, 'Kals MatMarkn', 42050, 'grillfest', 'dinner Friday'),
-       (16, 'Kals MatMarkn', -1350, 'Deposit on Beer Bottles', 'dinner Friday'),
-       (17, 'System Bolaget', 15500, 'Cederlunds Caloric', 'dinner Thursday'),
-       (17, 'System Bolaget', 22400, '4 x Farnese Sangiovese 56SEK', 'various'),
-       (17, 'System Bolaget', 22400, '4 x Farnese Sangiovese 56SEK', 'various'),
-       (17, 'System Bolaget', 13800, '2 x Jacobs Creek 69SEK', 'various'),
-       (18, 'J and Ls winecabinet', 10800, '2 x Parrotes 54SEK', 'various'),
-       (18, 'J and Ls winecabinet', 14700, '3 x Saint Paulin 49SEK', 'various'),
-       (18, 'J and Ls winecabinet', 10400, '2 x Farnese Sangioves 52SEK',
-        'cheaper when we bought it'),
-       (18, 'J and Ls winecabinet', 17800, '2 x Le Poiane 89SEK', 'various'),
-       (18, 'J and Ls winecabinet', 9800, '2 x Something Else 49SEK', 'various'),
-       (19, 'Konsum', 26000, 'Saturday Bread and Fruit', 'Slip MISSING'),
-       (20, 'Konsum', 15245, 'Mooseburgers', 'found slip'),
-       (21, 'Kals MatMarkn', 20650, 'Grilling', 'Friday dinner'),
-       (22, 'J and Ls freezer', 21000, 'Meat for Curry, grilling', ''),
-       (22, 'J and Ls cupboard', 3000, 'Rice', ''),
-       (22, 'J and Ls cupboard', 4000, 'Charcoal', ''),
-       (23, 'Fram', 2975, 'Potatoes', '3.5 kg @ 8.50SEK'),
-       (23, 'Fram', 1421, 'Peas', 'Thursday dinner'),
-       (24, 'Kals MatMarkn', 20650, 'Grilling', 'Friday dinner'),
-       (24, 'Kals MatMarkn', -2990, 'TP', 'None'),
-       (24, 'Kals MatMarkn', -2320, 'T-Gul', 'None')
-       ]
- 
-print [t[2] for t in slips]
-print (reduce(lambda x, y: x+y, [t[2] for t in slips], 0))/900

Deleted: /pypy/dist/goal/gadfly-demo.py
==============================================================================
--- /pypy/dist/goal/gadfly-demo.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,23 +0,0 @@
-import os
-os.mkdir('db')
-
-import gadfly
-connection = gadfly.gadfly()
-connection.startup('test', 'db')
-cursor = connection.cursor()
-
-def print_and_execute(cursor, operation):
-    print operation
-    cursor.execute(operation)
-
-print_and_execute(cursor, "CREATE TABLE pypy(py varchar)")
-print_and_execute(cursor, "INSERT INTO pypy(py) VALUES ('py')")
-print_and_execute(cursor, "SELECT * FROM pypy")
-for row in cursor.fetchall():
-    print row
-
-connection.commit()
-connection.close()
-
-import shutil
-shutil.rmtree('db')

Deleted: /pypy/dist/goal/hello_world.py
==============================================================================
--- /pypy/dist/goal/hello_world.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,2 +0,0 @@
-aStr = 'hello world'
-print len(aStr)

Deleted: /pypy/dist/goal/http-and-html.py
==============================================================================
--- /pypy/dist/goal/http-and-html.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,9 +0,0 @@
-url = 'http://www.python.org/'
-html = 'python.html'
-import urllib
-content = urllib.urlopen(url).read()
-file(html, 'w').write(content)
-import htmllib
-htmllib.test([html])
-import os
-os.remove(html)

Deleted: /pypy/dist/goal/objectspace-reconstruct.py
==============================================================================
--- /pypy/dist/goal/objectspace-reconstruct.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,163 +0,0 @@
-
-def __getattribute__(w_obj,w_name):
-  name = space.unwrap(w_name)
-  w_descr = space.lookup(w_obj, name)
-  if w_descr is not None:
-     if space.is_data_descr(w_descr):
-         return space.get(w_descr,w_obj,space.type(w_obj))
-  w_dict = space.getdict(w_obj)
-  if w_dict is not None:
-     try:
-       return space.getitem(w_dict,w_name)
-     except OperationError, e:
-       if not e.match(space,space.w_KeyError):
-         raise
-  if w_descr is not None:
-     return space.get(w_descr,w_obj,space.wrap(type))
-  raise OperationError(space.w_AttributeError,w_name)
-
-def space.getattr(w_obj,w_name):
-   w_descr = space.lookup(w_obj, '__getattribute__')
-   try:
-     return space.get_and_call_function(w_descr, w_obj, w_name)
-   except: # AttributeError
-     w_descr = space.lookup(w_obj, '__getattr__')
-     if w_descr is None:
-       raise
-     return space.get_and_call_function(w_descr, w_obj, w_name)
-
-def space.get(w_obj,w_name):
-   w_descr = space.lookup(w_obj, '__get__')
-   if w_descr is not None:
-     return space.get_and_call(w_descr, w_obj, space.newtuple([w_name]))
-   else:
-     return w_obj
-
-def space.call(w_obj, w_args, w_kwargs):
-   w_descr = space.lookup(w_obj, '__call__')
-   if w_descr is None:
-     raise OperationError(space.w_TypeError, space.wrap('...'))
-   return space.get_and_call(w_descr, w_obj, w_args, w_kwargs)
-
-
-class BaseObjSpace:
-  def get_and_call(self, w_descr, w_obj, w_args, w_kwargs):
-    if isinstance(w_descr, W_Function):
-      args_w = space.unpacktuple(w_args)
-      return w_descr.func.call(space.newtuple([w_obj]+args_w),w_kwargs)
-    else:
-      w_bound = space.get(w_descr,w_obj,space.gettype(w_obj))
-      return space.call(w_bound, w_args, w_kwargs)
-
-class Wrappable:
-    def __wrap__(self, space):
-        return self
-
-class Function(Wrappable):
-    TypeDef = Type("function", [], {
-        '__call__' : app_descr_function_call,
-        'func_code' : Property(func_code_getter) 
-        })
-
-class BuiltinType:
-    def __init__(self, name, bases, rawdict):
-        self.name = name 
-        self.bases = bases 
-        self.rawdict = rawdict
-        self.mro = []
-
-class W_Function:
-    def __init__(self, space, func):
-        self.func = func
-        self.space = space
-
-    def gettype(self):
-        space = self.space
-        try:
-            return space.FunctionType 
-        except AttributeError:
-            space.FunctionType = f = Type(space, [space.ObjectType]) 
-            f.dict_w['__call__'] = space.wrap(app_descr_function_call)
-            func_code_property = Property(func_code_getter)
-            f.dict_w['func_code'] = space.wrap(func_code_property) 
-            return f 
-
-class StdObjectSpace:
-    def lookup(space, w_obj, name):
-        typ = space._gettype(w_obj)
-        return space.wrap(typ.lookup(name))
-
-    def type(space,w_obj):
-        return space.wrap(space._gettype(w_obj))
-
-    def _gettype
-        try:
-            return space._types[w_obj.__class__]
-        except KeyError:
-            typ = space.buildtype(w_obj.TypeDef) 
-            space._types[w_obj.__class__] = typ
-            return typ
-
-    def buildtype(space, typedef):
-        typ = Type(w_
-        for name, value 
-
-    def wrap(space, obj):
-        
-        assert self.space == space 
-        return W_Type(space, self)
-
-def trivspace.lookup(space, w_obj, name):
-    if isinstance(w_obj, Wrappable):
-        for basedef in w_obj.TypeDef.mro():
-            if name in basedef.rawdict:
-                return space.wrap(basedef.rawdict[name])
-        return None 
-    else:
-        for cls in w_obj.__class__.__mro__:
-            if name in cls.__dict__:
-                return cls.__dict__[name]
-        return None
-
-
-def func_code_getter(space,w_func):
-    return space.wrap(w_func.func.code)
-
-def object___class__(space,w_obj):
-    return space.type(w_obj)
-
-def descr_function_call(space, w_func, w_args, w_kwds): 
-    return w_func.func.call(w_args, w_kwds)
-app_descr_function_call = gateway.interp2app(descr_function_call) 
-
-
-
-
-class Property:
-    def __init__(self, fget, fset=None, fdel=None, doc=None):
-        self.fget = fget
-        self.fset = fset
-        self.fdel = fdel
-        self.doc = doc
-    def __wrap__(self, space):
-        return W_Property(space, self)
-
-class W_Property(...Wrapped):
-    def __init__(self, space, property):
-        self.space = space
-        self.property = property
-    def gettype(self):
-        space = self.space
-        try:
-            return space.PropertyType
-        except AttributeError:
-            space.PropertyType = t = Type(space, "builtin-property", [])
-            t.dict_w["__get__"] = space.wrap(app_descr_property_get)
-            return t
-
-def descr_property_get(space, w_property, w_obj, w_ignored):
-    return w_property.property.fget(space, w_obj)
-
-app_descr_property_get = gateway.interp2app(descr_property_get)
-
-

Deleted: /pypy/dist/goal/pydoc-goal.py
==============================================================================
--- /pypy/dist/goal/pydoc-goal.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,2 +0,0 @@
-import pydoc
-pydoc.help(pydoc)

Deleted: /pypy/dist/goal/pydoc-pregoal.py
==============================================================================
--- /pypy/dist/goal/pydoc-pregoal.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1 +0,0 @@
-import pydoc

Deleted: /pypy/dist/goal/stringcomp.py
==============================================================================
--- /pypy/dist/goal/stringcomp.py	Wed May 18 19:15:26 2005
+++ (empty file)
@@ -1,17 +0,0 @@
-
-### a trivial program to test strings, lists, functions and methods ###
-
-def addstr(s1,s2):
-    return s1 + s2
-
-str = "an interesting string"
-str2 = 'another::string::xxx::y:aa'
-str3 = addstr(str,str2)
-arr = []
-for word in str.split():
-    if word in str2.split('::'):
-        arr.append(word)
-print ''.join(arr)
-print "str + str2 = ", str3
-
-

Modified: pypy/dist/pypy/translator/goal/translate_pypy.py
==============================================================================
--- pypy/dist/goal/translate_pypy.py	(original)
+++ pypy/dist/pypy/translator/goal/translate_pypy.py	Wed May 18 19:15:26 2005
@@ -1,4 +1,4 @@
-#
+#! /usr/bin/env python
 #  
 #
 """
@@ -10,7 +10,7 @@
               targetspec.py is a python file defining
               what is the translation target and setting things up for it,
               it should have a target function returning an entry_point ...;
-              defaults to targetpypy. The .py suffix is optional.
+              defaults to targetpypymain. The .py suffix is optional.
    -text      Don't start the Pygame viewer
    -no-a      Don't infer annotations, just translate everything
    -no-s      Don't simplify the graph after annotation
@@ -175,7 +175,7 @@
 
 if __name__ == '__main__':
 
-    targetspec = 'targetpypy'
+    targetspec = 'targetpypymain'
     huge = 100
 
     options = {'-text': False,

Modified: pypy/dist/pypy/translator/translator.py
==============================================================================
--- pypy/dist/pypy/translator/translator.py	(original)
+++ pypy/dist/pypy/translator/translator.py	Wed May 18 19:15:26 2005
@@ -1,36 +1,9 @@
 """PyPy Translator Frontend
 
-Glue script putting together the various pieces of the translator.
-Can be used for interactive testing of the translator. Run as:
-
-    python -i translator.py
-
-Example:
-
-    t = Translator(func)
-    t.view()                           # control flow graph
-
-    print t.source()                   # original source
-    print t.c()                        # C translation
-    print t.cl()                       # common lisp translation
-    print t.llvm()                     # LLVM translation
-
-    t.simplify()                       # flow graph simplification
-    a = t.annotate([int])              # pass the list of args types
-    a.simplify()                       # simplification by annotator
-    t.view()                           # graph + annotations under the mouse
-
-    t.call(arg)                        # call original function
-    t.dis()                            # bytecode disassemble
-
-    f = t.ccompile()                   # C compilation
-    f = t.llvmcompile()                # LLVM compilation
-    assert f(arg) == t.call(arg)       # sanity check
-
-Some functions are provided for the benefit of interactive testing.
-Try dir(test) for list of current snippets.
+The Translator is a glue class putting together the various pieces of the
+translation-related code.  It can be used for interactive testing of the
+translator; see pypy/bin/translator.py.
 """
-
 import autopath, os, sys
 
 from pypy.objspace.flow.model import *
@@ -315,16 +288,3 @@
             result = self.concretetypes[cls, args] = cls(self, *args)
             self.ctlist.append(result)
             return result
-
-
-if __name__ == '__main__':
-    from pypy.translator.test import snippet as test
-    import sys
-    if (os.getcwd() not in sys.path and
-        os.path.curdir not in sys.path):
-        sys.path.insert(0, os.getcwd())
-    print __doc__
-
-    # 2.3 specific -- sanxiyn
-    import os
-    os.putenv("PYTHONINSPECT", "1")



More information about the Pypy-commit mailing list