[pypy-svn] r34048 - in pypy/dist/pypy/lang/js: . test
stephan at codespeak.net
stephan at codespeak.net
Wed Nov 1 17:42:37 CET 2006
Author: stephan
Date: Wed Nov 1 17:42:36 2006
New Revision: 34048
Modified:
pypy/dist/pypy/lang/js/astgen.py
pypy/dist/pypy/lang/js/interpreter.py
pypy/dist/pypy/lang/js/jsobj.py
pypy/dist/pypy/lang/js/parser.py
pypy/dist/pypy/lang/js/test/test_interp.py
Log:
(stephan, santagada) making progress with 'arguments'
Modified: pypy/dist/pypy/lang/js/astgen.py
==============================================================================
--- pypy/dist/pypy/lang/js/astgen.py (original)
+++ pypy/dist/pypy/lang/js/astgen.py Wed Nov 1 17:42:36 2006
@@ -16,6 +16,10 @@
# getlist = staticmethod(getlist)
+class Array(Node):
+ def __init__(self, items=()):
+ self.items = items
+
class Assign(Node):
def __init__(self, identifier, expr):
self.identifier = identifier
@@ -111,6 +115,8 @@
if tp == 'SCRIPT':
# XXX: Cannot parse it right now
return Script(getlist(d), [], [])
+ elif tp == 'ARRAY_INIT':
+ return Array(getlist(d))
elif tp == 'SEMICOLON':
return Semicolon(from_dict(d['expression']))
elif tp == 'NUMBER':
Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py (original)
+++ pypy/dist/pypy/lang/js/interpreter.py Wed Nov 1 17:42:36 2006
@@ -11,6 +11,11 @@
def __init__(self, value):
self.value = value
+class __extend__(Array):
+ def call(self, context):
+ d = dict(enumerate(self.items))
+ return W_Array(d)
+
class __extend__(Assign):
def call(self, context):
val = self.expr.call(context)
@@ -148,3 +153,4 @@
def call(self, context=None):
for var in self.nodes:
var.call(context)
+
Modified: pypy/dist/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/dist/pypy/lang/js/jsobj.py (original)
+++ pypy/dist/pypy/lang/js/jsobj.py Wed Nov 1 17:42:36 2006
@@ -24,6 +24,10 @@
def __repr__(self):
return "<%s(%s)>" % (self.__class__.__name__, str(self))
+class W_Array(W_Root):
+ # TODO to be continued :-)
+ pass
+
class W_Undefined(W_Root):
def __str__(self):
return ""
Modified: pypy/dist/pypy/lang/js/parser.py
==============================================================================
--- pypy/dist/pypy/lang/js/parser.py (original)
+++ pypy/dist/pypy/lang/js/parser.py Wed Nov 1 17:42:36 2006
@@ -30,7 +30,7 @@
def parse(code_string):
read_code = read_js_output(code_string)
output = read_code.split(os.linesep)
- print '\n'.join(output)
+ #print '\n'.join(output)
try:
code = eval("\n".join(output))
except (SyntaxError, NameError):
Modified: pypy/dist/pypy/lang/js/test/test_interp.py
==============================================================================
--- pypy/dist/pypy/lang/js/test/test_interp.py (original)
+++ pypy/dist/pypy/lang/js/test/test_interp.py Wed Nov 1 17:42:36 2006
@@ -129,3 +129,10 @@
print(x[1]);
"""), ["test"])
+ def test_array_initializer(self):
+ py.test.skip('not ready yet')
+ self.assert_prints(parse_d("""
+ x = [];
+ print(x);
+ """), ["[]"])
+
More information about the Pypy-commit
mailing list