Class: Ethereum::VM::CallData
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #extract32(i) ⇒ Object
- #extract_all ⇒ Object
- #extract_copy(mem, memstart, datastart, size) ⇒ Object
-
#initialize(parent_memory, offset = 0, size = nil) ⇒ CallData
constructor
A new instance of CallData.
Constructor Details
#initialize(parent_memory, offset = 0, size = nil) ⇒ CallData
Returns a new instance of CallData.
10 11 12 13 14 15 |
# File 'lib/ethereum/vm/call_data.rb', line 10 def initialize(parent_memory, offset=0, size=nil) @data = parent_memory @offset = offset @size = size || @data.size @rlimit = @offset + @size end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
8 9 10 |
# File 'lib/ethereum/vm/call_data.rb', line 8 def size @size end |
Instance Method Details
#extract32(i) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/ethereum/vm/call_data.rb', line 23 def extract32(i) return 0 if i >= @size right = [@offset+i+32, @rlimit].min o = @data.safe_slice(@offset+i...right) Utils.bytearray_to_int(o + [0]*(32-o.size)) end |
#extract_all ⇒ Object
17 18 19 20 21 |
# File 'lib/ethereum/vm/call_data.rb', line 17 def extract_all d = @data.safe_slice(@offset, @size) d += [0] * (@size - d.size) Utils.int_array_to_bytes(d) end |
#extract_copy(mem, memstart, datastart, size) ⇒ Object
31 32 33 34 35 |
# File 'lib/ethereum/vm/call_data.rb', line 31 def extract_copy(mem, memstart, datastart, size) size.times do |i| mem[memstart+i] = datastart+i < @size ? @data[@offset+datastart+i] : 0 end end |