Class: RMasm::Struct::Field

Inherits:
Object show all
Defined in:
lib/rmasm/struct.rb

Overview

Field inside a struct

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, name, array_size = nil) ⇒ Field

Returns a new instance of Field.



153
154
155
156
157
158
# File 'lib/rmasm/struct.rb', line 153

def initialize(type, name, array_size = nil)
  @type = type
  @array_size = array_size
  @name = name
  @offset = 0
end

Instance Attribute Details

#array_sizeObject (readonly)

Returns the value of attribute array_size.



151
152
153
# File 'lib/rmasm/struct.rb', line 151

def array_size
  @array_size
end

#nameObject (readonly)

Returns the value of attribute name.



151
152
153
# File 'lib/rmasm/struct.rb', line 151

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



150
151
152
# File 'lib/rmasm/struct.rb', line 150

def offset
  @offset
end

#typeObject (readonly)

Returns the value of attribute type.



151
152
153
# File 'lib/rmasm/struct.rb', line 151

def type
  @type
end

Instance Method Details

#sizeofObject



160
161
162
163
# File 'lib/rmasm/struct.rb', line 160

def sizeof()
  return (@array_size * @type.sizeof) if !@array_size.nil?
  @type.sizeof
end

#to_sObject



165
166
167
# File 'lib/rmasm/struct.rb', line 165

def to_s()
  "Field type=[#{@type}] name=#{@name} size_of_field=#{sizeof} offset=#{@offset} array=#{@array_size}"
end