Class: ElfUtils::Section::DebugLine::LineNumberProgram::StateMachine::StateRegisters
- Inherits:
-
Struct
- Object
- Struct
- ElfUtils::Section::DebugLine::LineNumberProgram::StateMachine::StateRegisters
- Defined in:
- lib/elf_utils/section/debug_line/line_number_program/state_machine.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#basic_block ⇒ Object
Returns the value of attribute basic_block.
-
#column ⇒ Object
Returns the value of attribute column.
-
#discriminator ⇒ Object
Returns the value of attribute discriminator.
-
#end_sequence ⇒ Object
Returns the value of attribute end_sequence.
-
#epilogue_begin ⇒ Object
Returns the value of attribute epilogue_begin.
-
#file ⇒ Object
Returns the value of attribute file.
-
#is_stmt ⇒ Object
Returns the value of attribute is_stmt.
-
#isa ⇒ Object
Returns the value of attribute isa.
-
#line ⇒ Object
Returns the value of attribute line.
-
#op_index ⇒ Object
Returns the value of attribute op_index.
-
#prologue_end ⇒ Object
Returns the value of attribute prologue_end.
Instance Method Summary collapse
-
#advance(operation_advance) ⇒ Object
advance ‘address` & `op_index` by the provided `operation_advance`.
- #flags ⇒ Object
-
#initialize(args) ⇒ StateRegisters
constructor
A new instance of StateRegisters.
-
#reset ⇒ Object
reset the registers to their initial values.
- #to_s ⇒ Object
Constructor Details
#initialize(args) ⇒ StateRegisters
Returns a new instance of StateRegisters.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 13 def initialize(args) # save off values we need for `#advance` @maximum_operations_per_instruction = args.delete(:maximum_operations_per_instruction) @minimum_instruction_length = args.delete(:minimum_instruction_length) # add the hard-coded defaults args.merge!( address: 0, op_index: 0, file: 1, line: 1, column: 0, basic_block: false, end_sequence: false, prologue_end: false, epilogue_begin: false, isa: 0, discriminator: 0 ) # save off the initial values to support `#reset` @initial_values = args super end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def address @address end |
#basic_block ⇒ Object
Returns the value of attribute basic_block
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def basic_block @basic_block end |
#column ⇒ Object
Returns the value of attribute column
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def column @column end |
#discriminator ⇒ Object
Returns the value of attribute discriminator
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def discriminator @discriminator end |
#end_sequence ⇒ Object
Returns the value of attribute end_sequence
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def end_sequence @end_sequence end |
#epilogue_begin ⇒ Object
Returns the value of attribute epilogue_begin
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def epilogue_begin @epilogue_begin end |
#file ⇒ Object
Returns the value of attribute file
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def file @file end |
#is_stmt ⇒ Object
Returns the value of attribute is_stmt
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def is_stmt @is_stmt end |
#isa ⇒ Object
Returns the value of attribute isa
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def isa @isa end |
#line ⇒ Object
Returns the value of attribute line
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def line @line end |
#op_index ⇒ Object
Returns the value of attribute op_index
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def op_index @op_index end |
#prologue_end ⇒ Object
Returns the value of attribute prologue_end
10 11 12 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 10 def prologue_end @prologue_end end |
Instance Method Details
#advance(operation_advance) ⇒ Object
advance ‘address` & `op_index` by the provided `operation_advance`
40 41 42 43 44 45 46 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 40 def advance(operation_advance) self.address += @minimum_instruction_length * ((op_index + operation_advance) / @maximum_operations_per_instruction) self.op_index = (op_index + operation_advance) % @maximum_operations_per_instruction end |
#flags ⇒ Object
53 54 55 56 57 58 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 53 def flags flags = [] %i[is_stmt basic_block end_sequence prologue_end epilogue_begin] .each { |f| flags << f if send(f) } flags end |
#reset ⇒ Object
reset the registers to their initial values
49 50 51 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 49 def reset @initial_values.each { |k, v| self[k] = v } end |
#to_s ⇒ Object
60 61 62 63 64 |
# File 'lib/elf_utils/section/debug_line/line_number_program/state_machine.rb', line 60 def to_s "0x%016x %6d %6d %6d %3d %13d %s" % [ address, line, column, file, isa, discriminator, flags.join(" ") ] end |