[pypy-svn] r34183 - pypy/dist/pypy/lang/js
santagada at codespeak.net
santagada at codespeak.net
Sat Nov 4 16:30:22 CET 2006
Author: santagada
Date: Sat Nov 4 16:30:21 2006
New Revision: 34183
Modified:
pypy/dist/pypy/lang/js/astgen.py
pypy/dist/pypy/lang/js/interpreter.py
pypy/dist/pypy/lang/js/jsobj.py
Log:
(stephan, santagada) trying to make this work
Modified: pypy/dist/pypy/lang/js/astgen.py
==============================================================================
--- pypy/dist/pypy/lang/js/astgen.py (original)
+++ pypy/dist/pypy/lang/js/astgen.py Sat Nov 4 16:30:21 2006
@@ -175,7 +175,11 @@
elif tp == 'FUNCTION':
scope = scope_manager.enter_scope()
body = from_dict(d['body'])
- f = Function(d['params'].split(','), body, scope)
+ if d['params'] == '':
+ params = []
+ else:
+ params = d['params'].split(',')
+ f = Function(params, body, scope)
scope_manager.leave_scope()
return f
elif tp == 'GROUP':
Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py (original)
+++ pypy/dist/pypy/lang/js/interpreter.py Sat Nov 4 16:30:21 2006
@@ -26,11 +26,10 @@
class __extend__(Assign):
def call(self, context):
val = self.expr.call(context)
- scope_manager.set_variable(self.identifier.name, val)
- return val
+ self.identifier.put(context,val)
class __extend__(Block):
- def call(self, context=None):
+ def call(self, context):
try:
last = w_Undefined
for node in self.nodes:
@@ -40,7 +39,7 @@
return e.value
class __extend__(Call):
- def call(self, context=None):
+ def call(self, context):
name = self.identifier.get_literal()
if name == 'print':
writer(",".join([i.ToString() for i in self.arglist.call(context)]))
@@ -54,7 +53,7 @@
return retval
class __extend__(Comma):
- def call(self, context=None):
+ def call(self, context):
self.left.call(context)
return self.right.call(context)
@@ -63,6 +62,12 @@
w_obj = self.left.call(context).GetValue().ToObject()
name = self.right.get_literal()
return w_obj.Get(name)
+
+ def put(self, context, val):
+ w_obj = self.left.call(context).GetValue().ToObject()
+ name = self.right.get_literal()
+ w_obj.dict_w[self.name] = val
+
class __extend__(Function):
def call(self, context=None):
@@ -76,7 +81,11 @@
try:
return context.access(self.name)
except NameError:
- return scope_manager.get_variable(self.name)
+ try:
+ return scope_manager.get_variable(self.name)
+ except NameError:
+ return self.name
+
def get_literal(self):
return self.name
@@ -128,7 +137,6 @@
class __extend__(New):
def call(self, context=None):
- print context.__dict__
obj = W_Object({})
obj.Class = 'Object'
try:
@@ -181,10 +189,7 @@
return W_Number(num_left + num_right)
class __extend__(Script):
- def call(self, context=None, args=(), this=None, params=None):
- print 'params',params
- if params == None:
- params = []
+ def call(self, context=None, args=(), params=[]):
ncontext = ExecutionContext(context)
for i, item in enumerate(params):
try:
Modified: pypy/dist/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/dist/pypy/lang/js/jsobj.py (original)
+++ pypy/dist/pypy/lang/js/jsobj.py Sat Nov 4 16:30:21 2006
@@ -39,10 +39,10 @@
self.function = function
#self.class_ = None
- def Call(self, context=None, args=None, this=None):
+ def Call(self, context=None, args=[]):
if self.function:
return self.function.body.call(context=context,
- args=args, this=this,
+ args=args,
params= self.function.params)
else:
return W_Object({})
More information about the Pypy-commit
mailing list