[pypy-svn] r66798 - in pypy/branch/avm: ctypes_configure demo dotviewer lib-python/2.5.2 lib-python/2.5.2/ctypes/macholib lib-python/2.5.2/idlelib lib-python/2.5.2/lib-tk lib-python/2.5.2/plat-aix3 lib-python/2.5.2/plat-aix4 lib-python/2.5.2/plat-beos5 lib-python/2.5.2/plat-darwin lib-python/2.5.2/plat-freebsd2 lib-python/2.5.2/plat-freebsd3 lib-python/2.5.2/plat-generic lib-python/2.5.2/plat-irix5 lib-python/2.5.2/plat-irix6 lib-python/2.5.2/plat-linux2 lib-python/2.5.2/plat-mac lib-python/2.5.2/plat-mac/Carbon lib-python/2.5.2/plat-netbsd1 lib-python/2.5.2/plat-next3 lib-python/2.5.2/plat-sunos5 lib-python/2.5.2/plat-unixware7 lib-python/2.5.2/test lib-python/modified-2.5.2 lib-python/modified-2.5.2/ctypes/macholib lib-python/modified-2.5.2/test pypy pypy/bin pypy/doc pypy/lang/gameboy/debug pypy/lang/gameboy/profiling/evaluation pypy/lang/js pypy/lang/js/test/ecma pypy/lang/js/test/ecma/ExecutionContexts pypy/lang/malbolge pypy/lang/malbolge/examples pypy/lang/prolog/interpreter pypy/lang/scheme pypy/lang/smalltalk pypy/lib/app_test pypy/lib/test2 pypy/module/unicodedata pypy/rlib/rcairo pypy/rlib/rcairo/test pypy/rpython/tool pypy/tool pypy/tool/pytest pypy/translator/avm1 pypy/translator/avm1/test pypy/translator/c/gcc pypy/translator/goal pypy/translator/microbench pypy/translator/microbench/pybench pypy/translator/sandbox

magcius at codespeak.net magcius at codespeak.net
Thu Aug 13 00:29:08 CEST 2009


Author: magcius
Date: Thu Aug 13 00:29:02 2009
New Revision: 66798

Added:
   pypy/branch/avm/pypy/translator/avm1/
   pypy/branch/avm/pypy/translator/avm1/authoring.py
   pypy/branch/avm/pypy/translator/avm1/avm.py
   pypy/branch/avm/pypy/translator/avm1/avm1.py
   pypy/branch/avm/pypy/translator/avm1/avm1gen.py
   pypy/branch/avm/pypy/translator/avm1/constant.py
   pypy/branch/avm/pypy/translator/avm1/database.py
   pypy/branch/avm/pypy/translator/avm1/genavm.py
   pypy/branch/avm/pypy/translator/avm1/records.py
   pypy/branch/avm/pypy/translator/avm1/swf.py
   pypy/branch/avm/pypy/translator/avm1/tags.py
   pypy/branch/avm/pypy/translator/avm1/test/
   pypy/branch/avm/pypy/translator/avm1/test/autopath.py
   pypy/branch/avm/pypy/translator/avm1/test/bootstrap.py
   pypy/branch/avm/pypy/translator/avm1/test/browsertest.py
   pypy/branch/avm/pypy/translator/avm1/test/harness.py
   pypy/branch/avm/pypy/translator/avm1/test/runtest.py
   pypy/branch/avm/pypy/translator/avm1/test/test_harness.py
   pypy/branch/avm/pypy/translator/avm1/test/test_int.py
   pypy/branch/avm/pypy/translator/avm1/test/test_weakref.py
Modified:
   pypy/branch/avm/ctypes_configure/configure.py   (contents, props changed)
   pypy/branch/avm/demo/bpnn.py   (contents, props changed)
   pypy/branch/avm/dotviewer/dotviewer.py   (contents, props changed)
   pypy/branch/avm/dotviewer/graphserver.py   (contents, props changed)
   pypy/branch/avm/dotviewer/sshgraphserver.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/UserString.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/base64.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/cProfile.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/cgi.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/ctypes/macholib/fetch_macholib   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/idlelib/idle.bat   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/keyword.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/lib-tk/Tix.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/mailbox.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/mimify.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/pdb.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-aix3/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-aix4/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-beos5/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-darwin/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-freebsd2/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-freebsd3/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-generic/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/AL.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/CD.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/CL.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/CL_old.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/DEVICE.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/ERRNO.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/FILE.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/FL.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/GET.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/GL.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/GLWS.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/IN.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/IOCTL.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/SV.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/WAIT.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/cddb.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/cdplayer.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/flp.doc   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/flp.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/jpeg.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/panel.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/panelparser.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/readcd.doc   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/readcd.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix5/torgb.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-irix6/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-linux2/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-mac/Carbon/CG.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-mac/Carbon/CarbonEvents.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-mac/Carbon/CarbonEvt.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-mac/Carbon/CoreGraphics.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-mac/appletrunner.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-mac/bundlebuilder.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-netbsd1/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-next3/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-sunos5/IN.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-sunos5/SUNAUDIODEV.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-sunos5/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/plat-unixware7/regen   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/platform.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/profile.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/pydoc.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/quopri.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/runpy.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/smtpd.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/smtplib.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/symbol.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/tabnanny.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/pystone.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/re_tests.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/regrtest.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_aepack.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_al.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_array.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_binascii.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_binhex.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_bsddb.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_cd.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_cl.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_cmath.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_crypt.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_dbm.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_dl.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_errno.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_fcntl.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_gdbm.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_gl.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_grp.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_htmlparser.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_imageop.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_imgfile.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_strftime.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_userstring.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/test/test_wsgiref.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/token.py   (contents, props changed)
   pypy/branch/avm/lib-python/2.5.2/uu.py   (contents, props changed)
   pypy/branch/avm/lib-python/modified-2.5.2/ctypes/macholib/fetch_macholib   (contents, props changed)
   pypy/branch/avm/lib-python/modified-2.5.2/mailbox.py   (contents, props changed)
   pypy/branch/avm/lib-python/modified-2.5.2/platform.py   (contents, props changed)
   pypy/branch/avm/lib-python/modified-2.5.2/pydoc.py   (contents, props changed)
   pypy/branch/avm/lib-python/modified-2.5.2/test/regrtest.py   (contents, props changed)
   pypy/branch/avm/lib-python/modified-2.5.2/test/test_array.py   (contents, props changed)
   pypy/branch/avm/lib-python/modified-2.5.2/test/test_dbm.py   (contents, props changed)
   pypy/branch/avm/lib-python/modified-2.5.2/uu.py   (contents, props changed)
   pypy/branch/avm/pypy/bin/carbonpython.py   (contents, props changed)
   pypy/branch/avm/pypy/bin/checkmodule.py   (contents, props changed)
   pypy/branch/avm/pypy/bin/dotviewer.py   (contents, props changed)
   pypy/branch/avm/pypy/bin/py.py   (contents, props changed)
   pypy/branch/avm/pypy/bin/pyrolog.py   (contents, props changed)
   pypy/branch/avm/pypy/bin/reportstaticdata.py   (contents, props changed)
   pypy/branch/avm/pypy/bin/translatorshell.py   (contents, props changed)
   pypy/branch/avm/pypy/doc/parse_logs.py   (contents, props changed)
   pypy/branch/avm/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py   (contents, props changed)
   pypy/branch/avm/pypy/lang/gameboy/profiling/evaluation/run.sh   (contents, props changed)
   pypy/branch/avm/pypy/lang/js/commit   (contents, props changed)
   pypy/branch/avm/pypy/lang/js/driver.py   (contents, props changed)
   pypy/branch/avm/pypy/lang/js/js_interactive.py   (contents, props changed)
   pypy/branch/avm/pypy/lang/js/test/ecma/ExecutionContexts/10.1.3-2.js   (contents, props changed)
   pypy/branch/avm/pypy/lang/js/test/ecma/README   (contents, props changed)
   pypy/branch/avm/pypy/lang/malbolge/examples/99bottles.mbs   (contents, props changed)
   pypy/branch/avm/pypy/lang/malbolge/examples/copy.mbs   (contents, props changed)
   pypy/branch/avm/pypy/lang/malbolge/examples/hello-world.mbs   (contents, props changed)
   pypy/branch/avm/pypy/lang/malbolge/malbolge.py   (contents, props changed)
   pypy/branch/avm/pypy/lang/prolog/interpreter/interactive.py   (contents, props changed)
   pypy/branch/avm/pypy/lang/scheme/interactive.py   (contents, props changed)
   pypy/branch/avm/pypy/lang/smalltalk/find_untested_bytecodes.sh   (contents, props changed)
   pypy/branch/avm/pypy/lang/smalltalk/find_untested_prims.sh   (contents, props changed)
   pypy/branch/avm/pypy/lib/app_test/test_binascii.py   (contents, props changed)
   pypy/branch/avm/pypy/lib/test2/pickledtasklet.py   (contents, props changed)
   pypy/branch/avm/pypy/module/unicodedata/generate_unicodedb.py   (contents, props changed)
   pypy/branch/avm/pypy/rlib/rcairo/ll_cairo.py   (contents, props changed)
   pypy/branch/avm/pypy/rlib/rcairo/test/test_ll_cairo.py   (contents, props changed)
   pypy/branch/avm/pypy/rpython/tool/genrffi.py   (contents, props changed)
   pypy/branch/avm/pypy/rpython/tool/rffi_platform.py   (contents, props changed)
   pypy/branch/avm/pypy/test_all.py   (contents, props changed)
   pypy/branch/avm/pypy/tool/fixeol   (contents, props changed)
   pypy/branch/avm/pypy/tool/pytest/genreportdata.py   (contents, props changed)
   pypy/branch/avm/pypy/translator/c/gcc/trackgcroot.py   (contents, props changed)
   pypy/branch/avm/pypy/translator/goal/bench-cronjob.py   (contents, props changed)
   pypy/branch/avm/pypy/translator/goal/launch-bench-cronjob.sh   (contents, props changed)
   pypy/branch/avm/pypy/translator/goal/translate.py   (contents, props changed)
   pypy/branch/avm/pypy/translator/microbench/microbench.py   (contents, props changed)
   pypy/branch/avm/pypy/translator/microbench/pybench/platform.py   (contents, props changed)
   pypy/branch/avm/pypy/translator/microbench/pybench/pybench.py   (contents, props changed)
   pypy/branch/avm/pypy/translator/sandbox/interact.py   (contents, props changed)
   pypy/branch/avm/pypy/translator/sandbox/pypy_interact.py   (contents, props changed)
Log:
Test

Modified: pypy/branch/avm/ctypes_configure/configure.py
==============================================================================

Modified: pypy/branch/avm/demo/bpnn.py
==============================================================================

Modified: pypy/branch/avm/dotviewer/dotviewer.py
==============================================================================

Modified: pypy/branch/avm/dotviewer/graphserver.py
==============================================================================

Modified: pypy/branch/avm/dotviewer/sshgraphserver.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/UserString.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/base64.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/cProfile.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/cgi.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/ctypes/macholib/fetch_macholib
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/idlelib/idle.bat
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/keyword.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/lib-tk/Tix.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/mailbox.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/mimify.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/pdb.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-aix3/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-aix4/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-beos5/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-darwin/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-freebsd2/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-freebsd3/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-generic/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/AL.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/CD.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/CL.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/CL_old.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/DEVICE.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/ERRNO.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/FILE.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/FL.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/GET.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/GL.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/GLWS.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/IN.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/IOCTL.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/SV.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/WAIT.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/cddb.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/cdplayer.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/flp.doc
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/flp.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/jpeg.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/panel.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/panelparser.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/readcd.doc
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/readcd.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix5/torgb.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-irix6/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-linux2/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-mac/Carbon/CG.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-mac/Carbon/CarbonEvents.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-mac/Carbon/CarbonEvt.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-mac/Carbon/CoreGraphics.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-mac/appletrunner.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-mac/bundlebuilder.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-netbsd1/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-next3/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-sunos5/IN.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-sunos5/SUNAUDIODEV.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-sunos5/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/plat-unixware7/regen
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/platform.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/profile.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/pydoc.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/quopri.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/runpy.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/smtpd.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/smtplib.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/symbol.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/tabnanny.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/pystone.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/re_tests.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/regrtest.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_aepack.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_al.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_array.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_binascii.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_binhex.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_bsddb.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_cd.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_cl.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_cmath.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_crypt.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_dbm.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_dl.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_errno.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_fcntl.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_gdbm.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_gl.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_grp.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_htmlparser.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_imageop.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_imgfile.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_strftime.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_userstring.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/test/test_wsgiref.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/token.py
==============================================================================

Modified: pypy/branch/avm/lib-python/2.5.2/uu.py
==============================================================================

Modified: pypy/branch/avm/lib-python/modified-2.5.2/ctypes/macholib/fetch_macholib
==============================================================================

Modified: pypy/branch/avm/lib-python/modified-2.5.2/mailbox.py
==============================================================================

Modified: pypy/branch/avm/lib-python/modified-2.5.2/platform.py
==============================================================================

Modified: pypy/branch/avm/lib-python/modified-2.5.2/pydoc.py
==============================================================================

Modified: pypy/branch/avm/lib-python/modified-2.5.2/test/regrtest.py
==============================================================================

Modified: pypy/branch/avm/lib-python/modified-2.5.2/test/test_array.py
==============================================================================

Modified: pypy/branch/avm/lib-python/modified-2.5.2/test/test_dbm.py
==============================================================================

Modified: pypy/branch/avm/lib-python/modified-2.5.2/uu.py
==============================================================================

Modified: pypy/branch/avm/pypy/bin/carbonpython.py
==============================================================================

Modified: pypy/branch/avm/pypy/bin/checkmodule.py
==============================================================================

Modified: pypy/branch/avm/pypy/bin/dotviewer.py
==============================================================================

Modified: pypy/branch/avm/pypy/bin/py.py
==============================================================================

Modified: pypy/branch/avm/pypy/bin/pyrolog.py
==============================================================================

Modified: pypy/branch/avm/pypy/bin/reportstaticdata.py
==============================================================================

Modified: pypy/branch/avm/pypy/bin/translatorshell.py
==============================================================================

Modified: pypy/branch/avm/pypy/doc/parse_logs.py
==============================================================================

Modified: pypy/branch/avm/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py
==============================================================================

Modified: pypy/branch/avm/pypy/lang/gameboy/profiling/evaluation/run.sh
==============================================================================

Modified: pypy/branch/avm/pypy/lang/js/commit
==============================================================================

Modified: pypy/branch/avm/pypy/lang/js/driver.py
==============================================================================

Modified: pypy/branch/avm/pypy/lang/js/js_interactive.py
==============================================================================

Modified: pypy/branch/avm/pypy/lang/js/test/ecma/ExecutionContexts/10.1.3-2.js
==============================================================================

Modified: pypy/branch/avm/pypy/lang/js/test/ecma/README
==============================================================================

Modified: pypy/branch/avm/pypy/lang/malbolge/examples/99bottles.mbs
==============================================================================

Modified: pypy/branch/avm/pypy/lang/malbolge/examples/copy.mbs
==============================================================================

Modified: pypy/branch/avm/pypy/lang/malbolge/examples/hello-world.mbs
==============================================================================

Modified: pypy/branch/avm/pypy/lang/malbolge/malbolge.py
==============================================================================

Modified: pypy/branch/avm/pypy/lang/prolog/interpreter/interactive.py
==============================================================================

Modified: pypy/branch/avm/pypy/lang/scheme/interactive.py
==============================================================================

Modified: pypy/branch/avm/pypy/lang/smalltalk/find_untested_bytecodes.sh
==============================================================================

Modified: pypy/branch/avm/pypy/lang/smalltalk/find_untested_prims.sh
==============================================================================

Modified: pypy/branch/avm/pypy/lib/app_test/test_binascii.py
==============================================================================

Modified: pypy/branch/avm/pypy/lib/test2/pickledtasklet.py
==============================================================================

Modified: pypy/branch/avm/pypy/module/unicodedata/generate_unicodedb.py
==============================================================================

Modified: pypy/branch/avm/pypy/rlib/rcairo/ll_cairo.py
==============================================================================

Modified: pypy/branch/avm/pypy/rlib/rcairo/test/test_ll_cairo.py
==============================================================================

Modified: pypy/branch/avm/pypy/rpython/tool/genrffi.py
==============================================================================

Modified: pypy/branch/avm/pypy/rpython/tool/rffi_platform.py
==============================================================================

Modified: pypy/branch/avm/pypy/test_all.py
==============================================================================

Modified: pypy/branch/avm/pypy/tool/fixeol
==============================================================================

Modified: pypy/branch/avm/pypy/tool/pytest/genreportdata.py
==============================================================================

Added: pypy/branch/avm/pypy/translator/avm1/authoring.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/authoring.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,46 @@
+
+from pypy.translator.avm.tags import ShapeWithStyle
+from pypy.translator.avm.records import StyleChangeRecord, CurvedEdgeRecord, StraightEdgeRecord
+
+class Circle(object):
+
+    def __init__(self, x, y, radius, linestyle, fillstyle0, fillstyle1):
+        self.x = x
+        self.y = y
+        self.radius = radius
+        self.linestyle = linestyle
+        self.fillstyle0 = fillstyle0
+        self.fillstyle1 = fillstyle1
+
+    def to_shape(self):
+        shape = ShapeWithStyle()
+
+        if self.linestyle: shape.add_line_style(self.linestyle)
+        if self.fillstyle0: shape.add_fill_style(self.fillstyle0)
+        if self.fillstyle1: shape.add_fill_style(self.fillstyle1)
+
+        # Precalculated:
+        # math.tan(math.radians(22.5)) = 0.41421356237309503
+        # math.sin(math.radians(45))   = 0.70710678118654746
+        
+        c = self.radius * 0.41421356237309503
+        a = self.radius * 0.70710678118654746 - c
+
+        shape.add_shape_record(StyleChangeRecord(self.x + self.radius, self.y, self.linestyle, self.fillstyle0, self.fillstyle1))
+        # 0 to PI/2
+        shape.add_shape_record(CurvedEdgeRecord(0, -c, -a, -a))
+        shape.add_shape_record(CurvedEdgeRecord(-a, -a, -c, 0))
+
+        # PI/2 to PI
+        shape.add_shape_record(CurvedEdgeRecord(-c, 0, -a, a))
+        shape.add_shape_record(CurvedEdgeRecord(-a, a, 0, c))
+
+        # PI to 3PI/2
+        shape.add_shape_record(CurvedEdgeRecord(0, c, a, a))
+        shape.add_shape_record(CurvedEdgeRecord(a, a, c, 0))
+
+        # 3PI/2 to 2PI
+        shape.add_shape_record(CurvedEdgeRecord(c, 0, a, -a))
+        shape.add_shape_record(CurvedEdgeRecord(a, -a, 0, -c))
+
+        return shape

Added: pypy/branch/avm/pypy/translator/avm1/avm.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/avm.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,66 @@
+
+import py, os
+
+from pypy.rpython.rmodel import inputconst
+from pypy.rpython.typesystem import getfunctionptr
+from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.ootypesystem import ootype
+from pypy.tool.udir import udir
+from pypy.translator.avm.log import log
+from pypy.translator.avm.asmgen import AsmGen
+from pypy.translator.avm.avm1types import AVM1TypeSystem
+#from pypy.translator.js.opcodes import opcodes
+from pypy.translator.avm.function import Function
+from pypy.translator.avm.database import LowLevelDatabase
+from pypy.translator.avm import bootstrap
+
+from pypy.translator.oosupport.genoo import GenOO
+from heapq import heappush, heappop
+
+
+class AVM1(GenOO):
+    TypeSystem = AVM1TypeSystem
+    Function = Function
+    Database = LowLevelDatabase
+
+    def __init__(self, translator, function=[], stackless=False, compress=False, \
+                 logging=False, use_debug=False):
+        if not isinstance(function, list):
+            functions = [functions]
+        GenOO.__init__(self, udir, translator, None)
+
+        pending_graphs = [ translator.annotator.bookeeeper.getdesc(f).cachedgraph(None) for f in functions ]
+        for graph in pending_graphs:
+            self.db.pending_function(graph)
+
+        self.db.translator = translator
+        self.use_debug = use_debug
+        self.assembly_name = self.translator.graphs[0].name
+        self.tmpfile = udir.join(self.assembly_name + '.swf')
+
+    def stack_optimization(self):
+        pass
+
+    def gen_pendings(self):
+        while self.db._pending_nodes:
+            node = self.db.pending_nodes.pop()
+            to_render = []
+            nparent = node
+            while nparent-order != 0:
+                nparent = nparent.parent
+                to_render.append(nparent)
+            to_render.reverse()
+            for i in to_render:
+                i.render(self.ilasm)
+
+    def create_assembler(self):
+        return bootstrap.create_assembler(self.assembly_name)
+
+    def generate_swf(self):
+        self.ilasm = self.create_assembler()
+        self.fix_names()
+        self.gen_entrypoint()
+        while self.db._pending_nodes:
+            self.gen_pendings()
+            self.db.gen_constants(self.ilasm, self.db._pending_nodes)
+        # self.ilasm.close()

Added: pypy/branch/avm/pypy/translator/avm1/avm1.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/avm1.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,649 @@
+
+# AVM1 = ActionScript Virtual Machine 1
+# Used for ActionScript 1 and 2
+
+from pypy.translator.avm.util import BitStream
+from collections import namedtuple
+import struct
+
+DataType = namedtuple("DataType", "id name size")
+
+STRING      = DataType(0, "string", "Z")
+FLOAT       = DataType(1, "float", "f")
+NULL        = DataType(2, "null", "!")
+UNDEFINED   = DataType(3, "undefined", "!")
+REGISTER    = DataType(4, "register", "B")
+BOOLEAN     = DataType(5, "boolean", "B")
+DOUBLE      = DataType(6, "double", "d")
+INTEGER     = DataType(7, "integer", "l")
+CONSTANT8   = DataType(8, "constant 8", "B")
+CONSTANT16  = DataType(9, "constant 16", "H")
+
+class Index(object):
+    def __init__(self, index):
+        self.index = index
+
+class Value(object):
+    def __init__(self, value):
+        self.value = value
+
+class Null(object):
+    type = NULL
+
+class Undefined(object):
+    type = UNDEFINED
+
+class ConstantIndexDescriptor(object):
+    def __get__(self, obj, objtype):
+        return CONSTANT8 if obj.index < 256 else CONSTANT16
+
+class Constant(Index):
+    type = ConstantIndexDescriptor()
+
+class Register(object):
+    type = REGISTER
+    
+class RegisterByIndex(Register, Index):
+    pass
+
+class RegisterByValue(Register, Value):
+    pass
+
+class Action(object):
+    
+    ACTION_NAME = "NotImplemented"
+    ACTION_ID = 0x00
+
+    offset = 0
+    label_name = ""
+    
+    def serialize(self):
+        inner_data = self.gen_data()
+        outer_data = self.gen_outer_data()
+        header = struct.pack("<BH", self.ACTION_ID, len(inner_data))
+        return header + inner_data + outer_data
+    
+    def __len__(self):
+        return 6 + len(self.gen_data()) + len(self.gen_outer_data())
+    
+    def gen_data(self):
+        return ""
+
+    def gen_outer_data(self):
+        return ""
+    
+    def get_block_props_early(self, block):
+        pass
+
+    def get_block_props_late(self, block):
+        pass
+
+class RegisterError(IndexError):
+    pass
+
+class SealedBlockError(Exception):
+    pass
+
+class ActionConstantPool(Action):
+    ACTION_NAME = "ActionConstantPool"
+    ACTION_ID = 0x88
+
+    def __init__(self, *args):
+        self.pool = []
+        for string in args:
+            if not string in self.pool:
+                self.pool.append(args)
+
+    def add_constant(self, string):
+        if not string in self.pool:
+            self.pool.append(string)
+            return len(self.pool)-1
+        return self.pool.index(string)
+
+    def serialize(self):
+        if len(self.pool) == 0:
+            return ""
+        else:
+            return super(ActionConstantPool, self).serialize()
+    
+    def gen_data(self):
+        return struct.pack("H", len(self.pool)) + "\0".join(self.pool) + "\0"
+
+class Block(object):
+
+    AUTO_LABEL_TEMPLATE = "label%d"
+    MAX_REGISTERS = 4
+    FUNCTION_TYPE = 0
+    
+    def __init__(self, toplevel, insert_end=False):
+        if toplevel:
+            self.constants = toplevel.constants
+            self.registers = toplevel.registers
+        else:
+            self.constants = ActionConstantPool()
+            self.registers = []
+        
+        self.code = ""
+        self._sealed = False
+        self.insert_end = insert_end
+        
+        self.labels = {}
+        self.branch_blocks = {}
+        self.actions = []
+        
+        self.current_offset = 0
+        self.label_count = 0
+    
+    def get_free_register(self):
+        if None in self.registers:
+            return self.registers.index(None)
+        elif len(self.registers) < self.MAX_REGISTERS:
+            self.registers.append(None)
+            return len(self.registers)-1
+        else:
+            raise RegisterError("maximum number of registers in use")
+
+    def store_register(self, value, index=-1):
+        if value in self.registers:
+            index = self.registers.index(value)
+            return index
+        if index < 1:
+            index = self.get_free_register()
+        self.registers[index] = value
+        return index
+    
+    def find_register(self, value):
+        if value in self.registers:
+            return self.registers.index(value)
+        return -1
+    
+    def free_register(self, index):
+        self.registers[index] = None
+    
+    def __len__(self):
+        return self.current_offset + (2 if self.insert_end else 0)
+
+    def seal(self):
+        self._sealed = True
+        return len(self)
+
+    @property
+    def sealed(self):
+        return self._sealed
+    
+    def add_action(self, action):
+        if self._sealed:
+            raise SealedBlockError("Block is sealed. Cannot add new actions")
+        self.code = "" # Dirty the code.
+        action.offset = self.current_offset
+        action.get_block_props_early(self)
+        
+        # Do some early optimizations. Combine two pushes into one.
+        if len(self.actions) > 0 and action.ACTION_NAME == "ActionPush" and self.actions[-1].ACTION_NAME == "ActionPush":
+            old_action = self.actions[-1]
+            old_len = len(old_action)
+            self.actions[-1].values.extend(action.values)
+            self.current_offset += len(old_action) - old_len
+            return old_action
+
+        # Two nots negate. Take them out.
+        if action.ACTION_NAME == "ActionNot" and action.ACTION_NAME == "ActionNot":
+            self.actions.pop()
+            self.current_offset -= 1 # len(ShortAction) is 1
+            return None
+            
+        if not isinstance(action, Block): # Don't add block length until we've finalized.
+            self.current_offset += len(action)
+        
+        self.actions.append(action)
+        return action
+    
+    def serialize(self):
+        if len(self.code) > 0:
+            return self.code
+        bytes = []
+        for action in self.actions:
+            action.get_block_props_late(self)
+            bytes += action.serialize()
+        if self.insert_end:
+            bytes += "\0"
+        self.code = "".join(bytes)
+        return self.code
+
+    def new_label(self):
+        self.label_count += 1
+        name = Block.AUTO_LABEL_TEMPLATE % self.label_count
+        self.labels[name] = -1
+        return name
+        
+    def set_label_here(self, name):
+        self.labels[name] = self.current_offset
+
+    def new_label_here(self):
+        name = self.new_label()
+        self.labels[name] = self.current_offset
+        return name
+
+class ActionCall(Action):
+    ACTION_NAME = "ActionCall"
+    ACTION_ID = 0x9e
+
+class ActionDefineFunction(Action, Block):
+    ACTION_NAME = "ActionDefineFunction"
+    ACTION_ID = 0x9b
+    FUNCTION_TYPE = 1
+
+    def __init__(self, toplevel, name, parameters):
+        Block.__init__(self, toplevel, False)
+        self.function_name = name
+        self.params = parameters
+
+    def gen_data(self):
+        self.block_data = Block.serialize(self)
+        bytes = [self.function_name, "\0", struct.pack("H", len(self.params))]
+        bytes += [p + "\0" for p in self.params]
+        bytes += struct.pack("H", len(self.block_data))
+        return "".join(bytes)
+
+    def gen_outer_data(self):
+        return self.block_data
+
+class ActionDefineFunction2(Action, Block):
+    ACTION_NAME = "ActionDefineFunction2"
+    ACTION_ID = 0x8e
+    MAX_REGISTERS = 256
+    FUNCTION_TYPE = 2
+
+    def __init__(self, toplevel, name, parameters):
+        Block.__init__(self, toplevel, False)
+        self.function_name = name
+        self.params = parameters
+        
+        # Flags
+        self.preload_parent   = False
+        self.preload_root     = False
+        self.suppress_super   = True
+        self.preload_super    = False
+        self.suppress_args    = False
+        self.preload_args     = True
+        self.suppress_this    = True
+        self.preload_this     = False
+        self.preload_global   = False
+        self.eval_flags()
+    
+    def eval_flags(self): # WARNING! eval_flags will clear registers!
+        # bits = BitStream()
+        # bits.write_bit_value(self.flags, 16)
+        # bits.rewind()
+        # preload_parent  = bits.read_bit()
+        # preload_root    = bits.read_bit()
+        # suppress_super  = bits.read_bit()
+        # preload_super   = bits.read_bit()
+        # suppress_args   = bits.read_bit()
+        # preload_args    = bits.read_bit()
+        # suppress_this   = bits.read_bit()
+        # preload_this    = bits.read_bit()
+        # bits.cursor += 7 # skip over 7 Reserved bits
+        # preload_global  = bits.read_bit()
+        
+        self.registers = [None]
+        
+        # According to the docs, this is the order of register allocation.
+        if self.preload_this:   self.registers.append("this")
+        if self.preload_args:   self.registers.append("arguments")
+        if self.preload_super:  self.registers.append("super")
+        if self.preload_root:   self.registers.append("_root")
+        if self.preload_parent: self.registers.append("_parent")
+        if self.preload_global: self.registers.append("_global")
+        
+        for name in self.params:
+            self.registers.append(name)
+        
+    def gen_data(self):
+
+        bits = BitStream()
+        bits.write_bit(self.preload_parent)
+        bits.write_bit(self.preload_root)
+        bits.write_bit(self.suppress_super)
+        bits.write_bit(self.preload_super)
+        bits.write_bit(self.suppress_args)
+        bits.write_bit(self.preload_args)
+        bits.write_bit(self.suppress_this)
+        bits.write_bit(self.preload_this)
+        bits.zero_fill(7) # skip over 7 Reserved bits
+        bits.write_bit(self.preload_global)
+        
+        self.block_data = Block.serialize(self)
+        bytes = [self.function_name, "\0",
+                 struct.pack("HB", len(self.params), len(self.registers)-1),
+                 bits.serialize()]
+        
+        for name in self.params:
+            bytes += [chr(self.registers.index(name)), name, "\0"]
+        
+        bytes += [struct.pack("H", len(self.block_data))]
+        return "".join(bytes)
+
+    def gen_outer_data(self):
+        return self.block_data
+
+class ActionGetURL(Action):
+    ACTION_NAME = "ActionGetURL"
+    ACTION_ID = 0x83
+
+    def __init__(self, url, target=""):
+        self.url = url
+        self.target = target
+
+    def gen_data(self):
+        return "%s\0%s\0" % (self.url, self.target)
+
+class ActionGetURL2(Action):
+    ACTION_NAME = "ActionGetURL2"
+    ACTION_ID = 0x9a
+
+    METHODS = {"": 0, "GET": 1, "POST": 2}
+
+    def __init__(self, method, load_target=False, load_variables=False):
+        self.method = method
+        self.load_target = load_target
+        self.load_variables = load_variables
+
+    def gen_data(self):
+        # The SWF 10 spec document is incorrect.
+        # method goes at the low end
+        # and the flags at the high end
+        bits = BitStream()
+        bits.write_bit(self.load_variables)
+        bits.write_bit(self.load_target)
+        bits.zero_fill(4)
+        bits.write_int_value(self.METHODS[self.method.upper()], 2)
+        return bits.serialize()
+
+class ActionGotoFrame(Action):
+    ACTION_NAME = "ActionGotoFrame"
+    ACTION_ID = 0x81
+
+    def __init__(self, index):
+        self.index = index
+
+    def gen_data(self):
+        return struct.pack("H", self.index)
+
+class ActionGotoFrame2(Action):
+    ACTION_NAME = "ActionGotoFrame2"
+    ACTION_ID = 0x9f
+
+    def __init__(self, play=False, scene_bias=0):
+        self.play = play
+        self.scene_bias = scene_bias
+
+    def gen_data(self):
+        bits = BitStream()
+        bits.zero_fill(6)
+        bits.write_bit(self.scene_bias > 0)
+        bits.write_bit(self.play)
+
+        if self.scene_bias > 0:
+            return bits.serialize() + struct.pack("<H", self.scene_bias)
+
+        return bits.serialize()
+
+class ActionGotoLabel(Action):
+    ACTION_NAME = "ActionGotoLabel"
+    ACTION_ID = 0x81
+
+    def __init__(self, label_name):
+        self.label_name = label_name
+
+    def serialize(self):
+        return self.label_name + "\0"
+
+class BranchingActionBase(Action):
+
+    def __init__(self, branch):
+        if isinstance(branch, str):
+            self.branch_label = branch
+            self.branch_offset = 0
+        elif isinstance(branch, int):
+            self.branch_label = None
+            self.branch_offset = branch
+
+    def get_block_props_late(self, block):
+        if len(self.branch_label) > 0:
+            self.branch_offset = block.labels[self.branch_label] - self.offset
+
+    def gen_data(self):
+        return struct.pack("H", self.branch_offset)
+
+class ActionJump(BranchingActionBase):
+    ACTION_NAME = "ActionJump"
+    ACTION_ID = 0x99
+
+class ActionIf(BranchingActionBase):
+    ACTION_NAME = "ActionIf"
+    ACTION_ID = 0x9d
+
+class ActionPush(Action):
+    ACTION_NAME = "ActionPush"
+    ACTION_ID = 0x96
+
+    def __init__(self, *args):
+        self.values = []
+        self.add_element(*args)
+    
+    def add_element(self, element):
+        if hasattr(element, "__iter__") and not isinstance(element, basestring):
+            for e in element:
+                self.add_element(e)
+        if isinstance(element, (Null, Undefined)):
+            self.values.append((0, element.type))
+        elif isinstance(element, basestring):
+            self.values.append((element, STRING))
+        elif isinstance(element, bool):
+            self.values.append((element, BOOLEAN))
+        elif isinstance(element, int):
+            self.values.append((element, INTEGER))
+        elif isinstance(element, float):
+            if element > 0xFFFFFFFF:
+                self.values.append((element, DOUBLE))
+            else:
+                self.values.append((element, FLOAT))
+        elif isinstance(element, Index):
+            self.values.append((element.index, element.type))
+        elif isinstance(element, RegisterByValue):
+            self.values.append((element.value, RegisterByValue))
+
+    def get_block_props_early(self, block):
+        for index, (value, type) in enumerate(self.values):
+            if type == STRING:
+                constant_index = block.constants.add_constant(value)
+                self.values[index] = (constant_index, CONSTANT8 if constant_index < 256 else CONSTANT16)
+            elif type == RegisterByValue:
+                register_index = block.find_register(value)
+                if register_index < 0:
+                    raise ValueError("register value '%s' not found in registers at this point" % value)
+                self.values[index] = (register_index, REGISTER)
+    
+    def gen_data(self):
+        bytes = []
+        for value, type in self.values:
+            bytes += chr(type.id)
+            if type.size == "Z":
+                bytes += [value, "\0"]
+            elif type.size != "!":
+                bytes += struct.pack("<"+type.size, value)
+        return "".join(bytes)
+
+class ActionSetTarget(Action):
+    ACTION_NAME = "ActionSetTarget"
+    ACTION_ID = 0x8b
+
+    def __init__(self, target):
+        self.target = target
+
+    def gen_data(self):
+        return self.target + "\0"
+
+class ActionStoreRegister(Action):
+    ACTION_NAME = "ActionStoreRegister"
+    ACTION_ID = 0x87
+
+    def __init__(self, index):
+        self.index = index
+
+    def gen_data(self):
+        return chr(self.index)
+
+class ActionTry(Action):
+    ACTION_NAME = "ActionTry"
+    ACTION_ID = 0x8f
+
+    def __init__(self, catch_object, try_block=None, catch_block=None, finally_block=None):
+
+        self.catch_object = catch_object
+        
+        self.try_block = try_block or Block()
+        self.catch_block = catch_block or Block()
+        self.finally_block = finally_block or Block()
+
+    def gen_data(self):
+        has_catch_block = len(self.catch_block.actions) > 0
+        bits = BitStream()
+        bits.zero_fill(5)
+        bits.write_bit(isinstance(self.catch_object, Register))
+        bits.write_bit(len(self.finally_block.actions) > 0)
+        bits.write_bit(has_catch_block)
+        bytes = [bits.serialize()]
+        bytes += [struct.pack("HHH", len(self.try_block) + 5 if has_catch_block else 0, len(self.catch_block), len(self.finally_block))]
+        bytes += self.catch_object.index if isinstance(self.catch_object, Register) else (self.catch_object + "\0")
+        return "".join(bytes)
+
+    def gen_outer_data(self):
+        bytes = [self.try_block.serialize()]
+        if len(self.catch_block.actions) > 0:
+            bytes += ActionJump(len(self.catch_block)).serialize()
+            bytes += self.catch_block.serialize()
+        bytes += self.finally_block.serialize()
+
+class ActionWaitForFrame(Action):
+    ACTION_NAME = "ActionWaitForFrame"
+    ACTION_ID = 0x8a
+
+    def __init__(self, index, skip_count=0):
+        self.index = index
+        self.skip_count = skip_count
+
+    def gen_data(self):
+        return struct.pack("HB", self.index, self.skip_count)
+    
+class ActionWaitForFrame2(Action):
+    ACTION_NAME = "ActionWaitForFrame2"
+    ACTION_ID = 0x8d
+
+    def __init__(self, skip_count=0):
+        self.skip_count = skip_count
+
+    def gen_data(self):
+        return chr(self.skip_count)
+
+class ActionWith(Action):
+    ACTION_NAME = "ActionWith"
+    ACTION_ID = 0x94
+    
+    def __init__(self, with_block):
+        self.block = with_block or Block()
+    
+    def gen_data(self):
+        return struct.pack("H", len(self.block)) + self.block.serialize()
+    
+def make_short_action(value, name):
+    
+    def __len__(self):
+        return 1 # 1 (Action ID)
+    
+    def serialize(self):
+        return chr(self.ACTION_ID)
+
+    return type(name, (Action,), dict(ACTION_ID=value, ACTION_NAME=name,
+                                      __len__=__len__, serialize=serialize))
+
+ActionNextFrame           = make_short_action(0x04, "ActionNextFrame")
+ActionPreviousFrame       = make_short_action(0x05, "ActionPreviousFrame")
+ActionPlay                = make_short_action(0x06, "ActionPlay")
+ActionStop                = make_short_action(0x07, "ActionStop")
+ActionToggleQuality       = make_short_action(0x08, "ActionToggleQuality")
+ActionStopSounds          = make_short_action(0x09, "ActionStopSounds")
+ActionAdd                 = make_short_action(0x0a, "ActionAdd")
+ActionSubtract            = make_short_action(0x0b, "ActionSubtract")
+ActionMultiply            = make_short_action(0x0c, "ActionMultiply")
+ActionDivide              = make_short_action(0x0d, "ActionDivide")
+ActionEquals              = make_short_action(0x0e, "ActionEquals")
+ActionLess                = make_short_action(0x0f, "ActionLess")
+ActionAnd                 = make_short_action(0x10, "ActionAnd")
+ActionOr                  = make_short_action(0x11, "ActionOr")
+ActionNot                 = make_short_action(0x12, "ActionNot")
+ActionStringEquals        = make_short_action(0x13, "ActionStringEquals")
+ActionStringLength        = make_short_action(0x14, "ActionStringLength")
+ActionStringExtract       = make_short_action(0x15, "ActionStringExtract")
+ActionPop                 = make_short_action(0x17, "ActionPop")
+ActionToInteger           = make_short_action(0x18, "ActionToInteger")
+ActionGetVariable         = make_short_action(0x1c, "ActionGetVariable")
+ActionSetVariable         = make_short_action(0x1d, "ActionSetVariable")
+ActionSetTarget2          = make_short_action(0x20, "ActionSetTarget2")
+ActionStringAdd           = make_short_action(0x21, "ActionStringAdd")
+ActionGetProperty         = make_short_action(0x22, "ActionGetProperty")
+ActionSetProperty         = make_short_action(0x23, "ActionSetProperty")
+ActionCloneSprite         = make_short_action(0x24, "ActionCloneSprite")
+ActionRemoveSprite        = make_short_action(0x25, "ActionRemoveSprite")
+ActionTrace               = make_short_action(0x26, "ActionTrace")
+ActionStartDrag           = make_short_action(0x27, "ActionStartDrag")
+ActionEndDrag             = make_short_action(0x28, "ActionEndDrag")
+ActionStringLess          = make_short_action(0x29, "ActionStringLess")
+ActionThrow               = make_short_action(0x2a, "ActionThrow")
+ActionCastOp              = make_short_action(0x2b, "ActionCastOp")
+ActionImplementsOp        = make_short_action(0x2c, "ActionImplementsOp")
+ActionRandomNumber        = make_short_action(0x30, "ActionRandomNumber")
+ActionMBStringLength      = make_short_action(0x31, "ActionMBStringLength")
+ActionCharToAscii         = make_short_action(0x32, "ActionCharToAscii")
+ActionAsciiToChar         = make_short_action(0x33, "ActionAsciiToChar")
+ActionGetTime             = make_short_action(0x34, "ActionGetTime")
+ActionMBStringExtract     = make_short_action(0x35, "ActionMBStringExtract")
+ActionMBCharToAscii       = make_short_action(0x36, "ActionMBCharToAscii")
+ActionMBAsciiToChar       = make_short_action(0x37, "ActionMBAsciiToChar")
+ActionDelVar              = make_short_action(0x3a, "ActionDelVar")
+ActionDelThreadVars       = make_short_action(0x3b, "ActionDelThreadVars")
+ActionDefineLocalVal      = make_short_action(0x3c, "ActionDefineLocalVal")
+ActionCallFunction        = make_short_action(0x3d, "ActionCallFunction")
+ActionReturn              = make_short_action(0x3e, "ActionReturn")
+ActionModulo              = make_short_action(0x3f, "ActionModulo")
+ActionNewObject           = make_short_action(0x40, "ActionNewObject")
+ActionDefineLocal         = make_short_action(0x41, "ActionDefineLocal")
+ActionInitArray           = make_short_action(0x42, "ActionInitArray")
+ActionInitObject          = make_short_action(0x43, "ActionInitObject")
+ActionTypeof              = make_short_action(0x44, "ActionTypeof")
+ActionGetTargetPath       = make_short_action(0x45, "ActionGetTargetPath")
+ActionEnumerate           = make_short_action(0x46, "ActionEnumerate")
+ActionTypedAdd            = make_short_action(0x47, "ActionTypedAdd")
+ActionTypedLessThan       = make_short_action(0x48, "ActionTypedLessThan")
+ActionTypedEquals         = make_short_action(0x49, "ActionTypedEquals")
+ActionConvertToNumber     = make_short_action(0x4a, "ActionConvertToNumber")
+ActionConvertToString     = make_short_action(0x4b, "ActionConvertToString")
+ActionDuplicate           = make_short_action(0x4c, "ActionDuplicate")
+ActionSwap                = make_short_action(0x4d, "ActionSwap")
+ActionGetMember           = make_short_action(0x4e, "ActionGetMember")
+ActionSetMember           = make_short_action(0x4f, "ActionSetMember")
+ActionIncrement           = make_short_action(0x50, "ActionIncrement")
+ActionDecrement           = make_short_action(0x51, "ActionDecrement")
+ActionCallMethod          = make_short_action(0x52, "ActionCallMethod")
+ActionCallNewMethod       = make_short_action(0x53, "ActionCallNewMethod")
+ActionBitAnd              = make_short_action(0x60, "ActionBitAnd")
+ActionBitOr               = make_short_action(0x61, "ActionBitOr")
+ActionBitXor              = make_short_action(0x62, "ActionBitXor")
+ActionShiftLeft           = make_short_action(0x63, "ActionShiftLeft")
+ActionShiftRight          = make_short_action(0x64, "ActionShiftRight")
+ActionShiftUnsigned       = make_short_action(0x65, "ActionShiftUnsigned")
+ActionStrictEquals        = make_short_action(0x66, "ActionStrictEquals")
+ActionGreater             = make_short_action(0x67, "ActionGreater")
+ActionStringGreater       = make_short_action(0x68, "ActionStringGreater")
+ActionExtends             = make_short_action(0x69, "ActionExtends")

Added: pypy/branch/avm/pypy/translator/avm1/avm1gen.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/avm1gen.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,310 @@
+
+""" backend generator routines
+"""
+
+from pypy.translator.avm import avm1
+from collections import namedtuple
+
+Scope = namedtuple("Scope", "block parent callback stack")
+
+def make_variable(name):
+    if isinstance(name, Variable):
+        return name
+    return Variable(name)
+
+class StackDummy(object):
+    def __init__(self, name):
+        self.name = name
+
+class Variable(StackDummy):
+    def __str__(self):
+        return 'Variable(name="%s")' % self.name
+    __repr__ = __str__
+
+    def __add__(self, other):
+        if isinstance(other, StackDummy):
+            other = other.name
+        return Variable("CONCAT %r %r" % (self.name, other))
+
+    def __radd__(self, other):
+        if isinstance(other, StackDummy):
+            other = other.name
+        return Variable("CONCAT %r %r" % (other, self.name))
+        
+    
+class Function(StackDummy):
+    pass
+
+class AVM1Gen(object):
+    """ AVM1 'assembler' generator routines """
+
+    def __getattribute__(self, name):
+        return object.__getattribute__(self, name)
+    
+    def __init__(self, block=None):
+        self.block = block or avm1.Block(None, True)
+        self.scope = Scope(self.block, None, None, [])
+        self.action(self.block.constants)
+        
+    def new_label(self):
+        return self.scope.block.new_label()
+
+    def push_stack(self, *values):
+        print "PUSHSTACK:", values
+        for element in values:
+            if isinstance(element, avm1.RegisterByIndex):
+                element = Variable(self.scope.block.registers[element.index])
+            elif isinstance(element, avm1.RegisterByValue):
+                element = Variable(element.value)
+            self.scope.stack.append(element)
+    
+    def pop_stack(self, n=1):
+        v = [self.scope.stack.pop() for i in xrange(n)]
+        print "POPSTACK:", v
+        return v
+    
+    def store_register(self, name, index=-1):
+        index = self.scope.block.store_register(name, index)
+        self.action(avm1.ActionStoreRegister(index))
+        return index
+    
+    def find_register(self, name):
+        return self.scope.block.find_register(name)
+    
+    def action(self, action):
+        return self.scope.block.add_action(action)
+    
+    def enter_scope(self, new_code_obj, exit_callback=None):
+        self.scope = Scope(new_code_obj, self.scope, exit_callback, [])
+
+    def in_function(self):
+        return self.scope.block.FUNCTION_TYPE
+    
+    def exit_scope(self):
+        block_len = self.finalize_block(self.scope.block)
+        exit_callback = self.scope.callback
+        
+        # Go up to the parent scope.
+        self.scope = self.scope.parent
+        
+        self.scope.block.current_offset += block_len
+        if exit_callback is not None:
+            exit_callback()
+
+    def finalize_block(self, block):
+        for label, branch_block in block.branch_blocks.iteritems():
+            if not branch_block.is_sealed():
+                raise Exception, "Branch block hasn't been finalized"
+            # Set the label.
+            block.labels[label] = block.current_offset
+            # Add the actions, which updates current_offset
+            for act in branch_block.actions:
+                block.add_action(act)
+        return block.seal()
+    
+    def begin_function(self, name, arglist):
+        self.enter_scope(self.action(avm1.ActionDefineFunction2(self.block, name, arglist)))
+    
+    def begin_prototype_method(self, function_name, _class, arglist):
+        def exit_callback(block):
+            self.set_member()
+        self.push_const(function_name, "prototype", _class)
+        self.get_variable()
+        self.get_member()
+        self.enter_scope(self.action(avm1.ActionDefineFunction2(self.block, "", arglist, 0)), exit_callback)
+        self.push_stack(Function(function_name))
+
+    def set_variable(self):
+        value, name = self.pop_stack(2)
+        print "SETVARIABLE: %r = %r" % (name, value)
+        if isinstance(name, Variable):
+            name = name.name
+        assert isinstance(name, basestring)
+        if self.find_register(name) >= 0:
+            self.store_register(name)
+        self.action(avm1.ActionSetVariable())
+        
+    def get_variable(self):
+        name, = self.pop_stack()
+        print "GETVARIABLE: %s" % (name,)
+        self.action(avm1.ActionGetVariable())
+        self.push_stack(make_variable(name))
+    
+    def set_member(self):
+        self.action(avm1.ActionSetMember())
+        self.pop_stack(3)
+
+    def get_member(self):
+        self.action(avm1.ActionGetMember())
+        value, name, obj = self.pop_stack(3)
+        print "GETMEMBER:", value, name, obj
+        self.push_stack(Variable("%s.%s") % obj, name)
+        
+    def push_reg_index(self, index):
+        self.push_const(avm1.RegisterByIndex(index))
+    
+    def push_arg(self, v):
+        assert self.in_function() > 0, "avm1gen::push_arg called while not in function scope."
+        self.push_local(v)
+    
+#    def push_value(self, v):
+#        self.action(avm1.ActionPush(v.name))
+
+    def push_var(self, v):
+        k = self.find_register(v)
+        if k >= 0:
+            self.push_reg_index(k)
+        else:
+            self.push_const(v)
+            self.get_variable()
+            index = self.store_register(v)
+
+    def push_this(self):
+        self.push_var("this")
+    
+    def push_local(self, v):
+        self.push_var(v.name)
+        
+    def push_const(self, *v):
+        self.push_stack(*v)
+        return self.action(avm1.ActionPush(v))
+
+    def push_undefined(self):
+        self.push_const(avm1.Undefined)
+
+    def push_null(self):
+        self.push_const(avm1.Null)
+        
+    def return_stmt(self):
+        self.pop_stack()
+        self.action(avm1.ActionReturn())
+
+    def swap(self):
+        a, b = self.pop_stack(2)
+        self.push_stack(b, a)
+        self.action(avm1.ActionSwap())
+    
+    def is_equal(self, value=None):
+        if value is not None:
+            self.push_const(value)
+        self.action(avm1.ActionEquals())
+        self.pop_stack(2)
+
+    def is_not_equal(self, value=None):
+        self.is_equal(value)
+        self.action(avm1.ActionNot())
+        self.pop_stack(2)
+    
+    def init_object(self, members=None):
+        self.push_const(members.iteritems(), len(members))
+        self.action(avm1.ActionInitObject())
+        self.pop_stack(2)
+
+    def init_array(self, members=None):
+        self.push_const(members, len(members))
+        self.pop_stack(2)
+        self.action(avm1.ActionInitArray())
+
+    # Assumes the args and number of args are on the stack.
+    def call_function(self, func_name):
+        self.push_const(func_name)
+        self.action(avm1.ActionCallFunction())
+        name, nargs = self.pop_stack()
+        self.pop_stack(nargs)
+        self.push_stack(Variable("%s_RETURN" % func_name))
+    
+    def call_function_constargs(self, func_name, *args):
+        p = self.push_const(*reversed((func_name, len(args))+args))
+        self.action(avm1.ActionCallFunction())
+        self.pop_stack(2+len(args))
+        self.push_stack(Variable("%s_RETURN" % func_name))
+        
+    # Assumes the args and number of args and ScriptObject are on the stack.
+    def call_method(self, func_name):
+        self.push_const(func_name)
+        self.action(avm1.ActionCallMethod())
+        name, obj, nargs = self.pop_stack(3)
+        self.pop_stack(nargs)
+        self.push_stack(Variable("%s.%s_RETURN" % (obj.name, name)))
+
+    # Assumes the args and number of args are on the stack.
+    def call_method_constvar(self, _class, func_name):
+        self.push_var(_class)
+        self.call_method()
+
+    # Boolean value should be on stack when this is called
+    def branch_if_true(self, label=""):
+        if len(label) == 0:
+            label = self.new_label()
+        self.scope.block.branch_blocks[label] = avm1.Block(self.block, False)
+        self.action(avm1.ActionIf(label))
+        self.pop_stack()
+        return (label, self.scope.block.branch_blocks[label])
+    
+    # Assumes the value is on the stack.
+    def set_proto_field(self, objname, member_name):
+        self.push_const("prototype")
+        self.push_var(objname)
+        self.get_member()
+        self.swap()
+        self.push_const(member_name)
+        self.swap()
+        self.set_member()
+
+    # Assumes the value is on the stack.
+    def set_static_field(self, objname, member_name):
+        self.push_var(objname)
+        self.swap()
+        self.push_const(member_name)
+        self.swap()
+        self.set_member()
+
+    # If no args are passed then it is assumed that the args and number of args are on the stack.
+    def newobject_constthis(self, obj, *args):
+        if len(args) > 0:
+            self.push_const(args, len(args), obj)
+        else:
+            self.push_const(obj)
+        self.newobject()
+        
+    
+    def newobject(self):
+        self.action(avm1.ActionNewObject())
+        _, nargs = self.pop_stack()
+        self.pop_stack(nargs)
+        
+    # FIXME: will refactor later
+    #load_str = load_const
+    
+    def begin_switch_varname(self, varname):
+        self.push_var(varname)
+        self.switch_register = self.store_register(varname)
+    
+    def write_case(self, testee):
+        self.push_const(avm1.RegisterByIndex(self.switch_register), testee)
+        self.action(avm1.ActionStrictEquals())
+        self.pop_stack(2)
+        if len(self.case_label) < 1:
+            self.case_label, self.case_block = self.branch_if_true()
+        else:
+            self.branch_if_true(self.case_label)
+
+    def write_break(self):
+        self.exit_scope()
+        self.case_flag = False
+        self.case_block = None
+    
+    def enter_case_branch(self):
+        self.enter_scope(self.case_block)
+    
+    def throw(self): # Assumes the value to be thrown is on the stack.
+        self.action(avm1.ActionThrow())
+        self.pop_stack()
+
+    def concat_string(self):
+        self.action(avm1.ActionTypedAdd())
+        self.push_stack(self.pop_stack()[0] + self.pop_stack()[0])
+    
+    #def extends(self):
+    #    pass
+        

Added: pypy/branch/avm/pypy/translator/avm1/constant.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/constant.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,43 @@
+
+from pypy.translator.oosupport.constant import BaseConstantGenerator
+
+CONST_OBJNAME = "PYPY_INTERNAL_CONSTANTS"
+
+DEBUG_CONST_INIT = False
+DEBUG_CONST_INIT_VERBOSE = False
+SERIALIZE = False
+
+# ______________________________________________________________________
+# Constant Generators
+#
+# Different generators implementing different techniques for loading
+# constants (Static fields, singleton fields, etc)
+
+class AVM1ConstGenerator(BaseConstantGenerator):
+    """
+    AVM1 constant generator.  It implements the oosupport
+    constant generator in terms of the AVM1 virtual machine.
+    """
+
+    def __init__(self, db):
+        BaseConstantGenerator.__init__(self, db)
+        self.cts = db.genoo.TypeSystem(db)
+
+    def _begin_gen_constants(self, asmgen, all_constants):
+        self.asmgen = asmgen
+        self.asmgen.init_object()
+        self.asmgen.store_register(CONST_OBJNAME)
+        self.asmgen.push_const(CONST_OBJNAME)
+        self.asmgen.set_variable()
+        return asmgen
+    
+    # _________________________________________________________________
+    # OOSupport interface
+    
+    def push_constant(self, gen, const):
+        gen.asmgen.push_var(CONST_OBJNAME)
+        gen.asmgen.push_const(const.name)
+        gen.asmgen.get_member()
+
+    def _store_constant(self, gen, const):
+        gen.asmgen.set_static_field(CONST_OBJNAME, const.name)

Added: pypy/branch/avm/pypy/translator/avm1/database.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/database.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,130 @@
+import string
+from pypy.translator.avm.class_ import Class
+from pypy.translator.avm.delegate import Delegate
+from pypy.translator.avm.cts import types
+from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.ootypesystem.module import ll_os
+from pypy.translator.oosupport.database import Database as OODatabase
+
+try:
+    set
+except NameError:
+    from sets import Set as set
+
+class LowLevelDatabase(OODatabase):
+    def __init__(self, genoo):
+        OODatabase.__init__(self, genoo)
+        self.classes = {} # INSTANCE --> class_name
+        self.classnames = set() # (namespace, name)
+        self.recordnames = {} # RECORD --> name
+        self.functions = {} # graph --> function_name
+        self.methods = {} # graph --> method_name
+        self.consts = {}  # value --> AbstractConst
+        self.delegates = {} # StaticMethod --> type_name
+        self.const_count = Counter() # store statistics about constants
+
+    def next_count(self):
+        return self.unique()
+
+    def _default_record_name(self, RECORD):
+        trans = string.maketrans('[]<>(), :', '_________')
+        name = ['Record']
+        # XXX: refactor this: we need a proper way to ensure unique names
+        for f_name, (FIELD_TYPE, f_default) in RECORD._fields.iteritems():
+            type_name = FIELD_TYPE._short_name().translate(trans)
+            name.append(f_name)
+            name.append(type_name)
+            
+        return '__'.join(name)
+
+    def _default_class_name(self, INSTANCE):
+        parts = INSTANCE._name.rsplit('.', 1)
+        if len(parts) == 2:
+            return parts
+        else:
+            return None, parts[0]
+
+    def pending_function(self, graph, functype=None):
+        if functype is None:
+            function = self.genoo.Function(self, graph)
+        else:
+            function = functype(self, graph)
+        self.pending_node(function)
+        return function.get_name()
+
+    def pending_class(self, INSTANCE):
+        try:
+            return self.classes[INSTANCE]
+        except KeyError:
+            pass
+        
+        if isinstance(INSTANCE, dotnet.NativeInstance):
+            self.classes[INSTANCE] = INSTANCE._name
+            return INSTANCE._name
+        else:
+            namespace, name = self._default_class_name(INSTANCE)
+            name = self.get_unique_class_name(namespace, name)
+            if namespace is None:
+                full_name = name
+            else:
+                full_name = '%s.%s' % (namespace, name)
+            self.classes[INSTANCE] = full_name
+            cls = Class(self, INSTANCE, namespace, name)
+            self.pending_node(cls)
+            return full_name
+
+    def pending_record(self, RECORD):
+        try:
+            return BUILTIN_RECORDS[RECORD]
+        except KeyError:
+            pass
+        try:
+            return self.recordnames[RECORD]
+        except KeyError:
+            pass
+        name = self._default_record_name(RECORD)
+        name = self.get_unique_class_name(None, name)
+        self.recordnames[RECORD] = name
+        r = Record(self, RECORD, name)
+        self.pending_node(r)
+        return name
+
+    def record_function(self, graph, name):
+        self.functions[graph] = name
+
+    def graph_name(self, graph):
+        # XXX: graph name are not guaranteed to be unique
+        return self.functions.get(graph, None)
+
+    def get_unique_class_name(self, namespace, name):
+        base_name = name
+        i = 0
+        while (namespace, name) in self.classnames:
+            name = '%s_%d' % (base_name, i)
+            i+= 1
+        self.classnames.add((namespace, name))            
+        return name
+
+    def class_name(self, INSTANCE):
+        if INSTANCE is ootype.ROOT:
+            return types.object.classname()
+        try:
+            NATIVE_INSTANCE = INSTANCE._hints['NATIVE_INSTANCE']
+            return NATIVE_INSTANCE._name
+        except KeyError:
+            return self.classes[INSTANCE]
+
+    def get_record_name(self, RECORD):
+        try:
+            return BUILTIN_RECORDS[RECORD]
+        except KeyError:
+            return self.recordnames[RECORD]
+
+    def record_delegate(self, TYPE):
+        try:
+            return self.delegates[TYPE]
+        except KeyError:
+            name = 'StaticMethod__%d' % len(self.delegates)
+            self.delegates[TYPE] = name
+            self.pending_node(Delegate(self, TYPE, name))
+            return name

Added: pypy/branch/avm/pypy/translator/avm1/genavm.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/genavm.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,21 @@
+import sys
+import shutil
+
+import py
+from py.compat import subprocess
+from pypy.config.config import Config
+from pypy.translator.oosupport.genoo import GenOO
+from pypy.translator.cli import conftest
+from pypy.translator.cli.avm1gen import AVM1Gen
+
+class GenAVM1(GenOO):
+    
+    ConstantGenerator = constant.AVM1ConstGenerator
+
+    def __init__(self, tmpdir, translator, entrypoint, config=None, exctrans=False):
+        GenOO.__init__(self, tmpdir, translator, entrypoint, config, exctrans)
+        self.assembly_name = entrypoint.get_name()
+        self.const_stat = str(tmpdir.join('const_stat'))
+            
+    def create_assembler(self):
+        return AVM1Gen()

Added: pypy/branch/avm/pypy/translator/avm1/records.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/records.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,737 @@
+
+from pypy.translator.avm.util import BitStream
+from math import log, ceil, sqrt
+
+def serialize_style_list(lst):
+    bits = BitStream()
+
+    if len(lst) <= 0xFF:
+        bits.write_bit_value(len(lst), 8)
+    else:
+        bits.write_bit_value(0xFF, 8)
+        bits.write_bit_value(len(lst), 16)
+
+    for style in lst:
+        bits += style.serialize()
+
+    return bits
+
+def nbits(n, *a):
+    return int(ceil(log(max(1, n, *a), 2)))
+
+def nbits_abs(n, *a):
+    return nbits(abs(n), *(abs(n) for n in a))
+
+def style_list_bits(lst):
+    return nbits(len(lst))
+
+def clamp(n, minimum, maximum):
+    return max(minimum, min(n, maximum))
+
+class RecordHeader(object):
+
+    def __init__(self, type, length):
+        self.type = type
+        self.length = length
+
+    def serialize(self):
+        bits = BitStream()
+        bits.write_int_value(self.type, 10)
+        if self.length < 0x3F:
+            bits.write_int_value(self.length, 6)
+        else:
+            bits.write_int_value(0x3F, 6)
+            bits.write_int_value(self.length, 32)
+        return bits
+
+    def parse(self, bitstream):
+        self.type = bitstream.read_bit_value(10)
+        self.length = bitstream.read_bit_value(6)
+        if self.length >= 0x3F:
+            self.length = bitstream.read_bit_value(32)
+
+class _EndShapeRecord(object):
+    
+    def __call__(self, *a, **b):
+        pass
+
+    def serialize(self):
+        bitstream = BitStream()
+        bitstream.zero_fill(6)
+        return bitstream
+
+EndShapeRecord = _EndShapeRecord()
+
+class Rect(object):
+
+    def __init__(self, XMin=0, XMax=0, YMin=0, YMax=0):
+        self.XMin = XMin
+        self.XMax = XMax
+        self.YMin = YMin
+        self.YMax = YMax
+        
+    def union(self, rect, *rects):
+        r = Rect(min(self.XMin, rect.XMin),
+                 max(self.XMax, rect.XMax),
+                 min(self.YMin, rect.YMin),
+                 max(self.YMax, rect.YMax))
+        if len(rects) > 0:
+            return r.union(*rects)
+        return r
+    
+    def serialize(self):
+        if self.XMin > self.XMax or self.YMin > self.YMax:
+            raise ValueError, "Maximum values in a RECT must be larger than the minimum values."
+
+        # Find our values in twips.
+        twpXMin = self.XMin * 20
+        twpXMax = self.XMax * 20
+        twpYMin = self.YMin * 20
+        twpYMax = self.YMax * 20
+        
+        # Find the number of bits required to store the longest
+        # value, then add one to account for the sign bit.
+        NBits = nbits_abs(twpXMin, twpXMax, twpYMin, twpYMax)+1
+
+        if NBits > 31:
+            raise ValueError, "Number of bits per value field cannot exceede 31."
+
+        # And write out our bits.
+        bits = BitStream()
+        bits.write_int_value(NBits, 5)
+        bits.write_int_value(twpXMin, NBits)
+        bits.write_int_value(twpXMax, NBits)
+        bits.write_int_value(twpYMin, NBits)
+        bits.write_int_value(twpYMax, NBits)
+
+        return bits
+
+    def parse(self, bitstream):
+        
+        NBits = bitstream.read_bit_value(5)
+        self.XMin = bitstream.read_bit_value(NBits)
+        self.XMax = bitstream.read_bit_value(NBits)
+        self.YMin = bitstream.read_bit_value(NBits)
+        self.YMax = bitstream.read_bit_value(NBits)
+
+class XY(object):
+
+    def __init__(self, X=0, Y=0):
+        self.X = 0
+        self.Y = 0
+
+    def serialize(self):
+        # Convert to twips plz.
+        twpX = self.X * 20
+        twpY = self.Y * 20
+
+        # Find the number of bits required to store the longest
+        # value, then add one to account for the sign bit.
+        NBits = nbits_abs(twpX, twpY)
+
+        bits = BitStream()
+        bits.write_int_value(NBits, 5)
+        bits.write_int_value(twpX, NBits)
+        bits.write_int_value(twpY, NBits)
+
+        return bits
+
+    def parse(self, bitstream):
+        
+        NBits = bitstream.read_bit_value(5)
+        self.X = bitstream.read_bit_value(NBits)
+        self.Y = bitstream.read_bit_value(NBits)
+
+class RGB(object):
+
+    def __init__(self, color):
+        self.color = color & 0xFFFFFF
+
+    def serialize(self):
+        bits = BitStream()
+        bits.write_int_value(self.color, 24)
+        return bits
+
+    def parse(self, bitstream):
+        self.color = bitstream.read_bit_value(24)
+
+class RGBA(RGB):
+    
+    def __init__(self, color, alpha=1.0):
+        super(RGBA, self).__init__(color)
+        self.alpha = alpha
+
+    def serialize(self):
+        bits = RGB.serialize(self)
+        
+        from pypy.translator.avm.tags import DefineShape
+        
+        # If we are in a DefineShape and the version does not support
+        # alpha (DefineShape1 or DefineShape2), don't use alpha!
+        if DefineShape._current_variant not in (1, 2):
+            bits.write_int_value(int(self.alpha * 0xFF), 8)
+        
+        return bits
+
+    def parse(self, bitstream):
+        RGB.parse(self, bitstream)
+        self.alpha = bitstream.read_bit_value(8) / 0xFF
+
+class CXForm(object):
+    has_alpha = False
+    def __init__(self, rmul=1, gmul=1, bmul=1, radd=0, gadd=0, badd=0):
+        self.rmul = rmul
+        self.gmul = gmul
+        self.bmul = bmul
+        self.amul = 1
+        self.radd = radd
+        self.gadd = gadd
+        self.badd = badd
+        self.aadd = 0
+
+    def serialize(self):
+        has_add_terms = self.radd != 0 or self.gadd != 0 or self.badd != 0 or self.aadd != 0
+        has_mul_terms = self.rmul != 1 or self.gmul != 1 or self.bmul != 1 or self.amul != 1
+        
+        rm = abs(self.rmul * 256)
+        gm = abs(self.gmul * 256)
+        bm = abs(self.bmul * 256)
+        am = abs(self.amul * 256)
+        
+        ro = clamp(self.radd, -255, 255)
+        go = clamp(self.gadd, -255, 255)
+        bo = clamp(self.badd, -255, 255)
+        ao = clamp(self.aadd, -225, 255)
+        
+        NBits = 0
+        if has_mul_terms: NBits = nbits_abs(rm, gm, bm, am)
+        if has_add_terms: NBits = max(NBits, nbits_abs(ro, go, bo, ao))
+        
+        bits = BitStream()
+        bits.write_int_value(NBits, 4)
+
+        if has_mul_terms:
+            bits.write_int_value(rm, NBits)
+            bits.write_int_value(gm, NBits)
+            bits.write_int_value(bm, NBits)
+            if self.has_alpha: bits.write_int_value(am, NBits)
+
+        if has_add_terms:
+            bits.write_int_value(ro, NBits)
+            bits.write_int_value(go, NBits)
+            bits.write_int_value(bo, NBits)
+            if self.has_alpha: bits.write_int_value(ao, NBits)
+
+        return bits
+
+class CXFormWithAlpha(CXForm):
+    has_alpha = True
+    def __init__(self, rmul=1, gmul=1, bmul=1, amul=1, radd=0, gadd=0, badd=0, aadd=0):
+        super(self, CXFormWithAlpha).__init__(rmul, gmul, bmul, radd, gadd, badd)
+        self.amul = amul
+        self.aadd = aadd
+
+class Matrix(object):
+    
+    def __init__(self, a=1, b=0, c=0, d=1, tx=0, ty=0):
+        self.a, self.b, self.c, self.d, self.tx, self.ty = a, b, c, d, tx, ty
+
+    def serialize(self):
+        
+        def write_prefixed_values(a, b):
+            NBits = nbits(a, b)
+            bits.write_int_value(NBits, 5)
+            bits.write_int_value(a, NBits)
+            bits.write_int_value(b, NBits)
+        
+        bits = BitStream()
+        if self.a != 1 or self.d != 1: # HasScale
+            bits.write_bit(True)
+            write_prefixed_values(self.a, self.d)
+        else:
+            bits.write_bit(False)
+
+        if self.b != 0 or self.c != 0: # HasRotate
+            bits.write_bit(True)
+            write_prefixed_values(self.b, self.c)
+        else:
+            bits.write_bit(False)
+
+        write_prefixed_values(self.tx * 20, self.ty * 20)
+        return bits
+
+class Shape(object):
+
+    def __init__(self):
+        self.shapes = []
+        
+        self.edge_bounds = Rect()
+        self.shape_bounds = Rect()
+        
+        self.has_scaling = False
+        self.has_non_scaling = False
+        
+        self.bounds_calculated = False
+
+    def add_shape_record(self, shape):
+        self.shapes.append(shape)
+        self.bounds_calculated = False
+    
+    def add_shape(self, shape):
+        self.shapes.expand(shape.shapes)
+        self.bounds_calculated = False
+
+    def serialize(self):
+        if EndShapeRecord not in self.shapes:
+            self.shapes.append(EndShapeRecord())
+
+        bits = BitStream()
+
+        bits.write_int_value(0, 8) # NumFillBits and NumLineBits
+        for record in self.shapes:
+            bits += record.serialize()
+
+        return bits
+
+    def calculate_bounds(self):
+
+        if self.bounds_calculated:
+            return
+
+        last = 0, 0
+        style = None
+        for record in self.shapes:
+            last, (self.shape_bounds, self.edge_bounds), (has_scale, has_non_scale, style) = \
+                  record.calculate_bounds(last, self.shape_bounds, self.edge_bounds, style)
+            if has_scale:
+                self.has_scaling = True
+            if has_non_scale:
+                self.has_non_scaling = True
+
+        self.bounds_calculated = True
+
+class ShapeWithStyle(Shape):
+
+    def __init__(self, fills=None, strokes=None):
+        super(self, ShapeWithStyle).__init__(self)
+        self.fills = fills or []
+        self.strokes = strokes or []
+
+    def add_fill_style(self, style):
+        style.parent = self.fills
+        self.fills.append(style)
+
+    def add_line_style(self, style):
+        style.parent = self.strokes
+        self.strokes.append(style)
+        
+    def add_shape(self, shape):
+        Shape.add_shape(self, shape)
+        try:
+            self.fills += shape.fills
+            self.strokes += shape.strokes
+        except AttributeError:
+            pass
+    
+    def serialize(self):
+        bits = BitStream()
+        bits += serialize_style_list(self.fills)
+        bits += serialize_style_list(self.strokes)
+        bits.write_int_value(style_list_bits(self.fills), 4)
+        bits.write_int_value(style_list_bits(self.strokes), 4)
+        return bits
+
+class LineStyle(object):
+
+    caps = "round"
+    
+    def __init__(self, width=1, color=0, alpha=1.0):
+        self.width = width
+        self.color = RGBA(color, alpha)
+
+    @property
+    def index(self):
+        return self.parent.find(self)
+    
+    def serialize(self):
+        bits = BitStream()
+        bits.write_int_value(self.width * 20, 16)
+        bits += self.color.serialize()
+        return bits
+
+class LineStyle2(LineStyle):
+
+    def __init__(self, width=1, fillstyle=None, pixel_hinting=False, scale_mode=None, caps="round", joints="round", miter_limit=3):
+
+        color, alpha, self.fillstyle = 0, 1.0, None
+        
+        if isinstance(fillstyle, RGBA):
+            color = fillstyle.color
+            alpha = fillstyle.alpha
+        elif isinstance(fillstyle, RGB):
+            color = fillstyle.color
+        elif isinstance(fillstyle, int):
+            if fillstyle > 0xFFFFFF:
+                color = fillstyle & 0xFFFFFF
+                alpha = fillstyle >> 6 & 0xFF
+            else:
+                color = fillstyle
+        elif isinstance(fillstyle, FillStyleSolidFill):
+            color = fillstyle.color.color
+            alpha = fillstyle.color.alpha
+        elif isinstance(fillstyle, FillStyle):
+            self.fillstyle = fillstyle
+        
+        super(self, LineStyle2).__init__(self, width, color, alpha)
+        self.pixel_hinting = pixel_hinting
+        self.h_scale = (scale_mode == "normal" or scale_mode == "horizontal")
+        self.v_scale = (scale_mode == "normal" or scale_mode == "vertical")
+
+        if caps == "square":  self.caps = 2
+        elif caps == None:    self.caps = 1
+        elif caps == "round": self.caps = 0
+        else:
+            raise ValueError, "Invalid cap style '%s'." % caps
+
+        if joints == "miter":   self.joints = 2
+        elif joints == "bevel": self.joints = 1
+        elif joints == "round": self.joints = 0
+
+        self.miter_limit = miter_limit
+
+    def serialize(self):
+
+        bits = BitStream()
+        bits.write_int_value(self.width * 20, 8)
+        bits.write_int_value(self.width * 20 >> 8, 8)
+
+        bits.write_int_value(self.caps, 2)
+        bits.write_int_value(self.joints, 2)
+        bits.write_bit(self.fillstyle is not None);
+        bits.write_bit(self.h_scale)
+        bits.write_bit(self.v_scale)
+        bits.write_bit(self.pixel_hinting)
+
+        if self.joints == 2:
+            bits.write_fixed_value(self.miter_limit, 16, True)
+
+        if self.fillstyle:
+            bits.write_bits(self.fillstyle.serialize())
+        else:
+            bits.write_bits(self.color.serialize())
+
+        return bits
+
+    def cap_style_logic(self, style, last, delta):
+        # Half thickness (radius of round cap; diameter is thickness)
+        off = style.width / 2.0
+        dx, dy = delta
+        lx, ly = last
+        
+        if style.caps == "round":
+            r = Rect()
+            r.XMin = cmp(dx, 0) * off
+            r.YMin = cmp(dy, 0) * off
+            r.XMax = r.XMin + dx
+            r.YMax = r.XMax + dy
+            return r
+        
+        if style.caps == "square":
+            
+            # Account for the length of the caps.
+            dellen = sqrt(dx*dx + dy*dy)  # Delta length
+            norm = (dellen+off*2)/dellen  # Extra length
+            dx *= norm                    # Add the extra length
+            dy *= norm
+            sqx, sqy = delta              # Square cap offset
+            norm = off/dellen             # Offset amount
+            sqx *= norm                   # Position offsets.
+            sqy *= norm
+            
+            # And offset the position.
+            lx -= sqx
+            ly -= sqy
+
+        # Right-hand normal to vector delta relative to (0, 0).
+        p1x, p1y = (-dy, dx)
+        norm = sqrt(p1x*p1x + p1y*p1y)
+        p1x /= norm
+        p1y /= norm
+
+        # Left-hand normal to vector delta relative to (0, 0)
+        p2x, p2y = (-p1x, -p1y)
+        
+        # Right-hand normal to vector delta relative to delta.
+        p3x, p3y = (p1x + dx, p1y + dy)
+
+        # Left-hand normal to vector delta relative to delta.
+        p4x, p4y = (p2x + dx, p2y + dy)
+
+        return Rect(
+            min(p1x, p2x, p3x, p4x) + lx,
+            max(p1x, p2x, p3x, p4x) + lx,
+            min(p1y, p2y, p3y, p4y) + ly,
+            max(p1y, p2y, p3y, p4y) + ly)
+
+class FillStyle(object):
+
+    TYPE = -1
+    
+    @property
+    def index(self):
+        return self.parent.find(self)
+    
+    def serialize(self):
+        bits = BitStream()
+        bits.write_int_value(self.TYPE, 8)
+        bits += self.serialize_inner()
+        return bits
+
+class FillStyleSolidFill(object):
+    
+    def __init_(self, color, alpha=1.0):
+        self.color = RGBA(color, alpha)
+
+    def serialize_inner(self):
+        return self.color.serialize()
+
+class GradRecord(object):
+
+    def __init__(self, ratio, color, alpha=1.0):
+        self.ratio = ratio
+        self.color = RGBA(color, alpha)
+
+    def serialize(self):
+        bits = BitStream()
+        bits.write_int_value(self.ratio, 8)
+        bits += self.color.serialize()
+        return bits
+
+class Gradient(object):
+
+    def __init__(self, grads, spread="pad", interpolation="rgb", focalpoint=0):
+        import operator
+        grads.sort(key=operator.attrgetter("ratio"))
+        self.grads = grads
+        self.spread = spread
+        self.interpolation = interpolation
+        self.focalpoint = focalpoint
+        
+    @classmethod
+    def from_begin_gradient_fill(cls, colors, alphas, ratios, spread, interpolation, focalpoint):
+        grads = [GradRecord(*t) for t in zip(ratios, colors, alphas)]
+        return cls(grads, spread, interpolation, focalpoint)
+    
+class StraightEdgeRecord(object):
+
+    def __init__(self, delta_x, delta_y):
+        self.delta_x = delta_x
+        self.delta_y = delta_y
+        self.bounds_calculated = False
+
+    def serialize(self):
+            
+        bits = BitStream()
+        
+        if self.delta_x == 0 and self.delta_y == 0:
+            return bits
+
+        bits.write_bit(True) # TypeFlag
+        bits.write_bit(True) # StraightFlag
+
+        X = self.delta_x * 20
+        Y = self.delta_y * 20
+
+        NBits = nbits_abs(X, Y)
+
+        if NBits > 15:
+            raise ValueError("Number of bits per value field cannot exceed 15")
+        
+        bits.write_int_value(NBits, 4)
+        NBits += 2
+        if X == 0:
+            # Vertical Line
+            bits.write_bit(False) # GeneralLineFlag
+            bits.write_bit(True)  # VerticalLineFlag
+            bits.write_int_value(Y, NBits)
+        elif Y == 0:
+            # Horizontal Line
+            bits.write_bit(False) # GeneralLineFlag
+            bits.write_bit(True)  # HorizontalLineFlag
+            bits.write_int_value(X, NBits)
+        else:
+            # General Line
+            bits.write_bit(True) # GeneralLineFlag
+            bits.write_int_value(X, NBits)
+            bits.write_int_value(Y, NBits)
+
+        return bits
+
+    def calculate_bounds(self, last, shape_bounds, edge_bounds, style):
+        rect = Rect(last[0], last[1], self.delta_x, self.delta_y)
+        return ((self.delta_x, self.delta_y),
+                (shape_bounds.union(rect),
+                 edge_bounds.union(LineStyle2.cap_style_logic(style,
+                              last, (self.delta_x, self.delta_y)))),
+                (False, False, style))
+
+
+class CurvedEdgeRecord(object):
+
+    def __init__(self, controlx, controly, anchorx, anchory):
+        self.controlx = controlx
+        self.controly = controly
+        self.anchorx = anchorx
+        self.anchory = anchory
+
+    def serialize(self):
+            
+        bits = BitStream()
+        
+        if self.delta_x == 0 and self.delta_y == 0:
+            return bits
+
+        bits.write_bit(True)  # TypeFlag
+        bits.write_bit(False) # StraightFlag
+
+        cX = self.controlx * 20
+        cY = self.controly * 20
+        aX = self.anchorx  * 20
+        aY = self.anchory  * 20
+        
+        NBits = nbits_abs(cX, cY, aX, aY)
+
+        if NBits > 15:
+            raise ValueError("Number of bits per value field cannot exceed 15")
+
+        bits.write_int_value(NBits, 4)
+        NBits += 2
+        bits.write_int_value(cX, NBits)
+        bits.write_int_value(cY, NBits)
+        bits.write_int_value(aX, NBits)
+        bits.write_int_value(aY, NBits)
+        return bits
+    
+    def _get_x(self, t):
+        return self.controlx * 2 * (1-t) * t + self.anchorx * t * t;
+
+    def _get_y(self, t):
+        return self.controly * 2 * (1-t) * t + self.anchory * t * t;
+
+    def _get_p(self, t):
+        return (self._get_x(t), self._get_y(t))
+    
+    def calculate_bounds(self, last, shape_bounds, edge_bounds, style):
+        union = Rect(0, 0, 0, 0)
+        # CurvedEdgeRecord Bounds
+        # Formulas somewhat based on
+        # http://code.google.com/p/bezier/source/browse/trunk/bezier/src/flash/geom/Bezier.as
+        # Maths here may be incorrect
+        
+        # extremumX = last.x - 2 * control.x + anchor.x
+        # extremumX = last.x - 2 * ( controlDeltaX - last.x ) + anchorDeltaX - last.x
+        # extremumX = (last.x - last.x) - 2 * ( controlDeltaX - last.x ) + anchorDeltaX
+	# extremumX = -2 * ( controlDeltaX - last.x ) + anchorDeltaX
+        
+	# For the case of last.[x/y] = 0, we can use the formula below.
+
+        x = -2 * self.controlx + self.anchorx
+        t = -self.controlx / x
+        p = self._get_x(t)
+
+        if t <= 0 or t >= 1:
+            union.XMin = last[0] + min(self.anchorx, 0)
+            union.XMax = union.XMin + max(self.anchorx, 0)
+        else:
+            union.XMin = min(p, 0, self.anchorx + last[0])
+            union.XMax = union.XMin + max(p - last[0], 0, self.anchorx)
+            
+        y = -2 * self.controly + self.anchory
+        t = -self.controly / y
+        p = self._get_y(t)
+
+        if t <= 0 or t >= 1:
+            union.YMin = last[1] + min(self.anchory, 0)
+            union.YMax = union.YMin + max(self.anchory, 0)
+        else:
+            union.YMin = min(p, 0, self.anchory + last[1])
+            union.YMax = union.YMin + max(p - last[0], 0, self.anchorY)
+
+        # CapStyle logic:
+
+        # Assume that p0 is last (start anchor),
+        # p1 is control, and p2 is (end) anchor.
+
+        # Get some small increments in the segment to
+        # find somewhat of a slope derivative type thing.
+
+        # We should be able to pass these two line deltas
+        # into LineStyle2.cap_style_logic and union the
+        # results.
+        
+        slope1 = self._get_p(0.01)
+        slope2 = (self.anchorx - self._get_x(0.99), self.anchory - self._get_y(0.99))
+        end_cap_rect   = LineStyle2.cap_style_logic(style, last, slope2)
+        start_cap_rect = LineStyle2.cap_style_logic(style, last, slope1)
+
+        return ((self.anchorx, self.anchory),
+                (shape_bounds.union(union),
+                 edge_bounds.union(union, start_cap_rect, end_cap_rect)),
+                (False, False, style))
+
+class StyleChangeRecord(object):
+
+    def __init__(self, delta_x, delta_y, linestyle=None,
+                 fillstyle0=None, fillstyle1=None,
+                 fillstyles=None, linestyles=None):
+        
+        self.delta_x = delta_x
+        self.delta_y = delta_y
+        self.linestyle = linestyle
+        self.fillstyle0 = fillstyle0
+        self.fillstyle1 = fillstyle1
+        self.fillstyles = fillstyles
+        self.linestyles = linestyles
+
+    def serialize(self):
+        bits = BitStream()
+        if self.fillstyle0 is not None and self.fillstyle1 is not None and \
+               self.fillstyle0.parent != self.fillstyle1.parent:
+            raise ValueError("fillstyle0 and fillstyle1 do not have the same parent!")
+        
+        fsi0 = 0 if self.fillstyle0 is None else self.fillstyle0.index
+        fsi1 = 0 if self.fillstyle1 is None else self.fillstyle1.index
+        lsi  = 0 if self.linestyle  is None else self.linestyle.index
+
+        fbit = 0 if self.fillstyle0 is None else style_list_bits(self.fillstyle0.parent)
+        lbit = 0 if self.linestyle  is None else style_list_bits(self.linestyle.parent)
+        
+        from pypy.translator.avm.tags import DefineShape
+        
+        new_styles = ((DefineShape._current_variant > 1) and
+                     ((self.linestyles != None and len(self.linestyles) > 0) or
+                      (self.fillstyles != None and len(self.fillstyles) > 0)))
+
+        bits.write_bit(False)       # TypeFlag
+        bits.write_bit(new_styles)  # StateNewStyles
+        bits.write_bit(lsi  > 0)    # StateLineStyle
+        bits.write_bit(fsi0 > 0)    # StateFillStyle0
+        bits.write_bit(fsi1 > 0)    # StateFillStyle1
+
+        move_flag = self.delta_x != 0 or self.delta_y != 0
+
+        if move_flag:
+            bits += XY(self.delta_x, self.delta_y).serialize()
+
+        if fsi0 > 0:  bits.write_int_value(fsi0, fbit) # FillStyle0
+        if fsi1 > 0:  bits.write_int_value(fsi1, fbit) # FillStyle1
+        if lsi  > 0:  bits.write_int_value(lsi,  lbit) # LineStyle
+        
+        if new_styles:
+            bits += ShapeWithStyle._serialize_style_list(self.fillstyles) # FillStyles
+            bits += ShapeWithStyle._serialize_style_list(self.linestyles) # LineStyles
+
+            bits.write_int_value(style_list_bits(self.fillstyles), 4) # FillBits
+            bits.write_int_value(style_list_bits(self.linestyles), 4) # LineBits
+
+        return bits

Added: pypy/branch/avm/pypy/translator/avm1/swf.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/swf.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,58 @@
+
+import struct
+
+from pypy.translator.avm.util import BitStream
+from pypy.translator.avm.records import Rect
+
+class SwfData(object):
+
+    def __init__(self, width=600, height=400, fps=24, compress=False, version=10):
+        self.width = width
+        self.height = height
+        self.fps = fps
+        self.compress = compress
+        self.version = version
+        self.frame_count = 1
+
+        self.tags = []
+
+    def __getitem__(self, i):
+        return self.tags.__getitem__(i)
+    
+    def __iadd__(self, other):
+        if hasattr(other, "TAG_TYPE"):
+            self.add_tag(other)
+        else:
+            self.add_tags(other)
+        return self
+    
+    def add_tag(self, tag):
+        if self.version > tag.TAG_MIN_VERSION:
+            self.tags.append(tag)
+
+    def add_tags(self, tag_container):
+        if hasattr(tag_container, "tags"):
+            self.tags += tag_container.tags
+        else:
+            self.tags += tag_container
+    
+    def serialize(self):
+
+        header = self._gen_header()
+        data = self._gen_data_stub()
+        data += ''.join(tag.serialize() for tag in self.tags)
+        
+        header[2] = struct.pack("<L", 8 + len(data)) # FileSize
+        if self.compress:
+            import zlib
+            data = zlib.compress(data)
+            
+        return "".join(header + [data])
+    
+    def _gen_header(self):
+        return ["CWS" if self.compress else "FWS", struct.pack("<B", self.version), "\0\0\0\0"]
+    
+    def _gen_data_stub(self):
+        data = Rect(XMax=self.width, YMax=self.height).serialize().serialize()
+        return data + struct.pack("<BBH", int((self.fps - int(self.fps)) * 0x100),
+                                  self.fps, self.frame_count)

Added: pypy/branch/avm/pypy/translator/avm1/tags.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/tags.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,212 @@
+
+import struct
+
+from pypy.translator.avm.records import RecordHeader, ShapeWithStyle, Matrix, CXForm
+from pypy.translator.avm.avm1 import Block
+
+next_character_id = 1
+
+class SwfTag(object):
+
+    TAG_TYPE = -1
+    TAG_MIN_VERSION = -1
+
+    def serialize_data(self):
+        return ""
+    
+    def serialize(self):
+        data = self.serialize_data()
+        return RecordHeader(self.TAG_TYPE, len(data)).serialize().serialize(endianness="<") + data
+
+class SetBackgroundColor(SwfTag):
+    
+    TAG_TYPE = 9
+    TAG_MIN_VERSION = 1
+
+    def __init__(self, color):
+        self.color = color
+
+    def serialize_data(self):
+        return struct.pack("<HB", (self.color >> 8) & 0xFFFF, self.color & 0xFF)
+
+class DoAction(SwfTag, Block):
+
+    TAG_TYPE = 12
+    TAG_MIN_VERSION = 3
+
+    def __init__(self):
+        Block.__init__(self, None, True)
+
+    def serialize_data(self):
+        return Block.serialize(self)
+    
+class DefineShape(SwfTag):
+
+    TAG_TYPE = 2
+    TAG_MIN_VERSION = 1
+    TAG_VARIANT = 1
+    
+    _current_variant = None
+    
+    def __init__(self, shapes=None, shapeid=None):
+        self.shapes = ShapeWithStyle() if shapes is None else shapes
+        if shapeid is None:
+            global next_character_id
+            self.shapeid = next_character_id
+            next_character_id += 1
+        else:
+            self.shapeid = shapeid
+
+    def serialize_data(self):
+        self.shapes.calculate_bounds()
+        DefineShape._current_variant = self.TAG_VARIANT
+        bytes = struct.pack("<H", self.shapeid) + (self.shapes.shape_bounds.serialize() + self.shapes.serialize()).serialize()
+        DefineShape._current_variant = None
+        return bytes
+
+class DefineShape2(DefineShape):
+    TAG_TYPE = 22
+    TAG_MIN_VERSION = 2
+    TAG_VARIANT = 2
+
+class DefineShape3(DefineShape):
+    TAG_TYPE = 32
+    TAG_MIN_VERSION = 32
+    TAG_VARIANT = 3
+
+class DefineShape4(DefineShape):
+    
+    TAG_TYPE = 83
+    TAG_MIN_VERSION = 8
+    TAG_VARIANT = 4
+
+    def serialize_data(self):
+        self.shapes.calculate_bounds()
+        DefineShape._current_variant = 4
+        shapeidshort = struct.pack("<H", self.shapeid)  # Shape ID
+        bits =  (self.shapes.shape_bounds.serialize() + # ShapeBounds Rect
+                 self.shapes.edge_bounds.serialize())   # EdgeBounds Rect
+        
+        bits.zero_fill(6) # Reserved
+
+        bits.write_bit(self.shapes.has_scaling)     # UsesNonScalingStrokes
+        bits.write_bit(self.shapes.has_non_scaling) # UsesScalingStrokes
+        
+        bits += self.shapes.serialize() # ShapeWithStyle
+        
+        DefineShape._current_variant = None
+
+        return shapeidshort + bits.serialize()
+
+class ShowFrame(SwfTag):
+    TAG_TYPE = 1
+    TAG_MIN_VERSION = 1
+
+class PlaceObject(SwfTag):
+    
+    TAG_TYPE = 4
+    TAG_MIN_VERSION = 1
+
+    def __init__(self, shapeid, depth, transform=None, colortransform=None):
+        self.shapeid = shapeid
+        self.depth = depth
+        self.transform = transform or Matrix()
+        self.colortransform = colortransform or CXForm()
+
+    def serialize_data(self):
+        return (struct.pack("<HH", self.shapeid, self.depth) +
+                (self.transform.serialize() + self.colortransform.serialize()).serialize())
+
+class DefineEditText(SwfTag):
+
+    TAG_TYPE = 37
+    TAG_MIN_VERSION = 4
+    
+    def __init__(self, rect, variable, text="", readonly=False, isHTML=False,
+                 wordwrap=False, multiline=True, password=False, autosize=True,
+                 selectable=True, border=False, color=None, maxlength=None,
+                 layout=None, font=None, size=12, fontclass=None, characterid=None):
+        
+        self.rect        = rect
+        self.variable    = variable
+        self.text        = text
+        self.readonly    = readonly
+        self.isHTML      = isHTML
+        self.wordwrap    = wordwrap
+        self.multiline   = multiline
+        self.password    = password
+        self.autosize    = autosize
+        self.selectable  = selectable
+        self.border      = border
+        self.color       = color
+        self.maxlength   = maxlength
+        self.layout      = layout
+        self.font        = font
+        self.size        = size
+        self.fontclass   = fontclass
+
+        if characterid is None:
+            global next_character_id
+            self.characterid = next_character_id
+            next_character_id += 1
+        else:
+            self.characterid = characterid
+
+        self.outlines    = False
+        self.wasstatic   = False
+
+    def serialize_data(self):
+        bits = self.rect.serialize()
+        bits.flush()
+        bits.write_bit(self.text != "")
+        bits.write_bit(self.wordwrap)
+        bits.write_bit(self.multiline)
+        bits.write_bit(self.password)
+        bits.write_bit(self.readonly)
+        bits.write_bit(self.color is not None)
+        bits.write_bit(self.maxlength is not None)
+        bits.write_bit(self.font is not None)
+        bits.write_bit(self.fontclass is not None)
+        bits.write_bit(self.autosize)
+        bits.write_bit(self.layout is not None)
+        bits.write_bit(not self.selectable)
+        bits.write_bit(self.border)
+        bits.write_bit(self.wasstatic)
+        bits.write_bit(self.isHTML)
+        bits.write_bit(self.outlines)
+        
+        bytes = struct.pack("<H", self.characterid) + bits.serialize()
+        if self.font is not None:
+            bytes += struct.pack("<H", self.font.id) # Doesn't exist yet.
+        if self.fontclass is not None:
+            bytes += self.fontclass + "\0"
+        if self.font is not None:
+            bytes += struct.pack("<H", self.size * 20)
+            
+        if self.color is not None:
+            bytes += self.color.serialize().serialize()
+        if self.maxlength is not None:
+            bytes += struct.pack("<H", self.maxlength)
+        if self.layout is not None:
+            bytes += self.layout.serialize() # Doesn't exist yet.
+
+        bytes += self.variable + "\0"
+
+        if self.text != "":
+            bytes += self.text + "\0"
+
+        return bytes
+        
+class End(SwfTag):
+
+    TAG_TYPE = 0
+    TAG_MIN_VERSION = 0
+
+    def __call__(self):
+        return self
+    
+    def serialize(self):
+        return "\0\0"
+
+End = End()
+

Added: pypy/branch/avm/pypy/translator/avm1/test/autopath.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/test/autopath.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,135 @@
+"""
+self cloning, automatic path configuration 
+
+copy this into any subdirectory of pypy from which scripts need 
+to be run, typically all of the test subdirs. 
+The idea is that any such script simply issues
+
+    import autopath
+
+and this will make sure that the parent directory containing "pypy"
+is in sys.path. 
+
+If you modify the master "autopath.py" version (in pypy/tool/autopath.py) 
+you can directly run it which will copy itself on all autopath.py files
+it finds under the pypy root directory. 
+
+This module always provides these attributes:
+
+    pypydir    pypy root directory path 
+    this_dir   directory where this autopath.py resides 
+
+"""
+
+def __dirinfo(part):
+    """ return (partdir, this_dir) and insert parent of partdir
+    into sys.path.  If the parent directories don't have the part
+    an EnvironmentError is raised."""
+
+    import sys, os
+    try:
+        head = this_dir = os.path.realpath(os.path.dirname(__file__))
+    except NameError:
+        head = this_dir = os.path.realpath(os.path.dirname(sys.argv[0]))
+
+    error = None
+    while head:
+        partdir = head
+        head, tail = os.path.split(head)
+        if tail == part:
+            # check if "../py/__init__.py" exists
+            checkfile = os.path.join(partdir, os.pardir, 'py', '__init__.py')
+            if not os.path.exists(checkfile):
+                error = "Cannot find %r" % (os.path.normpath(checkfile),)
+            break
+    else:
+        error = "Cannot find the parent directory %r of the path %r" % (
+            partdir, this_dir)
+    if not error:
+        # check for bogus end-of-line style (e.g. files checked out on
+        # Windows and moved to Unix)
+        f = open(__file__.replace('.pyc', '.py'), 'r')
+        data = f.read()
+        f.close()
+        if data.endswith('\r\n') or data.endswith('\r'):
+            error = ("Bad end-of-line style in the .py files. Typically "
+                     "caused by a zip file or a checkout done on Windows and "
+                     "moved to Unix or vice-versa.")
+    if error:
+        raise EnvironmentError("Invalid source tree - bogus checkout! " +
+                               error)
+    
+    pypy_root = os.path.join(head, '')
+    try:
+        sys.path.remove(head)
+    except ValueError:
+        pass
+    sys.path.insert(0, head)
+
+    munged = {}
+    for name, mod in sys.modules.items():
+        if '.' in name:
+            continue
+        fn = getattr(mod, '__file__', None)
+        if not isinstance(fn, str):
+            continue
+        newname = os.path.splitext(os.path.basename(fn))[0]
+        if not newname.startswith(part + '.'):
+            continue
+        path = os.path.join(os.path.dirname(os.path.realpath(fn)), '')
+        if path.startswith(pypy_root) and newname != part:
+            modpaths = os.path.normpath(path[len(pypy_root):]).split(os.sep)
+            if newname != '__init__':
+                modpaths.append(newname)
+            modpath = '.'.join(modpaths)
+            if modpath not in sys.modules:
+                munged[modpath] = mod
+
+    for name, mod in munged.iteritems():
+        if name not in sys.modules:
+            sys.modules[name] = mod
+        if '.' in name:
+            prename = name[:name.rfind('.')]
+            postname = name[len(prename)+1:]
+            if prename not in sys.modules:
+                __import__(prename)
+                if not hasattr(sys.modules[prename], postname):
+                    setattr(sys.modules[prename], postname, mod)
+
+    return partdir, this_dir
+
+def __clone():
+    """ clone master version of autopath.py into all subdirs """
+    from os.path import join, walk
+    if not this_dir.endswith(join('pypy','tool')):
+        raise EnvironmentError("can only clone master version "
+                               "'%s'" % join(pypydir, 'tool',_myname))
+
+
+    def sync_walker(arg, dirname, fnames):
+        if _myname in fnames:
+            fn = join(dirname, _myname)
+            f = open(fn, 'rwb+')
+            try:
+                if f.read() == arg:
+                    print "checkok", fn
+                else:
+                    print "syncing", fn
+                    f = open(fn, 'w')
+                    f.write(arg)
+            finally:
+                f.close()
+    s = open(join(pypydir, 'tool', _myname), 'rb').read()
+    walk(pypydir, sync_walker, s)
+
+_myname = 'autopath.py'
+
+# set guaranteed attributes
+
+pypydir, this_dir = __dirinfo('pypy')
+import py
+libpythondir = str(py.path.local(pypydir).dirpath().join('lib-python', '2.5.2'))
+libpythonmodifieddir = str(py.path.local(libpythondir).dirpath().join('modified-2.5.2'))
+
+if __name__ == '__main__':
+    __clone()

Added: pypy/branch/avm/pypy/translator/avm1/test/bootstrap.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/test/bootstrap.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,22 @@
+import autopath
+
+from pypy.translator.avm import swf as s, avm1 as a, tags as t, records as r
+
+if __name__ == "__main__":
+    with open("test.swf", "w") as f:
+        data = s.SwfData()
+        data.add_tag(t.SetBackgroundColor(0x333333))
+        data.add_tag(t.DefineEditText(r.Rect(0, 0, 0, 0), "txt", "Testing!", color=r.RGBA(0xFFFFFF)))
+        data.add_tag(t.PlaceObject(1, 2))
+        actions = t.DoAction()
+        actions.add_action(a.ActionPush("txt", "txt"))
+        actions.add_action(a.ActionGetVariable())
+        actions.add_action(a.ActionPush("\nTesting 2!"))
+        actions.add_action(a.ActionStringAdd())
+        actions.add_action(a.ActionSetVariable())
+        actions.add_action(a.ActionPush("/test.result", ""))
+        actions.add_action(a.ActionGetURL2("POST"))
+        data.add_tag(actions)
+        data.add_tag(t.ShowFrame())
+        data.add_tag(t.End())
+        f.write(data.serialize())

Added: pypy/branch/avm/pypy/translator/avm1/test/browsertest.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/test/browsertest.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,93 @@
+from BaseHTTPServer import HTTPServer as BaseHTTPServer, BaseHTTPRequestHandler
+from cgi import parse_qs
+
+import webbrowser
+
+class HTTPServer(BaseHTTPServer):
+    allow_reuse_address = True
+
+class config(object):
+    http_port = 10001
+
+    html_page = """<html>
+<head>
+<title>PyPy AVM Backend Test Case: %s</title>
+</head>
+<body>
+<object type="application/x-shockwave-flash" data="test.swf" width="%d" height="%d">
+<param name="movie" value="test.swf" />
+</object>
+</body>
+</html>"""
+
+    crossdomain_xml="""<cross-domain-policy>
+<allow-access-from domain="*" secure="false"/>
+</cross-domain-policy>"""
+
+def parse_result(string):
+    if string == "true":
+        return True
+    elif string == "false":
+        return False
+    elif string == "null" or string == "undefined":
+        return None
+    elif string.isdigit():
+        return int(string)
+    return string
+
+class TestCase(object):
+    def __init__(self, name, swfdata, testcount):
+        self.name = name
+        self.swfdata = swfdata
+        self.results = []
+        self.testcount = testcount
+    
+class TestHandler(BaseHTTPRequestHandler):
+    """The HTTP handler class that provides the tests and handles results"""
+
+    def do_GET(self):
+        testcase = self.server.testcase
+        if self.path == "/test.html":
+            data = config.html_page % (testcase.name, testcase.swfdata.width, testcase.swfdata.height)
+            mime = 'text/html'
+        elif self.path == "/test.swf":
+            data = testcase.swfdata.serialize()
+            mime = 'application/x-shockwave-flash'
+        elif self.path == "/crossdomain.xml":
+            data = config.crossdomain_xml
+            mime = 'text/xml'
+        self.serve_data(mime, data)
+        
+    def do_POST(self):
+        if self.path == "/test.result":
+            form = parse_qs(self.rfile.read(int(self.headers['content-length'])))
+            self.server.testcase.results.append(parse_result(form['result'][0]))
+
+    def serve_data(self, content_type, data):
+        self.send_response(200)
+        self.send_header("Content-type", content_type)
+        self.send_header("Content-length", len(data))
+        self.end_headers()
+        self.wfile.write(data)
+
+class BrowserTest(object):
+    """The browser driver"""
+
+    def start_server(self, port, testcase):
+        server_address = ('', port)
+        self.httpd = HTTPServer(server_address, TestHandler)
+        self.httpd.testcase = testcase
+
+    def get_result(self):
+        testcase = self.httpd.testcase
+        while len(testcase.results) < testcase.testcount:
+            self.httpd.handle_request()
+        return self.httpd.testcase.results
+
+def browsertest(name, swfdata, testcount):
+    testcase = TestCase(str(name), swfdata, testcount)
+    driver = BrowserTest()
+    driver.start_server(config.http_port, testcase)
+    webbrowser.open('http://localhost:%d/test.html' % config.http_port)
+
+    return driver.get_result()

Added: pypy/branch/avm/pypy/translator/avm1/test/harness.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/test/harness.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,70 @@
+
+from pypy.translator.avm.test import browsertest as b
+from pypy.translator.avm import avm1 as a, avm1gen as g, swf as s, tags as t, records as r
+
+class TestHarness(object):
+    def __init__(self, name):
+        self.testname  = name
+        self.in_test   = False
+        self.expected  = []
+        self.swf = s.SwfData()
+        self.swf.add_tag(t.SetBackgroundColor(0x333333))
+        self.swf.add_tag(t.DefineEditText(r.Rect(0, 0, 0, 0), "txt",
+                                          "Testing %s." % (name,), color=r.RGBA(0xFFFFFF)))
+        self.swf.add_tag(t.PlaceObject(1, 2))
+        self.actions = g.AVM1Gen(t.DoAction())
+        self.swf.add_tag(self.actions.block)
+        self.swf.add_tag(t.ShowFrame())
+        self.swf.add_tag(t.End())
+        
+    def print_text(self, text):
+        self.actions.push_const("txt", "\n" + text)
+        self.actions.push_var("txt")
+        self.actions.swap()
+        self.actions.concat_string()
+        self.actions.set_variable()
+
+    def print_var(self, prefix, varname):
+        self.actions.push_const("txt")
+        self.actions.push_var("txt")
+        self.actions.push_const("\n" + prefix)
+        self.actions.push_var(varname)
+        self.actions.concat_string()
+        self.actions.concat_string()
+        self.actions.set_variable()
+
+    def print_stack(self, prefix):
+        self.actions.push_const("txt")
+        self.actions.swap()
+        self.actions.push_var("txt")
+        self.actions.swap()
+        self.actions.push_const("\n" + prefix)
+        self.actions.swap()
+        self.actions.concat_string()
+        self.actions.concat_string()
+        self.actions.set_variable()
+    
+    def start_test(self, name):
+        assert not self.in_test
+        self.in_test = True
+        self.print_text("Running test %s." % name)
+        self.actions.push_const("result")
+        
+    def finish_test(self, expected):
+        # result value is on the stack,
+        # followed by the string "result"
+        assert self.in_test
+        self.in_test = False
+        self.expected.append(expected)
+        self.actions.set_variable()
+        self.print_var("Got: ", "result")
+        self.actions.push_const("/test.result", "") # URL, target
+        self.actions.action(a.ActionGetURL2("POST", True, True))
+
+    def do_test(self):
+        assert not self.in_test
+        with open("test.swf", "w") as f:
+            f.write(self.swf.serialize())
+        results = b.browsertest(self.testname, self.swf, len(self.expected))
+        for e, r in zip(self.expected, results):
+            assert e == r

Added: pypy/branch/avm/pypy/translator/avm1/test/runtest.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/test/runtest.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,171 @@
+import platform
+
+import py
+from pypy.translator.translator import TranslationContext
+from pypy.rpython.test.tool import BaseRtypingTest, OORtypeMixin
+from pypy.rpython.lltypesystem.lltype import typeOf
+from pypy.rpython.ootypesystem import ootype
+from pypy.annotation.model import lltype_to_annotation
+from pypy.translator.backendopt.all import backend_optimizations
+from pypy.translator.backendopt.checkvirtual import check_virtual_methods
+from pypy.translator.oosupport.support import patch_os, unpatch_os
+from pypy.translator.avm.test.harness import TestHarness
+
+def translate_space_op(gen, op):
+    if op.opname == "cast_int_to_char":
+        gen.push_arg(op.args[0])
+        gen.push_const(1)
+        gen.push_var("String")
+        gen.call_method("fromCharCode")
+
+def compile_function(func, name, annotation=[], graph=None, backendopt=True,
+                     auto_raise_exc=False, exctrans=False,
+                     annotatorpolicy=None, nowrap=False):
+    olddefs = patch_os()
+    gen = _build_gen(func, annotation, name, graph, backendopt,
+                     exctrans, annotatorpolicy, nowrap)
+    unpatch_os(olddefs) # restore original values
+    return gen
+
+def _build_gen(func, annotation, name, graph=None, backendopt=True, exctrans=False,
+               annotatorpolicy=None, nowrap=False):
+    try: 
+        func = func.im_func
+    except AttributeError: 
+        pass
+    t = TranslationContext()
+    if graph is not None:
+        graph.func = func
+        ann = t.buildannotator(policy=annotatorpolicy)
+        inputcells = [ann.typeannotation(an) for an in annotation]
+        ann.build_graph_types(graph, inputcells)
+        t.graphs.insert(0, graph)
+    else:
+        ann = t.buildannotator(policy=annotatorpolicy)
+        ann.build_types(func, annotation)
+
+    t.buildrtyper(type_system="ootype").specialize()
+    if backendopt:
+        check_virtual_methods(ootype.ROOT)
+        backend_optimizations(t)
+    
+    main_graph = t.graphs[0]
+
+    harness = TestHarness(name)
+    harness.actions.begin_function(main_graph.name, [v.name for v in main_graph.getargs()])
+    for op in main_graph.startblock.operations:
+        translate_space_op(harness.actions, op)
+    harness.actions.return_stmt()
+    harness.actions.exit_scope()
+    
+    return harness
+
+class StructTuple(tuple):
+    def __getattr__(self, name):
+        if name.startswith('item'):
+            i = int(name[len('item'):])
+            return self[i]
+        else:
+            raise AttributeError, name
+
+class OOList(list):
+    def ll_length(self):
+        return len(self)
+
+    def ll_getitem_fast(self, i):
+        return self[i]
+
+class InstanceWrapper:
+    def __init__(self, class_name):
+        self.class_name = class_name
+
+class ExceptionWrapper:
+    def __init__(self, class_name):
+        self.class_name = class_name
+
+    def __repr__(self):
+        return 'ExceptionWrapper(%s)' % repr(self.class_name)
+
+class AVM1Test(BaseRtypingTest, OORtypeMixin):
+    def __init__(self):
+        self._func = None
+        self._ann = None
+        self._harness = None
+        self._test_count = 1
+
+    def _compile(self, fn, args, ann=None, backendopt=True, auto_raise_exc=False, exctrans=False):
+        if ann is None:
+            ann = [lltype_to_annotation(typeOf(x)) for x in args]
+        if self._func is fn and self._ann == ann:
+            return self._harness
+        else:
+            self._harness = compile_function(fn, self.__class__.__name__, ann,
+                                             backendopt=backendopt,
+                                             auto_raise_exc=auto_raise_exc,
+                                             exctrans=exctrans)
+            self._func = fn
+            self._ann = ann
+            return self._harness
+
+    def _skip_win(self, reason):
+        if platform.system() == 'Windows':
+            py.test.skip('Windows --> %s' % reason)
+
+    def _skip_powerpc(self, reason):
+        if platform.processor() == 'powerpc':
+            py.test.skip('PowerPC --> %s' % reason)
+
+    def _skip_llinterpreter(self, reason, skipLL=True, skipOO=True):
+        pass
+
+    def _get_backendopt(self, backendopt):
+        if backendopt is None:
+            backendopt = getattr(self, 'backendopt', True) # enable it by default
+        return backendopt
+    
+    def interpret(self, fn, args, expected=None, annotation=None, backendopt=None, exctrans=False):
+        backendopt = self._get_backendopt(backendopt)
+        harness = self._compile(fn, args, annotation, backendopt=backendopt, exctrans=exctrans)
+        harness.start_test("%d" % self._test_count)
+        self._test_count += 1
+        harness.actions.call_function_constargs(fn.func_name, *args)
+        harness.finish_test(expected)
+
+    def do_test(self):
+        self._harness.do_test()
+    
+    def interpret_raises(self, exception, fn, args, backendopt=None, exctrans=False):
+        import exceptions # needed by eval
+        backendopt = self._get_backendopt(backendopt)
+        try:
+            self.interpret(fn, args, backendopt=backendopt, exctrans=exctrans)
+        except ExceptionWrapper, ex:
+            assert issubclass(eval(ex.class_name), exception)
+        else:
+            assert False, 'function did raise no exception at all'
+
+    float_eq = BaseRtypingTest.float_eq_approx
+
+    def is_of_type(self, x, type_):
+        return True # we can't really test the type
+
+    def ll_to_string(self, s):
+        return s
+
+    def ll_to_unicode(self, s):
+        return s
+
+    def ll_to_list(self, l):
+        return l
+
+    def ll_to_tuple(self, t):
+        return t
+
+    def class_name(self, value):
+        return value.class_name.split(".")[-1] 
+
+    def is_of_instance_type(self, val):
+        return isinstance(val, InstanceWrapper)
+
+    def read_attr(self, obj, name):
+        py.test.skip('read_attr not supported on gencli tests')

Added: pypy/branch/avm/pypy/translator/avm1/test/test_harness.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/test/test_harness.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,14 @@
+import autopath
+
+from pypy.translator.avm.test import browsertest, harness as h
+from pypy.translator.avm import avm1 as a
+
+def test_harness():
+    harness = h.TestHarness("harness")
+    harness.start_test("harness")
+    harness.actions.add_action(a.ActionPush(True))
+    harness.finish_test(True)
+    harness.do_test()
+
+if __name__ == "__main__":
+    test_harness()

Added: pypy/branch/avm/pypy/translator/avm1/test/test_int.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/test/test_int.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,21 @@
+import autopath
+import py
+from pypy.translator.avm.test.runtest import AVM1Test
+from pypy.rpython.test.test_rint import BaseTestRint
+
+class TestAVM1Int(AVM1Test, BaseTestRint):
+    def test_char_constant(self):
+        def dummyfn(i):
+            return chr(i)
+        self.interpret(dummyfn, [ord(' ')], ' ')
+        self.interpret(dummyfn, [ord('a')], 'a')
+        self.do_test()
+
+    def test_rarithmetic(self):
+        pass # it doesn't make sense here
+
+    div_mod_iteration_count = 20
+
+
+if __name__ == "__main__":
+    TestAVM1Int().test_char_constant()

Added: pypy/branch/avm/pypy/translator/avm1/test/test_weakref.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/pypy/translator/avm1/test/test_weakref.py	Thu Aug 13 00:29:02 2009
@@ -0,0 +1,6 @@
+import py
+from pypy.translator.cli.test.runtest import CliTest
+from pypy.rpython.test.test_rweakref import BaseTestRweakref
+
+class TestCliWeakRef(CliTest, BaseTestRweakref):
+    pass

Modified: pypy/branch/avm/pypy/translator/c/gcc/trackgcroot.py
==============================================================================

Modified: pypy/branch/avm/pypy/translator/goal/bench-cronjob.py
==============================================================================

Modified: pypy/branch/avm/pypy/translator/goal/launch-bench-cronjob.sh
==============================================================================

Modified: pypy/branch/avm/pypy/translator/goal/translate.py
==============================================================================

Modified: pypy/branch/avm/pypy/translator/microbench/microbench.py
==============================================================================

Modified: pypy/branch/avm/pypy/translator/microbench/pybench/platform.py
==============================================================================

Modified: pypy/branch/avm/pypy/translator/microbench/pybench/pybench.py
==============================================================================

Modified: pypy/branch/avm/pypy/translator/sandbox/interact.py
==============================================================================

Modified: pypy/branch/avm/pypy/translator/sandbox/pypy_interact.py
==============================================================================



More information about the Pypy-commit mailing list