Class: Udb::InterruptCode

Inherits:
TopLevelDatabaseObject show all
Extended by:
T::Sig
Includes:
Comparable, Code
Defined in:
lib/udb/obj/exception_code.rb

Overview

an asynchroncous interrupt code

Instance Attribute Summary

Attributes inherited from DatabaseObject

#arch, #data, #data_path, #long_name, #name

Instance Method Summary collapse

Methods included from Code

#display_name, #num, #var

Methods inherited from TopLevelDatabaseObject

create_json_schemer_resolver, #initialize, #key?, #keys

Methods inherited from DatabaseObject

#__source, #cfg_arch, #cfg_arch?, #clone, #defer, #defined_by_condition, #description, #initialize, #inspect, #kind, #source_line

Constructor Details

This class inherits a constructor from Udb::TopLevelDatabaseObject

Instance Method Details

#<=>(other) ⇒ Object



84
85
86
87
88
# File 'lib/udb/obj/exception_code.rb', line 84

def <=>(other)
  return nil unless T.cast(other, Object).is_a?(ExceptionCode)

  num <=> T.cast(other, ExceptionCode).num
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/udb/obj/exception_code.rb', line 91

def eql?(other)
  (self <=> other) == 0
end

#hashObject



96
# File 'lib/udb/obj/exception_code.rb', line 96

def hash = [ExceptionCode, num].hash

#validate(resolver) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/udb/obj/exception_code.rb', line 71

def validate(resolver)
  super(resolver)

  @arch.interrupt_codes.each do |code|
    next if code == self

    if num == code.num
      raise ValidationError, "Duplicate interrupt code #{num} for #{name}, #{code.name}"
    end
  end
end