[pypy-svn] r53255 - pypy/branch/js-refactoring/pypy/lang/js
fijal at codespeak.net
fijal at codespeak.net
Wed Apr 2 18:25:54 CEST 2008
Author: fijal
Date: Wed Apr 2 18:25:51 2008
New Revision: 53255
Modified:
pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
pypy/branch/js-refactoring/pypy/lang/js/operations.py
Log:
eval
Modified: pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/interpreter.py (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/interpreter.py Wed Apr 2 18:25:51 2008
@@ -100,26 +100,26 @@
TEST = False
def evaljs(ctx, args, this):
- raise NotImplementedError
if len(args) >= 1:
if isinstance(args[0], W_String):
- code = args[0]
+ src = args[0].strval
else:
return args[0]
else:
- code = W_String('')
+ src = ''
try:
- node = load_source(code.ToString(ctx), 'evalcode')
+ node = load_source(src, 'evalcode')
except ParseError, e:
- raise ThrowException(W_String('SintaxError: '+str(e)))
-
- if TEST:
- try:
- return node.execute(ctx)
- except ThrowException, e:
- return W_String("error")
- else:
- return node.execute(ctx)
+ raise ThrowException(W_String('SyntaxError: '+str(e)))
+
+ bytecode = JsCode()
+ node.emit(bytecode)
+ # XXX awful hack, we shall have a general way of doing that
+ from pypy.lang.js.jscode import POP
+ assert isinstance(bytecode.opcodes[-1], POP)
+ bytecode.opcodes.pop()
+ bytecode.run(ctx, check_stack=False)
+ return bytecode.stack[-1]
def parseIntjs(ctx, args, this):
if len(args) < 1:
Modified: pypy/branch/js-refactoring/pypy/lang/js/operations.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/operations.py (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/operations.py Wed Apr 2 18:25:51 2008
@@ -928,19 +928,6 @@
bytecode.emit('JUMP', precond)
bytecode.emit('LABEL', finish)
- def execute(self, ctx):
- self.setup.eval(ctx).GetValue()
- while self.condition.eval(ctx).ToBoolean():
- try:
- self.body.execute(ctx)
- self.update.eval(ctx)
- except ExecutionReturned, e:
- if e.type == 'break':
- break
- elif e.type == 'continue':
- self.update.eval(ctx)
- continue
-
class Boolean(Expression):
def __init__(self, pos, boolval):
self.pos = pos
More information about the pypy-svn
mailing list