public
Description: a ruby-to-pyc compiler
Clone URL: git://github.com/why/unholy.git
Search Repo:
 * lib/unholy/pyasm.rb: class initialize method, aliased at __init__ in 
 Python.
why (author)
Thu May 15 08:02:02 -0700 2008
commit  12d52c4ce7154d3cd8300be129d15ed7e57e8b1e
tree    e914a334f60827097074f2570f76e66d0588f0b1
parent  3fa5d7dd9a996c915b4c7415283b493de0790ede
...
292
293
294
295
 
 
 
296
297
298
299
...
318
319
320
321
322
 
 
 
 
 
 
 
 
323
324
325
 
326
327
328
...
292
293
294
 
295
296
297
298
299
300
301
...
320
321
322
 
 
323
324
325
326
327
328
329
330
331
 
 
332
333
334
335
0
@@ -292,7 +292,9 @@
0
     bytes = @bytecode.slice! idx..-1
0
     bytes.shift unless receiver
0
 
0
- asm = Pyasm.new(@filename, type, id.to_s, @lines.last[0], iseq[5][:arg_size])
0
+ argc = iseq[4][:arg_size]
0
+ argc += 1 if type == :method # python's self
0
+ asm = Pyasm.new(@filename, type, id.to_s, @lines.last[0], argc)
0
     if type == :class
0
       asm.load_name(:__name__)
0
       asm.store_name(:__module__)
0
0
@@ -318,11 +320,16 @@
0
     store_name(id)
0
 
0
     # this is a bit redundant, but decompyle requires it
0
- if type == :method and @type == nil
0
- unless receiver
0
+ if type == :method
0
+ if @type == nil
0
+ unless receiver
0
+ load_name(id)
0
+ load_name(:Kernel)
0
+ store_attr(id)
0
+ end
0
+ elsif @type == :class and id == :initialize
0
         load_name(id)
0
- load_name(:Kernel)
0
- store_attr(id)
0
+ store_name(:__init__)
0
       end
0
     end
0
   end
...
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
0
@@ -1 +1,9 @@
0
+# init
0
+class Smalls
0
+ def initialize
0
+ puts "init"
0
+ end
0
+end
0
+
0
+Smalls.new

Comments

    No one has commented yet.