Class: DTRToRust::InstructionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/instruction_handler.rb

Overview

This class is responsible for generating Rust code for a single instruction.

Instance Method Summary collapse

Constructor Details

#initialize(instruction) ⇒ InstructionHandler

Returns a new instance of InstructionHandler.



6
7
8
# File 'lib/instruction_handler.rb', line 6

def initialize(instruction)
  @instruction = instruction
end

Instance Method Details

#generate_rustObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/instruction_handler.rb', line 10

def generate_rust
  case @instruction[:instruction]
  when 'AddSymbols'
    handle_add_symbols
  when 'Return'
    handle_return
  else
    raise "Unknown instruction type: #{@instruction[:instruction]}"
  end
end