public this repo is viewable by everyone
Description: a ruby-to-pyc compiler
Clone URL: git://github.com/why/unholy.git
 * lib/unholy/pyasm.rb: working on object instantiation and the 
 VM_CALL_FCALL_BIT.
why (author)
7 days ago
commit  d15375b5c542aba81333671d08691bc67153b30b
tree    fa08e76ff0ec2b1b6e5ad420808c57c32373228a
parent  aa1939a1878fbe48fb9b743a39e8a42da2f83d02
...
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
0
@@ -1,3 +1,7 @@
0
+class Module
0
+ def to_pickle; self.name.to_pickle end
0
+end
0
+
0
 class NilClass
0
   def to_pickle; "N" end
0
 end
...
2
3
4
 
 
5
6
7
...
11
12
13
14
 
15
16
17
...
200
201
202
203
 
204
205
206
...
220
221
222
223
 
 
 
224
225
226
...
228
229
230
231
 
232
233
234
...
277
278
279
280
 
281
282
283
...
2
3
4
5
6
7
8
9
...
13
14
15
 
16
17
18
19
...
202
203
204
 
205
206
207
208
...
222
223
224
 
225
226
227
228
229
230
...
232
233
234
 
235
236
237
238
...
281
282
283
 
284
285
286
287
0
@@ -2,6 +2,8 @@ class Pyasm
0
   CO_NEWLOCALS = 0x02
0
   CO_NOFREE = 0x40
0
 
0
+ VM_CALL_FCALL_BIT = 0x08
0
+
0
   OPS = {
0
     :== => 2
0
   }
0
@@ -11,7 +13,7 @@ class Pyasm
0
   def initialize(fname, type = nil, name = "<module>", lineno = 0)
0
     @argc, @nlocals, @stacksize, @flags, @filename, @lineno, @name, @stack, @nopop, @type =
0
       0, 0, 1, CO_NOFREE, fname, lineno, name, [], 0, type
0
- @flags |= CO_NEWLOCALS if type == :class
0
+ @flags |= CO_NEWLOCALS if [:class, :method].include?(type)
0
     @consts = [-1, nil]
0
     @symbols = [:Kernel]
0
     @bytecode, @varsyms, @labels, @lines, @jumps = [], [], {}, [], {}
0
@@ -200,7 +202,7 @@ class Pyasm
0
       bytes = @bytecode.slice! idx..-1
0
 
0
       unless receiver
0
- unpop
0
+ unpop
0
         case meth
0
         when :import
0
           return import(*args)
0
@@ -220,7 +222,9 @@ class Pyasm
0
       bytes = @bytecode.slice! idx..-1
0
     end
0
 
0
- load_attr(meth)
0
+ if meth != :new
0
+ load_attr(meth)
0
+ end
0
     @bytecode += bytes
0
     call_func(op_argc)
0
   end
0
@@ -228,7 +232,7 @@ class Pyasm
0
     @nopop = 2
0
   end
0
   def pop
0
- pop_top unless @nopop > 0
0
+ pop_top unless @nopop > 0 or @stack.empty?
0
   end
0
   def opt_eq arg
0
     compare_op :==
0
@@ -277,7 +281,7 @@ class Pyasm
0
     store_name(id)
0
 
0
     # this is a bit redundant, but decompyle requires it
0
- if type == :method
0
+ if type == :method and @type == nil
0
       unless receiver
0
         load_name(id)
0
         load_name(:Kernel)

Comments

    No one has commented yet.