[pypy-svn] r36109 - in pypy/dist/pypy/translator/js: . modules tutorial
fijal at codespeak.net
fijal at codespeak.net
Tue Jan 2 16:32:45 CET 2007
Author: fijal
Date: Tue Jan 2 16:32:43 2007
New Revision: 36109
Removed:
pypy/dist/pypy/translator/js/modules/browser.py
Modified:
pypy/dist/pypy/translator/js/asmgen.py
pypy/dist/pypy/translator/js/jsbuiltin.py
pypy/dist/pypy/translator/js/modules/dom.py
pypy/dist/pypy/translator/js/support.py
pypy/dist/pypy/translator/js/tutorial/step2.py
Log:
Kill another suggested_primitive and move back alert to dom, because alert is window.alert
Modified: pypy/dist/pypy/translator/js/asmgen.py
==============================================================================
--- pypy/dist/pypy/translator/js/asmgen.py (original)
+++ pypy/dist/pypy/translator/js/asmgen.py Tue Jan 2 16:32:43 2007
@@ -44,7 +44,6 @@
self.subst_table = subst_table
def pop(self):
- #if len(self.l) == 0:
el = self.l.pop()
return self.subst_table.get(el, el)
@@ -193,11 +192,6 @@
def set_static_field(self, _type, namespace, _class, varname):
self.codegenerator.writeline("%s.prototype.%s = %s;"%(_class, varname, self.right_hand.pop()))
- #def load_set_field(self, _type, name):
- # #self.right_hand.append("")
- # #self.codegenerator.writeline("set field %r %r"%(_type, name))
- # pass
-
def set_field(self, useless_parameter, name):
v = self.right_hand.pop()
self.codegenerator.writeline("%s.%s = %s;"%(self.right_hand.pop(), name, v))
@@ -226,10 +220,8 @@
if len(self.right_hand) == 0:
return
v = self.right_hand.pop()
- # if v is not calling anything, drop it
if v is not None and v.find('('):
self.codegenerator.writeline(v+";")
- #self.right_hand.pop()
def begin_consts(self, name):
# load consts, maybe more try to use stack-based features?
@@ -293,6 +285,3 @@
def throw_real(self, s):
self.codegenerator.writeline("throw(%s);"%s)
-
- #def finish ( self ):
- # self . outfile . write ( "%r" % self . right_hand )
Modified: pypy/dist/pypy/translator/js/jsbuiltin.py
==============================================================================
--- pypy/dist/pypy/translator/js/jsbuiltin.py (original)
+++ pypy/dist/pypy/translator/js/jsbuiltin.py Tue Jan 2 16:32:43 2007
@@ -20,7 +20,7 @@
'll_int_str' : lambda g,op: Call._render_builtin_method(g, 'toString' , [op.args[2]]),
'll_strconcat' : InstructionList([PushAllArgs, '+']),
'll_int' : CallBuiltin('parseInt'),
- 'alert' : CallBuiltin('alert'),
+ #'alert' : CallBuiltin('alert'),
'seval' : CallBuiltin('seval'),
'date': NewBuiltin('Date'),
'll_math_fmod' : InstructionList([PushAllArgs, '%']),
Modified: pypy/dist/pypy/translator/js/modules/dom.py
==============================================================================
--- pypy/dist/pypy/translator/js/modules/dom.py (original)
+++ pypy/dist/pypy/translator/js/modules/dom.py Tue Jan 2 16:32:43 2007
@@ -6,7 +6,7 @@
note that the API is not and will not be complete: more exotic features
will most probably not behave as expected, or are not implemented at all
-
+
http://www.w3.org/DOM/ - main standard
http://www.w3schools.com/dhtml/dhtml_dom.asp - more informal stuff
http://developer.mozilla.org/en/docs/Gecko_DOM_Reference - Gecko reference
@@ -764,6 +764,9 @@
raise ValueError('unsupported node type %s' % (node.nodeType,))
return ''.join(ret)
+def alert(msg):
+ window.alert(msg)
+
# initialization
# set the global 'window' instance to an empty HTML document, override using
Modified: pypy/dist/pypy/translator/js/support.py
==============================================================================
--- pypy/dist/pypy/translator/js/support.py (original)
+++ pypy/dist/pypy/translator/js/support.py Tue Jan 2 16:32:43 2007
@@ -17,7 +17,7 @@
namespace native new null package private protected
public return short static super switch synchronized
this throw throws transient true try typeof
- use var void volatile while with
+ use var void volatile while with alert
'''
for name in reserved_words.split():
self.reserved[name] = True
Modified: pypy/dist/pypy/translator/js/tutorial/step2.py
==============================================================================
--- pypy/dist/pypy/translator/js/tutorial/step2.py (original)
+++ pypy/dist/pypy/translator/js/tutorial/step2.py Tue Jan 2 16:32:43 2007
@@ -23,13 +23,13 @@
from pypy.translator.js.main import rpython2javascript
# here we import rpython -> javascript conversion utility
-from pypy.translator.js.modules import browser
+from pypy.translator.js.modules import dom
# and here we import functions from modules that we want to use
# this is function which will be translated into javascript,
# we can put it in a different module if we like so
def show():
- browser.alert("Alert")
+ dom.alert("Alert")
class Handler(server.TestHandler):
More information about the Pypy-commit
mailing list