[pypy-svn] r66546 - in pypy/branch/io-lang/pypy/lang/io: . test

david at codespeak.net david at codespeak.net
Thu Jul 23 18:23:09 CEST 2009


Author: david
Date: Thu Jul 23 18:23:07 2009
New Revision: 66546

Modified:
   pypy/branch/io-lang/pypy/lang/io/call.py
   pypy/branch/io-lang/pypy/lang/io/model.py
   pypy/branch/io-lang/pypy/lang/io/test/test_call.py
Log:
target and sender on Call objects


Modified: pypy/branch/io-lang/pypy/lang/io/call.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/call.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/call.py	Thu Jul 23 18:23:07 2009
@@ -11,4 +11,12 @@
                                         
 @register_method('Call', 'evalArgAt')
 def call_eval_arg_at(space, w_target, w_message, w_context):
-    return call_arg_at(space, w_target, w_message, w_context).eval(space, w_context, w_context)
\ No newline at end of file
+    return call_arg_at(space, w_target, w_message, w_context).eval(space, w_context, w_context)
+    
+ at register_method('Call', 'sender')
+def call_sender(space, w_target, w_message, w_context):
+    return w_target.sender
+
+ at register_method('Call', 'target')
+def call_target(space, w_target, w_message, w_context):
+    return w_target.target
\ No newline at end of file

Modified: pypy/branch/io-lang/pypy/lang/io/model.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/model.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/model.py	Thu Jul 23 18:23:07 2009
@@ -219,7 +219,11 @@
         
     def call(self, space, w_receiver, w_message, w_context):
         w_locals = self.space.w_locals.clone()
+
         w_call = self.space.w_call.clone()
+        w_call.sender = w_context
+        w_call.target = w_receiver
+
         assert w_locals is not None
         assert w_call is not None
         

Modified: pypy/branch/io-lang/pypy/lang/io/test/test_call.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/test/test_call.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_call.py	Thu Jul 23 18:23:07 2009
@@ -8,7 +8,21 @@
     assert res.name == '2'
     
     
-def test_message_evalArgAt():
+def test_call_evalArgAt():
     inp = """t := 99; a := method(x, y, z, call); a(1,t,3) evalArgAt(1)"""
     res, space = interpret(inp)
-    assert res.value == 99
\ No newline at end of file
+    assert res.value == 99
+    
+def test_call_sender():
+    inp = """foo := Object clone
+    foo a := method(x, y, z, call); 
+    foo a(1,2,3) sender"""
+    res, space = interpret(inp)
+    assert res == space.w_lobby
+    
+def test_call_receiver():
+    inp = """foo := Object clone
+    foo a := method(x, y, z, call); 
+    foo a(1,2,3) target"""
+    res, space = interpret(inp)
+    assert res == space.w_lobby.slots['foo']
\ No newline at end of file



More information about the Pypy-commit mailing list