[pypy-svn] r29632 - in pypy/dist/pypy/translator/js: . demo/jsdemo test

fijal at codespeak.net fijal at codespeak.net
Tue Jul 4 21:19:57 CEST 2006


Author: fijal
Date: Tue Jul  4 21:19:41 2006
New Revision: 29632

Modified:
   pypy/dist/pypy/translator/js/_class.py
   pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py
   pypy/dist/pypy/translator/js/jsbuiltin.py
   pypy/dist/pypy/translator/js/opcodes.py
   pypy/dist/pypy/translator/js/test/runtest.py
   pypy/dist/pypy/translator/js/test/test_genllvm.py
   pypy/dist/pypy/translator/js/test/test_merge_if_blocks.py
   pypy/dist/pypy/translator/js/test/test_typed.py
Log:
Added ord operation.
Fixed fmod stuff.
Fixed some other glitches.


Modified: pypy/dist/pypy/translator/js/_class.py
==============================================================================
--- pypy/dist/pypy/translator/js/_class.py	(original)
+++ pypy/dist/pypy/translator/js/_class.py	Tue Jul  4 21:19:41 2006
@@ -35,7 +35,7 @@
         return self.name
 
     def render(self, ilasm):
-        if self.is_root(self.classdef):
+        if self.is_root(self.classdef) or self.name == 'Object':
             return
 
         if self.db.class_name(self.classdef) is not None:

Modified: pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py
==============================================================================
--- pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py	(original)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py	Tue Jul  4 21:19:41 2006
@@ -52,7 +52,7 @@
         def gen(data):
             yield data
         
-        cherrypy.response.headerMap['Content-Type'] = 'test/javascript'
+        cherrypy.response.headerMap['Content-Type'] = 'text/javascript'
         cherrypy.response.headerMap['Content-Length'] = len(self.jssource)
         return gen(self.jssource)
     

Modified: pypy/dist/pypy/translator/js/jsbuiltin.py
==============================================================================
--- pypy/dist/pypy/translator/js/jsbuiltin.py	(original)
+++ pypy/dist/pypy/translator/js/jsbuiltin.py	Tue Jul  4 21:19:41 2006
@@ -27,7 +27,8 @@
             #'ll_int' : lambda g,op: Call._render_builtin(g, 'parseInt', [op.args[0], op.args[0]]),
             'alert' : CallBuiltin('alert'),
             'seval' : CallBuiltin('seval'),
-            'date': NewBuiltin('Date')
+            'date': NewBuiltin('Date'),
+            'll_math_fmod' : InstructionList([PushAllArgs, '%']),
         }
         self.builtin_obj_map = {
             ootype.String.__class__: {

Modified: pypy/dist/pypy/translator/js/opcodes.py
==============================================================================
--- pypy/dist/pypy/translator/js/opcodes.py	(original)
+++ pypy/dist/pypy/translator/js/opcodes.py	Tue Jul  4 21:19:41 2006
@@ -131,8 +131,8 @@
     'cast_bool_to_int':         CopyName,
     'cast_bool_to_uint':        CopyName,
     'cast_bool_to_float':       CopyName,
-    'cast_char_to_int':         CopyName,
-    'cast_unichar_to_int':      CopyName,
+    'cast_char_to_int':         [PushAllArgs,_CastFun("String.charCodeAt",1)],
+    'cast_unichar_to_int':      [PushAllArgs,_CastFun("String.charCodeAt",1)],
     'cast_int_to_char':         [PushAllArgs,_CastFun("String.fromCharCode",1)],
     'cast_int_to_unichar':      [PushAllArgs,_CastFun("String.fromCharCode",1)],
     'cast_int_to_uint':         CopyName,

Modified: pypy/dist/pypy/translator/js/test/runtest.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/runtest.py	(original)
+++ pypy/dist/pypy/translator/js/test/runtest.py	Tue Jul  4 21:19:41 2006
@@ -11,6 +11,8 @@
 from pypy.translator.js import conftest
 from pypy.translator.js.log import log
 from pypy.conftest import option
+from pypy.rpython.test.tool import BaseRtypingTest, OORtypeMixin
+
 log = log.runtest
 use_browsertest = conftest.option.browser
 use_tg = conftest.option.tg
@@ -99,3 +101,60 @@
             except:
                 res = str(s)
         return res
+
+class JsTest(BaseRtypingTest, OORtypeMixin):
+    #def __init__(self):
+    #    self._func = None
+    #    self._ann = None
+    #    self._cli_func = None
+
+    def _compile(self, fn, args):
+        #ann = [lltype_to_annotation(typeOf(x)) for x in args]
+        #if self._func is fn and self._ann == ann:
+        #    return self._cli_func
+        #else:
+        #    self._func = fn
+        #    self._ann = ann
+        #    self._cli_func = compile_function(fn, ann)
+        #    return self._cli_func
+        def f():
+            res = fn(*args)
+            return str(res)
+        return compile_function(f, [])
+    
+    def interpret(self, fn, args):
+        #def f(args):
+        #   fn(*args)
+        
+        f = self._compile(fn, args)
+        res = f(*args)
+        return res
+        #if isinstance(res, ExceptionWrapper):
+        #    raise res
+        #return res
+
+    def interpret_raises(self, exception, fn, args):
+        #import exceptions # needed by eval
+        #try:
+        #import pdb; pdb.set_trace()
+        #self.interpret(fn, args)
+        assert False
+        #except ExceptionWrapper, ex:
+        #    assert issubclass(eval(ex.class_name), exception)
+        #else:
+        #    assert False, 'function did raise no exception at all'
+
+    def ll_to_string(self, s):
+        return s
+
+    def ll_to_list(self, l):
+        return l
+
+    def class_name(self, value):
+        return value.class_name.split(".")[-1] 
+
+    def is_of_instance_type(self, val):
+        import pdb; pdb.set_trace()
+
+    def read_attr(self, obj, name):
+        py.test.skip('read_attr not supported on gencli tests')

Modified: pypy/dist/pypy/translator/js/test/test_genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_genllvm.py	(original)
+++ pypy/dist/pypy/translator/js/test/test_genllvm.py	Tue Jul  4 21:19:41 2006
@@ -284,7 +284,7 @@
             assert f(i,j) == list_basic_ops(i,j)
 
 def test_string_simple():
-    py.test.skip("ord semantics")
+    #py.test.skip("ord semantics")
     def string_simple(i): 
         return ord(str(i))
     f = compile_function(string_simple, [int])
@@ -358,7 +358,7 @@
     assert f() == 4
 
 def test_dict_creation():
-    py.test.skip("Dict support not implemented")
+    #py.test.skip("Dict support not implemented")
     d = {'hello' : 23,
          'world' : 21}
     l = ["hello", "world"]

Modified: pypy/dist/pypy/translator/js/test/test_merge_if_blocks.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_merge_if_blocks.py	(original)
+++ pypy/dist/pypy/translator/js/test/test_merge_if_blocks.py	Tue Jul  4 21:19:41 2006
@@ -26,7 +26,7 @@
         assert basic(i) == merge_if_blocks_basic(i)
 
 def test_merge_if_blocks_chr():
-    py.test.skip("String support in ootypesystem")
+    #py.test.skip("String support in ootypesystem")
     def merge_if_blocks_chr(i):
         c = chr(i)
         if c == '\x05':
@@ -39,7 +39,7 @@
         assert basic(i) == merge_if_blocks_chr(i)
 
 def test_merge_if_blocks_uni():
-    py.test.skip("String support in ootypesystem")
+    py.test.skip("Unicode support")
     def merge_if_blocks_uni(i):
         c = unichr(i)
         if c == u'\x05':

Modified: pypy/dist/pypy/translator/js/test/test_typed.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_typed.py	(original)
+++ pypy/dist/pypy/translator/js/test/test_typed.py	Tue Jul  4 21:19:41 2006
@@ -172,6 +172,7 @@
             assert res == testfn(i, j)
 
 def test_unichr_eq():
+    py.test.skip("Unicode support")
     l = list(u'Hello world')
     def f(i, j):
         return l[i] == l[j]
@@ -182,6 +183,7 @@
             assert res == f(i,j) 
 
 def test_unichr_ne():
+    py.test.skip("Unicode support")
     l = list(u'Hello world')
     def f(i, j):
         return l[i] != l[j]
@@ -192,7 +194,8 @@
             assert res == f(i, j)
 
 def test_unichr_ord():
-    py.test.skip("ord semantics")
+    #py.test.skip("ord semantics")
+    py.test.skip("Unicode support")
     l = list(u'Hello world')
     def f(i):
         return ord(l[i]) 
@@ -202,7 +205,7 @@
         assert res == f(i)
 
 def test_unichr_unichr():
-    py.test.skip("unichr function")
+    py.test.skip("Unicode support")
     l = list(u'Hello world')
     def f(i, j):
         return l[i] == unichr(j)
@@ -214,7 +217,7 @@
 
 # floats 
 def test_float_operations():
-    py.test.skip("issue with ll_math_fmod calling itself")
+    #py.test.skip("issue with ll_math_fmod calling itself")
     import math
     def func(x, y): 
         z = x + y / 2.1 * x 
@@ -313,7 +316,7 @@
         assert f(ii) == ii
 
 def test_char_comparisons():
-    py.test.skip("chr/ord semantics")
+    #py.test.skip("chr/ord semantics")
     def comps(v):
         x = chr(v)
         res = 0



More information about the Pypy-commit mailing list