Method: HDLRuby::Viz::Node#to_s

Defined in:
lib/HDLRuby/hruby_viz.rb

#to_s(spc = "") ⇒ Object

Convert to a string.



3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
# File 'lib/HDLRuby/hruby_viz.rb', line 3092

def to_s(spc = "")
  case type
  when :assign
    return spc + @branches[0].to_s + " <= "  + @branches[1].to_s
  when :if
    res = spc + "if " + @branches[0].to_s
    return res
  when :case
    res = spc + "case " + @branches[0].to_s + "==" + @branches[1].to_s
    return res
  when :wait
    return spc + "wait(#{@branches[0].to_s})"
  when :repeat
    res = spc + "repeat " + @branches[0].to_s
    return res
  when :terminate
    return "terminate"
  when :value, :delay, :string
    return self.name
  when :print
    return spc + "print(#{@branches.map {|b| b.to_s}.join(",")})"
  when :cast
    return spc + "(" + self.name + ")" + "(" + branches[0].to_s + ")"
  when :concat
    return spc + "concat(" +@branches.map {|b| b.to_s }.join(",") + ")"
  when :[]
    if @branches.size == 2 then
      return spc + @branches[0].to_s + "[" + @branches[1].to_s + "]"
    else
      return spc + @branches[0].to_s + "[" +
        @branches[1].to_s + ".." + @branches[2].to_s + "]"
    end
  when :"." 
    if @branches[0] then
      return spc + @branches[0].to_s + "." + self.name
    else
      return spc + self.name
    end
  else
    case(@branches.size)
    when 0
      return spc + type.to_s
    when 1
      return spc + "(" + HDLRuby::Viz.to_svg_text(type.to_s) + 
        @branches[0].to_s + ")"
    when 2
      return spc + "(" + @branches[0].to_s + 
        HDLRuby::Viz.to_svg_text(type.to_s) +
        @branches[1].to_s + ")"
    else
      return spc + type.to_s + "(" + @branches.join(",") + ")"
    end
  end
end