Class: Fisk::Helpers::JITBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/fisk/helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(memory) ⇒ JITBuffer

Returns a new instance of JITBuffer.



54
55
56
57
# File 'lib/fisk/helpers.rb', line 54

def initialize memory
  @memory = memory
  @pos = 0
end

Instance Attribute Details

#memoryObject (readonly)

Returns the value of attribute memory.



52
53
54
# File 'lib/fisk/helpers.rb', line 52

def memory
  @memory
end

#posObject (readonly)

Returns the value of attribute pos.



52
53
54
# File 'lib/fisk/helpers.rb', line 52

def pos
  @pos
end

Instance Method Details

#putc(byte) ⇒ Object



59
60
61
62
# File 'lib/fisk/helpers.rb', line 59

def putc byte
  @memory[@pos] = byte
  @pos += 1
end

#seek(pos, whence = IO::SEEK_SET) ⇒ Object

Raises:

  • (NotImplementedError)


64
65
66
67
68
69
# File 'lib/fisk/helpers.rb', line 64

def seek pos, whence = IO::SEEK_SET
  raise NotImplementedError if whence != IO::SEEK_SET

  @pos = pos
  self
end

#to_function(params, ret) ⇒ Object



71
72
73
# File 'lib/fisk/helpers.rb', line 71

def to_function params, ret
  Fiddle::Function.new memory.to_i, params, ret
end