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

santagada at codespeak.net santagada at codespeak.net
Wed May 30 04:43:37 CEST 2007


Author: santagada
Date: Wed May 30 04:43:35 2007
New Revision: 43892

Modified:
   pypy/dist/pypy/lang/js/interpreter.py
   pypy/dist/pypy/lang/js/operations.py
Log:
fixed the bugs discovered in translation and the addition of sqrt to the Math object.

Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py	(original)
+++ pypy/dist/pypy/lang/js/interpreter.py	Wed May 30 04:43:35 2007
@@ -134,7 +134,10 @@
 
 def powjs(ctx, args, this):
     return W_Number(math.pow(args[0].ToNumber(), args[1].ToNumber()))
-    
+
+def sqrtjs(ctx, args, this):
+    return W_Number(math.sqrt(args[0].ToNumber()))
+
 def versionjs(ctx, args, this):
     return w_Undefined
 
@@ -167,6 +170,7 @@
         w_math.Put('abs', W_Builtin(absjs, Class='function'))
         w_math.Put('floor', W_Builtin(floorjs, Class='function'))
         w_math.Put('pow', W_Builtin(powjs, Class='function'))
+        w_math.Put('sqrt', W_Builtin(sqrtjs, Class='function'))
         w_math.Put('E', W_Number(math.e))
         w_math.Put('PI', W_Number(math.pi))
         

Modified: pypy/dist/pypy/lang/js/operations.py
==============================================================================
--- pypy/dist/pypy/lang/js/operations.py	(original)
+++ pypy/dist/pypy/lang/js/operations.py	Wed May 30 04:43:35 2007
@@ -720,6 +720,7 @@
     def string_unquote(self, string):
         temp = []
         stop = len(string)-1
+        assert stop >= 0
         last = ""
         
         #removing the begining quotes (" or \')
@@ -866,7 +867,7 @@
             ctx.variable.Put(name, w_Undefined)
         else:
             ctx.variable.Put(name, self.expr.eval(ctx).GetValue())
-        return self.identifier
+        return self.identifier.eval(ctx)
     
 
 class VariableDeclList(Expression):
@@ -956,12 +957,12 @@
         self.body = body
     
     def execute(self, ctx):
-        identifier = self.vardecl.eval(ctx)
+        self.vardecl.eval(ctx)
         obj = self.object.eval(ctx).GetValue().ToObject()
         for prop in obj.propdict.values():
             if prop.de:
                 continue
-            iterator = identifier.eval(ctx)
+            iterator = self.vardecl.eval(ctx)
             iterator.PutValue(prop.value, ctx)
             try:
                 result = self.body.execute(ctx)



More information about the Pypy-commit mailing list