Class: Symbol

Inherits:
Object show all
Includes:
RMasm::ExpressionOperations, RMasm::SymbolExtension
Defined in:
lib/rmasm/core_override.rb

Overview

Override Symbols operations (+,*,-)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RMasm::SymbolExtension

#_, #__, #label

Methods included from RMasm::ExpressionOperations

#*, #+, #-, #/, #check_arg, #coerce

Class Method Details

.install_modifier_hookObject



25
26
27
28
29
30
31
# File 'lib/rmasm/core_override.rb', line 25

def self.install_modifier_hook()
  # Warning, need to check if [] is defined. 1.8.6 => Undefined, 1.9.1 => defined
  # If defined, we can perform an alias, otherwise, we just create the method
  define_method(:rmasm_array_square_hook, instance_method(:[])) if Symbol.method_defined?(:[])
  define_method(:[], instance_method(:array_modifier))
  define_method(:<<, instance_method(:inject_modifier))
end

.remove_modifier_hookObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/rmasm/core_override.rb', line 49

def self.remove_modifier_hook()
  # Warning, need to check the alias on the old [] is defined.
  # If defined, we can restore the original [] method from Symbol
  if Symbol.method_defined?(:rmasm_array_square_hook)
    define_method(:[], instance_method(:rmasm_array_square_hook))
  else
    undef_method(:[])
  end
  undef_method(:<<)
end

Instance Method Details

#array_modifier(*args) ⇒ Object



33
34
35
36
# File 'lib/rmasm/core_override.rb', line 33

def array_modifier(*args)
  # RMasmReport.error(:R0021, self) if ( args.length != 1 )
  RMasm::SymbolModifier.new(self, args)
end

#inject_modifier(arg) ⇒ Object



38
39
40
41
42
43
# File 'lib/rmasm/core_override.rb', line 38

def inject_modifier(arg)
  # 0 Size array
  value = RMasm::SymbolModifier.new(self, 0)
  value << arg
  value
end

#struct(*args, &block) ⇒ Object



45
46
47
# File 'lib/rmasm/core_override.rb', line 45

def struct(*args,&block)
  RMasm::Struct.rmasm_define_struct_by_block_binding(self, *args, &block)
end