Module: RgGen::Core::Base::ComponentLayerExtension::RegisterFile

Includes:
Common
Defined in:
lib/rggen/core/base/component_layer_extension.rb

Instance Method Summary collapse

Methods included from Common

#bit_field?, #register?, #register_block?, #register_file?, #root?

Instance Method Details

#bit_fieldsObject



122
123
124
# File 'lib/rggen/core/base/component_layer_extension.rb', line 122

def bit_fields
  registers.flat_map(&:bit_fields)
end

#block_or_fileObject



90
91
92
# File 'lib/rggen/core/base/component_layer_extension.rb', line 90

def block_or_file
  parent
end

#files_and_registersObject



102
103
104
# File 'lib/rggen/core/base/component_layer_extension.rb', line 102

def files_and_registers
  children
end

#register_blockObject



94
95
96
# File 'lib/rggen/core/base/component_layer_extension.rb', line 94

def register_block
  parent.register_block? && parent || parent.register_block
end

#register_fileObject



98
99
100
# File 'lib/rggen/core/base/component_layer_extension.rb', line 98

def register_file
  parent.register_file? && parent || nil
end

#register_files(include_lower_layer = true) ⇒ Object



106
107
108
109
110
# File 'lib/rggen/core/base/component_layer_extension.rb', line 106

def register_files(include_lower_layer = true)
  files_and_registers
    .select(&:register_file?)
    .flat_map { |rf| [rf, *(include_lower_layer ? rf : nil)&.register_files] }
end

#registers(include_lower_layer = true) ⇒ Object



112
113
114
115
116
117
118
119
120
# File 'lib/rggen/core/base/component_layer_extension.rb', line 112

def registers(include_lower_layer = true)
  files_and_registers.flat_map do |file_or_register|
    if file_or_register.register?
      file_or_register
    else
      [*(include_lower_layer ? file_or_register : nil)&.registers]
    end
  end
end

#rootObject



86
87
88
# File 'lib/rggen/core/base/component_layer_extension.rb', line 86

def root
  register_block.root
end