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

santagada at codespeak.net santagada at codespeak.net
Sun Feb 4 16:56:21 CET 2007


Author: santagada
Date: Sun Feb  4 16:56:11 2007
New Revision: 37923

Modified:
   pypy/dist/pypy/lang/js/driver.py
   pypy/dist/pypy/lang/js/interpreter.py
Log:
checks for the js interpreter, and a quick hack to add String


Modified: pypy/dist/pypy/lang/js/driver.py
==============================================================================
--- pypy/dist/pypy/lang/js/driver.py	(original)
+++ pypy/dist/pypy/lang/js/driver.py	Sun Feb  4 16:56:11 2007
@@ -2,18 +2,25 @@
 
 import autopath
 from py import path
+import py
 import os
+import sys
 
-shell = path.local(__file__).dirpath('test', 'ecma', 'shell.js')
-
+pwd = path.local(__file__)
+shell = pwd.dirpath('test', 'ecma', 'shell.js')
 exclusionlist = ['shell.js', 'browser.js']
 def filter(filename):
     if filename.basename in exclusionlist or not filename.basename.endswith('.js'):
         return False
     else:
         return True
+
+if py.path.local.sysfind("js") is None:
+    print "js interpreter not found in path"
+    sys.exit()
+
 results = open('results.txt', 'w')
-for f in path.local(__file__).dirpath('test', 'ecma').visit(filter):
+for f in pwd.dirpath('test', 'ecma').visit(filter):
     print f.basename
     stdout = os.popen('./js_interactive.py -n -f %s -f %s'%(shell.strpath,f.strpath), 'r')
     passed = 0

Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py	(original)
+++ pypy/dist/pypy/lang/js/interpreter.py	Sun Feb  4 16:56:11 2007
@@ -128,6 +128,11 @@
         return W_Boolean(args[0].ToBoolean())
     return W_Boolean(False)
 
+def stringjs(ctx, args, this):
+    if len(args) > 0:
+        return W_String(args[0].ToString())
+    return W_String('')
+
 def numberjs(ctx, args, this):
     if len(args) > 0:
         return W_Number(args[0].ToNumber())
@@ -170,6 +175,7 @@
         w_math.Put('abs', W_Builtin(absjs, Class='function'))
         w_math.Put('floor', W_Builtin(floorjs, Class='function'))
         
+        w_Global.Put('String', W_Builtin(stringjs, Class='String'))
         
         #Global Properties
         w_Global.Put('Object', w_Object)
@@ -177,6 +183,7 @@
         w_Global.Put('Array', W_Array())
         w_Global.Put('version', W_Builtin(versionjs))
         
+        #Number
         w_Number = W_Builtin(numberjs, Class="Number")
         w_Number.Put('NaN', W_Number(NaN))
         w_Number.Put('POSITIVE_INFINITY', W_Number(Infinity))
@@ -873,7 +880,7 @@
 def get_string(t, string):
         simb = get_tree_item(t, string)
         if isinstance(simb, Symbol):
-            return simb.additional_info
+            return str(simb.additional_info)
         else:
             return ''
 
@@ -891,7 +898,7 @@
             if x.children[0].additional_info == name:
                 return x.children[1]
     return None
-
+    
 opcodedict = {}
 for i in locals().values():
     if isinstance(i, type(Node)) and issubclass(i, Node):


More information about the pypy-svn mailing list