Method: RepeatJoinPlugin#initialize

Defined in:
lib/tecsgen/plugin/RepeatJoinPlugin.rb

#initialize(cell, option) ⇒ RepeatJoinPlugin

Returns a new instance of RepeatJoinPlugin.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/tecsgen/plugin/RepeatJoinPlugin.rb', line 45

def initialize(cell, option)
  super
  print "RepeatJoinPlugin: #{@cell.get_name}\n"
  # cell.show_tree 0
  @plugin_arg_check_proc_tab = RepeatJoinPluginArgProc
  parse_plugin_arg

  @cell.get_join_list.get_items.each{|j|
    # print "Join: #{j.get_name} = #{j.get_rhs.to_s}\n"

    # Join の右辺を解析
    ret = j.get_rhs.analyze_cell_join_expression
    if ret.nil?
      next
    end
    rhs_nsp = ret[0]
    rhs_subscript = ret[1]
    rhs_port_name = ret[2]

    # 呼び口配列で、添数が 0 の場合にのみカウントアップさせる
    if j.get_subscript == 0
      rhs_name = rhs_nsp.get_name.to_s
      if rhs_name =~ /(.*[^0-9])([0-9]+)\z/
        b_rhs_name_count = true
        rhs_name = $1
        n_digits = $2.length
        rhs_count_base = $2.to_i
      else
        b_rhs_name_count = false
        rhs_count_base = 0
      end

      if rhs_subscript && rhs_subscript == 0
        b_rhs_subscript_count = true
      else
        b_rhs_subscript_count = false
      end

      count = 1
      while count < @count
        count_str = (count + rhs_count_base).to_s

        if b_rhs_subscript_count
          rhs_subscript = count
        end

        if b_rhs_name_count
          if n_digits - count_str.length > 0
            leading_zero = "0" * (n_digits - count_str.length)
          else
            leading_zero = ""
          end

          rhs_name_real = rhs_name + leading_zero + count_str
        else
          rhs_name_real = rhs_name
        end
        rhs_nsp2 = rhs_nsp.change_name_clone rhs_name_real.to_sym

        rhs = Expression.create_cell_join_expression(rhs_nsp2, rhs_subscript, rhs_port_name)
        j2 = Join.new(j.get_name, count, rhs)
        cell.new_join j2

        count += 1
      end
    end
  }
end