[pypy-svn] r37687 - in pypy/dist/pypy/translator/js: . jssrc test
fijal at codespeak.net
fijal at codespeak.net
Wed Jan 31 20:34:33 CET 2007
Author: fijal
Date: Wed Jan 31 20:34:09 2007
New Revision: 37687
Added:
pypy/dist/pypy/translator/js/test/test_rdict.py
Modified:
pypy/dist/pypy/translator/js/jsbuiltin.py
pypy/dist/pypy/translator/js/jssrc/misc.js
pypy/dist/pypy/translator/js/metavm.py
Log:
Add some support for dictionaries and a test. Still too much stuff does not
pass :-(
Modified: pypy/dist/pypy/translator/js/jsbuiltin.py
==============================================================================
--- pypy/dist/pypy/translator/js/jsbuiltin.py (original)
+++ pypy/dist/pypy/translator/js/jsbuiltin.py Wed Jan 31 20:34:09 2007
@@ -57,6 +57,8 @@
'll_contains' : ListContains,
'll_get_items_iterator' : CallBuiltin('dict_items_iterator'),
'll_length' : CallBuiltin('get_dict_len'),
+ 'll_remove' : lambda g, op: CallBuiltin('delete')._render_builtin_prepared_args(g, 'delete', ['%s[%s]' % (op.args[1], op.args[2])]),
+ 'll_clear': CallBuiltin('clear_dict'),
},
ootype.Record: {
'll_get' : ListGetitem,
Modified: pypy/dist/pypy/translator/js/jssrc/misc.js
==============================================================================
--- pypy/dist/pypy/translator/js/jssrc/misc.js (original)
+++ pypy/dist/pypy/translator/js/jssrc/misc.js Wed Jan 31 20:34:09 2007
@@ -169,4 +169,10 @@
function substring(s, l, c) {
return (s.substring(l, l+c));
}
+
+function clear_dict(d) {
+ for (var elem in d) {
+ delete(d[elem]);
+ }
+}
// ends hand written code
Modified: pypy/dist/pypy/translator/js/metavm.py
==============================================================================
--- pypy/dist/pypy/translator/js/metavm.py (original)
+++ pypy/dist/pypy/translator/js/metavm.py Wed Jan 31 20:34:09 2007
@@ -50,6 +50,11 @@
for func_arg in args[1:]: # push parameters
generator.load(func_arg)
generator.call_external(builtin, args[1:])
+
+ def _render_builtin_prepared_args(self, generator, builtin, args):
+ for func_arg in args:
+ generator.load_str(func_arg)
+ generator.call_external(builtin, args)
def _render_builtin_method(self, generator, builtin, args):
for func_arg in args:
Added: pypy/dist/pypy/translator/js/test/test_rdict.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/test/test_rdict.py Wed Jan 31 20:34:09 2007
@@ -0,0 +1,43 @@
+
+import py
+from pypy.rpython.test.test_rdict import BaseTestRdict
+from pypy.translator.js.test.runtest import JsTest
+
+class TestJsDict(JsTest, BaseTestRdict):
+ def test_tuple_dict(self):
+ py.test.skip("rdict not implemented")
+
+ def test_dict_itermethods(self):
+ py.test.skip("itermethods not implemented")
+
+ def test_dict_copy(self):
+ py.test.skip("itermethods not implemented")
+
+ def test_dict_update(self):
+ py.test.skip("itermethods not implemented")
+
+ def test_dict_inst_iterkeys(self):
+ py.test.skip("itermethods not implemented")
+
+ def test_dict_values(self):
+ py.test.skip("itermethods not implemented")
+
+ def test_dict_inst_values(self):
+ py.test.skip("itermethods not implemented")
+
+ def test_dict_inst_itervalues(self):
+ py.test.skip("itermethods not implemented")
+
+ def test_dict_items(self):
+ py.test.skip("itermethods not implemented")
+
+ def test_dict_inst_items(self):
+ py.test.skip("itermethods not implemented")
+
+ def test_dict_inst_iteritems(self):
+ py.test.skip("itermethods not implemented")
+
+
+ def test_specific_obscure_bug(self):
+ py.test.skip("rdict not implemented")
+
More information about the Pypy-commit
mailing list