Class: MrubyBridgeCellPlugin
- Inherits:
-
CellPlugin
- Object
- Node
- Plugin
- CellPlugin
- MrubyBridgeCellPlugin
- Defined in:
- lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb
Overview
celltype プラグインの共通の親クラス
Constant Summary collapse
- MrubyBridgePluginArgProc =
プラグイン引数名 => Proc
{ "ignoreUnsigned" => Proc.new {|obj, rhs| obj.set_ignoreUnsigned rhs }, "exclude_port" => Proc.new {|obj, rhs| obj.set_exclude_port rhs }, "exclude_port_func" => Proc.new {|obj, rhs| obj.set_exclude_port_func rhs }, "auto_exclude" => Proc.new {|obj, rhs| obj.set_auto_exclude rhs }, }
- @@b_gen_post_code_by_dependent =
true if gen_post_code is called by MrubyBridgeCelltypePlugin
false
- @@cell_list =
gen_cdl_file’ed list to avoid duplicate generation
{}
- @@signature_list =
{}
Constants inherited from Plugin
Class Method Summary collapse
-
.gen_post_code(file) ⇒ Object
後ろの CDL コードを生成 プラグインの後ろの CDL コードを生成 file:: File:.
- .gen_post_code_body(file) ⇒ Object
-
.set_gen_post_code_by_dependent ⇒ Object
by MrubyBridgeCelltypePlugin.
Instance Method Summary collapse
- #gen_cdl_file(file) ⇒ Object
-
#initialize(cell, option) ⇒ MrubyBridgeCellPlugin
constructor
CellPlugin# initialize cell:: Cell セル(インスタンス) このメソッドは、セルの構文解析が終わったところで呼び出される この段階では意味解析が終わっていない.
-
#set_auto_exclude(rhs) ⇒ Object
プラグイン引数 auto_exclude.
-
#set_exclude_port(rhs) ⇒ Object
プラグイン引数 exclude_port.
-
#set_exclude_port_func(rhs) ⇒ Object
プラグイン引数 exclude_port_func.
-
#set_ignoreUnsigned(rhs) ⇒ Object
プラグイン引数 ignoreUnsigned.
Methods inherited from Plugin
#cdl_error, #check_plugin_arg, #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) ⇒ MrubyBridgeCellPlugin
CellPlugin# initialize
- cell
-
Cell セル(インスタンス)
このメソッドは、セルの構文解析が終わったところで呼び出される この段階では意味解析が終わっていない
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 113 114 115 116 |
# File 'lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb', line 62 def initialize(cell, option) dbgPrint " #{self.class.name}: initialzie=#{cell.get_name} option=#{option}\n" super @cell = cell # option @b_ignoreUnsigned = false @exclude_port = [] @exclude_port_func = {} @b_auto_exclude = true # auto_exclude = true by default MrubyBridgeSignaturePlugin.set_gen_post_code_by_dependent @plugin_arg_str = CDLString.remove_dquote option # @plugin_arg_str = option.gsub( /\A"(.*)/, '\1' ) # 前後の "" を取り除く # @plugin_arg_str.sub!( /(.*)"\z/, '\1' ) @plugin_arg_list = {} dbgPrint "#{self.class.name}: initialzie: #{cell.get_name}\n" @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc parse_plugin_arg @port_list = {} # set @port_list before return ct = @cell.get_celltype return if ct.nil? # error case port_list = ct.get_port_list if @exclude_port.length > 0 # この実装では、存在しない port を指定されてもチェックできない # print "MRBBridgeCellPlugin: exclude list\n" port_list.each{|port| if !@exclude_port.include?(port.get_name.to_s) # print "MRBBridgeCellPlugin: #{port.get_name} included\n" @port_list[port] = "" else # print "MRBBridgeCellPlugin: #{port.get_name} excluded\n" end } else port_list.each{|port| @port_list[port] = "" } end if @exclude_port_func.length > 0 @port_list.each{|port, opt_str| delim = "" if @exclude_port_func.include?(port.get_name.to_s) @exclude_port_func[port.get_name.to_s].each{|func_name| opt_str += delim + "exclude=" + func_name delim = "," } end @port_list[port] = opt_str } end end |
Class Method Details
.gen_post_code(file) ⇒ Object
後ろの CDL コードを生成
プラグインの後ろの CDL コードを生成
- file
-
File:
179 180 181 182 183 184 |
# File 'lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb', line 179 def self.gen_post_code(file) dbgPrint "#{self.name}: gen_post_code\n" if !@@b_gen_post_code_by_dependent gen_post_code_body file end end |
.gen_post_code_body(file) ⇒ Object
192 193 194 195 196 197 |
# File 'lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb', line 192 def self.gen_post_code_body(file) # 複数のプラグインの post_code が一つのファイルに含まれるため、以下のような見出しをつけること # file.print "/* '#{self.class.name}' post code */\n" dbgPrint "#{self.name}: gen_post_code_body\n" MrubyBridgeSignaturePlugin.gen_post_code_body file end |
.set_gen_post_code_by_dependent ⇒ Object
by MrubyBridgeCelltypePlugin
186 187 188 189 190 |
# File 'lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb', line 186 def self.set_gen_post_code_by_dependent # by MrubyBridgeCelltypePlugin dbgPrint "#{self.name}: set_gen_post_code_by_dependent\n" @@b_gen_post_code_by_dependent = true MrubyBridgeSignaturePlugin.set_gen_post_code_by_dependent end |
Instance Method Details
#gen_cdl_file(file) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb', line 118 def gen_cdl_file(file) dbgPrint "#{self.class.name}: gen_cdl_file: #{@cell.get_name}\n" file.print <<EOT /* MrubyBridgeCellPlugin: generate for cell=#{@cell.get_name} */ EOT if @@cell_list[@cell] file.print <<EOT /* * generate for #{@cell.get_name} duplicate and ignored. * This might comes from generate for celltype. */ EOT cdl_info("MrubyBridgeCellPlugin: generate duplicate for cell '$1'", @cell.get_name) return end @@cell_list[@cell] = @cell @port_list.each{|port, opt_str| next if port.get_signature.nil? case port.get_signature.get_context when "task", "any" else next end if port.get_port_type == :ENTRY print " MrubyBridgeCellPlugin: [cell.port] #{@cell.get_name}.#{port.get_name} => [mruby instance] TECS::T#{port.get_signature.get_name}.new( '#{@cell.get_name}#{port.get_name}Bridge' ) \n" if @@signature_list[port.get_signature].nil? opt_str = "ignoreUnsigned=#{@b_ignoreUnsigned}, auto_exclude=#{@b_auto_exclude}, " + opt_str # p "opt_str=#{opt_str}" file.print <<EOT /* cell.port=#{@cell.get_name}.#{port.get_name} */ generate( MrubyBridgePlugin, #{port.get_signature.get_namespace_path}, "#{opt_str}" ); EOT @@signature_list[port.get_signature] = true end # mikan option nest = @cell.get_region.gen_region_str_pre file nest_str = " " * nest file.print <<EOT #{nest_str}/* BridgeCell */ #{nest_str}cell nMruby::t#{port.get_signature.get_name} #{@cell.get_name}#{port.get_name}Bridge { #{nest_str} cTECS = #{@cell.get_namespace_path}.#{port.get_name}; #{nest_str}}; EOT @cell.get_region.gen_region_str_post file end } end |
#set_auto_exclude(rhs) ⇒ Object
プラグイン引数 auto_exclude
254 255 256 257 258 259 260 261 262 263 |
# File 'lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb', line 254 def set_auto_exclude(rhs) # print "MrubyBridgeCellPlugin: auto_exclude=#{rhs}\n" if rhs == "false" @b_auto_exclude = false elsif rhs == "true" @b_auto_exclude = true # auto_exclude = true by default else cdl_warning("MRB9999 auto_exclude: unknown rhs value ignored. specify true or false") end end |
#set_exclude_port(rhs) ⇒ Object
プラグイン引数 exclude_port
207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb', line 207 def set_exclude_port(rhs) ports = rhs.split "," ct = @cell.get_celltype return if ct.nil? # error case ports.each{|rhs_port| obj = ct.find(rhs_port.to_sym) if (!obj.instance_of? Port) || obj.get_port_type != :ENTRY cdl_error("MRB9999 exclude_port '$1' not found or not entry in celltype '$2'", rhs_port, ct.get_name) else # print "MRBBridgeCellPlugin: exclude #{rhs_port}\n" @exclude_port << rhs_port end } end |
#set_exclude_port_func(rhs) ⇒ Object
プラグイン引数 exclude_port_func
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb', line 223 def set_exclude_port_func(rhs) port_funcs = rhs.split "," ct = @cell.get_celltype return if ct.nil? # error case port_funcs.each{|rhs_port_func| port_func = rhs_port_func.split "." if port_func.length != 2 cdl_error("MRB9999 exclude_port_func: '$1' not in 'port.func' form", rhs_port_func) end obj = ct.find(port_func[0].to_sym) if (!obj.instance_of? Port) || obj.get_port_type != :ENTRY cdl_error("MRB9999 exclude_port_func: port '$1' not found in celltype '$2'", rhs_port, ct.get_name) else signature = obj.get_signature next if signature.nil? # error case if signature.get_function_head port_func[1].to_sym # print "MRBBridgeCellPlugin: #{port_func[0]}.#{port_func[1]} exclude\n" if @exclude_port_func[port_func[0]] @exclude_port_func[port_func[0]] << port_func[1] else @exclude_port_func[port_func[0]] = [port_func[1]] end else cdl_error("MRB9999 exclude_port_func: func '$1' not found in port '$2' celltype $3", port_func[1], port_func[0], ct.get_name) end end } end |
#set_ignoreUnsigned(rhs) ⇒ Object
プラグイン引数 ignoreUnsigned
200 201 202 203 204 |
# File 'lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb', line 200 def set_ignoreUnsigned(rhs) if rhs == "true" || rhs.nil? @b_ignoreUnsigned = true end end |