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

santagada at codespeak.net santagada at codespeak.net
Mon Dec 25 18:55:11 CET 2006


Author: santagada
Date: Mon Dec 25 18:55:05 2006
New Revision: 35980

Modified:
   pypy/dist/pypy/lang/js/interpreter.py
   pypy/dist/pypy/lang/js/jsobj.py
Log:
All tests passing :) Lets play with named functions and then prototypes.


Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py	(original)
+++ pypy/dist/pypy/lang/js/interpreter.py	Mon Dec 25 18:55:05 2006
@@ -2,6 +2,7 @@
 from pypy.lang.js.astgen import *
 from pypy.lang.js.jsparser import parse
 from pypy.lang.js.jsobj import *
+from pypy.lang.js.reference import Reference
 
 def writer(x):
     print x
@@ -45,7 +46,9 @@
 
 class __extend__(Assign):
     def call(self, ctx):
+        print "Assign LHS = ", self.LHSExp
         v1 = self.LHSExp.call(ctx)
+        print "Assign Exp = ", self.AssignmentExp
         v3 = self.AssignmentExp.call(ctx).GetValue()
         v1.PutValue(v3, ctx)
         return v3
@@ -77,21 +80,21 @@
         return self.right.call(ctx)
 
 class __extend__(Dot):
-    def call(self, ctx=None):
+    def call(self, ctx):
         w_obj = self.left.call(ctx).GetValue().ToObject()
         name = self.right.get_literal()
-        return w_obj.Get(name)
+        return Reference(name, w_obj)
         
-    def put(self, ctx, val):
-        print self.left.name, self.right.name, val
-        if isinstance(self.left,Identifier):
-            obj = ctx.access(self.left.name)
-            print obj.Class
-            obj.dict_w[self.right.name] = val
-        elif isinstance(self.left,Dot):
-            obj = self.left.put(ctx, val)
-
-        return obj
+    # def put(self, ctx, val):
+    #     print self.left.name, self.right.name, val
+    #     if isinstance(self.left,Identifier):
+    #         obj = ctx.access(self.left.name)
+    #         print obj.Class
+    #         obj.dict_w[self.right.name] = val
+    #     elif isinstance(self.left,Dot):
+    #         obj = self.left.put(ctx, val)
+    # 
+    #     return obj
 
         #w_obj = self.left.put(ctx).GetValue().ToObject()
         #name = self.right.get_literal()
@@ -110,8 +113,8 @@
             ref.PutValue(self.initialiser.call(ctx), ctx)
         return ctx.resolve_identifier(self.name)
 
-    def put(self, ctx, val, obj=None):            
-        ctx.assign(self.name, val)
+    # def put(self, ctx, val, obj=None):            
+    #     ctx.assign(self.name, val)
     
     def get_literal(self):
         return self.name

Modified: pypy/dist/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/dist/pypy/lang/js/jsobj.py	(original)
+++ pypy/dist/pypy/lang/js/jsobj.py	Mon Dec 25 18:55:05 2006
@@ -17,6 +17,9 @@
         self.ReadOnly = ReadOnly
         self.DontEnum = DontEnum
         self.Internal = Internal
+    
+    def __repr__(self):
+        return "|%s %d%d%d|"%(self.value, self.DontDelete, self.ReadOnly, self.DontEnum)
 
 def internal_property(name, value):
     """return a internal property with the right attributes"""
@@ -251,10 +254,6 @@
         return w_Undefined
 
 
-class W_Reference(W_Root):
-    def GetValue(self):
-        raise NotImplementedError("W_Reference.GetValue")
-
 class W_Builtin(W_Root):
     def __init__(self, builtinfunction):
         #W_Object.__init__(self)



More information about the Pypy-commit mailing list