Class: Module
Constant Summary collapse
- @@asm =
[]
Instance Method Summary collapse
Instance Method Details
#defasm(name, *args, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/wilson.rb', line 35 def defasm name, *args, &block asm = Wilson::MachineCodeX86.new asm.ebp.push # asm.esi.push # TODO? # asm.edi.push asm.ebp.mov asm.esp size = asm.stream.size asm.instance_eval(&block) if asm.stream.size == size # return nil warn "returning nil for #{self}##{name}" asm.eax.mov 4 end # asm.edi.pop # asm.esi.pop # asm.ebp.pop asm.leave asm.ret code = asm.stream.pack("C*") @@asm << code Ruby.rb_define_method self, name.to_s, code, 0 end |