Class: Object

Inherits:
BasicObject
Includes:
RMasm::ObjectExtension
Defined in:
lib/rmasm/core_override.rb

Instance Method Summary collapse

Methods included from RMasm::ObjectExtension

#__, #asm, #data, #db, #dd, #double, #dq, #dw, #extern, #float, #float2, #float3, #float4, #label, #section, #struct, #union, #use

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



196
197
198
199
200
201
202
203
204
# File 'lib/rmasm/core_override.rb', line 196

def method_missing(meth, *args)
  # Is the method name is in fact a data type that is declaring data?
  structure_found = RMasm::Data.try_declare_data(self, meth, *args)
  if structure_found.nil?
    # raise "Invalid constant or method [#{meth}]"
    rmasm_old_method_missing meth
  end
  structure_found
end

Instance Method Details

#is_primitive?Boolean

Helper global method, accessible from anywhere

Returns:

  • (Boolean)


152
153
154
155
# File 'lib/rmasm/core_override.rb', line 152

def is_primitive?
  return false if self.class != Class
  return self.ancestors.include?(RMasm::Primitive)
end

#is_register?Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/rmasm/core_override.rb', line 157

def is_register?
  return self.is_a?(RMasm::Register)
end

#is_struct?Boolean

Returns:

  • (Boolean)


161
162
163
164
# File 'lib/rmasm/core_override.rb', line 161

def is_struct?
  return false if self.class != Class
  return self.ancestors.include?(RMasm::Struct)
end

#rmasm_old_method_missingObject

Try to find a structure already defined in case of a method_missing (name starting with a non uppercase character) If this structure is found, than return it instead of an error



194
# File 'lib/rmasm/core_override.rb', line 194

alias :rmasm_old_method_missing :method_missing

#type_of?Boolean

Returns:

  • (Boolean)


166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/rmasm/core_override.rb', line 166

def type_of?
  if is_a?(Numeric)
    :numeric
  elsif is_a?(String)
    :string
  elsif is_a?(Symbol)
    :symbol
  elsif is_a?(Array)
    :array
  elsif is_a?(Hash)
    :hash
  elsif is_a?(RMasm::Modifier)
    :modifier
  elsif is_primitive?
    :primitive
  elsif is_struct?
    :struct
  elsif is_a?(RMasm::ExpressionElement)
    :expression
  elsif is_register?
    :register
  else
    :object
  end
end