Method: HDLRuby::Viz::Node#number_statements
- Defined in:
- lib/HDLRuby/hruby_viz.rb
#number_statements ⇒ Object
Get the number of statements within and from current node.
3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 |
# File 'lib/HDLRuby/hruby_viz.rb', line 3164 def number_statements # puts "number_statements from #{self.name} (#{self.type})" case self.type when :par, :seq # Recurse on branch. snum = @branches[0].number_statements when :if, :repeat # Recurse on the statement branches. snum = @branches[1..-1].reduce(1) do |sum,branch| sum + branch.number_statements end when :case # Recurse on the statement branches. snum = @branches[2..-1].reduce(1) do |sum,branch| sum + branch.number_statements end else # Other cases: count one. snum = 1 end # And recurse on the successor. snum += self.successor.number_statements if self.successor return snum end |