[pypy-svn] r27298 - in pypy/dist/pypy: doc translator

ericvrp at codespeak.net ericvrp at codespeak.net
Tue May 16 21:14:19 CEST 2006


Author: ericvrp
Date: Tue May 16 21:14:18 2006
New Revision: 27298

Modified:
   pypy/dist/pypy/doc/getting-started.txt
   pypy/dist/pypy/translator/interactive.py
Log:
Added javascript source display to interactive shell and
wrote some documention about this for getting-started.


Modified: pypy/dist/pypy/doc/getting-started.txt
==============================================================================
--- pypy/dist/pypy/doc/getting-started.txt	(original)
+++ pypy/dist/pypy/doc/getting-started.txt	Tue May 16 21:14:18 2006
@@ -406,6 +406,26 @@
    5
 
 
+Translating the flow graph to Javascript code
++++++++++++++++++++++++++++++++++++++++++++++
+
+The Javascript backend is still experimental but will be worked on during this
+years `Google summer of code`_. It contains some rudimentary support for
+stackless features and a good integration with PyPy's unittesting framework.
+Code can be tested with the `Spidermonkey`_ commandline javascript interpreter
+in addition to a multitude of javascript capable browsers. 
+The emphasis of the Javascript backend is to compile RPython code into
+javascript snippets that can be used in a range of browsers. The goal is
+to make it more and more capable to produce full featured web applications.
+Please see the pypy/translator/js/test directory for example unittests.
+
+Here is a simple example to try::
+
+   >>> t = Translation(snippet.my_gcd)
+   >>> a = t.annotate([int, int])
+   >>> t.rtype()
+   >>> t.source_js()
+
 A slightly larger example
 +++++++++++++++++++++++++
 
@@ -638,6 +658,8 @@
 .. _`LLVM mailing list`: http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
 .. _`LLVM installed with version 1.7`: http://llvm.org/releases
 
+.. _`Spidermonkey`: http://www.mozilla.org/js/spidermonkey/
+.. _`Google summer of code`: http://code.google.com/soc
 
 .. _Dot Graphviz:           http://www.research.att.com/sw/tools/graphviz/
 .. _Pygame:                 http://www.pygame.org/

Modified: pypy/dist/pypy/translator/interactive.py
==============================================================================
--- pypy/dist/pypy/translator/interactive.py	(original)
+++ pypy/dist/pypy/translator/interactive.py	Tue May 16 21:14:18 2006
@@ -18,6 +18,7 @@
 
    'fork_before': None,
 
+   'raisingop2direct_call' : False,
    'merge_if_blocks': True
 }
 
@@ -49,10 +50,11 @@
         'annotate': ['debug'],
         'rtype': ['insist'],
         'ootype': [],
-        'backendopt': ['merge_if_blocks'],
+        'backendopt': ['raisingop2direct_call', 'merge_if_blocks'],
         'stackcheckinsertion': [],
         'database_c': ['gc', 'stackless'],
-        'source_llvm': ['gc', 'stackless'],
+        'source_llvm': [],
+        'source_js': [],
         'source_c': [],
         'compile_c': [],
         'compile_llvm': [],
@@ -161,6 +163,12 @@
         self.ensure_backend('llvm')
         self.driver.source_llvm()
 
+    def source_js(self, argtypes=None, **kwds):
+        self.update_options(argtypes, kwds)
+        self.ensure_backend('js')
+        self.driver.source_js()
+        print open(str(self.driver.gen.filename)).read()
+
     def source_cl(self, argtypes=None, **kwds):
         self.update_options(argtypes, kwds)
         self.ensure_backend('cl')



More information about the Pypy-commit mailing list