[pypy-svn] r47983 - pypy/dist/pypy/translator/goal

arigo at codespeak.net arigo at codespeak.net
Thu Oct 25 20:42:27 CEST 2007


Author: arigo
Date: Thu Oct 25 20:42:26 2007
New Revision: 47983

Modified:
   pypy/dist/pypy/translator/goal/targetfibsmalltalk.py
Log:
Fix the target.


Modified: pypy/dist/pypy/translator/goal/targetfibsmalltalk.py
==============================================================================
--- pypy/dist/pypy/translator/goal/targetfibsmalltalk.py	(original)
+++ pypy/dist/pypy/translator/goal/targetfibsmalltalk.py	Thu Oct 25 20:42:26 2007
@@ -9,21 +9,33 @@
 def new_interpreter(bytes):
     assert isinstance(bytes, str)
     w_method = model.W_CompiledMethod(0, bytes=bytes)
-    w_frame = w_method.createFrame(objtable.w_nil, [])
+    w_frame = w_method.create_frame(objtable.w_nil, [])
     interp = interpreter.Interpreter()
     interp.w_active_context = w_frame
     return interp
 
+def build():
+    bytecode = ''.join(map(chr, [ 16, 119, 178, 154, 118, 164, 11, 112, 16, 118, 177, 224, 112, 16, 119, 177, 224, 176, 124 ]))
+    shadow = mockclass(0).as_class_get_shadow()
+    method = model.W_CompiledMethod(1, bytecode, 1)
+    method.literals = fakeliterals("fib:")
+    shadow.installmethod("fib:", method)
+    w_object = shadow.new()
+    interp = new_interpreter(sendLiteralSelectorBytecode(16) + returnTopFromMethod)
+    interp.w_active_context.w_method().literals = fakeliterals("fib:")
+    return interp, w_object
+
+def check_me():
+    interp, w_object = build()
+    interp.w_active_context.push(w_object)
+    interp.w_active_context.push(wrap_int(8))
+    result = interp.interpret()
+    assert primitives.unwrap_int(result) == 34
+    print "check_me() ok"
+check_me()
 
-bytecode = ''.join(map(chr, [ 16, 119, 178, 154, 118, 164, 11, 112, 16, 118, 177, 224, 112, 16, 119, 177, 224, 176, 124 ]))
-shadow = mockclass(0).as_class_get_shadow()
-method = model.W_CompiledMethod(1, bytecode, 1)
-method.literals = fakeliterals("fib:")
-shadow.installmethod("fib:", method)
-w_object = shadow.new()
-interp = new_interpreter(sendLiteralSelectorBytecode(16) + returnTopFromMethod)
-interp.w_active_context.method.literals = fakeliterals("fib:")
 
+interp, w_object = build()
 
 def entry_point(argv):
     if len(argv) > 1:



More information about the Pypy-commit mailing list