Class: RegularExpression::Compiler::X86::Compiled
- Inherits:
-
Object
- Object
- RegularExpression::Compiler::X86::Compiled
- Defined in:
- lib/regular_expression/compiler/x86.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
Instance Method Summary collapse
- #disasm ⇒ Object
-
#initialize(buffer) ⇒ Compiled
constructor
A new instance of Compiled.
- #to_proc ⇒ Object
Constructor Details
#initialize(buffer) ⇒ Compiled
Returns a new instance of Compiled.
9 10 11 |
# File 'lib/regular_expression/compiler/x86.rb', line 9 def initialize(buffer) @buffer = buffer end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
7 8 9 |
# File 'lib/regular_expression/compiler/x86.rb', line 7 def buffer @buffer end |
Instance Method Details
#disasm ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/regular_expression/compiler/x86.rb', line 13 def disasm output = StringIO.new crabstone = Crabstone::Disassembler.new(Crabstone::ARCH_X86, Crabstone::MODE_64) crabstone.disasm(buffer.memory.to_s(buffer.pos), buffer.memory.to_i).each do |insn| output.printf( "0x%<address>x:\t%<instruction>s\t%<details>s\n", address: insn.address, instruction: insn.mnemonic, details: insn.op_str ) end output.string end |
#to_proc ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/regular_expression/compiler/x86.rb', line 29 def to_proc function = buffer.to_function([Fiddle::TYPE_VOIDP, Fiddle::TYPE_SIZE_T], Fiddle::TYPE_SIZE_T) lambda do |string| value = function.call(string, string.length) value if value != string.length + 1 end end |