Class: AVR::OpcodeDecoder::OperandParser

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/avr/opcode_decoder.rb

Constant Summary collapse

ProcType =
T.type_alias do
  T.proc.params(cpu: CPU, operands: Opcode::OperandValueHashType).returns(Opcode::OperandValueHashType)
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, parse_proc) ⇒ OperandParser

Returns a new instance of OperandParser.



101
102
103
104
# File 'lib/avr/opcode_decoder.rb', line 101

def initialize(pattern, parse_proc)
  @pattern = T.let(pattern.gsub(/[^01a-zA-Z_]/, ''), String)
  @parse_proc = T.let(parse_proc, OperandParser::ProcType)
end

Instance Attribute Details

#parse_procObject (readonly)

Returns the value of attribute parse_proc.



98
99
100
# File 'lib/avr/opcode_decoder.rb', line 98

def parse_proc
  @parse_proc
end

#patternObject (readonly)

Returns the value of attribute pattern.



91
92
93
# File 'lib/avr/opcode_decoder.rb', line 91

def pattern
  @pattern
end

Instance Method Details

#parse(cpu, operands) ⇒ Object



107
108
109
# File 'lib/avr/opcode_decoder.rb', line 107

def parse(cpu, operands)
  parse_proc.call(cpu, operands)
end