[pypy-svn] r35898 - in pypy/dist/pypy/lang/js: . test
santagada at codespeak.net
santagada at codespeak.net
Tue Dec 19 19:09:50 CET 2006
Author: santagada
Date: Tue Dec 19 19:09:40 2006
New Revision: 35898
Modified:
pypy/dist/pypy/lang/js/context.py
pypy/dist/pypy/lang/js/interpreter.py
pypy/dist/pypy/lang/js/test/test_interp.py
pypy/dist/pypy/lang/js/test/test_parser.py
Log:
Finishing the work on cleaning up the code and making some tests work again
4 test passing, 31 failling... still better than nothing
Modified: pypy/dist/pypy/lang/js/context.py
==============================================================================
--- pypy/dist/pypy/lang/js/context.py (original)
+++ pypy/dist/pypy/lang/js/context.py Tue Dec 19 19:09:40 2006
@@ -1,6 +1,5 @@
# encoding: utf-8
-from copy import copy
from pypy.lang.js.jsobj import w_Undefined, Property
from pypy.lang.js.reference import Reference
@@ -28,17 +27,17 @@
return Reference(property_name)
-def global_context(global):
+def global_context(w_global):
ctx = ExecutionContext()
- ctx.push_object(global)
- ctx.this = global
- ctx.variable = global
+ ctx.push_object(w_global)
+ ctx.this = w_global
+ ctx.variable = w_global
ctx.property = Property('', w_Undefined, DontDelete=True)
return ctx
def eval_context(calling_context):
ctx = ExecutionContext()
- ctx.scope = copy(calling_context.scope)
+ ctx.scope = calling_context.scope[:]
ctx.this = calling_context.this
ctx.variable = calling_context.variable
ctx.property = Property('', w_Undefined)
Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py (original)
+++ pypy/dist/pypy/lang/js/interpreter.py Tue Dec 19 19:09:40 2006
@@ -236,30 +236,30 @@
return W_Number(num_left + num_right)
class __extend__(Script):
- def call(self, context=None, args=(), params=[], this=w_Undefined, first = False):
- ncontext = ExecutionContext(context)
- for i, item in enumerate(params):
- try:
- temp = args[i]
- except IndexError:
- temp = w_Undefined
- ncontext.assign(item, temp)
-
- for var in self.var_decl:
- if first:
- ncontext.globals[var.name] = w_Undefined
- else:
- ncontext.locals[var.name] = w_Undefined
-
- w_Arguments = W_Arguments(dict([(str(x),y) for x,y in enumerate(args)]))
- ncontext.assign('arguments', w_Arguments)
-
- ncontext.assign('this', this)
+ def call(self, ctx):
+ # ncontext = ExecutionContext(context)
+ # for i, item in enumerate(params):
+ # try:
+ # temp = args[i]
+ # except IndexError:
+ # temp = w_Undefined
+ # ncontext.assign(item, temp)
+ #
+ # for var in self.var_decl:
+ # if first:
+ # ncontext.globals[var.name] = w_Undefined
+ # else:
+ # ncontext.locals[var.name] = w_Undefined
+
+ # w_Arguments = W_Arguments(dict([(str(x),y) for x,y in enumerate(args)]))
+ # ncontext.assign('arguments', w_Arguments)
+ #
+ # ncontext.assign('this', this)
try:
last = w_Undefined
for node in self.nodes:
- last = node.call(ncontext)
+ last = node.call(ctx)
return last
except ExecutionReturned, e:
return e.value
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 Tue Dec 19 19:09:40 2006
@@ -12,18 +12,12 @@
from StringIO import StringIO
-def parse_d(code):
- return build_interpreter(parse(code))
-
def js_is_on_path():
try:
py.path.local.sysfind("js")
except py.error.ENOENT:
- return False
- return True
+ py.test.skip("js binary not found")
-if not js_is_on_path():
- py.test.skip("js binary not found")
class TestInterp(object):
@@ -34,7 +28,7 @@
l = []
interpreter.writer = l.append
Script([Semicolon(Call(Identifier('print', None),
- List([Number(1), Number(2)])))],[],[]).call()
+ List([Number(1), Number(2)])))],[],[]).call(ExecutionContext())
assert l == ['1,2']
def assert_prints(self, code, assval):
Modified: pypy/dist/pypy/lang/js/test/test_parser.py
==============================================================================
--- pypy/dist/pypy/lang/js/test/test_parser.py (original)
+++ pypy/dist/pypy/lang/js/test/test_parser.py Tue Dec 19 19:09:40 2006
@@ -3,8 +3,7 @@
import py
-if not js_is_on_path():
- py.test.skip("js binary not found")
+js_is_on_path()
def test_read_js_output():
More information about the Pypy-commit
mailing list