[pypy-commit] lang-js default: wip
stepahn
noreply at buildbot.pypy.org
Fri Dec 28 11:33:30 CET 2012
Author: Stephan <stephan at stzal.com>
Branch:
Changeset: r190:cdde097cbad2
Date: 2012-05-21 11:03 +0200
http://bitbucket.org/pypy/lang-js/changeset/cdde097cbad2/
Log: wip
diff --git a/js/builtins_number.py b/js/builtins_number.py
--- a/js/builtins_number.py
+++ b/js/builtins_number.py
@@ -76,6 +76,7 @@
elif isinstance(this, W_NumericObject):
num = this.PrimitiveValue()
else:
+ import pdb; pdb.set_trace()
raise JsTypeError()
# TODO radix, see 15.7.4.2
diff --git a/js/execution_context.py b/js/execution_context.py
--- a/js/execution_context.py
+++ b/js/execution_context.py
@@ -189,3 +189,35 @@
def argv(self):
return self._argument_values_
+
+class WithExecutionContext(ExecutionContext):
+ def __init__(self, code, expr_obj, calling_context):
+ ExecutionContext.__init__(self)
+ self._code_ = code
+ self._strict_ = code.strict
+ self._calling_context_ = calling_context
+ self._expr_obj_ = expr_obj
+
+ from js.lexical_environment import ObjectEnvironment
+ parent_environment = calling_context.lexical_environment()
+ local_env = ObjectEnvironment(expr_obj, outer_environment = parent_environment)
+ local_env.environment_record.provide_this = True
+
+ self._lexical_environment_ = local_env
+ self._variable_environment_ = local_env
+ self._this_binding_ = local_env.environment_record.implicit_this_value()
+
+ self.declaration_binding_initialization()
+
+ def stack_append(self, value):
+ self._calling_context_.stack_append(value)
+
+ def stack_pop(self):
+ return self._calling_context_.stack_pop()
+
+ def stack_top(self):
+ return self._calling_context_.stack_top()
+
+ def stack_pop_n(self, n):
+ return self._calling_context_.stack_pop_n(n)
+
diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -674,21 +674,15 @@
self.body = body
def eval(self, ctx):
- from lexical_environment import ObjectEnvironment
+ from execution_context import WithExecutionContext
# 12.10
expr = self.expr.run(ctx)
expr_obj = expr.ToObject()
- old_env = ctx.lexical_environment()
- new_env = ObjectEnvironment(expr_obj, outer_environment = old_env)
- new_env.environment_record.provide_this = True
- ctx.set_lexical_environment(new_env)
+ with_ctx = WithExecutionContext(self.body, expr_obj, ctx)
- try:
- c = self.body.run(ctx)
- ctx.stack_append(c)
- finally:
- ctx.set_lexical_environment(old_env)
+ c = self.body.run(with_ctx)
+ ctx.stack_append(c)
# ------------------ delete -------------------------
More information about the pypy-commit
mailing list