Class: Udb::InstructionSubtype::Opcode

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/udb/obj/instruction.rb

Direct Known Subclasses

Udb::Instruction::Opcode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, range)

Parameters:

  • name (String)
  • range (Range)


44
45
46
47
# File 'lib/udb/obj/instruction.rb', line 44

def initialize(name, range)
  @name = name
  @range = range
end

Instance Attribute Details

#nameString (readonly)

Returns:

  • (String)


38
39
40
# File 'lib/udb/obj/instruction.rb', line 38

def name
  @name
end

#rangeRange (readonly)

Returns:

  • (Range)


41
42
43
# File 'lib/udb/obj/instruction.rb', line 41

def range
  @range
end

Instance Method Details

#overlaps?(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


50
51
52
53
54
55
56
# File 'lib/udb/obj/instruction.rb', line 50

def overlaps?(other)
  if other.is_a?(Opcode)
    range.eql?(other.range) || range.cover?(other.range.first) || other.range.cover?(range.first)
  else
    other.location_bits.any? { |i| range.cover?(i)}
  end
end