Class: Raudi::Source::Controller

Inherits:
Base
  • Object
show all
Includes:
Interrupt
Defined in:
lib/raudi/source/controller.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#source_text

Instance Method Summary collapse

Methods included from Interrupt

#allow_interrupt, #generate_interrupts, #interrupt_block, #vector_name

Methods inherited from Base

#code_line, #code_lines, #new_line, #reset_source_text

Methods included from Variable

#generate_variable

Methods included from Function

#function_arguments, #function_block, #generate_function_header, #generate_result

Methods included from Block

#block_in, #block_out, #code_block, #indent_count, #indent_count=, #indent_line, #reset_indent_count

Methods included from BitOperations

#clear_register, #join_bits, #write_register

Methods included from Action

#insert_action

Constructor Details

#initialize(controller) ⇒ Controller

Returns a new instance of Controller.



15
16
17
# File 'lib/raudi/source/controller.rb', line 15

def initialize(controller)
  self.controller = controller
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



13
14
15
# File 'lib/raudi/source/controller.rb', line 13

def controller
  @controller
end

Instance Method Details

#generate_headersObject



19
20
21
22
23
24
# File 'lib/raudi/source/controller.rb', line 19

def generate_headers
  controller.headers.each do |name|
    code_line "#include <#{name}.h>", skip_semicolon: true
  end
  new_line
end

#to_cObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/raudi/source/controller.rb', line 26

def to_c
  generate_headers
  generate_interrupts

  function_block(:main) do
    generate_config
    insert_action :setup
    allow_interrupt
    code_block('while(1)') do
      insert_action :main
    end
  end

  source_text
end