[pypy-svn] r28398 - in pypy/dist/pypy/translator/js2: . test

fijal at codespeak.net fijal at codespeak.net
Tue Jun 6 18:18:17 CEST 2006


Author: fijal
Date: Tue Jun  6 18:18:16 2006
New Revision: 28398

Modified:
   pypy/dist/pypy/translator/js2/jts.py
   pypy/dist/pypy/translator/js2/metavm.py
   pypy/dist/pypy/translator/js2/opcodes.py
   pypy/dist/pypy/translator/js2/test/test_genllvm.py
Log:
Indirect call support. Right now it does only support user-defined functions (you cannot access predefined functions that way)


Modified: pypy/dist/pypy/translator/js2/jts.py
==============================================================================
--- pypy/dist/pypy/translator/js2/jts.py	(original)
+++ pypy/dist/pypy/translator/js2/jts.py	Tue Jun  6 18:18:16 2006
@@ -82,6 +82,7 @@
             # FIXME: It's not ok to use always empty list
             val = "[]"
         elif isinstance(_type,StaticMethod):
+            self.db.pending_function(v.graph)
             val = v._name
         elif _type is UniChar or _type is Char:
             #log("Constant %r"%v)

Modified: pypy/dist/pypy/translator/js2/metavm.py
==============================================================================
--- pypy/dist/pypy/translator/js2/metavm.py	(original)
+++ pypy/dist/pypy/translator/js2/metavm.py	Tue Jun  6 18:18:16 2006
@@ -148,6 +148,13 @@
         generator.ilasm.load_const(op.args[1].value._name.replace('.', '_'))#[-1])
         generator.cast_function("isinstanceof", 2)
 
+class _IndirectCall(MicroInstruction):
+    def render(self, generator, op):
+        for func_arg in op.args[1:]: # push parameters
+            generator.load(func_arg)
+        generator.call_external(op.args[0].name, op.args[1:])
+
+IndirectCall = _IndirectCall()
 IsInstance = _IsInstance()
 CallMethod = _CallMethod()
 CopyName = [PushAllArgs, _SameAs ()]

Modified: pypy/dist/pypy/translator/js2/opcodes.py
==============================================================================
--- pypy/dist/pypy/translator/js2/opcodes.py	(original)
+++ pypy/dist/pypy/translator/js2/opcodes.py	Tue Jun  6 18:18:16 2006
@@ -9,7 +9,8 @@
     _CallDispatcher, _MethodDispatcher
 
 from pypy.translator.js2.metavm import SameAs, IsInstance, Call, CallMethod, CopyName, CastString,\
-    _Prefix, _CastFun, _NotImplemented, CallBuiltin, CallBuiltinObject, GetBuiltinField, SetBuiltinField
+    _Prefix, _CastFun, _NotImplemented, CallBuiltin, CallBuiltinObject, GetBuiltinField, SetBuiltinField,\
+    IndirectCall
 
 from pypy.translator.js2.jsbuiltin import Builtins
 
@@ -104,7 +105,7 @@
     'float_is_true': [PushAllArgs,_Prefix('!!')],
     
     'direct_call' : [_CallDispatcher(Builtins, class_map)],
-    'indirect_call' : [_NotImplemented("Indirect call not implemented")],
+    'indirect_call' : [IndirectCall],
     'same_as' : SameAs,
     'new' : [New],
     'instanceof' : [IsInstance],

Modified: pypy/dist/pypy/translator/js2/test/test_genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/js2/test/test_genllvm.py	(original)
+++ pypy/dist/pypy/translator/js2/test/test_genllvm.py	Tue Jun  6 18:18:16 2006
@@ -7,7 +7,7 @@
 from pypy.translator.js2.test.runtest import compile_function
 
 def test_simple_function_pointer(): 
-    py.test.skip("ootypesystem problems with lists")
+    #py.test.skip("ootypesystem problems with lists")
     def f1(x):
         return x + 1
     def f2(x):
@@ -29,7 +29,7 @@
     assert f() == 1
 
 def test_invoke_function_pointer(): 
-    py.test.skip("ootypesystem problems with lists")
+    #py.test.skip("ootypesystem problems with lists")
     def f1(x): 
         return x + 1
     def f2(x): 



More information about the Pypy-commit mailing list