[pypy-svn] r34188 - pypy/dist/pypy/lang/js

stephan at codespeak.net stephan at codespeak.net
Sat Nov 4 16:59:25 CET 2006


Author: stephan
Date: Sat Nov  4 16:59:24 2006
New Revision: 34188

Modified:
   pypy/dist/pypy/lang/js/interpreter.py
Log:
(stephan, santagada) assignment is still somewhat broken...

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:59:24 2006
@@ -63,10 +63,18 @@
         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
+    def put(self, context, val, obj=None):
+        if isinstance(self.left,Identifier):
+            assobj = obj or context
+            assobj.assign(self.left.name,val)
+        elif isinstance(self.left,Dot):
+            assobj = self.left.put(context, val, obj)
+
+        return assobj
+
+        #w_obj = self.left.put(context).GetValue().ToObject()
+        #name = self.right.get_literal()
+        #w_obj.dict_w[self.name] = val
         
 
 class __extend__(Function):
@@ -85,7 +93,19 @@
                 return scope_manager.get_variable(self.name)
             except NameError:
                 return self.name
-                
+
+    def put(self, context, val, obj=None):            
+        if self.initialiser is not None:
+            scope_manager.set_variable(self.name, self.initialiser.call(context))
+        try:
+            nobj = context.access(self.name)
+        except NameError:
+            try:
+                nobj = scope_manager.get_variable(self.name)
+            except NameError:
+                return self.name
+        nobj.assign(self.name, val)
+        return nobj
     
     def get_literal(self):
         return self.name



More information about the Pypy-commit mailing list