Module: Convinius::ASM

Extended by:
ASM
Included in:
ASM
Defined in:
lib/convinius/asm.rb

Instance Method Summary collapse

Instance Method Details

#asm(file = "(asm)", line = 1, method = :call, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/convinius/asm.rb', line 5

def asm(file = "(asm)", line = 1, method = :call, &block)
  g = Rubinius::Generator.new
  g.name = method.to_sym
  g.file = file.to_sym
  g.set_line line

  g.required_args = 0
  g.total_args = 0
  g.splat_index = nil

  g.local_count = 0
  g.local_names = []

  block.arity > 0 ? yield(g) : g.instance_eval(&block)

  g.ret
  g.close

  g.encode
  cm = g.package Rubinius::CompiledMethod
  puts cm.decode if $DEBUG

  code = Object.new
  ss = Rubinius::StaticScope.new Object
  Rubinius.attach_method g.name, cm, ss, code

  code
end