[pypy-svn] r55542 - pypy/branch/js-refactoring/pypy/lang/js

santagada at codespeak.net santagada at codespeak.net
Wed Jun 4 01:36:48 CEST 2008


Author: santagada
Date: Wed Jun  4 01:36:46 2008
New Revision: 55542

Modified:
   pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
   pypy/branch/js-refactoring/pypy/lang/js/jscode.py
   pypy/branch/js-refactoring/pypy/lang/js/jsobj.py
Log:
removed super, a specialization, and added array reverse and some flags to constants on globals

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 Jun  4 01:36:46 2008
@@ -430,6 +430,28 @@
         
         return W_String(common_join(ctx, this, sep))
 
+class W_ArrayReverse(W_NewBuiltin):
+    length = 0
+    def Call(self, ctx, args=[], this=None):
+        r2 = this.Get(ctx, 'length').ToUInt32(ctx)
+        k = r_uint(0)
+        r3 = r_uint(math.floor( float(r2)/2.0 ))
+        if r3 == k:
+            return this
+        
+        while k < r3:
+            r6 = r2 - k - 1
+            r7 = str(k)
+            r8 = str(r6)
+            
+            r9 = this.Get(ctx, r7)
+            r10 = this.Get(ctx, r8)
+            
+            this.Put(ctx, r7, r10)
+            this.Put(ctx, r8, r9)
+            k += 1
+        
+        return this
 
 class W_DateFake(W_NewBuiltin): # XXX This is temporary
     def Call(self, ctx, args=[], this=None):
@@ -573,6 +595,7 @@
             '__proto__': w_ArrPrototype,
             'toString': W_ArrayToString(ctx),
             'join': w_arr_join,
+            'reverse': W_ArrayReverse(ctx),
         })
         
         w_Array.Put(ctx, 'prototype', w_ArrPrototype, flags = allon)
@@ -599,9 +622,9 @@
         w_Date = W_DateFake(ctx, Class='Date')
         w_Global.Put(ctx, 'Date', w_Date)
         
-        w_Global.Put(ctx, 'NaN', W_FloatNumber(NAN))
-        w_Global.Put(ctx, 'Infinity', W_FloatNumber(INFINITY))
-        w_Global.Put(ctx, 'undefined', w_Undefined)
+        w_Global.Put(ctx, 'NaN', W_FloatNumber(NAN), flags = DE|DD)
+        w_Global.Put(ctx, 'Infinity', W_FloatNumber(INFINITY), flags = DE|DD)
+        w_Global.Put(ctx, 'undefined', w_Undefined, flags = DE|DD)        
         w_Global.Put(ctx, 'eval', W_Builtin(evaljs))
         w_Global.Put(ctx, 'parseInt', W_Builtin(parseIntjs))
         w_Global.Put(ctx, 'parseFloat', W_Builtin(parseFloatjs))

Modified: pypy/branch/js-refactoring/pypy/lang/js/jscode.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/jscode.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/jscode.py	Wed Jun  4 01:36:46 2008
@@ -133,7 +133,7 @@
                 self.opcodes.append(opcode)
                 return opcode
         raise ValueError("Unknown opcode %s" % (operation,))
-    emit._annspecialcase_ = 'specialize:arg(1)'
+    #emit._annspecialcase_ = 'specialize:arg(1)'
 
     def run(self, ctx, check_stack=True, retlast=False):
         if self.has_labels:

Modified: pypy/branch/js-refactoring/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/jsobj.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/jsobj.py	Wed Jun  4 01:36:46 2008
@@ -313,7 +313,7 @@
 class W_Array(W_ListObject):
     def __init__(self, ctx=None, Prototype=None, Class='Array',
                  Value=w_Undefined, callfunc=None):
-        super(W_Array, self).__init__(ctx, Prototype, Class, Value, callfunc)
+        W_ListObject.__init__(self, ctx, Prototype, Class, Value, callfunc)
         self.Put(ctx, 'length', W_IntNumber(0), flags = DD)
         self.length = r_uint(0)
 
@@ -358,7 +358,7 @@
 
 class W_Boolean(W_Primitive):
     def __init__(self, boolval):
-        super(W_Boolean, self).__init__()
+        W_Primitive.__init__(self)
         self.boolval = bool(boolval)
     
     def ToObject(self, ctx):
@@ -385,7 +385,7 @@
 
 class W_String(W_Primitive):
     def __init__(self, strval):
-        super(W_String, self).__init__()
+        W_Primitive.__init__(self)
         self.strval = strval
 
     def __repr__(self):
@@ -441,7 +441,7 @@
     """ Number known to be an integer
     """
     def __init__(self, intval):
-        super(W_IntNumber, self).__init__()
+        W_BaseNumber.__init__(self)
         self.intval = intmask(intval)
 
     def ToString(self, ctx=None):
@@ -471,7 +471,7 @@
     """ Number known to be a float
     """
     def __init__(self, floatval):
-        super(W_FloatNumber, self).__init__()
+        W_BaseNumber.__init__(self)
         self.floatval = float(floatval)
     
     def ToString(self, ctx = None):



More information about the Pypy-commit mailing list