Class: LibFST::Reader::Scope
- Inherits:
-
Object
- Object
- LibFST::Reader::Scope
- Defined in:
- lib/libfst/reader.rb,
ext/libfst_rb.c
Overview
A Scope corresponds to a design element
Instance Attribute Summary collapse
- #attributes ⇒ Array<Attribute>
- #children ⇒ Array<Scope> readonly
- #component ⇒ String? readonly
- #name ⇒ String readonly
- #parent ⇒ Scope?
-
#type ⇒ Symbol
readonly
Either
:vcd_module,:vcd_task,:vcd_function,:vcd_begin,:vcd_fork,:vcd_generate,:vcd_struct,:vcd_union,:vcd_class,:vcd_interface,:vcd_package,:vcd_program,:vhdl_architecture,:vhdl_procedure,:vhdl_function,:vhdl_record,:vhdl_process,:vhdl_block,:vhdl_for_generate,:vhdl_if_generate,:vhdl_generateor:vhdl_package. - #variables ⇒ Array<Variable> readonly
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Array<Attribute>
146 147 148 |
# File 'lib/libfst/reader.rb', line 146 def attributes @attributes end |
#children ⇒ Array<Scope> (readonly)
148 149 150 |
# File 'lib/libfst/reader.rb', line 148 def children @children end |
#component ⇒ String? (readonly)
144 145 146 |
# File 'lib/libfst/reader.rb', line 144 def component @component end |
#name ⇒ String (readonly)
143 144 145 |
# File 'lib/libfst/reader.rb', line 143 def name @name end |
#type ⇒ Symbol (readonly)
Returns Either :vcd_module, :vcd_task, :vcd_function, :vcd_begin, :vcd_fork, :vcd_generate, :vcd_struct, :vcd_union, :vcd_class, :vcd_interface, :vcd_package, :vcd_program, :vhdl_architecture, :vhdl_procedure, :vhdl_function, :vhdl_record, :vhdl_process, :vhdl_block, :vhdl_for_generate, :vhdl_if_generate, :vhdl_generate or :vhdl_package.
142 143 144 |
# File 'lib/libfst/reader.rb', line 142 def type @type end |
#variables ⇒ Array<Variable> (readonly)
145 146 147 |
# File 'lib/libfst/reader.rb', line 145 def variables @variables end |
Instance Method Details
#path ⇒ String
162 163 164 165 166 167 168 169 170 171 |
# File 'lib/libfst/reader.rb', line 162 def path return @path if @path s = self p = '' until s.nil? p = "/#{s.name}#{p}" s = s.parent end @path = p end |
#to_s ⇒ String
174 175 176 |
# File 'lib/libfst/reader.rb', line 174 def to_s "<#{self.class.name} #{path}, type: #{@type}, component: \"#{@component}\">" end |
#tree ⇒ String
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/libfst/reader.rb', line 180 def tree(prefix = '', last: true, first: true) str = prefix + (first ? '' : (last ? '└─ ' : '├─ ')) str += "\e[34;1m#{@name}\e[0m (#{@type})\n" prefix += (first ? '' : (last ? ' ' : '│ ')) mxvarnamelen = ([0] + @variables.collect{|v| v.name.length}).max mxlenlen = ([0] + @variables.collect { |v| v.length == 0 ? 0 : v.length.to_s.length }).max @variables.each_with_index do |v, i| l = (@children.empty? and (i+1 == @variables.length)) str += prefix + (l ? '└─ ' : '├─ ') + v.name + ' '*(mxvarnamelen+1-v.name.length) str += case v.direction when :input then ' I ' when :output then ' O ' when :inout then 'IO ' else ' ' end str += (v.length > 0 ? v.length.to_s : '').rjust(mxlenlen) str += " #{v.type}\n" end @children.each_with_index do |c, i| str += c.tree(prefix, (i+1 == @children.length), false) end str end |