Class: RepeatJoinPlugin
- Inherits:
-
CellPlugin
- Object
- Node
- Plugin
- CellPlugin
- RepeatJoinPlugin
- Defined in:
- lib/tecsgen/plugin/RepeatJoinPlugin.rb
Overview
TECS Generator
Generator for TOPPERS Embedded Component System
Copyright (C) 2015-2018 by TOPPERS Project
–
++
Constant Summary collapse
- RepeatJoinPluginArgProc =
{ "count" => Proc.new {|obj, rhs| obj.set_count rhs } }
Constants inherited from Plugin
Instance Method Summary collapse
-
#initialize(cell, option) ⇒ RepeatJoinPlugin
constructor
A new instance of RepeatJoinPlugin.
-
#set_count(rhs) ⇒ Object
count オプションの解析.
Methods inherited from CellPlugin
Methods inherited from Plugin
#cdl_error, #check_plugin_arg, #gen_cdl_file, #gen_ep_func?, #gen_postamble, #gen_preamble, #new_cell, #parse_plugin_arg, #print_msg, #set_locale, #set_silent
Methods inherited from Node
#cdl_error, #cdl_error2, #cdl_error3, #cdl_info, #cdl_info2, #cdl_warning, #cdl_warning2, #get_locale, #locale_str, #set_locale
Constructor Details
#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 |
Instance Method Details
#set_count(rhs) ⇒ Object
count オプションの解析
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/tecsgen/plugin/RepeatJoinPlugin.rb', line 115 def set_count(rhs) if rhs =~ /\A\d+\z/ @count = rhs.to_i else nsp = NamespacePath.new(rhs.to_sym, true) expr = Expression.create_single_identifier(nsp, nil) res = expr.eval_const(nil) if res.nil? cdl_error("count value ($1): not single identifier or integer number", rhs.to_s) @count = 0 else @count = res end end end |