- Timestamp:
- May 22, 2019, 10:03:37 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/generate.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2019 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 134 119 end 135 120 136 # celltype_private.h ãçæ121 # celltype_private.h を生成 137 122 138 123 class Namespace … … 141 126 142 127 begin 143 # root namespace ãªãã° makefile ãåºåãã(å 144 ¨ã»ã«ã¿ã¤ãã«é¢ãããã®ã ã) 145 # å 146 ã«åºåãã 128 # root namespace ならば makefile を出力する(全セルタイプに関わるものだけ) 129 # 先に出力する 147 130 if @name == "::" then 148 131 … … 159 142 160 143 dbgPrint "generating region: #{$generating_region.get_name} namespace=#{@name} gen_dir=#{$gen}\n" 161 # global_tecsgen.h (typedef, struct, const) ã®çæ144 # global_tecsgen.h (typedef, struct, const) の生成 162 145 gen_global_header 163 146 … … 171 154 end 172 155 173 # signature ã®ã³ã¼ããçæ156 # signature のコードを生成 174 157 @signature_list.each { |s| 175 158 s.generate 176 159 } 177 160 178 # celltype ã®ã³ã¼ããçæ161 # celltype のコードを生成 179 162 @celltype_list.each { |t| 180 163 t.generate 181 164 } 182 165 183 # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ166 # サブネームスペースのコードを生成 184 167 @namespace_list.each { |n| 185 168 n.generate … … 187 170 188 171 rescue => evar 189 # ããã¹ã¿ãã¯ãã¬ã¼ã¹ãåºãã¾ã§ãæéãããããããªãã°ã次ãã³ã¡ã³ãã¢ã¦ããã¦ã¿ãã¹ã172 # もしスタックトレースが出るまでい時間がかかるようならば、次をコメントアウトしてみるべし 190 173 cdl_error( "H1001 tecsgen: fatal internal error during code generation" ) 191 174 print_exception( evar ) … … 200 183 201 184 begin 202 # global_tecsgen.h (typedef, struct, const) ã®çµããã®ã¬ã¼ãã³ã¼ãçæ185 # global_tecsgen.h (typedef, struct, const) の終わりのガードコード生成 203 186 gen_global_header_post 204 187 205 # signature ã®ã³ã¼ããçæ188 # signature のコードを生成 206 189 @signature_list.each { |s| 207 190 s.generate_post 208 191 } 209 192 210 # celltype ã®ã³ã¼ããçæ193 # celltype のコードを生成 211 194 @celltype_list.each { |t| 212 195 t.generate_post 213 196 } 214 197 215 # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ198 # サブネームスペースのコードを生成 216 199 @namespace_list.each { |n| 217 200 n.generate_post … … 227 210 def gen_global_header 228 211 229 # global_tecs.h ã®çæ212 # global_tecs.h の生成 230 213 f = AppFile.open( "#{$gen}/global_tecsgen.#{$h_suffix}" ) 231 214 … … 233 216 print_note f 234 217 235 # ã¬ã¼ãã³ã¼ããåºå218 # ガードコードを出力 236 219 f.print <<EOT 237 220 #ifndef GLOBAL_TECSGEN_H … … 240 223 EOT 241 224 242 # import_C ã§æå®ãããããããã¡ã¤ã«ã® #include ãåºå225 # import_C で指定されたヘッダファイルの #include を出力 243 226 if Import_C.get_header_list2.length > 0 then 244 # ããã include ã®åºå227 # ヘッダ include の出力 245 228 f.printf TECSMsg.get( :IMP_comment ), "#_IMP_#" 246 229 Import_C.get_header_list2.each{ |h| … … 253 236 end 254 237 255 # typedef, struct, enum ãçæ238 # typedef, struct, enum を生成 256 239 @decl_list.each { |d| 257 240 258 # d 㯠Typedef, StructType, EnumType ã®ãããã241 # d は Typedef, StructType, EnumType のいずれか 259 242 if d.instance_of?( Typedef ) then 260 243 261 # Typedef ã®å ´åãdeclarator ã® @type ããCType ã§ãªãã244 # Typedef の場合、declarator の @type が CType でないか 262 245 if ! d.get_declarator.get_type.kind_of?( CType ) then 263 246 d.gen_gh f … … 265 248 elsif ! d.kind_of?( CType ) then 266 249 267 # CType ã§ã¯ãªã (StructType ã¾ãã¯EnumType)250 # CType ではない (StructType または EnumType) 268 251 d.gen_gh f 269 252 # else 270 # ããã«è©²å½ããã®ã¯CStructType, CEnumType253 # ここに該当するのは CStructType, CEnumType 271 254 end 272 255 } … … 297 280 end 298 281 299 # const ãçæmikan282 # const を生成 mikan 300 283 @const_decl_list.each { |d| 301 284 f.printf( "#define %-14s ((%s%s)%s)\n", d.get_global_name, … … 310 293 def gen_global_header_post 311 294 312 # global_tecs.h ãéã295 # global_tecs.h を開く 313 296 f = AppFile.open( "#{$gen}/global_tecsgen.#{$h_suffix}" ) 314 297 … … 324 307 end 325 308 326 #=== Makefile.tecsgen, Makefile.templ ã®åºå 327 # å 328 ¨ã»ã«ã¿ã¤ãåãåºåããé¨åãåºå 329 # ï¼æ¬ã¡ã½ãã㯠root namespace ã«å¯¾ãã¦å¼åºãï¼ 330 # åã 331 ã®ã»ã«ã¿ã¤ãã®ã¡ã¼ã¯ã«ã¼ã«ã¯ Celltype ã¯ã©ã¹ã§åºå 309 #=== Makefile.tecsgen, Makefile.templ の出力 310 # 全セルタイプ名を出力する部分を出力 311 # (本メソッドは root namespace に対して呼出す) 312 # 個々のセルタイプのメークルールは Celltype クラスで出力 332 313 def gen_makefile 333 314 gen_makefile_template … … 339 320 return if $generate_no_template 340 321 341 ### Makefile.templ ã®çæ322 ### Makefile.templ の生成 342 323 f = AppFile.open( "#{$gen}/Makefile.templ" ) 343 324 344 325 print_Makefile_note f 345 326 346 # Makefile ã®å¤æ°ã®åºå327 # Makefile の変数の出力 347 328 f.printf TECSMsg.get( :MVAR_comment ), "#_MVAR_#" 348 329 f.printf "# fixed variable (unchangeable by config or plugin)\n" 349 330 350 # TARGET ã®åºå (第ä¸å¼æ° $target ã« region åããã³ .exe ãä»å)331 # TARGET の出力 (第一引数 $target に region 名および .exe を付加) 351 332 target = $target 352 333 if $generating_region != @@root_namespace then 353 # å region ã®ãªã³ã¯ã¿ã¼ã²ããã®å ´å334 # 子 region のリンクターゲットの場合 354 335 target += "-#{$generating_region.get_global_name}" 355 336 end … … 433 414 EOT 434 415 435 # make ã«ã¼ã«ã®åºå416 # make ルールの出力 436 417 f.printf( TECSMsg.get( :MRUL_comment), "#_MRUL_#" ) 437 418 … … 461 442 f.print "-include $(GEN_DIR)/Makefile.tecsgen\n" 462 443 if $generating_region.get_n_cells != 0 then 463 # Makefile.depend ã®include444 # Makefile.depend の include 464 445 f.print "-include $(GEN_DIR)/Makefile.depend\n\n" 465 446 … … 471 452 f.print "\nsub_regions:$(TIMESTAMP)\n" 472 453 Region.get_link_roots.each {|region| 473 if region.get_global_name != "" then # Root region: ãã® Makefile èªèº«454 if region.get_global_name != "" then # Root region: この Makefile 自身 474 455 f.print "\tcd #{region.get_global_name}; make all\n" 475 456 end … … 478 459 end 479 460 480 # clean: ã¿ã¼ã²ãã461 # clean: ターゲット 481 462 f.print "clean :\n" 482 463 if $generating_region == @@root_namespace then 483 464 Region.get_link_roots.each {|region| 484 if region.get_global_name != "" then # Root region: ãã® Makefile èªèº«465 if region.get_global_name != "" then # Root region: この Makefile 自身 485 466 f.print "\tcd #{region.get_global_name}; make clean\n" 486 467 end … … 493 474 f.print "\n" 494 475 495 # tecs: ã¿ã¼ã²ãã476 # tecs: ターゲット 496 477 if $generating_region == @@root_namespace then 497 478 f.print "tecs : $(PRE_TECSGEN_TARGET) $(TIMESTAMP) $(POST_TECSGEN_TARGET)\n\n" … … 504 485 end 505 486 506 # tecsflow:, tcflow ã¿ã¼ã²ãã487 # tecsflow:, tcflow ターゲット 507 488 if $generating_region.get_n_cells != 0 || $generating_region == @@root_namespace then 508 489 f.print "##### TECSFlow targets #####\n" … … 561 542 562 543 def gen_makefile_tecsgen 563 ### Makefile.tecsgen ã®çæ544 ### Makefile.tecsgen の生成 564 545 f = AppFile.open( "#{$gen}/Makefile.tecsgen" ) 565 546 … … 658 639 domain_regions = nil 659 640 DomainType.get_domain_regions.each{ |dt, regions| 660 # domain_type ã¯ä¸ã¤ã®ãã¼ãã«ã¯ãä¸ã¤ãããªãã®ã§ããã®ã«ã¼ãã¯ãå¿ 661 ãä¸åããåããªã 662 ### mikan è¤æ°ã®ãã¼ãããããç°ãªã domain_type ãæå®ãããå¯è½æ§ã¯ãã 641 # domain_type は一つのノードには、一つしかないので、このループは、必ず一回しか回らない 642 ### mikan 複数のノードがあり、異なる domain_type が指定される可能性はある 663 643 domain_regions = regions 664 644 domain_type = dt … … 836 816 end 837 817 838 #=== ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå 839 #f:: FILE: åºåå 840 ãã¡ã¤ã« 841 #prepend:: string: åç½®æåå 842 #append:: string: å¾ç½®æåå 843 #b_plguin:: bool: plugin ã«ããçæãããã»ã«ã¿ã¤ããåºå 844 ##b_inline_only:: bool: true ãªãã° inline ã® entry port ã®ã¿ã®ã»ã«ã¿ã¤ããå«ãã 845 #b_inline_only_or_proc:: bool|Proc: true ãªãã° inline ã® entry port ã®ã¿ããã¤ã¤ã³ã¢ã¯ãã£ããªã»ã«ã¿ã¤ããå«ãã 846 # Proc ãªãã° Proc ãå®è¡ããçµæ true ãªãã°å«ãã 847 # namespace "::" ããå¼åºããã 818 #=== すべてのセルタイプの名前を出力 819 #f:: FILE: 出力先ファイル 820 #prepend:: string: 前置文字列 821 #append:: string: 後置文字列 822 #b_plguin:: bool: plugin により生成されたセルタイプを出力 823 ##b_inline_only:: bool: true ならば inline の entry port のみのセルタイプを含める 824 #b_inline_only_or_proc:: bool|Proc: true ならば inline の entry port のみ、かつインアクティブなセルタイプを含める 825 # Proc ならば Proc を実行した結果 true ならば含める 826 # namespace "::" から呼出される 848 827 def gen_celltype_names( f, prepend, append, b_plugin, b_inline_only_or_proc = true ) 849 828 dbgPrint "gen_celltype_names #{@name}\n" … … 865 844 end 866 845 867 #=== ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå846 #=== すべてのセルタイプの名前を出力 868 847 #region:: Region: 869 # gen_celltype_names ã¨gen_celltype_names_domain ã®ç¸éï¼ 870 # region ã domain_roots ã«å«ãå ´åãåºåããï¼ 871 # ã¾ãã¯ãregion ãå«ã¾ãªãããdomain_roots ãè¤æ°ãã¤ã«ã¼ããªã¼ã¸ã§ã³ã®å ´åãåºåããï¼ 872 # ãã以å¤ã¯ãgen_celltype_names ã®èª¬æãåç 873 § 848 # gen_celltype_names とgen_celltype_names_domain の相違: 849 # region を domain_roots に含む場合、出力する. 850 # または、region を含まないが、domain_roots が複数かつルートリージョンの場合、出力する. 851 # それ以外は、gen_celltype_names の説明を参照 874 852 def gen_celltype_names_domain( f, prepend, append, domain_type, region, b_plugin, b_inline_only = true ) 875 853 dbgPrint "gen_celltype_names #{@name}\n" … … 901 879 } 902 880 end 903 #== Namespace# ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå904 # ã»ã«ã¿ã¤ãã³ã¼ãã®ããã®åååºå905 # gen_celltype_names_domain 㨠gen_celltype_names_domain2 ã®ç¸é906 # ã»ã©ããä¸ã¤ã®ãªã¼ã¸ã§ã³ã«ããåºããªã907 # domain_roots ã1ã¤ã ãã§ãæå®ãªã¼ã¸ã§ã³ãå«ã908 # domain_roots ã2ã¤ä»¥ä¸ã§ãæå®ãªã¼ã¸ã§ã³ãã«ã¼ããªã¼ã¸ã§ã³909 # ã»ãã¡ã¤ã³åãä»å ããªã881 #== Namespace#すべてのセルタイプの名前を出力 882 # セルタイプコードのための名前出力 883 # gen_celltype_names_domain と gen_celltype_names_domain2 の相違 884 # ・どれか一つのリージョンにしか出さない 885 # domain_roots が1つだけで、指定リージョンを含む 886 # domain_roots が2つ以上で、指定リージョンがルートリージョン 887 # ・ドメイン名を付加しない 910 888 def gen_celltype_names_domain2( f, prepend, append, domain_type, region, b_plugin, b_inline_only = true ) 911 889 dbgPrint "gen_celltype_names #{@name}\n" … … 933 911 end 934 912 935 #=== Namespace# ãã¹ã¦ã®ã·ã°ããã£ããã©ã936 def travers_all_signature # ãããã¯å¼æ°{ |signature| }937 proc = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°913 #=== Namespace#すべてのシグニチャをたどる 914 def travers_all_signature # ブロック引数 { |signature| } 915 proc = Proc.new # このメソッドのブロック引数 938 916 @signature_list.each{ |sig| 939 917 proc.call sig … … 952 930 end 953 931 954 #=== Namespace# ãã¹ã¦ã®ã»ã«ã¿ã¤ãããã©ã955 def travers_all_celltype # ãããã¯å¼æ°{ |celltype| }956 proc = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°932 #=== Namespace#すべてのセルタイプをたどる 933 def travers_all_celltype # ブロック引数 { |celltype| } 934 proc = Proc.new # このメソッドのブロック引数 957 935 @celltype_list.each{ |ct| 958 936 proc.call ct … … 1078 1056 def gen_sh_func_tab f 1079 1057 1080 # ã·ã°ããã£ãã£ã¹ã¯ãªãã¿ã®åºå1058 # シグニチャディスクリプタの出力 1081 1059 f.printf TECSMsg.get(:SD_comment), "#_SD_#" 1082 1060 f.print "struct tag_#{@global_name}_VDES {\n" … … 1084 1062 f.print "};\n\n" 1085 1063 1086 # ã·ã°ããã£é¢æ°ãã¼ãã«ã®åºå1064 # シグニチャ関数テーブルの出力 1087 1065 f.printf TECSMsg.get(:SFT_comment), "#_SFT_#" 1088 1066 f.print( "struct tag_#{@global_name}_VMT {\n" ) … … 1099 1077 len = items.length 1100 1078 else 1101 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å1079 # ここで nil になるのは、引数なしの時に void がなかった場合 1102 1080 items = [] 1103 1081 len = 0 … … 1129 1107 end 1130 1108 1131 #=== Signature# é¢æ°ã® ID ã® define ãåºå1109 #=== Signature# 関数の ID の define を出力 1132 1110 def gen_sh_func_id f 1133 1111 f.print "/* function id */\n" … … 1148 1126 def generate 1149 1127 1150 if need_generate? # ã»ã«ã®ãªãã»ã«ã¿ã¤ãã¯çæããªã1128 if need_generate? # セルのないセルタイプは生成しない 1151 1129 1152 1130 generate_private_header … … 1159 1137 generate_makefile 1160 1138 1161 elsif $generate_all_template # ãã³ãã¬ã¼ãã³ã¼ãçæãªãã·ã§ã³1139 elsif $generate_all_template # テンプレートコード生成オプション 1162 1140 1163 1141 generate_template_code 1164 1142 generate_inline_template_code 1165 1143 1166 # generate_makefile_template 㯠Makefile ã«è¿½è¨ãããã®ã ãããå¼ã³åºããªã1144 # generate_makefile_template は Makefile に追記するものだから、呼び出さない 1167 1145 1168 1146 end … … 1171 1149 1172 1150 def generate_post 1173 return if ! need_generate? # ã»ã«ã®ãªãã»ã«ã¿ã¤ãã¯çæããªã1151 return if ! need_generate? # セルのないセルタイプは生成しない 1174 1152 1175 1153 generate_private_header_post … … 1191 1169 gen_ph_cell_cb_type f 1192 1170 gen_ph_INIB_as_CB f 1193 gen_ph_extern_cell f # ã»ã«ã¿ã¤ãã°ã«ã³ã¼ã以å¤ã¯åç 1194 §ããªã 1195 gen_ph_typedef_idx f # mikan åç 1196 §ãããã®ãã§ãã¦ããªã 1171 gen_ph_extern_cell f # セルタイプグルコード以外は参照しない 1172 gen_ph_typedef_idx f # mikan 参照するものができていない 1197 1173 gen_ph_ep_fun_prototype f 1198 1174 end_extern_C f … … 1202 1178 1203 1179 if @n_entry_port_inline == 0 then 1204 # inline ããªããã° CB_TYPE_ONLY ã¨ãã1205 # inline ããã®å ´åããã£ãã define ãã¦ããã¦ãå¾ã§ãã¹ã¦ undef ãã1180 # inline がなければ CB_TYPE_ONLY とする 1181 # inline ありの場合、いったん define しておいて、後ですべて undef する 1206 1182 ifndef_cb_type_only f 1207 1183 end … … 1229 1205 # gen_ph_cell_cb_type f 1230 1206 # gen_ph_INIB_as_CB f 1231 # gen_ph_extern_cell f # ã»ã«ã¿ã¤ãã°ã«ã³ã¼ã以å¤ã¯åç 1232 §ããªã 1233 # gen_ph_typedef_idx f # mikan åç 1234 §ãããã®ãã§ãã¦ããªã 1207 # gen_ph_extern_cell f # セルタイプグルコード以外は参照しない 1208 # gen_ph_typedef_idx f # mikan 参照するものができていない 1235 1209 # gen_ph_ep_fun_prototype f 1236 1210 gen_ph_ep_skel_prototype f 1237 1211 1238 #--- CB_TYPE_ONLY ã®å ´åãref_desc, set_desc é¢æ°ã¯å«ããªã (ãã¯ãåç 1239 §ãããã) 1212 #--- CB_TYPE_ONLY の場合、ref_desc, set_desc 関数は含めない (マクロ参照するため) 1240 1213 if @n_entry_port_inline == 0 then 1241 1214 ifndef_cb_type_only f … … 1249 1222 endif_macro_only f 1250 1223 1251 # ç縮形ãªã©ã®ãã¯ãåºå1224 # 短縮形などのマクロ出力 1252 1225 if @n_entry_port_inline == 0 then 1253 1226 ifndef_cb_type_only f … … 1261 1234 gen_ph_test_optional_call_port_abbrev f 1262 1235 gen_ph_ep_fun_macro f if @n_entry_port > 0 1263 gen_ph_foreach_cell f # FOREACH ãã¯ãã®åºå1264 gen_ph_cb_initialize_macro f # CB åæåãã¯ãã®åºåï¼æ¶è²»ããªãã®ã§ ram_initializer ãã©ã°ã«é¢ãããåºå1236 gen_ph_foreach_cell f # FOREACH マクロの出力 1237 gen_ph_cb_initialize_macro f # CB 初期化マクロの出力.消費しないので ram_initializer フラグに関わらず出力 1265 1238 gen_ph_dealloc_code f, "" 1266 1239 gen_ph_dealloc_code f, "_RESET" … … 1309 1282 next if p.get_port_type != :CALL 1310 1283 1311 # is_...joined 㯠omit ããã±ã¼ã¹ã§ãåºåããããããomit ãæ¤æ»ããåã«åºå1284 # is_...joined は omit するケースでも出力されるため、omit を検査する前に出力 1312 1285 if p.is_optional? then 1313 1286 f.print( "#undef is_#{p.get_name}_joined\n" ) … … 1353 1326 end 1354 1327 1355 #=== CELLTYPE_tecsgen.c ãçæ1328 #=== CELLTYPE_tecsgen.c を生成 1356 1329 def generate_cell_code 1357 1330 fs = { } … … 1388 1361 end 1389 1362 1390 # ãã¹ã¦ã® _tecsgen.c ã«åºå1363 # すべての _tecsgen.c に出力 1391 1364 print_note f 1392 1365 gen_cell_private_header f … … 1394 1367 gen_cell_ep_des_type f 1395 1368 1396 # ãã¹ã¦ã® _tecsgen.c ã«åºå1369 # すべての _tecsgen.c に出力 1397 1370 fs.each{ |r,f2| 1398 1371 if f == f2 then … … 1405 1378 } 1406 1379 1407 # ä¸ã¤ã® _tecsgen.c ã«åºå1380 # 一つの _tecsgen.c に出力 1408 1381 gen_cell_skel_fun f 1409 1382 gen_cell_fun_table f 1410 1383 gen_cell_var_init f 1411 1384 1412 # ã»ã«ãã¨ã« _tecsgen.c ã«åºå1385 # セルごとに _tecsgen.c に出力 1413 1386 gen_cell_ep_vdes fs 1414 1387 gen_cell_ep_vdes_array fs 1415 gen_cell_cb_out_init fs # INITIALIZE_CB ã§åç 1416 §ããããã ram_initializer=false ã§ãæ¶ããªã 1388 gen_cell_cb_out_init fs # INITIALIZE_CB で参照されるため ram_initializer=false でも消せない 1417 1389 gen_cell_cb fs 1418 1390 gen_cell_extern_mt fs 1419 1391 gen_cell_ep_des fs 1420 1392 1421 # ä¸ã¤ã® _tecsgen.c ã«åºå1393 # 一つの _tecsgen.c に出力 1422 1394 gen_cell_cb_tab f 1423 1395 if $ram_initializer then … … 1481 1453 1482 1454 def gen_ph_include f 1483 # ã©ã³ã¿ã¤ã ãããã®include1455 # ランタイムヘッダの include 1484 1456 # f.printf TECSMsg.get( :IRTH_comment), "#_IRTH_#" 1485 1457 # f.print "#include \"tecs.#{$h_suffix}\"\n\n" 1486 1458 1487 # ã°ãã¼ãã«ãããã®include1459 # グローバルヘッダの include 1488 1460 f.printf TECSMsg.get( :IGH_comment ), "#_IGH_#" 1489 1461 f.print "#include \"global_tecsgen.#{$h_suffix}\"\n\n" 1490 1462 1491 # ã·ã°ããã£ãããã®include1463 # シグニチャヘッダの include 1492 1464 f.printf TECSMsg.get( :ISH_comment ), "#_ISH_#" 1493 1465 @port.each { |p| … … 1507 1479 end 1508 1480 1509 # æé©åã®ããåç 1510 §ããã»ã«ã¿ã¤ãã® CB åã®å®ç¾©ãåè¾¼ã 1511 # _CB_TYPE_ONLY ãå®ç¾©ããä¸ã§ include ãã 1481 # 最適化のため参照するセルタイプの CB 型の定義を取込む 1482 # _CB_TYPE_ONLY を定義した上で include する 1512 1483 f.printf( TECSMsg.get( :ICT_comment ), "#_ICT_#" ) 1513 1484 … … 1522 1493 1523 1494 if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then 1524 # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©1495 # 最適化コード (optimize) # スケルトン不要など 1525 1496 p2 = p.get_real_callee_port 1526 1497 if p2 then … … 1531 1502 end 1532 1503 # else 1533 # optional ã§æªçµå1504 # optional で未結合 1534 1505 end 1535 1506 end … … 1543 1514 # next if p.get_port_type != :CALL 1544 1515 # if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then 1545 # # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©1516 # # 最適化コード (optimize) # スケルトン不要など 1546 1517 # p2 = p.get_real_callee_port 1547 1518 # ct = p2.get_celltype … … 1559 1530 return if @singleton 1560 1531 1561 # ID ã®åºæ°ããã³åæ°ã® define ãåºå1532 # ID の基数および個数の define を出力 1562 1533 f.printf("#define %-20s %10s /* %s #_NIDB_# */\n", "#{@global_name}_ID_BASE", "(#{@id_base})", TECSMsg.get(:NIDB_comment)) 1563 1534 f.printf("#define %-20s %10s /* %s #_NCEL_# */\n\n", "#{@global_name}_N_CELL", "(#{@n_cell_gen})", TECSMsg.get(:NCEL_comment)) … … 1567 1538 return if @singleton 1568 1539 1569 # mikan æé©å1570 # IDX æ£å½æ§ãã§ãã¯ãã¯ãã®åºå1540 # mikan 最適化 1541 # IDX 正当性チェックマクロの出力 1571 1542 f.printf( TECSMsg.get( :CVI_comment ), "#_CVI_#" ) 1572 1543 if @idx_is_id_act then … … 1581 1552 return if @singleton 1582 1553 1583 # IDX æ£å½æ§ãã§ãã¯ãã¯ãï¼ç縮形ï¼ã®åºå1554 # IDX 正当性チェックマクロ(短縮形)の出力 1584 1555 f.printf( TECSMsg.get( :CVIA_comment ), "#_CVIA_#") 1585 1556 f.print("#define VALID_IDX(IDX) #{@global_name}_VALID_IDX(IDX)\n\n") … … 1587 1558 end 1588 1559 1589 #=== å¼ã³å£é 1590 åã®å¤§ãããå¾ããã¯ãã®åºå 1560 #=== 呼び口配列の大きさを得るマクロの出力 1591 1561 # 1592 # ã»ã«ã¿ã¤ããããã¸å¼ã³å£ã®åæ°ãåºå1562 #セルタイプヘッダへ呼び口の個数を出力 1593 1563 def gen_ph_n_cp f 1594 1564 … … 1604 1574 end 1605 1575 1606 if p.get_array_size != "[]" then # åºå®é·é 1607 å 1576 if p.get_array_size != "[]" then # 固定長配列 1608 1577 f.print( "#define N_CP_#{p.get_name} (#{p.get_array_size})\n" ) 1609 1578 f.print( "#define NCP_#{p.get_name} (#{p.get_array_size})\n" ) 1610 else # å¯å¤é·é 1611 å 1579 else # 可変長配列 1612 1580 if @singleton then 1613 1581 if has_INIB? then … … 1618 1586 f.print( "#define N_CP_#{p.get_name} (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" ) 1619 1587 f.print( "#define NCP_#{p.get_name} (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" ) 1620 # mikan singleton ãªãã°ãåºå®é·åã§ãã1588 # mikan singleton ならば、固定長化できる 1621 1589 else 1622 1590 if has_CB? && has_INIB? then … … 1632 1600 end 1633 1601 1634 #=== åãå£é 1635 åã®å¤§ãããå¾ããã¯ãã®åºå 1602 #=== 受け口配列の大きさを得るマクロの出力 1636 1603 # 1637 # ã»ã«ã¿ã¤ããããã¸åãå£ã®åæ°ãåºå1604 #セルタイプヘッダへ受け口の個数を出力 1638 1605 def gen_ph_n_ep f 1639 1606 … … 1641 1608 @port.each { |p| 1642 1609 next if p.get_port_type != :ENTRY 1643 # next if p.is_omit? # åãå£é 1644 åã®åæ°ã¯çç¥ããªã 1610 # next if p.is_omit? # 受け口配列の個数は省略しない 1645 1611 next if p.get_array_size == nil 1646 1612 … … 1650 1616 end 1651 1617 1652 if p.get_array_size != "[]" then # åºå®é·é 1653 å 1618 if p.get_array_size != "[]" then # 固定長配列 1654 1619 f.print( "#define NEP_#{p.get_name} (#{p.get_array_size})\n" ) 1655 else # å¯å¤é·é 1656 å 1620 else # 可変長配列 1657 1621 if @singleton then 1658 1622 if has_INIB? then … … 1662 1626 end 1663 1627 f.print( "#define NEP_#{p.get_name} (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" ) 1664 # mikan singleton ãªãã°ãåºå®é·åã§ãã1628 # mikan singleton ならば、固定長化できる 1665 1629 else 1666 1630 if has_CB? && has_INIB? then … … 1675 1639 end 1676 1640 1677 #=== optional ãªå¼ã³å£ãçµåããã¦ããããã¹ãããã³ã¼ãã®çæ1641 #=== optional な呼び口が結合されているかテストするコードの生成 1678 1642 def gen_ph_test_optional_call_port f 1679 1643 b_comment = false … … 1696 1660 next if p.get_port_type != :CALL 1697 1661 next if ! p.is_optional? 1698 # next if p.is_omit? # omit ã§ã test ã³ã¼ãã¯çæãã1662 # next if p.is_omit? # omit でも test コードは生成する 1699 1663 1700 1664 if b_comment == false then … … 1720 1684 end 1721 1685 1722 # é¢æ°åã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãã VMT ã®é¢æ°åãæé©åï¼åãå£é¢æ° or åãå£ãã£ã¹ã¯ãªãã¿) 1723 # mikan å 1724 ¨é¨ã¤ãªãã£ã¦ãããã©ãã㧠(1) ãå¤å®ãã 1686 # 関数名の出力(標準:受け口ディスクリプタから VMT の関数名、最適化:受け口関数 or 受け口ディスクリプタ) 1687 # mikan 全部つながっているかどうかで (1) を判定する 1725 1688 if ! p.is_VMT_useless? then 1726 1689 if p.is_dynamic? then … … 1734 1697 end 1735 1698 1736 # æ¨æºã³ã¼ã1699 # 標準コード 1737 1700 if p.get_array_size == nil then 1738 1701 if @singleton then … … 1742 1705 end 1743 1706 else 1744 # é 1745 åã®å ´å 1707 # 配列の場合 1746 1708 if @singleton then 1747 1709 f.print( "\t ((#{@global_name}_SINGLE_CELL_#{inib_tmp}.#{p.get_name}!=0) \\\n" ) … … 1753 1715 end 1754 1716 else 1755 # æé©åã³ã¼ã (optimize) # VMT ä¸è¦ï¼é 1756 åè¦ç´ ãã¹ã¦åãï¼ 1717 # 最適化コード (optimize) # VMT 不要(配列要素すべて同じ) 1757 1718 p2 = p.get_real_callee_port 1758 1719 if p2 then 1759 1720 ct = p2.get_celltype 1760 1721 if p.is_skelton_useless? then 1761 # åãå£é¢æ°ãç´æ¥å¼åºã1722 # 受け口関数を直接呼出す 1762 1723 f.print( "\t (1)\n" ) 1763 1724 else 1764 # åãå£ã¹ã±ã«ãã³é¢æ°ãç´æ¥å¼åºã1725 # 受け口スケルトン関数を直接呼出す 1765 1726 f.print( "\t (1)\n" ) 1766 1727 end 1767 1728 else 1768 # optional ã§æªçµå1729 # optional で未結合 1769 1730 f.print( "\t (0) /* not joined */\n" ) 1770 1731 end … … 1773 1734 end 1774 1735 1775 #=== optional ãªå¼ã³å£ãçµåããã¦ããããã¹ãããã³ã¼ãã®çæï¼ç縮形ï¼1736 #=== optional な呼び口が結合されているかテストするコードの生成(短縮形) 1776 1737 def gen_ph_test_optional_call_port_abbrev f 1777 1738 b_comment = false … … 1780 1741 next if p.get_port_type != :CALL 1781 1742 next if ! p.is_optional? 1782 # next if p.is_omit? # omit ã§ã test ã³ã¼ãã¯çæãã1743 # next if p.is_omit? # omit でも test コードは生成する 1783 1744 1784 1745 if b_comment == false then … … 1805 1766 end 1806 1767 1807 #=== CELLCB ã¸ã®ãã¤ã³ã¿ãå¾ããã¯ããåºå1808 # ã»ã«ã¿ã¤ããããã¸åºå1768 #=== CELLCB へのポインタを得るマクロを出力 1769 # セルタイプヘッダへ出力 1809 1770 def gen_ph_get_cellcb f 1810 1771 f.printf( TECSMsg.get( :GCB_comment ), "#_GCB_#" ) 1811 1772 if ( ! has_CB? && ! has_INIB? ) || @singleton then 1812 1773 f.print( "#define #{@global_name}_GET_CELLCB(idx) ((void *)0)\n" ) 1813 elsif @idx_is_id_act then # mikan åä¸ã®ã»ã«ã®å ´åã®æé©å, idx_is_id ã§ãªãå ´å1774 elsif @idx_is_id_act then # mikan 単一のセルの場合の最適化, idx_is_id でない場合 1814 1775 f.print( "#define #{@global_name}_GET_CELLCB(idx) (#{@global_name}_CB_ptab[(idx) - #{@global_name}_ID_BASE])\n" ) 1815 1776 else … … 1818 1779 end 1819 1780 1820 #=== CELLCB ã¸ã®ãã¤ã³ã¿ãå¾ããã¯ãï¼ç縮形ï¼ãåºå1821 # ã»ã«ã¿ã¤ããããã¸åºå1781 #=== CELLCB へのポインタを得るマクロ(短縮形)を出力 1782 # セルタイプヘッダへ出力 1822 1783 def gen_ph_get_cellcb_abbrev f 1823 1784 f.printf( TECSMsg.get( :GCBA_comment ), "#_GCBA_#" ) … … 1835 1796 end 1836 1797 1837 #=== attribute, var ãã¢ã¯ã»ã¹ãããã¯ããåºå1838 # ã»ã«ã¿ã¤ããããã¸åºå1798 #=== attribute, var をアクセスするマクロを出力 1799 # セルタイプヘッダへ出力 1839 1800 def gen_ph_attr_access f 1840 1801 if @n_attribute_rw > 0 || @n_attribute_ro > 0 then … … 1846 1807 next if a.is_omit? 1847 1808 1848 # mikan const_value ã®å ´å1809 # mikan const_value の場合 1849 1810 f.print( "#define " ) 1850 1811 if @singleton then … … 1856 1817 f.printf( "%-20s", "#{@global_name}_ATTR_#{a.get_name}" ) 1857 1818 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name})\n" ) 1858 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1819 # mikan ここでは cell ではなく celltype の名前 1859 1820 else 1860 1821 if ! a.is_rw? && has_CB? && has_INIB? then … … 1887 1848 end 1888 1849 1889 # mikan const_value ã®å ´å1850 # mikan const_value の場合 1890 1851 f.print( "#define " ) 1891 1852 if @singleton then 1892 1853 f.printf( "%-20s", "#{@global_name}_GET_#{a.get_name}()" ) 1893 1854 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name})\n" ) 1894 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1855 # mikan ここでは cell ではなく celltype の名前 1895 1856 else 1896 1857 f.printf( "%-20s", "#{@global_name}_GET_#{a.get_name}(p_that)" ) … … 1903 1864 f.printf( "%-20s", "#{@global_name}_SET_#{a.get_name}(val)" ) 1904 1865 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name} = (val))\n" ) 1905 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1866 # mikan ここでは cell ではなく celltype の名前 1906 1867 else 1907 1868 f.printf( "%-20s", "#{@global_name}_SET_#{a.get_name}(p_that,val)" ) … … 1935 1896 end 1936 1897 1937 # mikan const_value ã®å ´å1898 # mikan const_value の場合 1938 1899 f.print( "#define " ) 1939 1900 if @singleton then 1940 1901 f.printf( "%-20s", "#{@global_name}_VAR_#{v.get_name}" ) 1941 1902 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{v.get_name})\n" ) 1942 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1903 # mikan ここでは cell ではなく celltype の名前 1943 1904 else 1944 1905 f.printf( "%-20s", "#{@global_name}_VAR_#{v.get_name}(p_that)" ) … … 1951 1912 next if v.is_omit? 1952 1913 1953 # mikan const_value ã®å ´å1914 # mikan const_value の場合 1954 1915 f.print( "#define " ) 1955 1916 if @singleton then 1956 1917 f.printf( "%-20s", "#{@global_name}_GET_#{v.get_name}()" ) 1957 1918 f.print( "\t(#{@global_name}_SINGLE_CELL_CB.#{v.get_name})\n" ) 1958 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1919 # mikan ここでは cell ではなく celltype の名前 1959 1920 else 1960 1921 f.printf( "%-20s", "#{@global_name}_GET_#{v.get_name}(p_that)" ) … … 1966 1927 f.printf( "%-20s", "#{@global_name}_SET_#{v.get_name}(val)" ) 1967 1928 f.print( "\t(#{@global_name}_SINGLE_CELL_CB.#{v.get_name}=(val))\n" ) 1968 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1929 # mikan ここでは cell ではなく celltype の名前 1969 1930 else 1970 1931 f.printf( "%-20s", "#{@global_name}_SET_#{v.get_name}(p_that,val)" ) … … 1976 1937 end 1977 1938 1978 #=== attribute/var ã¢ã¯ã»ã¹ãã¯ãï¼ç縮形ï¼ã³ã¼ãã®çæ1939 #=== attribute/var アクセスマクロ(短縮形)コードの生成 1979 1940 def gen_ph_attr_access_abbrev f 1980 1941 if @n_attribute_rw > 0 || @n_attribute_ro > 0 then … … 1985 1946 next if a.is_omit? 1986 1947 1987 # mikan const_value ã®å ´å1948 # mikan const_value の場合 1988 1949 f.print( "#define " ) 1989 1950 f.printf( "%-20s", "ATTR_#{a.get_name}" ) … … 2003 1964 next if v.is_omit? 2004 1965 2005 # mikan const_value ã®å ´å1966 # mikan const_value の場合 2006 1967 f.print( "#define " ) 2007 1968 f.printf( "%-20s", "VAR_#{v.get_name}" ) … … 2072 2033 delim = "" 2073 2034 2074 # é¢æ°åã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãã VMT ã®é¢æ°åãæé©åï¼åãå£é¢æ° or åãå£ãã£ã¹ã¯ãªãã¿)2035 # 関数名の出力(標準:受け口ディスクリプタから VMT の関数名、最適化:受け口関数 or 受け口ディスクリプタ) 2075 2036 if b_flow then 2076 2037 f.print( "\t (p_that)->#{p.get_name}#{subsc}.#{fun.get_name}__T( \\\n" ) 2077 2038 elsif ! p.is_VMT_useless? then 2078 # æ¨æºã³ã¼ã2039 # 標準コード 2079 2040 if @singleton then 2080 2041 f.print( "\t #{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}" ) … … 2084 2045 f.print( "#{subsc}->VMT->#{fun.get_name}__T( \\\n" ) 2085 2046 else 2086 # æé©åã³ã¼ã (optimize) # VMT ä¸è¦2047 # 最適化コード (optimize) # VMT 不要 2087 2048 p2 = p.get_real_callee_port 2088 2049 if p2 then 2089 2050 ct = p2.get_celltype 2090 2051 if p.is_skelton_useless? then 2091 # åãå£é¢æ°ãç´æ¥å¼åºã2052 # 受け口関数を直接呼出す 2092 2053 f.print( "\t #{ct.get_global_name}_#{p2.get_name}_#{fun.get_name}( \\\n" ) 2093 2054 else 2094 # åãå£ã¹ã±ã«ãã³é¢æ°ãç´æ¥å¼åºã2055 # 受け口スケルトン関数を直接呼出す 2095 2056 f.print( "\t #{ct.get_global_name}_#{p2.get_name}_#{fun.get_name}_skel( \\\n" ) 2096 2057 # print "skelton: #{@name} #{ct.get_global_name}_#{p2.get_name}\n" 2097 2058 end 2098 2059 else 2099 # optional ã§æªçµå2060 # optional で未結合 2100 2061 f.print( "\t ((#{fun.get_declarator.get_type.get_type.get_type_str} (*)()" ) 2101 2062 f.print( "#{fun.get_declarator.get_type.get_type.get_type_str_post})0)()\n" ) … … 2107 2068 end 2108 2069 2109 b_join = true # optional ã§çµåãã¦ããªãå ´å false 2110 2111 # åãå£æ 2112 å ±ã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãæé©åï¼IDX ãªã©) 2070 b_join = true # optional で結合していない場合 false 2071 2072 # 受け口情報の出力(標準:受け口ディスクリプタ、最適化:IDX など) 2113 2073 if b_flow then 2114 2074 elsif ! p.is_skelton_useless? && ! p.is_cell_unique? then 2115 # æ¨æºã³ã¼ã2075 # 標準コード 2116 2076 if @singleton then 2117 2077 f.print( "\t #{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}#{subsc}" ) … … 2122 2082 end 2123 2083 else 2124 # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦2125 c2 = p.get_real_callee_cell # å¯ä¸ã®ã»ã«(ã§ãªãå ´åããããè¤æ°ã»ã«ãããå ´å)2126 p2 = p.get_real_callee_port # å¯ä¸ã®ãã¼ã(ã§ãªãå ´åã¯ããªã)2084 # 最適化コード (optimize) # スケルトン不要 2085 c2 = p.get_real_callee_cell # 唯一のセル(でない場合もある、複数セルがある場合) 2086 p2 = p.get_real_callee_port # 唯一のポート(でない場合は、ない) 2127 2087 if p2 then 2128 ct = p2.get_celltype # å¼ã³å 2129 ã®ã»ã«ã¿ã¤ã 2088 ct = p2.get_celltype # 呼び先のセルタイプ 2130 2089 if ! ct.is_singleton? then 2131 2090 if ct.has_CB? || ct.has_INIB? then … … 2134 2093 f.print( "\t #{name_array[7]}" ) 2135 2094 else 2136 # CELLCB IDX ã渡ã (æ¨æºã³ã¼ãã¨åãã ããæ±ãåã¯ç°ãªã)2137 # p.is_skelton_useless? == true/false ã¨ãã«åã2095 # CELLCB IDX を渡す (標準コードと同じだが、扱う型は異なる) 2096 # p.is_skelton_useless? == true/false ともに同じ 2138 2097 f.print( "\t (p_that)#{inib}->#{p.get_name}#{subsc}" ) 2139 2098 end … … 2146 2105 end 2147 2106 else 2148 # optional ã§æªçµå2107 # optional で未結合 2149 2108 b_join = false 2150 2109 end … … 2163 2122 end 2164 2123 2165 #=== ref_desc æå®ãããå¼ã³å£ã«å¯¾ãããã£ã¹ã¯ãªãã¿åç 2166 §é¢æ°ã®çæ 2124 #=== ref_desc 指定された呼び口に対するディスクリプタ参照関数の生成 2167 2125 def gen_ph_ref_desc_func f 2168 2126 if @n_call_port_ref_desc >0 then … … 2219 2177 end 2220 2178 2221 #=== dynamic æå®ãããå¼ã³å£ã«å¯¾ãããã£ã¹ã¯ãªãã¿è¨å®é¢æ°ã®çæ2179 #=== dynamic 指定された呼び口に対するディスクリプタ設定関数の生成 2222 2180 def gen_ph_set_desc_func f 2223 2181 if @n_call_port_dynamic >0 then … … 2291 2249 end 2292 2250 2293 #=== send/receive ã§åãåã£ãã¡ã¢ãªé åã dealloc ãããã¯ãã³ã¼ã2251 #=== send/receive で受け取ったメモリ領域を dealloc するマクロコード 2294 2252 #f:: File 2295 #b_undef:: bool : true = #undef ã³ã¼ãã®çæ, false = #define ã³ã¼ãã®çæ2253 #b_undef:: bool : true = #undef コードの生成, false = #define コードの生成 2296 2254 def gen_ph_dealloc_code( f, append_name, b_undef = false ) 2297 2255 b_msg = false … … 2300 2258 2301 2259 p.each_param{ |port, fd, par| 2302 case par.get_direction # å¼æ°ã®æ¹åæå®å(in, out, inout, send, receive )2260 case par.get_direction # 引数の方向指定子 (in, out, inout, send, receive ) 2303 2261 when :SEND 2304 2262 # next if port.get_port_type == :CALL … … 2317 2275 end 2318 2276 2319 # ãã¼ãå é¢æ°å ãã©ã¡ã¼ã¿å2277 # ポート名 関数名 パラメータ名 2320 2278 dealloc_func_name = "#{port.get_name}_#{fd.get_name}_#{par.get_name}_dealloc" 2321 2279 dealloc_macro_name = dealloc_func_name.upcase … … 2356 2314 @port.each { |p| 2357 2315 next if p.get_port_type != :CALL 2358 # next if p.is_omit? å¼ã³åºãã¨ã¨ã©ã¼ãèµ·ããã³ã¼ããçæ2316 # next if p.is_omit? 呼び出すとエラーを起こすコードを生成 2359 2317 2360 2318 p.get_signature.get_function_head_array.each{ |fun| … … 2531 2489 f.print( "struct tag_#{@global_name}_CB *" ) 2532 2490 elsif has_INIB? then 2533 # f.print( "struct tag_#{@global_name}_INIB *" ) # const ãåºåãã¦ããªã2491 # f.print( "struct tag_#{@global_name}_INIB *" ) # const を出力していない 2534 2492 f.print( "const struct tag_#{@global_name}_INIB *" ) 2535 2493 else … … 2567 2525 2568 2526 if p.get_array_size then 2569 f.print( "#{delim} int_t subscript" ) # mikan singleton æã® ',' ã®å§æ«2527 f.print( "#{delim} int_t subscript" ) # mikan singleton 時の ',' の始末 2570 2528 delim = "," 2571 2529 end … … 2575 2533 len = items.length 2576 2534 else 2577 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å2535 # ここで nil になるのは、引数なしの時に void がなかった場合 2578 2536 items = [] 2579 2537 len = 0 … … 2596 2554 2597 2555 def gen_ph_ep_skel_prototype f 2598 # åãå£ã¹ã±ã«ãã³é¢æ°ã®ãããã¿ã¤ã宣è¨ãåºå2556 # 受け口スケルトン関数のプロトタイプ宣言を出力 2599 2557 if @n_entry_port >0 then 2600 2558 f.printf( TECSMsg.get( :EPSP_comment ), "#_EPSP_#" ) … … 2603 2561 next if p.get_port_type != :ENTRY 2604 2562 next if p.is_omit? 2605 # if p.is_skelton_useless? || ! p.is_VMT_useless? then # åãå£æé©å2606 if p.is_skelton_useless? then # åãå£æé©å2563 # if p.is_skelton_useless? || ! p.is_VMT_useless? then # 受け口最適化 2564 if p.is_skelton_useless? then # 受け口最適化 2607 2565 # f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" ) 2608 2566 next … … 2623 2581 len = items.length 2624 2582 else 2625 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å2583 # ここで nil になるのは、引数なしの時に void がなかった場合 2626 2584 items = [] 2627 2585 len = 0 … … 2646 2604 2647 2605 if ( $rom )then 2648 # å®æ°é¨ã¯ ROM, å¤æ°é¨ã¯RAM2606 # 定数部は ROM, 変数部は RAM 2649 2607 2650 2608 if has_INIB? then … … 2680 2638 2681 2639 else 2682 # å 2683 ¨ã¦ RAM 2640 # 全て RAM 2684 2641 f.printf( TECSMsg.get( :CCTPO_comment ), "#_CCTPO_#" ) 2685 2642 … … 2695 2652 2696 2653 2697 #=== attribute ã®å宣è¨åºå2698 #inib_cb:: :INIB ã¾ãã¯:CB2654 #=== attribute の型宣言出力 2655 #inib_cb:: :INIB または :CB 2699 2656 def gen_cell_cb_type_attribute( f, inib_cb ) 2700 2657 if inib_cb == :INIB && @n_attribute_ro > 0 then … … 2729 2686 next if v.is_omit? 2730 2687 next if v.get_size_is == nil 2731 next if $rom && inib_cb == :CB # size_is æå®ããããã®ã¯ INIB ã«ã®ã¿åºåãã2688 next if $rom && inib_cb == :CB # size_is 指定されたものは INIB にのみ出力する 2732 2689 2733 2690 f.print " " … … 2738 2695 2739 2696 def gen_cell_cb_type_var f 2740 # å¤æ°ã®åºå2697 # 変数の出力 2741 2698 if @n_var > 0 then 2742 2699 f.print " /* var #_VA_# */ \n" … … 2746 2703 2747 2704 next if v.is_omit? 2748 next if v.get_size_is != nil # size_is æå®ããã var 㯠attribute ã¸åºåãã2705 next if v.get_size_is != nil # size_is 指定された var は attribute へ出力する 2749 2706 2750 2707 f.print " " … … 2760 2717 2761 2718 def gen_cell_cb_type_call_port( f, inib_cb ) 2762 # å¼ã³å£2719 # 呼び口 2763 2720 if @n_call_port >0 then 2764 2721 f.print " /* call port #_TCP_# */\n" … … 2785 2742 2786 2743 if ! p.is_skelton_useless? then 2787 # æ¨æºå½¢2744 # 標準形 2788 2745 if inib_cb == :INIB && p.is_dynamic? && p.get_array_size != nil && $ram_initializer then 2789 2746 f.print( " struct tag_#{p.get_signature.get_global_name}_VDES #{ptr}#{const2}*#{p.get_name;}_init_;\n" ) … … 2795 2752 end 2796 2753 else 2797 # æé©å skelton é¢æ°ãå¼åºããªã(åãå£é¢æ°ãç´æ¥å¼åºã) 2798 # å¼ã³å 2799 ã»ã«ã¿ã¤ãã® CB ã® IDX å 2754 # 最適化 skelton 関数を呼出さない(受け口関数を直接呼出す) 2755 # 呼び先セルタイプの CB の IDX 型 2800 2756 if p.get_real_callee_cell then 2801 2757 f.print( " " ) 2802 2758 p.get_real_callee_cell.get_celltype.gen_ph_idx_type f 2803 2759 f.print( " #{ptr}#{p.get_name;};\n" ) 2804 # ç¸äºåç 2805 §ã«åãã¦ãtypedef ããåã使ããªã 2760 # 相互参照に備えて、typedef した型を使わない 2806 2761 # f.print( " #{p.get_real_callee_cell.get_celltype.get_global_name}_IDX #{ptr}#{p.get_name;};\n" ) 2807 2762 if p.get_array_size == "[]" then … … 2809 2764 end 2810 2765 #else 2811 # optional ã§æªçµå2766 # optional で未結合 2812 2767 end 2813 2768 end 2814 2769 # else 2815 # æé©å ä¸ã¤ããã»ã«ããªãå ´åãåãå£ãã£ã¹ã¯ãªãã¿ã¾ãã¯åãå´ã® IDX ã¯å¼ã³å£é¢æ°ãã¯ãã«åãè¾¼ã¾ãã 2816 end 2817 } 2818 end 2819 2820 #=== Celltype#åãå£é 2821 åæ·»æ°ãè¨æ¶ããå¤æ°ã®å®ç¾© 2770 # 最適化 一つしかセルがない場合、受け口ディスクリプタまたは受け側の IDX は呼び口関数マクロに埋め込まれる 2771 end 2772 } 2773 end 2774 2775 #=== Celltype#受け口配列添数を記憶する変数の定義 2822 2776 def gen_cell_cb_type_entry_port( f, inib_cb ) 2823 # å¼ã³å£2777 # 呼び口 2824 2778 if @n_entry_port >0 then 2825 2779 f.print " /* call port #_NEP_# */ \n" … … 2827 2781 2828 2782 @port.each{ |p| 2829 # next if p.is_omit? # åãå£é 2830 åã®åæ°ã¯çç¥ããªã 2783 # next if p.is_omit? # 受け口配列の個数は省略しない 2831 2784 if p.get_port_type == :ENTRY && p.get_array_size == "[]" 2832 2785 f.print( " int_t n_#{p.get_name};\n" ) … … 2850 2803 f.print "extern #{@global_name}_CB *const #{@global_name}_CB_ptab[];\n" 2851 2804 @ordered_cell_list.each{ |c| 2852 if c.is_generate? then # çæ対象ãï¼2805 if c.is_generate? then # 生成対象か? 2853 2806 name_array = get_name_array c 2854 2807 f.print "extern #{@global_name}_CB #{name_array[4]};\n" … … 2858 2811 f.print "extern #{@global_name}_INIB *const #{@global_name}_INIB_ptab[];\n" 2859 2812 @ordered_cell_list.each{ |c| 2860 if c.is_generate? then # çæ対象ãï¼2813 if c.is_generate? then # 生成対象か? 2861 2814 name_array = get_name_array c 2862 2815 f.print "extern #{@global_name}_INIB #{name_array[11]};\n" … … 2875 2828 2876 2829 def gen_ph_INIB_as_CB f 2877 # ããã¯ãææãã§ãããæ¬æ¥ãªã INIB ãåºåãã¹ã2830 # ここは、手抜きである。本来なら INIB を出力すべき 2878 2831 if ! has_CB? && has_INIB? then 2879 2832 f.printf( TECSMsg.get( :DCI_comment ), "#_DCI_#" ) … … 2892 2845 end 2893 2846 2894 #=== ã¤ãã¬ã¼ã¿ã³ã¼ã (FOREACH_CELL)ã®çæ2895 # singleton ã§ã¯åºåããªã2847 #=== イテレータコード (FOREACH_CELL)の生成 2848 # singleton では出力しない 2896 2849 def gen_ph_foreach_cell f 2897 2850 … … 2936 2889 2937 2890 2938 #=== å¤æ°varåæåã³ã¼ã2891 #=== 変数var初期化コード 2939 2892 # 2940 2893 def gen_ph_cb_initialize_macro f … … 2947 2900 type = v.get_type 2948 2901 if( type.kind_of? PtrType )then 2949 # PtrType 㯠ArrayType ã«ããæ¿ãã2950 2951 # åæååã®è¦ç´ æ°ã¨ãã (å¾ã¯ 0 ã§ãã)2902 # PtrType は ArrayType にすり替える 2903 2904 # 初期化子の要素数とする (後は 0 である) 2952 2905 t2 = ArrayType.new( Expression.create_integer_constant( init.length, nil ) ) 2953 2906 t2.set_type( type.get_type ) … … 3005 2958 } 3006 2959 3007 # dynamic call port ã®åæåã³ã¼ã2960 # dynamic call port の初期化コード 3008 2961 b_dyn_port = false 3009 2962 @port.each{ |p| … … 3061 3014 3062 3015 # else 3063 # ã»ã«ãä¸ã¤ããªããã°åºåããªã3016 # セルが一つもなければ出力しない 3064 3017 end 3065 3018 … … 3068 3021 3069 3022 def gen_ph_inline f 3070 # inline ãã¼ããä¸ã¤ã§ãããã°ãinline.h ã®include3023 # inline ポートが一つでもあれば、inline.h の include 3071 3024 if @n_entry_port_inline > 0 then 3072 3025 f.printf( TECSMsg.get( :INL_comment ), "#_INL_#" ) … … 3120 3073 next if p.get_port_type != :ENTRY 3121 3074 next if p.is_omit? 3122 if p.is_skelton_useless? # åãå£æé©å3075 if p.is_skelton_useless? # 受け口最適化 3123 3076 f.print( "/* #{p.get_name} : omitted by entry port optimize */\n\n" ) 3124 3077 next … … 3131 3084 f.print( " #{@name}_IDX idx;\n" ) 3132 3085 else 3133 # CB ã INIB ãåå¨ããªã (ã®ã§ãidx ã¨ãã¦æ´æ°ã§åæåãã¦ãã)3086 # CB も INIB も存在しない (ので、idx として整数で初期化しておく) 3134 3087 f.print( " int idx;\n" ) 3135 3088 end … … 3149 3102 next if p.get_port_type != :ENTRY 3150 3103 next if p.is_omit? 3151 if p.is_skelton_useless? then # åãå£æé©å3104 if p.is_skelton_useless? then # 受け口最適化 3152 3105 f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" ) 3153 3106 next … … 3168 3121 len = items.length 3169 3122 else 3170 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å3123 # ここで nil になるのは、引数なしの時に void がなかった場合 3171 3124 items = [] 3172 3125 len = 0 … … 3190 3143 end 3191 3144 3192 if functype.get_type_str == "void" then # mikan "void" ã® typedef ã«æªå¯¾å¿3145 if functype.get_type_str == "void" then # mikan "void" の typedef に未対応 3193 3146 f.print " " 3194 3147 else … … 3233 3186 next if p.get_port_type != :ENTRY 3234 3187 next if p.is_omit? 3235 if p.is_VMT_useless? then # åãå£æé©å3188 if p.is_VMT_useless? then # 受け口最適化 3236 3189 f.print "/* #{p.get_name} : omitted by entry port optimize */\n" 3237 3190 next … … 3259 3212 end 3260 3213 3261 # ãã®ã»ã«ã¿ã¤ãã®ãã¹ã¦ã®ã»ã«ã«ã¤ãã¦3214 # このセルタイプのすべてのセルについて 3262 3215 @ordered_cell_list.each{ |c| 3263 if c.is_generate? then # çæ対象ãï¼3216 if c.is_generate? then # 生成対象か? 3264 3217 3265 3218 f = fs[ c.get_region.get_domain_root ] 3266 3219 3267 # çµåã®ãªã¹ã(NamedList)3220 # 結合のリスト (NamedList) 3268 3221 jl = c.get_join_list 3269 3222 3270 # å 3271 ¨ã¦ã®çµåãªã¹ãã«ã¤ã㦠3223 # 全ての結合リストについて 3272 3224 jl.get_items.each{ |j| 3273 3225 3274 # 左辺ã®å®ç¾©ãå¾ã3226 # 左辺の定義を得る 3275 3227 definition = j.get_definition 3276 3228 3277 # å¼ã³å£ã§ã¯ãªãï¼ãï¼å±æ§ï¼3229 # 呼び口ではない? (属性) 3278 3230 next unless definition.instance_of? Port 3279 3231 3280 port = find j.get_name # celltype ã® Port (ãã¡ãã«æé©åæ 3281 å ±ããã) 3282 # port = definition # definition 㯠composite ã® Port ãå¾ããããã¨ããã 3232 port = find j.get_name # celltype の Port (こちらに最適化情報がある) 3233 # port = definition # definition は composite の Port が得られることがある 3283 3234 next if port.is_cell_unique? 3284 3235 next if port.is_omit? 3285 3236 3286 # é 3287 åè¦ç´ ãå¾ãï¼åãå£é 3288 åã§ãªããã° nil ãè¿ãï¼ 3237 # 配列要素を得る(受け口配列でなければ nil が返る) 3289 3238 am = j.get_array_member2 3290 3239 3291 # å¼ã³å£é 3292 åã? 3240 # 呼び口配列か? 3293 3241 if am then 3294 3242 i = 0 … … 3297 3245 if j then 3298 3246 if am[i].get_rhs_cell.get_celltype == self then 3299 # åãã»ã«ã¿ã¤ãã¸çµåãã¦ããå ´å(VDES ã§ã¯ type conflict ã«ãªã)3247 # 同じセルタイプへ結合している場合(VDES では type conflict になる) 3300 3248 p = am[i].get_rhs_port 3301 3249 des_type = "const struct tag_#{@global_name}_#{p.get_name}_DES" … … 3304 3252 end 3305 3253 3306 # å³è¾ºã¯åãå£é 3307 åãï¼ 3254 # 右辺は受け口配列か? 3308 3255 if j.get_rhs_subscript then 3309 3256 3310 # åãå£ã®é 3311 åæ·»æ° 3257 # 受け口の配列添数 3312 3258 subscript = j.get_rhs_subscript 3313 3259 … … 3322 3268 end 3323 3269 #else if j == nil 3324 # optioanl ã§é 3325 åè¦ç´ ãåæåããã¦ããªã 3270 # optioanl で配列要素が初期化されていない 3326 3271 end 3327 3272 i += 1 … … 3330 3275 dbgPrint "me=#{@name} callee=#{j.get_rhs_cell.get_celltype.get_name} #{j.get_cell.get_celltype.get_name} \n" 3331 3276 if j.get_rhs_cell.get_celltype == self then 3332 # åãã»ã«ã¿ã¤ãã¸çµåãã¦ããå ´å(VDES ã§ã¯ type conflict ã«ãªã)3277 # 同じセルタイプへ結合している場合(VDES では type conflict になる) 3333 3278 p = j.get_rhs_port 3334 3279 des_type = "const struct tag_#{@global_name}_#{p.get_name}_DES" … … 3338 3283 3339 3284 if j.get_rhs_subscript then 3340 # åãå£é 3341 å 3285 # 受け口配列 3342 3286 subscript = j.get_rhs_subscript 3343 3287 f.printf( "extern %s %s%d;\n", … … 3351 3295 end 3352 3296 end 3353 # mikan cell ã® namespace æªå¯¾å¿ãJoin 㧠Cell ãªãã¸ã§ã¯ããå¼å½ã¦ããå¿ 3354 è¦ãã 3297 # mikan cell の namespace 未対応、Join で Cell オブジェクトを引当ておく必要あり 3355 3298 } 3356 3299 … … 3362 3305 def gen_cell_ep_vdes_array fs 3363 3306 if @n_cell_gen >0 then 3364 fs.each{ |r, f| f.printf( TECSMsg.get( :CPA_comment ), "#_CPA_#" ) } # mikan å¼ã³å£é 3365 åãç¡ãå ´åãåºã¦ãã¾ã 3307 fs.each{ |r, f| f.printf( TECSMsg.get( :CPA_comment ), "#_CPA_#" ) } # mikan 呼び口配列が無い場合も出てしまう 3366 3308 end 3367 3309 … … 3371 3313 3372 3314 jl = c.get_join_list 3373 # ã«ã¼ããåãå¤æ°ã jl ãã @port ã«å¤æ´3315 # ループを回す変数を jl から @port に変更 3374 3316 # dynamic, optional 3375 3317 # jl.get_items.each{ |j| … … 3382 3324 j = jl.get_item( port.get_name ) 3383 3325 3384 # port = definition # definition 㯠composite ã® Port ãå¾ããããã¨ããã 3385 # port = find j.get_name # celltype ã® Port (ãã¡ãã«æé©åæ 3386 å ±ããã) 3326 # port = definition # definition は composite の Port が得られることがある 3327 # port = find j.get_name # celltype の Port (こちらに最適化情報がある) 3387 3328 next if port.is_cell_unique? 3388 3329 next if port.is_omit? … … 3405 3346 if b_array then 3406 3347 # if am then 3407 # 左辺ã¯é 3408 å 3348 # 左辺は配列 3409 3349 const = ( port.is_dynamic? && ! $ram_initializer ) ? '' : 'const ' 3410 3350 init = ( port.is_dynamic? && $ram_initializer ) ? '_init_' : '' … … 3417 3357 else 3418 3358 3419 # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©åã®å ´åããã®é 3420 åã¯åç 3421 §ãããªã 3422 # mikan ãã®ã±ã¼ã¹ããã¹ãããã¦ããªã 3359 # スケルトン関数不要最適化の場合、この配列は参照されない 3360 # mikan このケースがテストされていない 3423 3361 f.printf( "#{const}%s_IDX %s_%s[] = {\n", 3424 # "#{j.get_celltype.get_global_name}", # å³è¾º composite ã«å¯¾å¿ã§ããªã3362 # "#{j.get_celltype.get_global_name}", # 右辺 composite に対応できない 3425 3363 "#{j.get_rhs_cell.get_celltype.get_global_name}", 3426 3364 "#{c.get_global_name}", … … 3444 3382 3445 3383 if j then 3446 # åä¸ã»ã«ã¿ã¤ãã®çµåã®å ´åãVDES åã¸ã®ãã£ã¹ããå¿ 3447 è¦ 3384 # 同一セルタイプの結合の場合、VDES 型へのキャストが必要 3448 3385 if j.get_rhs_cell.get_celltype == self then 3449 3386 definition = j.get_definition … … 3455 3392 3456 3393 if j.get_rhs_subscript then 3457 # å³è¾ºé 3458 åã®å ´å(æé©åã¯ãªã) 3394 # 右辺配列の場合(最適化はない) 3459 3395 subscript = j.get_rhs_subscript 3460 3396 f.printf( " %s%d,\n", … … 3465 3401 3466 3402 else 3467 # å³è¾ºéé 3468 åã®å ´å */ 3403 # 右辺非配列の場合 */ 3469 3404 if ! port.is_skelton_useless? then 3470 3405 f.printf( " %s,\n", … … 3477 3412 end 3478 3413 else 3479 # optional ã§å¼ã³å£é 3480 åè¦ç´ ãåæåããã¦ããªã 3414 # optional で呼び口配列要素が初期化されていない 3481 3415 f.printf( " 0,\n" ) 3482 3416 end 3483 3417 # } 3484 3418 end 3485 # mikan cell ã® namespace æªå¯¾å¿ãJoin 㧠Cell ãªãã¸ã§ã¯ããå¼å½ã¦ããå¿ 3486 è¦ãã 3419 # mikan cell の namespace 未対応、Join で Cell オブジェクトを引当ておく必要あり 3487 3420 f.print "};\n" 3488 # dynamic ã®å¼ã³å£é 3489 å 3421 # dynamic の呼び口配列 3490 3422 if port.is_dynamic? && $ram_initializer then 3491 3423 f.printf( "struct %s * %s_%s[ #{length} ];\n", … … 3502 3434 end 3503 3435 3504 #=== CB ãåæåããããã°ã©ã ã®çæ3436 #=== CB を初期化するプログラムの生成 3505 3437 def gen_cell_cb_initialize_code f 3506 3438 if ! need_CB_initializer? … … 3534 3466 end 3535 3467 3536 # === CB/INIB ã®å¤ã§åæåãããå¤æ°ã®åºå3468 # === CB/INIB の外で初期化される変数の出力 3537 3469 def gen_cell_cb_out_init fs 3538 3470 3539 # ã»ã«ããªããã°ãåºåããªã3471 # セルがなければ、出力しない 3540 3472 if @n_cell_gen == 0 then 3541 3473 return … … 3544 3476 fs.each{ |r, f| f.printf( TECSMsg.get( :AVAI_comment ), "#_AVAI_#" ) } 3545 3477 3546 # attribute, var ã®ãã¤ã³ã¿åã®åç 3547 §ããé 3548 åãçæ 3478 # attribute, var のポインタ型の参照する配列を生成 3549 3479 @ordered_cell_list.each{ |c| 3550 3480 next if ! c.is_generate? … … 3556 3486 jl = c.get_join_list 3557 3487 3558 # attribute, var ã®ãã¤ã³ã¿å¤æ°ãé 3559 åã«ããåæåãããå ´åã®ãé 3560 åãåºå 3488 # attribute, var のポインタ変数が配列により初期化される場合の、配列を出力 3561 3489 av_list = ct.get_attribute_list + ct.get_var_list 3562 3490 if av_list.length != 0 then … … 3574 3502 3575 3503 if size then 3576 # å¼ãè©ä¾¡ãã(attribute, var ã«å«ã¾ããå¤æ°ãåç 3577 §å¯è½) 3504 # 式を評価する(attribute, var に含まれる変数を参照可能) 3578 3505 sz = size.eval_const( c.get_join_list, c.get_celltype.get_name_list ) 3579 # å¼ãçæããªãã (å¤æ°ãå«ã¾ãªãå½¢ã«ãã) ä¸å®å 3580 ¨ãªå½¢ã§ Token ãçæ (ã¨ã©ã¼çºçããªããã) 3506 # 式を生成しなおす (変数を含まない形にする) 不完全な形で Token を生成 (エラー発生しないから) 3581 3507 size = Expression.new( [:INTEGER_CONSTANT, Token.new(sz, nil, 0, 0)] ) 3582 3508 array_type = ArrayType.new( size ) … … 3592 3518 # name_array[3]: cell_CB_INIT 3593 3519 if !( $ram_initializer && a.get_kind == :VAR ) then 3594 # -R (ram initializer 使ç¨) ã®å ´å var ã¯åæåã³ã¼ããåºåããªã3520 # -R (ram initializer 使用) の場合 var は初期化コードを出力しない 3595 3521 if( init )then 3596 3522 str = " = #{gen_cell_cb_init( f, c, name_array, array_type, init, a.get_identifier, 1, true )}" … … 3610 3536 end 3611 3537 3612 #=== var ã®åæå¤ã® ROM é¨ã¸ã®3538 #=== var の初期値の ROM 部への 3613 3539 def gen_cell_var_init f 3614 # var ã®{ }ã§å²ã¾ããåæå¤æå®ãããã調ã¹ã3540 # var の{ }で囲まれた初期値指定があるか調べる 3615 3541 n_init = 0 3616 3542 @var.each { |v| … … 3630 3556 3631 3557 if( org_type.kind_of? PtrType )then 3632 # PtrType 㯠ArrayType ã«ããæ¿ãã3633 3634 # åæååã®è¦ç´ æ°ã ãã¨ããï¼å¾ã¯0)3558 # PtrType は ArrayType にすり替える 3559 3560 # 初期化子の要素数だけとする(後は 0) 3635 3561 t2 = ArrayType.new( Expression.create_integer_constant( init.length, nil ) ) 3636 3562 t2.set_type( type.get_type ) … … 3639 3565 end 3640 3566 3641 c = @ordered_cell_list[0] # 仮㮠cell (å®éã«ã¯ä½¿ãããªã)3567 c = @ordered_cell_list[0] # 仮の cell (実際には使われない) 3642 3568 name_array = get_name_array( c ) 3643 3569 # f.print "const #{type0.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type0.get_type_str_post} = " 3644 3570 f.print "const #{type.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type.get_type_str_post} = " 3645 3571 if org_type.kind_of? StructType then 3646 # celltype ã® default ã®åæå¤ãã3572 # celltype の default の初期値あり 3647 3573 str = gen_cell_cb_init( f, c, name_array, type, init, v.get_identifier, 1, true ) 3648 3574 elsif( org_type.kind_of?( PtrType ) || org_type.kind_of?( ArrayType ) ) then 3649 3575 str = "{ " 3650 3576 type = org_type.get_type 3651 # mikan ãã¤ã³ã¿ã§ã¯ãªããé 3652 ååã¨ããªãã¨ããã¤ã³ã¿å¤æ°ã®é åã®åãæãã 3577 # mikan ポインタではなく、配列型としないと、ポインタ変数の領域の分、損する 3653 3578 init.each { |i| 3654 3579 str += gen_cell_cb_init( f, c, name_array, type, i, v.get_identifier, 1, true ) … … 3707 3632 3708 3633 unless @singleton then 3709 # 1 ã¤ã® cell INIB ã®çµãã3634 # 1 つの cell INIB の終わり 3710 3635 if @b_need_ptab then 3711 3636 f.print( "};\n\n" ) … … 3725 3650 end 3726 3651 3727 # RAM initializer ã使ç¨ããªããã¾ã㯠ROM åããªã3652 # RAM initializer を使用しない、または ROM 化しない 3728 3653 if $ram_initializer == false || $rom == false then 3729 3654 if @singleton then … … 3772 3697 3773 3698 unless @singleton then 3774 # 1 ã¤ã® cell CB ã®çµãã3699 # 1 つの cell CB の終わり 3775 3700 if @b_need_ptab then 3776 3701 f.print( "};\n\n" ) … … 3810 3735 f.print "/* ID to INIB table #_INTAB_# */\n" 3811 3736 @ordered_cell_list.each{ |c| 3812 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # çæ対象ãã¤ãã«ã¼ã以å¤ã3737 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # 生成対象かつ、ルート以外か 3813 3738 name_array = get_name_array( c ) 3814 3739 print_indent( f, indent + 1 ) … … 3819 3744 f.print "#{@global_name}_INIB *const #{@global_name}_INIB_ptab[] ={\n" 3820 3745 @ordered_cell_list.each{ |c| 3821 if c.is_generate? then # çæ対象ãï¼3746 if c.is_generate? then # 生成対象か? 3822 3747 name_array = get_name_array( c ) 3823 3748 print_indent( f, indent + 1 ) … … 3830 3755 f.print "/* ID to CB table #_CBTAB_# */\n" 3831 3756 @ordered_cell_list.each{ |c| 3832 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # çæ対象ãã¤ãã«ã¼ã以å¤ã3757 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # 生成対象かつ、ルート以外か 3833 3758 name_array = get_name_array( c ) 3834 3759 print_indent( f, indent + 1 ) … … 3839 3764 f.print "#{@global_name}_CB *const #{@global_name}_CB_ptab[] ={\n" 3840 3765 @ordered_cell_list.each{ |c| 3841 if c.is_generate? then # çæ対象ãï¼3766 if c.is_generate? then # 生成対象か? 3842 3767 name_array = get_name_array( c ) 3843 3768 print_indent( f, indent + 1 ) … … 3851 3776 3852 3777 3853 #=== name_array ãçæ3778 #=== name_array を生成 3854 3779 # IN: cell : Cell 3855 # index : CB, INIB é 3856 åã®æ·»æ° 3780 # index : CB, INIB 配列の添数 3857 3781 # RETURN: name_array 3858 3782 # name_array[0] = @name # celltype name 3859 3783 # name_array[1] = cell.get_name # cell name 3860 3784 # name_array[2] = cell_CB_name # cell_CB_name 3861 # name_array[3] = cell_CB_INIT # cell_CB_INIT # CB ã®å¤å´ã§åæåãå¿ 3862 è¦ãªé 3863 åã®åå 3785 # name_array[3] = cell_CB_INIT # cell_CB_INIT # CB の外側で初期化が必要な配列の名前 3864 3786 # name_array[4] = cell_CB_proto # CB name for prototype 3865 3787 # name_array[5] = cell_INIB # INIB name … … 3903 3825 cell_CBP = "&#{cell_INIB_name}" 3904 3826 else 3905 cell_CBP = "NULL" # CB ã INIB ããªããã° NULL ã«ç½®æ3827 cell_CBP = "NULL" # CB も INIB もなければ NULL に置換 3906 3828 end 3907 3829 … … 3929 3851 end 3930 3852 3931 #=== attribute 㨠size_is æå®ããã var (ãã¤ã³ã¿)ã®åæåãã¼ã¿ãåºå3853 #=== attribute と size_is 指定された var (ポインタ)の初期化データを出力 3932 3854 # 3933 # ROM åãµãã¼ãã®æç¡ãããã³åºå対象ã CB ã INIB ãã«ããåºåãããå 3934 容ãç°ãªã 3855 # ROM 化サポートの有無、および出力対象が CB か INIB かにより出力される内容が異なる 3935 3856 def gen_cell_cb_attribute( cell, indent, f, name_array, cb_inib ) 3936 3857 ct = self … … 3942 3863 f.print "/* attribute(RO) */ \n" 3943 3864 elsif $rom then # && cb_inib == CB 3944 # CB 㧠rw ã¨var3865 # CB で rw と var 3945 3866 return if @n_attribute_rw == 0 3946 3867 print_indent( f, indent + 1 ) 3947 3868 f.print "/* attribute(RW) */ \n" 3948 3869 else # cb_inib == CB && $rom == false 3949 # CB ã«å 3950 ¨é¨ 3870 # CB に全部 3951 3871 return if @n_attribute_rw == 0 && @n_attribute_ro == 0 && @n_var_size_is == 0 3952 3872 print_indent( f, indent + 1 ) … … 3958 3878 next if a.is_omit? 3959 3879 if cb_inib == :INIB && a.is_rw? == true then 3960 # $rom == true ã§ãããããã¸æ¥ãªã3880 # $rom == true でしか、ここへ来ない 3961 3881 next 3962 3882 elsif cb_inib == :CB && $rom && ! a.is_rw? then … … 3966 3886 j = jl.get_item( a.get_identifier ) 3967 3887 if j then 3968 # cell ã®åæå¤æå®ãã3888 # cell の初期値指定あり 3969 3889 gen_cell_cb_init( f, cell, name_array, a.get_type, j.get_rhs, a.get_identifier, indent + 1 ) 3970 3890 elsif a.get_initializer then 3971 # celltype ã® default ã®åæå¤ãã3891 # celltype の default の初期値あり 3972 3892 gen_cell_cb_init( f, cell, name_array, a.get_type, a.get_initializer, a.get_identifier, indent + 1 ) 3973 3893 else 3974 # åæå¤æªæå®3894 # 初期値未指定 3975 3895 gen_cell_cb_init( f, cell, name_array, a.get_type, nil, a.get_identifier, indent + 1 ) 3976 3896 end … … 3978 3898 @var.each{ |v| 3979 3899 next if v.is_omit? 3980 next if v.get_size_is == nil # size_is æå®ãããå ´å attribute ã®ä¸é¨ã¨ãã¦åºå3900 next if v.get_size_is == nil # size_is 指定がある場合 attribute の一部として出力 3981 3901 3982 3902 if v.get_initializer && $ram_initializer == false then 3983 3903 gen_cell_cb_init( f, cell, name_array, v.get_type, v.get_initializer, v.get_identifier, indent + 1 ) 3984 3904 else 3985 # åæå¤æªæå® ã¾ã㯠RAM initializer 使ç¨3905 # 初期値未指定 または RAM initializer 使用 3986 3906 gen_cell_cb_init( f, cell, name_array, v.get_type, nil, v.get_identifier, indent + 1 ) 3987 3907 end … … 3989 3909 end 3990 3910 3991 #=== var ã®åæåãã¼ã¿ãåºå3911 #=== var の初期化データを出力 3992 3912 def gen_cell_cb_var( cell, indent, f, name_array ) 3993 3913 jl = cell.get_join_list … … 3999 3919 4000 3920 next if v.is_omit? 4001 next if v.get_size_is # size_is æå®ãããå ´å attribute ã®ä¸é¨ã¨ãã¦åºå3921 next if v.get_size_is # size_is 指定がある場合 attribute の一部として出力 4002 3922 4003 3923 if v.get_initializer && $ram_initializer == false then 4004 3924 gen_cell_cb_init( f, cell, name_array, v.get_type, v.get_initializer, v.get_identifier, indent + 1 ) 4005 3925 else 4006 # åæå¤æªæå® ã¾ã㯠RAM initializer 使ç¨3926 # 初期値未指定 または RAM initializer 使用 4007 3927 gen_cell_cb_init( f, cell, name_array, v.get_type, nil, v.get_identifier, indent + 1 ) 4008 3928 end … … 4017 3937 end 4018 3938 4019 #=== å¼ã³å£ã®åæåã³ã¼ãã®çæ3939 #=== 呼び口の初期化コードの生成 4020 3940 def gen_cell_cb_call_port( cell, indent, f, name_array, inib_cb ) 4021 3941 jl = cell.get_join_list … … 4031 3951 next if p.get_port_type != :CALL 4032 3952 next if p.is_omit? 4033 next if p.is_cell_unique? # æé©åï¼åä¸ã»ã«ã§å¼ã³å£ãã¯ãã«åãè¾¼ã¾ããï¼3953 next if p.is_cell_unique? # 最適化(単一セルで呼び口マクロに埋め込まれる) 4034 3954 next if inib_cb == :INIB && p.is_dynamic? && p.get_array_size == nil && ! $ram_initializer 4035 3955 next if inib_cb == :CB_DYNAMIC && ( ! p.is_dynamic? || p.get_array_size != nil ) … … 4041 3961 if j == nil then 4042 3962 dbgPrint "cell_cb_call_port: #{p.get_name} array size=#{p.get_array_size}\n" 4043 # optional å¼ã³å£3963 # optional 呼び口 4044 3964 # cdl_error( "H1003 internal error: cell \'$1\' port \'$2\': initializer not found\n" , cell.get_name, p.get_name ) 4045 3965 # exit( 1 ) … … 4059 3979 end 4060 3980 if p.get_array_size == "[]" then 4061 # æ·»æ°çç¥ã®å¼ã³å£é 4062 å 3981 # 添数省略の呼び口配列 4063 3982 print_indent( f, indent + 1 ) 4064 3983 f.printf( "%-40s /* %s #_CCP6_# */\n", "0,", "length of #{p.get_name} (n_#{p.get_name})" ) … … 4072 3991 am = j.get_array_member2 4073 3992 if am then 4074 # å¼ã³å£é 4075 åã®å ´å 3993 # 呼び口配列の場合 4076 3994 if inib_cb == :INIB && p.is_dynamic? && p.get_array_size != nil && $ram_initializer then 4077 3995 f.printf( "%-40s /* #_CCP3_# _init_ */\n", "#{cell.get_global_name}_#{j.get_name}_init_," ) … … 4080 3998 f.printf( "%-40s /* #_CCP3B_# */\n", "#{cell.get_global_name}_#{j.get_name}," ) 4081 3999 if p.get_array_size == "[]" then 4082 # æ·»æ°çç¥ã®å¼ã³å£é 4083 å 4000 # 添数省略の呼び口配列 4084 4001 print_indent( f, indent + 1 ) 4085 4002 f.printf( "%-40s /* %s #_CCP4_# */\n", "#{am.length},", "length of #{p.get_name} (n_#{p.get_name})" ) 4086 4003 end 4087 4004 else 4088 # åä¸ã»ã«ã¿ã¤ãã®çµåã®å ´åãVDES åã¸ã®ãã£ã¹ããå¿ 4089 è¦ 4005 # 同一セルタイプの結合の場合、VDES 型へのキャストが必要 4090 4006 #print "CCP0/CCP1 #{p.get_name}, #{j.get_rhs_cell.get_celltype.get_name}, #{@name}\n" 4091 4007 if j.get_rhs_cell.get_celltype == self then … … 4099 4015 4100 4016 if j.get_rhs_subscript then 4101 # åãå£é 4102 åã®å ´å 4017 # 受け口配列の場合 4103 4018 subscript = j.get_rhs_subscript 4104 4019 f.printf( "%-40s /* %s #_CCP0_# */\n", … … 4107 4022 p.get_name.to_s + init ) 4108 4023 else 4109 # å¼ã³å£é 4110 åã§ããåãå£é 4111 åã§ããªã 4024 # 呼び口配列でも、受け口配列でもない 4112 4025 if ! p.is_skelton_useless? then 4113 4026 f.printf( "%-40s /* %s #_CCP1_# */\n", … … 4115 4028 p.get_name.to_s + init ) 4116 4029 else 4117 # ã¹ã±ã«ãã³ä¸è¦æé©åï¼CB (INIB) ã¸ã®ãã¤ã³ã¿ãåãè¾¼ãï¼ 4118 c = j.get_rhs_cell # å¼ã³å 4119 ã»ã« 4120 ct = c.get_celltype # å¼ã³å 4121 ã»ã«ã¿ã¤ã 4122 name_array = ct.get_name_array( c ) # å¼ã³å 4123 ã»ã«ã¿ã¤ã㧠name_array ãå¾ã 4030 # スケルトン不要最適化(CB (INIB) へのポインタを埋め込む) 4031 c = j.get_rhs_cell # 呼び先セル 4032 ct = c.get_celltype # 呼び先セルタイプ 4033 name_array = ct.get_name_array( c ) # 呼び先セルタイプで name_array を得る 4124 4034 if ct.has_INIB? || ct.has_CB? then 4125 4035 f.printf( "%-40s /* %s #_CCP2_# */\n", "#{name_array[7]},", p.get_name ) 4126 4036 else 4127 # å¼ã³å 4128 㯠CB ã INIB ãæããªãï¼NULL ã«åæåï¼ 4037 # 呼び先は CB も INIB も持たない(NULL に初期化) 4129 4038 f.printf( "%-40s /* %s #_CCP2B_# */\n", "0,", p.get_name ) 4130 4039 end … … 4137 4046 end 4138 4047 4139 #=== åãå£ã®åæåã³ã¼ãã®çæ4048 #=== 受け口の初期化コードの生成 4140 4049 def gen_cell_cb_entry_port( cell, indent, f, name_array ) 4141 4050 jl = cell.get_join_list … … 4146 4055 f.print "/* entry port #_EP_# */ \n" 4147 4056 @port.each{ |p| 4148 # next if p.is_omit? # åãå£é 4149 åã®åæ°ã¯çç¥ããªã 4057 # next if p.is_omit? # 受け口配列の個数は省略しない 4150 4058 if p.get_port_type == :ENTRY && p.get_array_size == "[]" 4151 4059 print_indent( f, indent + 1 ) … … 4156 4064 end 4157 4065 4158 #=== ã»ã«ã® attribute ã®åæå¤ãåºå4066 #=== セルの attribute の初期値を出力 4159 4067 # 4160 #f_get_str:: true ã®å ´åãæååãè¿ããfalse ã®å ´åããã¡ã¤ã« f ã«åºåããï¼ 4161 # æååãè¿ãã¨ããæ«å°¾ã« ',' ã¯å«ã¾ããªãï¼ 4162 # ãã¡ã¤ã«ã¸åºåããã¨ããæ«å°¾ã« ',' ãåºåãããï¼æ§é ä½è¦ç´ ãé 4163 åè¦ç´ ã®åæå¤ãåºåãã㨠',' ãäºéã«åºåãããï¼ 4164 # ãã ãç¾ç¶ã§ã¯ããã¡ã¤ã«ã¸åºåãããã¨ã¯ãªã 4068 #f_get_str:: true の場合、文字列を返す、false の場合、ファイル f に出力する. 4069 # 文字列を返すとき、末尾に ',' は含まれない. 4070 # ファイルへ出力するとき、末尾に ',' が出力される.構造体要素、配列要素の初期値を出力すると ',' が二重に出力される. 4071 # ただし現状では、ファイルへ出力することはない 4165 4072 # 4166 4073 def gen_cell_cb_init( f, cell, name_array, type, init, identifier, indent, f_get_str = false ) … … 4176 4083 4177 4084 if f_get_str then 4178 # åæå¤æªæå®4085 # 初期値未指定 4179 4086 if type.kind_of?( BoolType ) then 4180 4087 str = "false" # formerly tecs_false … … 4200 4107 return str 4201 4108 else 4202 # åæå¤æªæå®4109 # 初期値未指定 4203 4110 if type.kind_of?( BoolType ) then 4204 4111 f.print " " * indent … … 4234 4141 end 4235 4142 4236 # ãã®ã¡ã½ãã㯠Celltype ã®ãã®ã§ããå¿ 4237 è¦ã¯ç¡ãï¼ä¸ã«ç¶ãã®ã§ããã«ç½®ãï¼ 4238 # åæå¤æå®ãã 4143 # このメソッドは Celltype のものである必要は無い(上に続くのでここに置く) 4144 # 初期値指定あり 4239 4145 if type.kind_of?( BoolType ) then 4240 4146 if init.instance_of?( C_EXP ) then … … 4302 4208 4303 4209 len.times { 4304 next if ! init[i] # mikan ãã®å¦ç½®ã¯é©åï¼4210 next if ! init[i] # mikan この処置は適切? 4305 4211 if f_get_str then 4306 4212 str += gen_cell_cb_init( f, cell, name_array, at, init[i], "#{identifier}[#{i}]", indent + 1, f_get_str ) … … 4384 4290 end 4385 4291 4386 #== é¢æ°ãã¼ãã«ã®å¤é¨åç 4387 § 4292 #== 関数テーブルの外部参照 4388 4293 def gen_cell_extern_mt fs 4389 4294 fs.each{ |r, f| … … 4400 4305 end 4401 4306 4402 #=== åãå£ãã£ã¹ã¯ãªãã¿ã®å®ç¾©ãçæ4307 #=== 受け口ディスクリプタの定義を生成 4403 4308 def gen_cell_ep_des fs 4404 4309 if @n_cell_gen >0 then … … 4413 4318 f = fs[ c.get_region.get_domain_root ] 4414 4319 4415 ct = c.get_celltype # ct = self ã§ãåã4320 ct = c.get_celltype # ct = self でも同じ 4416 4321 jl = c.get_join_list 4417 4322 name_array = get_name_array( c ) … … 4422 4327 next if p.get_port_type != :ENTRY 4423 4328 next if p.is_omit? 4424 if p.is_skelton_useless? # åãå£æé©ån ep_opt4329 if p.is_skelton_useless? # 受け口最適化n ep_opt 4425 4330 f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" ) 4426 4331 next … … 4433 4338 4434 4339 if len != nil then 4435 # åãå£é 4436 åã®å ´å 4340 # 受け口配列の場合 4437 4341 i = 0 4438 4342 while i < len … … 4519 4423 return if @b_reuse && ! $generate_all_template 4520 4424 if ! ( @plugin && @plugin.gen_ep_func? ) then 4521 return if $generate_no_template # $generate_all_template ããåªå 4522 ããã 4523 4524 # åèã¨ãã¦åºåãããã³ãã¬ã¼ããã¡ã¤ã«ã§ãããã¨ã示ãããã« "_templ" ãä»å ãã 4425 return if $generate_no_template # $generate_all_template より優先される 4426 4427 # 参考として出力するテンプレートファイルであることを示すために "_templ" を付加する 4525 4428 fname = "#{$gen}/#{@global_name}_templ.#{$c_suffix}" 4526 4429 else 4527 # Plugin ã«ããçæãããã»ã«ã¿ã¤ãã«ã¤ãã¦ã¯ãååçã«ãã³ãã¬ã¼ãã§ã¯ãªãã 4528 # ä¿®æ£ä¸è¦ãªã»ã«ã¿ã¤ãã®å®è£ 4529 ã³ã¼ããçæããï¼ 4530 # ãã®ããããã¡ã¤ã«åã« _temp ãä»å ããªã 4430 # Plugin により生成されたセルタイプについては、原則的にテンプレートではなく、 4431 # 修正不要なセルタイプの実装コードを生成する. 4432 # このため、ファイル名に _temp を付加しない 4531 4433 fname = "#{$gen}/#{@global_name}.#{$c_suffix}" 4532 4434 end … … 4543 4445 gen_template_attr_access f 4544 4446 gen_template_cp_fun f 4545 # gen_template_types f # 0805503 追å ãã¦ã¿ããããã£ã±ãããã4447 # gen_template_types f # 0805503 追加してみたが、やっぱりやめる 4546 4448 f.print( " *\n * #[</PREAMBLE>]# */\n\n" ) 4547 4449 f.printf TECSMsg.get( :PAC_comment ), "#_PAC_#" … … 4549 4451 gen_template_private_header f 4550 4452 if ( @plugin ) then 4551 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4453 # このメソッドの引数は plugin.rb の説明を見よ 4552 4454 @plugin.gen_preamble( f, @singleton, @name, @global_name ) 4553 4455 end … … 4558 4460 4559 4461 if ( @plugin ) then 4560 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4462 # このメソッドの引数は plugin.rb の説明を見よ 4561 4463 @plugin.gen_postamble( f, @singleton, @name, @global_name ) 4562 4464 end … … 4740 4642 next if p.get_port_type != :ENTRY 4741 4643 next if p.is_omit? 4742 next if b_inline && ! p.is_inline? # inline ãã¼ã4743 next if ! b_inline && p.is_inline? # é inline ãã¼ã4644 next if b_inline && ! p.is_inline? # inline ポート 4645 next if ! b_inline && p.is_inline? # 非 inline ポート 4744 4646 4745 4647 inline_prefix = "" … … 4798 4700 len = items.length 4799 4701 else 4800 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å4702 # ここで nil になるのは、引数なしの時に void がなかった場合 4801 4703 items = [] 4802 4704 len = 0 … … 4819 4721 4820 4722 if ( @plugin && @plugin.gen_ep_func? ) then 4821 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4723 # このメソッドの引数は plugin.rb の説明を見よ 4822 4724 @plugin.gen_ep_func_body( f, @singleton, @name, @global_name, p.get_signature.get_global_name, p.get_name, fun.get_name, "#{@global_name}_#{p.get_name}_#{fun.get_name}", functype, items ) 4823 4725 … … 4867 4769 if ! ( @plugin && @plugin.gen_ep_func? ) then 4868 4770 return if @b_reuse && ! $generate_all_template 4869 return if $generate_no_template # $generate_all_template ããåªå 4870 ããã 4871 4872 # åèã¨ãã¦åºåãããã³ãã¬ã¼ããã¡ã¤ã«ã§ãããã¨ã示ãããã« "_templ" ãä»å ãã 4771 return if $generate_no_template # $generate_all_template より優先される 4772 4773 # 参考として出力するテンプレートファイルであることを示すために "_templ" を付加する 4873 4774 fname = "#{$gen}/#{@global_name}_inline_templ.#{$h_suffix}" 4874 4775 else 4875 # Plugin ã«ããçæãããã»ã«ã¿ã¤ãã«ã¤ãã¦ã¯ãååçã«ãã³ãã¬ã¼ãã§ã¯ãªãã 4876 # ä¿®æ£ä¸è¦ãªã»ã«ã¿ã¤ãã®å®è£ 4877 ã³ã¼ããçæããï¼ 4878 # ãã®ããããã¡ã¤ã«åã« _temp ãä»å ããªã 4776 # Plugin により生成されたセルタイプについては、原則的にテンプレートではなく、 4777 # 修正不要なセルタイプの実装コードを生成する. 4778 # このため、ファイル名に _temp を付加しない 4879 4779 fname = "#{$gen}/#{@global_name}_inline.#{$h_suffix}" 4880 4780 end … … 4899 4799 4900 4800 if ( @plugin ) then 4901 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4801 # このメソッドの引数は plugin.rb の説明を見よ 4902 4802 @plugin.gen_postamble( f, @singleton, @name, @global_name ) 4903 4803 end … … 4916 4816 if fa.get_name == :write then 4917 4817 4918 # åå¾ã® " ãåãé¤ã4818 # 前後の " を取り除く 4919 4819 # file_name = fa.get_file_name.sub( /^\"(.*)\"$/, "\\1" ) 4920 4820 file_name = CDLString.remove_dquote fa.get_file_name 4921 4821 format = CDLString.remove_dquote fa.get_format 4922 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # åã® " ãåãé¤ã4923 # format = format.sub( /(.*)\"\z/, "\\1" ) # å¾ã® " ãåãé¤ã4822 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # 前の " を取り除く 4823 # format = format.sub( /(.*)\"\z/, "\\1" ) # 後の " を取り除く 4924 4824 format = format.gsub( /\\\n/, "\n" ) # \\\n => \n 4925 4825 4926 4826 4927 # mikan 以ä¸ã¯ subst_name ã§ç½®æããããã«å¤æ´ãã¹ã4928 file_name = file_name.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4929 file_name = file_name.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4930 format = format.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4931 format = format.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4932 format = format.gsub( /\$\$/, "\$" ) # $$ ã $ ã«ç½®æ4827 # mikan 以下は subst_name で置換するように変更すべき 4828 file_name = file_name.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ をセルタイプ名に置換 4829 file_name = file_name.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ をセルタイプ名に置換 4830 format = format.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ をセルタイプ名に置換 4831 format = format.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ をセルタイプ名に置換 4832 format = format.gsub( /\$\$/, "\$" ) # $$ を $ に置換 4933 4833 4934 4834 if file_name[0] != ?/ then … … 4942 4842 puts( format ) 4943 4843 end 4944 # format ä¸ã® \n, \r, \t, \f 㨠\" ãªã©ãç½®æ4844 # format 中の \n, \r, \t, \f と \" などを置換 4945 4845 fmt = CDLString.escape format 4946 4846 cfg_file.print( fmt ) … … 4959 4859 @ordered_cell_list.each{ |c| 4960 4860 4961 # cell ã®ãããã¿ã¤ã宣è¨ãªãç¡è¦4861 # cell のプロトタイプ宣言なら無視 4962 4862 next if ! c.is_generate? 4963 4863 … … 4968 4868 if fa.get_name == :write then 4969 4869 4970 # åå¾ã® " ãåãé¤ã4870 # 前後の " を取り除く 4971 4871 # file_name = fa.get_file_name.sub( /^\"(.*)\"$/, "\\1" ) 4972 4872 file_name = CDLString.remove_dquote fa.get_file_name 4973 4873 file_name = subst_name( file_name, name_array ) 4974 # format = fa.get_format.sub( /^\"(.*)\"$/, "\\1" ) # åå¾ã® "" ãåãé¤ã4874 # format = fa.get_format.sub( /^\"(.*)\"$/, "\\1" ) # 前後の "" を取り除く 4975 4875 format = CDLString.remove_dquote fa.get_format 4976 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # åã® " ãåãé¤ã4977 # format = format.sub( /(.*)\"\z/, "\\1" ) # å¾ã® " ãåãé¤ã4876 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # 前の " を取り除く 4877 # format = format.sub( /(.*)\"\z/, "\\1" ) # 後の " を取り除く 4978 4878 format = format.gsub( /\\\n/, "\n" ) # \\\n => \n 4979 4879 … … 4986 4886 end 4987 4887 4988 na = [] # ã·ã³ãã«ã attribute ã®å¤ã«ç½®ãæããå¾ã®å¼æ°4888 na = [] # シンボルを attribute の値に置き換えた後の引数 4989 4889 if arg_list then 4990 4890 arg_list.each { |a| 4991 4891 case a[0] 4992 when :STRING_LITERAL # æååå®æ°4993 # s = a[1].sub( /^\"(.*)\"$/, "\\1" ) # åå¾ã® "" ãåãé¤ã4892 when :STRING_LITERAL # 文字列定数 4893 # s = a[1].sub( /^\"(.*)\"$/, "\\1" ) # 前後の "" を取り除く 4994 4894 s = CDLString.remove_dquote a[1] 4995 4895 s = subst_name( s, name_array ) … … 4998 4898 na << s 4999 4899 when :IDENTIFIER 5000 param_name = a[1] # èå¥åï¼å±æ§ã®ååï¼4900 param_name = a[1] # 識別子(属性の名前) 5001 4901 attr = self.find( param_name ) 5002 init = attr.get_initializer # celltype ã§æå®ãããåæå¤5003 5004 # cell ã® join ã®ãªã¹ãããååãæ¢ã4902 init = attr.get_initializer # celltype で指定された初期値 4903 4904 # cell の join のリストから名前を探す 5005 4905 j = c.get_join_list.get_item( param_name ) 5006 if j then # param_name ã® cell ã®ã¸ã§ã¤ã³ãããã 5007 init = j.get_rhs # cell ã§æå®ãããåæå¤ãåªå 5008 4906 if j then # param_name の cell のジョインがあるか 4907 init = j.get_rhs # cell で指定された初期値を優先 5009 4908 end 5010 4909 … … 5012 4911 # file,cell, name_array, type, init, identifier, indent, f_get_str 5013 4912 5014 # str = str.sub( /^\"(.*)\"$/, "\\1" ) # åå¾ã® "" ãåãé¤ã mikan ããã§ç½®æã§ããï¼4913 # str = str.sub( /^\"(.*)\"$/, "\\1" ) # 前後の "" を取り除く mikan ここで置換でよい? 5015 4914 str = CDLString.remove_dquote str 5016 4915 na << str … … 5030 4929 end 5031 4930 5032 # format ä¸ã® \n, \r, \t, \f 㨠\" ãªã©ãç½®æ4931 # format 中の \n, \r, \t, \f と \" などを置換 5033 4932 fmt = CDLString.escape format 5034 4933 cfg_file.printf( fmt, *na ) … … 5054 4953 return if $generate_no_template 5055 4954 5056 # Makefile.templ ã®çæï¼è¿½è¨ï¼4955 # Makefile.templ の生成(追記) 5057 4956 5058 4957 f = AppFile.open( "#{$gen}/Makefile.templ" ) … … 5062 4961 5063 4962 EOT 5064 # ãã®çæè¦åã¯2ç¹ã§æå³ããªã5065 # ã»$(GEN_DIR) ã« .o ãçæããã«ã¼ã«ããªã5066 # ã»ãã³ãã¬ã¼ãã³ã¼ãããã®ã¾ã¾ãã«ãããã®ã¯ç´ãããã4963 # この生成規則は2点で意味がない 4964 # ・$(GEN_DIR) に .o を生成するルールがない 4965 # ・テンプレートコードをそのままビルドするのは紛らわしい 5067 4966 # # Celltype: #{@name} 5068 4967 # $(GEN_DIR)/#{@global_name}_tecsgen.o : $(GEN_DIR)/#{@global_name}_tecsgen.#{$c_suffix} … … 5081 4980 headers = [ "$(GEN_DIR)/#{@global_name}_tecsgen.#{$h_suffix}", "$(GEN_DIR)/#{@global_name}_factory.#{$h_suffix}", "$(GEN_DIR)/global_tecsgen.#{$h_suffix}" ] 5082 4981 5083 # inline åãå£ãæã¤ãï¼4982 # inline 受け口を持つか? 5084 4983 if @n_entry_port_inline > 0 then 5085 4984 headers << "#{@global_name}_inline.#{$h_suffix}" 5086 4985 end 5087 4986 5088 # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®ããã4987 # 呼び口または受け口のシグニチャのヘッダ 5089 4988 @port.each { |p| 5090 4989 next if p.is_omit? … … 5111 5010 end 5112 5011 5113 #=== decl ç¨ã® dealloc ã³ã¼ããçæ 5114 #b_reset:: Bool: ãªã»ããç¨ã® dealloc ã³ã¼ãã®çæ (NULL ãã¤ã³ã¿ã®å ´å dealloc ããªã) 5115 # mikan string 修飾ããããã¤ã³ã¿ã®å 5116 ã«ãã¤ã³ã¿ãæ¥ãªãã¨ä»®å®ããã¤ã³ã¿åãæã¤æ§é ä½ã®å¯è½æ§ãæé¤ãã¦ããªã 5117 # ãã®ã¡ã½ããã§ã¯ãè¡ãåºåããç´åã« " \\\n" ãåºåããè¡æ«ã§æ¹è¡æåãåºåããªã 5012 #=== decl 用の dealloc コードを生成 5013 #b_reset:: Bool: リセット用の dealloc コードの生成 (NULL ポインタの場合 dealloc しない) 5014 # mikan string 修飾されたポインタの先にポインタが来ないと仮定。ポインタ型を持つ構造体の可能性を排除していない 5015 # このメソッドでは、行を出力する直前に " \\\n" を出力し、行末で改行文字を出力しない 5118 5016 def gen_dealloc_code_for_type( f, type, dealloc_func_name, pre, name, post, level, b_reset, count_str = nil ) 5119 5017 type = type.get_original_type … … 5144 5042 post2 = "" 5145 5043 type2 = md.get_type.get_original_type 5146 if type2.kind_of? PtrType then # mikan typedef ãããå5044 if type2.kind_of? PtrType then # mikan typedef された型 5147 5045 if type2.get_count then 5148 5046 count_str = type2.get_count.to_str( members_decl, pre2, post2 ) … … 5217 5115 end 5218 5116 5219 # å¼ã³å£ã®çµåå 5220 ã®ã»ã«ã¿ã¤ãã®ãããï¼æé©åã®å ´åã®ã¿ï¼ 5221 # çµåå 5222 ã®åãå£ã inline ã®å ´åãinline ãããã 5117 # 呼び口の結合先のセルタイプのヘッダ(最適化の場合のみ) 5118 # 結合先の受け口が inline の場合、inline ヘッダも 5223 5119 @port.each { |p| 5224 5120 next if p.get_port_type != :CALL … … 5226 5122 5227 5123 if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then 5228 # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©5124 # 最適化コード (optimize) # スケルトン不要など 5229 5125 p2 = p.get_real_callee_port 5230 5126 if p2 then … … 5236 5132 headers += ct.get_depend_header_list_( celltype_list ) 5237 5133 #else 5238 # optional ã§æªçµå5134 # optional で未結合 5239 5135 end 5240 5136 end … … 5244 5140 5245 5141 5246 #=== $id$, $ct$, $cb$, $idx$ ç½®æ5142 #=== $id$, $ct$, $cb$, $idx$ 置換 5247 5143 # 5248 # str ã«ä»¥ä¸ã®ç½®æãè¡ã5249 #- $ct$ â ã»ã«ã¿ã¤ãå(ct)5250 #- $cell$ â ã»ã«å(cell) cell ã nil ãªãã°ä»¥ä¸ã®ç½®æã¯è¡ãããªã5251 #- $cb$ â CB ã® C è¨èªå(cb)5252 #- $cbp$ â CB ã¸ã®ãã¤ã³ã¿(cbp)5253 #- $cb_proto$ â CB ã® C è¨èªåãããã¿ã¤ã宣è¨ç¨(cb_proto)5254 #- $id$ â$ct$_$cell_global$ # ct_cell before or same V1.5.25255 #- $idx$ âidx5256 #- $ID$ â id (æ´æ°ã®çªå·)5257 #- $ct_global$ â ã»ã«ã¿ã¤ãå(ct)5258 #- $cell_global$ â ã»ã«å(cell)5259 #- $$ â$5144 # str に以下の置換を行う 5145 #- $ct$ ⇒ セルタイプ名(ct) 5146 #- $cell$ ⇒ セル名(cell) cell が nil ならば以下の置換は行われない 5147 #- $cb$ ⇒ CB の C 言語名(cb) 5148 #- $cbp$ ⇒ CB へのポインタ(cbp) 5149 #- $cb_proto$ ⇒ CB の C 言語名プロトタイプ宣言用(cb_proto) 5150 #- $id$ ⇒ $ct$_$cell_global$ # ct_cell before or same V1.5.2 5151 #- $idx$ ⇒ idx 5152 #- $ID$ ⇒ id (整数の番号) 5153 #- $ct_global$ ⇒ セルタイプ名(ct) 5154 #- $cell_global$ ⇒ セル名(cell) 5155 #- $$ ⇒ $ 5260 5156 def subst_name( str, name_array ) 5261 5157 ct = name_array[0] # celltype name 5262 5158 cell = name_array[1] # cell name 5263 5159 cb = name_array[2] # cell CB name 5264 cb_init = name_array[3] # cell CB INIT, ããã¯ç½®æã«ä½¿ãããªã5160 cb_init = name_array[3] # cell CB INIT, これは置換に使われない 5265 5161 cb_proto = name_array[4] # cell CB name for prototype 5266 5162 id = name_array[6] # cell ID … … 5283 5179 str = str.gsub( /(^|[^\$])\$cell_global\$/, "\\1#{cell_global}" ) 5284 5180 end 5285 str = str.gsub( /\$\$/, "\$" ) # $$ ã $ ã«ç½®æ5181 str = str.gsub( /\$\$/, "\$" ) # $$ を $ に置換 5286 5182 5287 5183 return str … … 5290 5186 end 5291 5187 5292 # Appendable File ï¼è¿½è¨å¯è½ãã¡ã¤ã«ï¼5188 # Appendable File(追記可能ファイル) 5293 5189 class AppFile 5294 # éãããã¡ã¤ã«ã®ãªã¹ã5190 # 開いたファイルのリスト 5295 5191 @@file_name_list = {} 5296 5192 … … 5309 5205 end 5310 5206 5311 # æ¢ã«éãã¦ãããï¼5207 # 既に開いているか? 5312 5208 if @@file_name_list[ name ] then 5313 5209 #2.0 5314 5210 mode = "a" + mode 5315 # 追è¨ã¢ã¼ãã§éã5211 # 追記モードで開く 5316 5212 file = File.open( real_name, mode ) 5317 5213 else 5318 5214 #2.0 5319 5215 mode = "w" + mode 5320 # æ°è¦ã¢ã¼ãã§éãï¼æ¢ã«ããã°ããµã¤ãºãï¼ã«ããï¼5216 # 新規モードで開く(既にあれば、サイズを0にする) 5321 5217 file = File.open( real_name, mode ) 5322 5218 @@file_name_list[ name ] = true 5323 5219 end 5324 # File ã¯ã©ã¹ã®ãªãã¸ã§ã¯ããè¿ã5220 # File クラスのオブジェクトを返す 5325 5221 return file 5326 5222 end -
Property svn:mime-type
changed from
Note:
See TracChangeset
for help on using the changeset viewer.