Author: Stephan <[email protected]>
Branch:
Changeset: r183:6e2544c27edd
Date: 2012-05-09 20:48 +0200
http://bitbucket.org/pypy/lang-js/changeset/6e2544c27edd/
Log: wip
diff --git a/js/builtins_global.py b/js/builtins_global.py
--- a/js/builtins_global.py
+++ b/js/builtins_global.py
@@ -104,7 +104,14 @@
args = ctx.argv()
src = args[0].to_string()
- ast = parse_to_ast(src)
+
+ from pypy.rlib.parsing.parsing import ParseError
+ try:
+ ast = parse_to_ast(src)
+ except ParseError, e:
+ from js.execution import JsSyntaxError
+ raise JsSyntaxError()
+
symbol_map = ast.symbol_map
code = ast_to_bytecode(ast, symbol_map)
diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -657,14 +657,17 @@
self.newctx = None
def eval(self, ctx):
+ from js.lexical_environment import ObjectEnvironment
obj = ctx.stack_pop().ToObject()
- from js.jsexecution_context import make_with_context
- self.newctx = make_with_context(ctx, obj)
+ old_env = ctx.lexical_environment()
+ new_env = ObjectEnvironment(obj, outer_environment = old_env)
+ new_env.environment_record.provide_this = True
+ ctx._lexical_environment_ = new_env
class WITH_END(Opcode):
_stack_change = 0
def eval(self, ctx):
- ctx = ctx.parent
+ ctx._lexical_environment_ = ctx.lexical_environment().outer_environment
# ------------------ delete -------------------------
diff --git a/js/operations.py b/js/operations.py
--- a/js/operations.py
+++ b/js/operations.py
@@ -733,19 +733,21 @@
# a bit naive operator for now
trycode = JsCode()
self.tryblock.emit(trycode)
- tryfunc = trycode.make_js_function()
+
+ #tryfunc = trycode.make_js_function()
if self.catchblock:
catchcode = JsCode()
self.catchblock.emit(catchcode)
- catchfunc = catchcode.make_js_function()
+ # catchfunc = catchcode.make_js_function()
else:
catchfunc = None
if self.finallyblock:
finallycode = JsCode()
self.finallyblock.emit(finallycode)
- finallyfunc = finallycode.make_js_function()
+ # finallyfunc = finallycode.make_js_function()
else:
finallyfunc = None
+ raise NotImplementedError()
bytecode.emit('TRYCATCHBLOCK', tryfunc, self.catchparam.get_literal(),
catchfunc, finallyfunc)
class VariableDeclaration(Expression):
diff --git a/js/test/test_interp.py b/js/test/test_interp.py
--- a/js/test/test_interp.py
+++ b/js/test/test_interp.py
@@ -216,6 +216,7 @@
print(x.length)
""", '\n0', capsys)
+@xfail
def test_throw(capsys):
assertp("throw(3);", "uncaught exception: 3", capsys)
@@ -374,14 +375,15 @@
print(z);
""", "3\n2", capsys)
-@xfail
def test_eval_syntax_error():
from js.execution import JsSyntaxError
asserte("eval('var do =true;');", JsSyntaxError)
def test_arrayobject():
- assertv("""var x = new Array();
- x.length == 0;""", 'true')
+ assertv("""
+ var x = new Array();
+ x.length == 0;
+ """, 'true')
def test_break(capsys):
assertp("""
@@ -572,7 +574,6 @@
print(x);
""", '4\n2\n3\n4', capsys)
-@xfail
def test_with_expr(capsys):
assertp("""
var x = 4;
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit