- Timestamp:
- Aug 23, 2017, 9:27:43 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/generate.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2016 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 # $Id : generate.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 … … 134 119 end 135 120 136 # celltype_private.h ãçæ121 # celltype_private.h を生成 137 122 138 123 class Namespace … … 140 125 141 126 begin 142 # root namespace ãªãã° makefile ãåºåãã(å 143 ¨ã»ã«ã¿ã¤ãã«é¢ãããã®ã ã) 144 # å 145 ã«åºåãã 127 # root namespace ならば makefile を出力する(全セルタイプに関わるものだけ) 128 # 先に出力する 146 129 if @name == "::" then 147 130 … … 155 138 156 139 dbgPrint "generating region: #{$generating_region.get_name} namespace=#{@name} gen_dir=#{$gen}\n" 157 # global_tecsgen.h (typedef, struct, const) ã®çæ140 # global_tecsgen.h (typedef, struct, const) の生成 158 141 gen_global_header 159 142 160 # signature ã®ã³ã¼ããçæ143 # signature のコードを生成 161 144 @signature_list.each { |s| 162 145 s.generate 163 146 } 164 147 165 # celltype ã®ã³ã¼ããçæ148 # celltype のコードを生成 166 149 @celltype_list.each { |t| 167 150 t.generate 168 151 } 169 152 170 # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ153 # サブネームスペースのコードを生成 171 154 @namespace_list.each { |n| 172 155 n.generate … … 174 157 175 158 rescue => evar 176 # ããã¹ã¿ãã¯ãã¬ã¼ã¹ãåºãã¾ã§ãæéãããããããªãã°ã次ãã³ã¡ã³ãã¢ã¦ããã¦ã¿ãã¹ã159 # もしスタックトレースが出るまでい時間がかかるようならば、次をコメントアウトしてみるべし 177 160 cdl_error( "H1001 tecsgen: fatal internal error during code generation" ) 178 161 print_exception( evar ) … … 187 170 188 171 begin 189 # global_tecsgen.h (typedef, struct, const) ã®çµããã®ã¬ã¼ãã³ã¼ãçæ172 # global_tecsgen.h (typedef, struct, const) の終わりのガードコード生成 190 173 gen_global_header_post 191 174 192 # signature ã®ã³ã¼ããçæ175 # signature のコードを生成 193 176 @signature_list.each { |s| 194 177 s.generate_post 195 178 } 196 179 197 # celltype ã®ã³ã¼ããçæ180 # celltype のコードを生成 198 181 @celltype_list.each { |t| 199 182 t.generate_post 200 183 } 201 184 202 # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ185 # サブネームスペースのコードを生成 203 186 @namespace_list.each { |n| 204 187 n.generate_post … … 214 197 def gen_global_header 215 198 216 # global_tecs.h ã®çæ199 # global_tecs.h の生成 217 200 f = AppFile.open( "#{$gen}/global_tecsgen.#{$h_suffix}" ) 218 201 … … 220 203 print_note f 221 204 222 # ã¬ã¼ãã³ã¼ããåºå205 # ガードコードを出力 223 206 f.print <<EOT 224 207 #ifndef GLOBAL_TECSGEN_H … … 227 210 EOT 228 211 229 # import_C ã§æå®ãããããããã¡ã¤ã«ã® #include ãåºå212 # import_C で指定されたヘッダファイルの #include を出力 230 213 if Import_C.get_header_list2.length > 0 then 231 # ããã include ã®åºå214 # ヘッダ include の出力 232 215 f.printf TECSMsg.get( :IMP_comment ), "#_IMP_#" 233 216 Import_C.get_header_list2.each{ |h| … … 240 223 end 241 224 242 # typedef, struct, enum ãçæ225 # typedef, struct, enum を生成 243 226 @decl_list.each { |d| 244 227 245 # d 㯠Typedef, StructType, EnumType ã®ãããã228 # d は Typedef, StructType, EnumType のいずれか 246 229 if d.instance_of?( Typedef ) then 247 230 248 # Typedef ã®å ´åãdeclarator ã® @type ããCType ã§ãªãã231 # Typedef の場合、declarator の @type が CType でないか 249 232 if ! d.get_declarator.get_type.kind_of?( CType ) then 250 233 d.gen_gh f … … 252 235 elsif ! d.kind_of?( CType ) then 253 236 254 # CType ã§ã¯ãªã (StructType ã¾ãã¯EnumType)237 # CType ではない (StructType または EnumType) 255 238 d.gen_gh f 256 239 # else 257 # ããã«è©²å½ããã®ã¯CStructType, CEnumType240 # ここに該当するのは CStructType, CEnumType 258 241 end 259 242 } … … 283 266 end 284 267 285 # const ãçæmikan268 # const を生成 mikan 286 269 @const_decl_list.each { |d| 287 270 f.printf( "#define %-14s ((%s%s)%s)\n", d.get_global_name, … … 296 279 def gen_global_header_post 297 280 298 # global_tecs.h ãéã281 # global_tecs.h を開く 299 282 f = AppFile.open( "#{$gen}/global_tecsgen.#{$h_suffix}" ) 300 283 … … 310 293 end 311 294 312 #=== Makefile.tecsgen, Makefile.templ ã®åºå 313 # å 314 ¨ã»ã«ã¿ã¤ãåãåºåããé¨åãåºå 315 # ï¼æ¬ã¡ã½ãã㯠root namespace ã«å¯¾ãã¦å¼åºãï¼ 316 # åã 317 ã®ã»ã«ã¿ã¤ãã®ã¡ã¼ã¯ã«ã¼ã«ã¯ Celltype ã¯ã©ã¹ã§åºå 295 #=== Makefile.tecsgen, Makefile.templ の出力 296 # 全セルタイプ名を出力する部分を出力 297 # (本メソッドは root namespace に対して呼出す) 298 # 個々のセルタイプのメークルールは Celltype クラスで出力 318 299 def gen_makefile 319 300 gen_makefile_template … … 325 306 return if $generate_no_template 326 307 327 ### Makefile.templ ã®çæ308 ### Makefile.templ の生成 328 309 f = AppFile.open( "#{$gen}/Makefile.templ" ) 329 310 330 311 print_Makefile_note f 331 312 332 # Makefile ã®å¤æ°ã®åºå313 # Makefile の変数の出力 333 314 f.printf TECSMsg.get( :MVAR_comment ), "#_MVAR_#" 334 315 f.printf "# fixed variable (unchangeable by config or plugin)\n" 335 316 336 # TARGET ã®åºå (第ä¸å¼æ° $target ã« region åããã³ .exe ãä»å)317 # TARGET の出力 (第一引数 $target に region 名および .exe を付加) 337 318 target = $target 338 319 if $generating_region != @@root_namespace then 339 # å region ã®ãªã³ã¯ã¿ã¼ã²ããã®å ´å320 # 子 region のリンクターゲットの場合 340 321 target += "-#{$generating_region.get_global_name}" 341 322 end … … 419 400 EOT 420 401 421 # make ã«ã¼ã«ã®åºå402 # make ルールの出力 422 403 f.printf( TECSMsg.get( :MRUL_comment), "#_MRUL_#" ) 423 404 … … 447 428 f.print "-include $(GEN_DIR)/Makefile.tecsgen\n" 448 429 if $generating_region.get_n_cells != 0 then 449 # Makefile.depend ã®include430 # Makefile.depend の include 450 431 f.print "-include $(GEN_DIR)/Makefile.depend\n\n" 451 432 … … 457 438 f.print "\nsub_regions:$(TIMESTAMP)\n" 458 439 Region.get_link_roots.each {|region| 459 if region.get_global_name != "" then # Root region: ãã® Makefile èªèº«440 if region.get_global_name != "" then # Root region: この Makefile 自身 460 441 f.print "\tcd #{region.get_global_name}; make all\n" 461 442 end … … 464 445 end 465 446 466 # clean: ã¿ã¼ã²ãã447 # clean: ターゲット 467 448 f.print "clean :\n" 468 449 if $generating_region == @@root_namespace then 469 450 Region.get_link_roots.each {|region| 470 if region.get_global_name != "" then # Root region: ãã® Makefile èªèº«451 if region.get_global_name != "" then # Root region: この Makefile 自身 471 452 f.print "\tcd #{region.get_global_name}; make clean\n" 472 453 end … … 479 460 f.print "\n" 480 461 481 # tecs: ã¿ã¼ã²ãã462 # tecs: ターゲット 482 463 if $generating_region == @@root_namespace then 483 464 f.print "tecs : $(PRE_TECSGEN_TARGET) $(TIMESTAMP) $(POST_TECSGEN_TARGET)\n\n" … … 508 489 509 490 def gen_makefile_tecsgen 510 ### Makefile.tecsgen ã®çæ491 ### Makefile.tecsgen の生成 511 492 f = AppFile.open( "#{$gen}/Makefile.tecsgen" ) 512 493 … … 563 544 domain_regions = nil 564 545 DomainType.get_domain_regions.each{ |dt, regions| 565 # domain_type ã¯ä¸ã¤ã®ãã¼ãã«ã¯ãä¸ã¤ãããªãã®ã§ããã®ã«ã¼ãã¯ãå¿ 566 ãä¸åããåããªã 546 # domain_type は一つのノードには、一つしかないので、このループは、必ず一回しか回らない 567 547 domain_regions = regions 568 548 domain_type = dt … … 687 667 end 688 668 689 #=== ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå 690 #f:: FILE: åºåå 691 ãã¡ã¤ã« 692 #prepend:: string: åç½®æåå 693 #append:: string: å¾ç½®æåå 694 #b_plguin:: bool: plugin ã«ããçæãããã»ã«ã¿ã¤ããåºå 695 ##b_inline_only:: bool: true ãªãã° inline ã® entry port ã®ã¿ã®ã»ã«ã¿ã¤ããå«ãã 696 #b_inline_only_or_proc:: bool|Proc: true ãªãã° inline ã® entry port ã®ã¿ããã¤ã¤ã³ã¢ã¯ãã£ããªã»ã«ã¿ã¤ããå«ãã 697 # Proc ãªãã° Proc ãå®è¡ããçµæ true ãªãã°å«ãã 698 # namespace "::" ããå¼åºããã 669 #=== すべてのセルタイプの名前を出力 670 #f:: FILE: 出力先ファイル 671 #prepend:: string: 前置文字列 672 #append:: string: 後置文字列 673 #b_plguin:: bool: plugin により生成されたセルタイプを出力 674 ##b_inline_only:: bool: true ならば inline の entry port のみのセルタイプを含める 675 #b_inline_only_or_proc:: bool|Proc: true ならば inline の entry port のみ、かつインアクティブなセルタイプを含める 676 # Proc ならば Proc を実行した結果 true ならば含める 677 # namespace "::" から呼出される 699 678 def gen_celltype_names( f, prepend, append, b_plugin, b_inline_only_or_proc = true ) 700 679 dbgPrint "gen_celltype_names #{@name}\n" … … 716 695 end 717 696 718 #=== ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå697 #=== すべてのセルタイプの名前を出力 719 698 #region:: Region: 720 # gen_celltype_names ã¨gen_celltype_names_domain ã®ç¸éï¼ 721 # region ã domain_roots ã«å«ãå ´åãåºåããï¼ 722 # ã¾ãã¯ãregion ãå«ã¾ãªãããdomain_roots ãè¤æ°ãã¤ã«ã¼ããªã¼ã¸ã§ã³ã®å ´åãåºåããï¼ 723 # ãã以å¤ã¯ãgen_celltype_names ã®èª¬æãåç 724 § 699 # gen_celltype_names とgen_celltype_names_domain の相違: 700 # region を domain_roots に含む場合、出力する. 701 # または、region を含まないが、domain_roots が複数かつルートリージョンの場合、出力する. 702 # それ以外は、gen_celltype_names の説明を参照 725 703 def gen_celltype_names_domain( f, prepend, append, domain_type, region, b_plugin, b_inline_only = true ) 726 704 dbgPrint "gen_celltype_names #{@name}\n" … … 752 730 } 753 731 end 754 #== Namespace# ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå755 # ã»ã«ã¿ã¤ãã³ã¼ãã®ããã®åååºå756 # gen_celltype_names_domain 㨠gen_celltype_names_domain2 ã®ç¸é757 # ã»ã©ããä¸ã¤ã®ãªã¼ã¸ã§ã³ã«ããåºããªã758 # domain_roots ã1ã¤ã ãã§ãæå®ãªã¼ã¸ã§ã³ãå«ã759 # domain_roots ã2ã¤ä»¥ä¸ã§ãæå®ãªã¼ã¸ã§ã³ãã«ã¼ããªã¼ã¸ã§ã³760 # ã»ãã¡ã¤ã³åãä»å ããªã732 #== Namespace#すべてのセルタイプの名前を出力 733 # セルタイプコードのための名前出力 734 # gen_celltype_names_domain と gen_celltype_names_domain2 の相違 735 # ・どれか一つのリージョンにしか出さない 736 # domain_roots が1つだけで、指定リージョンを含む 737 # domain_roots が2つ以上で、指定リージョンがルートリージョン 738 # ・ドメイン名を付加しない 761 739 def gen_celltype_names_domain2( f, prepend, append, domain_type, region, b_plugin, b_inline_only = true ) 762 740 dbgPrint "gen_celltype_names #{@name}\n" … … 885 863 def gen_sh_func_tab f 886 864 887 # ã·ã°ããã£ãã£ã¹ã¯ãªãã¿ã®åºå865 # シグニチャディスクリプタの出力 888 866 f.printf TECSMsg.get(:SD_comment), "#_SD_#" 889 867 f.print "struct tag_#{@global_name}_VDES {\n" … … 891 869 f.print "};\n\n" 892 870 893 # ã·ã°ããã£é¢æ°ãã¼ãã«ã®åºå871 # シグニチャ関数テーブルの出力 894 872 f.printf TECSMsg.get(:SFT_comment), "#_SFT_#" 895 873 f.print( "struct tag_#{@global_name}_VMT {\n" ) … … 906 884 len = items.length 907 885 else 908 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å886 # ここで nil になるのは、引数なしの時に void がなかった場合 909 887 items = [] 910 888 len = 0 … … 932 910 end 933 911 934 #=== Signature# é¢æ°ã® ID ã® define ãåºå912 #=== Signature# 関数の ID の define を出力 935 913 def gen_sh_func_id f 936 914 f.print "/* function id */\n" … … 951 929 def generate 952 930 953 if need_generate? # ã»ã«ã®ãªãã»ã«ã¿ã¤ãã¯çæããªã931 if need_generate? # セルのないセルタイプは生成しない 954 932 955 933 generate_private_header … … 962 940 generate_makefile 963 941 964 elsif $generate_all_template # ãã³ãã¬ã¼ãã³ã¼ãçæãªãã·ã§ã³942 elsif $generate_all_template # テンプレートコード生成オプション 965 943 966 944 generate_template_code 967 945 generate_inline_template_code 968 946 969 # generate_makefile_template 㯠Makefile ã«è¿½è¨ãããã®ã ãããå¼ã³åºããªã947 # generate_makefile_template は Makefile に追記するものだから、呼び出さない 970 948 971 949 end … … 974 952 975 953 def generate_post 976 return if ! need_generate? # ã»ã«ã®ãªãã»ã«ã¿ã¤ãã¯çæããªã954 return if ! need_generate? # セルのないセルタイプは生成しない 977 955 978 956 generate_private_header_post … … 994 972 gen_ph_cell_cb_type f 995 973 gen_ph_INIB_as_CB f 996 gen_ph_extern_cell f # ã»ã«ã¿ã¤ãã°ã«ã³ã¼ã以å¤ã¯åç 997 §ããªã 998 gen_ph_typedef_idx f # mikan åç 999 §ãããã®ãã§ãã¦ããªã 974 gen_ph_extern_cell f # セルタイプグルコード以外は参照しない 975 gen_ph_typedef_idx f # mikan 参照するものができていない 1000 976 gen_ph_ep_fun_prototype f 1001 977 end_extern_C f … … 1005 981 1006 982 if @n_entry_port_inline == 0 then 1007 # inline ããªããã° CB_TYPE_ONLY ã¨ãã1008 # inline ããã®å ´åããã£ãã define ãã¦ããã¦ãå¾ã§ãã¹ã¦ undef ãã983 # inline がなければ CB_TYPE_ONLY とする 984 # inline ありの場合、いったん define しておいて、後ですべて undef する 1009 985 ifndef_cb_type_only f 1010 986 end … … 1028 1004 # gen_ph_cell_cb_type f 1029 1005 # gen_ph_INIB_as_CB f 1030 # gen_ph_extern_cell f # ã»ã«ã¿ã¤ãã°ã«ã³ã¼ã以å¤ã¯åç 1031 §ããªã 1032 # gen_ph_typedef_idx f # mikan åç 1033 §ãããã®ãã§ãã¦ããªã 1006 # gen_ph_extern_cell f # セルタイプグルコード以外は参照しない 1007 # gen_ph_typedef_idx f # mikan 参照するものができていない 1034 1008 # gen_ph_ep_fun_prototype f 1035 1009 gen_ph_ep_skel_prototype f … … 1037 1011 endif_macro_only f 1038 1012 1039 # ç縮形ãªã©ã®ãã¯ãåºå1013 # 短縮形などのマクロ出力 1040 1014 if @n_entry_port_inline == 0 then 1041 1015 ifndef_cb_type_only f … … 1047 1021 gen_ph_test_optional_call_port_abbrev f 1048 1022 gen_ph_ep_fun_macro f if @n_entry_port > 0 1049 gen_ph_foreach_cell f # FOREACH ãã¯ãã®åºå1050 gen_ph_cb_initialize_macro f # CB åæåãã¯ãã®åºåï¼æ¶è²»ããªãã®ã§ ram_initializer ãã©ã°ã«é¢ãããåºå1023 gen_ph_foreach_cell f # FOREACH マクロの出力 1024 gen_ph_cb_initialize_macro f # CB 初期化マクロの出力.消費しないので ram_initializer フラグに関わらず出力 1051 1025 gen_ph_dealloc_code f, "" 1052 1026 gen_ph_dealloc_code f, "_RESET" … … 1095 1069 next if p.get_port_type != :CALL 1096 1070 1097 # is_...joined 㯠omit ããã±ã¼ã¹ã§ãåºåããããããomit ãæ¤æ»ããåã«åºå1071 # is_...joined は omit するケースでも出力されるため、omit を検査する前に出力 1098 1072 if p.is_optional? then 1099 1073 f.print( "#undef is_#{p.get_name}_joined\n" ) … … 1130 1104 end 1131 1105 1132 #=== CELLTYPE_tecsgen.c ãçæ1106 #=== CELLTYPE_tecsgen.c を生成 1133 1107 def generate_cell_code 1134 1108 fs = { } … … 1165 1139 end 1166 1140 1167 # ãã¹ã¦ã® _tecsgen.c ã«åºå1141 # すべての _tecsgen.c に出力 1168 1142 print_note f 1169 1143 gen_cell_private_header f … … 1171 1145 gen_cell_ep_des_type f 1172 1146 1173 # ãã¹ã¦ã® _tecsgen.c ã«åºå1147 # すべての _tecsgen.c に出力 1174 1148 fs.each{ |r,f2| 1175 1149 if f == f2 then … … 1182 1156 } 1183 1157 1184 # ä¸ã¤ã® _tecsgen.c ã«åºå1158 # 一つの _tecsgen.c に出力 1185 1159 gen_cell_skel_fun f 1186 1160 gen_cell_fun_table f 1187 1161 gen_cell_var_init f 1188 1162 1189 # ã»ã«ãã¨ã« _tecsgen.c ã«åºå1163 # セルごとに _tecsgen.c に出力 1190 1164 gen_cell_ep_vdes fs 1191 1165 gen_cell_ep_vdes_array fs 1192 gen_cell_cb_out_init fs # INITIALIZE_CB ã§åç 1193 §ããããã ram_initializer=false ã§ãæ¶ããªã 1166 gen_cell_cb_out_init fs # INITIALIZE_CB で参照されるため ram_initializer=false でも消せない 1194 1167 gen_cell_cb fs 1195 1168 gen_cell_extern_mt fs 1196 1169 gen_cell_ep_des fs 1197 1170 1198 # ä¸ã¤ã® _tecsgen.c ã«åºå1171 # 一つの _tecsgen.c に出力 1199 1172 gen_cell_cb_tab f 1200 1173 if $ram_initializer then … … 1251 1224 1252 1225 def gen_ph_include f 1253 # ã©ã³ã¿ã¤ã ãããã®include1226 # ランタイムヘッダの include 1254 1227 # f.printf TECSMsg.get( :IRTH_comment), "#_IRTH_#" 1255 1228 # f.print "#include \"tecs.#{$h_suffix}\"\n\n" 1256 1229 1257 # ã°ãã¼ãã«ãããã®include1230 # グローバルヘッダの include 1258 1231 f.printf TECSMsg.get( :IGH_comment ), "#_IGH_#" 1259 1232 f.print "#include \"global_tecsgen.#{$h_suffix}\"\n\n" 1260 1233 1261 # ã·ã°ããã£ãããã®include1234 # シグニチャヘッダの include 1262 1235 f.printf TECSMsg.get( :ISH_comment ), "#_ISH_#" 1263 1236 @port.each { |p| … … 1277 1250 end 1278 1251 1279 # æé©åã®ããåç 1280 §ããã»ã«ã¿ã¤ãã® CB åã®å®ç¾©ãåè¾¼ã 1281 # _CB_TYPE_ONLY ãå®ç¾©ããä¸ã§ include ãã 1252 # 最適化のため参照するセルタイプの CB 型の定義を取込む 1253 # _CB_TYPE_ONLY を定義した上で include する 1282 1254 f.printf( TECSMsg.get( :ICT_comment ), "#_ICT_#" ) 1283 1255 … … 1292 1264 1293 1265 if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then 1294 # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©1266 # 最適化コード (optimize) # スケルトン不要など 1295 1267 p2 = p.get_real_callee_port 1296 1268 if p2 then … … 1301 1273 end 1302 1274 # else 1303 # optional ã§æªçµå1275 # optional で未結合 1304 1276 end 1305 1277 end … … 1313 1285 # next if p.get_port_type != :CALL 1314 1286 # if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then 1315 # # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©1287 # # 最適化コード (optimize) # スケルトン不要など 1316 1288 # p2 = p.get_real_callee_port 1317 1289 # ct = p2.get_celltype … … 1329 1301 return if @singleton 1330 1302 1331 # ID ã®åºæ°ããã³åæ°ã® define ãåºå1303 # ID の基数および個数の define を出力 1332 1304 f.printf("#define %-20s %10s /* %s #_NIDB_# */\n", "#{@global_name}_ID_BASE", "(#{@id_base})", TECSMsg.get(:NIDB_comment)) 1333 1305 f.printf("#define %-20s %10s /* %s #_NCEL_# */\n\n", "#{@global_name}_N_CELL", "(#{@n_cell_gen})", TECSMsg.get(:NCEL_comment)) … … 1337 1309 return if @singleton 1338 1310 1339 # mikan æé©å1340 # IDX æ£å½æ§ãã§ãã¯ãã¯ãã®åºå1311 # mikan 最適化 1312 # IDX 正当性チェックマクロの出力 1341 1313 f.printf( TECSMsg.get( :CVI_comment ), "#_CVI_#" ) 1342 1314 if @idx_is_id_act then … … 1351 1323 return if @singleton 1352 1324 1353 # IDX æ£å½æ§ãã§ãã¯ãã¯ãï¼ç縮形ï¼ã®åºå1325 # IDX 正当性チェックマクロ(短縮形)の出力 1354 1326 f.printf( TECSMsg.get( :CVIA_comment ), "#_CVIA_#") 1355 1327 f.print("#define VALID_IDX(IDX) #{@global_name}_VALID_IDX(IDX)\n\n") … … 1357 1329 end 1358 1330 1359 #=== å¼ã³å£é 1360 åã®å¤§ãããå¾ããã¯ãã®åºå 1331 #=== 呼び口配列の大きさを得るマクロの出力 1361 1332 # 1362 # ã»ã«ã¿ã¤ããããã¸å¼ã³å£ã®åæ°ãåºå1333 #セルタイプヘッダへ呼び口の個数を出力 1363 1334 def gen_ph_n_cp f 1364 1335 … … 1374 1345 end 1375 1346 1376 if p.get_array_size != "[]" then # åºå®é·é 1377 å 1347 if p.get_array_size != "[]" then # 固定長配列 1378 1348 f.print( "#define N_CP_#{p.get_name} (#{p.get_array_size})\n" ) 1379 1349 f.print( "#define NCP_#{p.get_name} (#{p.get_array_size})\n" ) 1380 else # å¯å¤é·é 1381 å 1350 else # 可変長配列 1382 1351 if @singleton then 1383 1352 if has_INIB? then … … 1388 1357 f.print( "#define N_CP_#{p.get_name} (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" ) 1389 1358 f.print( "#define NCP_#{p.get_name} (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" ) 1390 # mikan singleton ãªãã°ãåºå®é·åã§ãã1359 # mikan singleton ならば、固定長化できる 1391 1360 else 1392 1361 if has_CB? && has_INIB? then … … 1402 1371 end 1403 1372 1404 #=== åãå£é 1405 åã®å¤§ãããå¾ããã¯ãã®åºå 1373 #=== 受け口配列の大きさを得るマクロの出力 1406 1374 # 1407 # ã»ã«ã¿ã¤ããããã¸åãå£ã®åæ°ãåºå1375 #セルタイプヘッダへ受け口の個数を出力 1408 1376 def gen_ph_n_ep f 1409 1377 … … 1411 1379 @port.each { |p| 1412 1380 next if p.get_port_type != :ENTRY 1413 # next if p.is_omit? # åãå£é 1414 åã®åæ°ã¯çç¥ããªã 1381 # next if p.is_omit? # 受け口配列の個数は省略しない 1415 1382 next if p.get_array_size == nil 1416 1383 … … 1420 1387 end 1421 1388 1422 if p.get_array_size != "[]" then # åºå®é·é 1423 å 1389 if p.get_array_size != "[]" then # 固定長配列 1424 1390 f.print( "#define NEP_#{p.get_name} (#{p.get_array_size})\n" ) 1425 else # å¯å¤é·é 1426 å 1391 else # 可変長配列 1427 1392 if @singleton then 1428 1393 if has_INIB? then … … 1432 1397 end 1433 1398 f.print( "#define NEP_#{p.get_name} (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" ) 1434 # mikan singleton ãªãã°ãåºå®é·åã§ãã1399 # mikan singleton ならば、固定長化できる 1435 1400 else 1436 1401 if has_CB? && has_INIB? then … … 1445 1410 end 1446 1411 1447 #=== optional ãªå¼ã³å£ãçµåããã¦ããããã¹ãããã³ã¼ãã®çæ1412 #=== optional な呼び口が結合されているかテストするコードの生成 1448 1413 def gen_ph_test_optional_call_port f 1449 1414 b_comment = false … … 1466 1431 next if p.get_port_type != :CALL 1467 1432 next if ! p.is_optional? 1468 # next if p.is_omit? # omit ã§ã test ã³ã¼ãã¯çæãã1433 # next if p.is_omit? # omit でも test コードは生成する 1469 1434 1470 1435 if b_comment == false then … … 1484 1449 end 1485 1450 1486 # é¢æ°åã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãã VMT ã®é¢æ°åãæé©åï¼åãå£é¢æ° or åãå£ãã£ã¹ã¯ãªãã¿) 1487 # mikan å 1488 ¨é¨ã¤ãªãã£ã¦ãããã©ãã㧠(1) ãå¤å®ãã 1451 # 関数名の出力(標準:受け口ディスクリプタから VMT の関数名、最適化:受け口関数 or 受け口ディスクリプタ) 1452 # mikan 全部つながっているかどうかで (1) を判定する 1489 1453 if ! p.is_VMT_useless? then 1490 # æ¨æºã³ã¼ã1454 # 標準コード 1491 1455 if p.get_array_size == nil then 1492 1456 if @singleton then … … 1496 1460 end 1497 1461 else 1498 # é 1499 åã®å ´å 1462 # 配列の場合 1500 1463 if @singleton then 1501 1464 f.print( "\t ((#{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}!=0) \\\n" ) … … 1507 1470 end 1508 1471 else 1509 # æé©åã³ã¼ã (optimize) # VMT ä¸è¦ï¼é 1510 åè¦ç´ ãã¹ã¦åãï¼ 1472 # 最適化コード (optimize) # VMT 不要(配列要素すべて同じ) 1511 1473 p2 = p.get_real_callee_port 1512 1474 if p2 then 1513 1475 ct = p2.get_celltype 1514 1476 if p.is_skelton_useless? then 1515 # åãå£é¢æ°ãç´æ¥å¼åºã1477 # 受け口関数を直接呼出す 1516 1478 f.print( "\t (1)\n" ) 1517 1479 else 1518 # åãå£ã¹ã±ã«ãã³é¢æ°ãç´æ¥å¼åºã1480 # 受け口スケルトン関数を直接呼出す 1519 1481 f.print( "\t (1)\n" ) 1520 1482 end 1521 1483 else 1522 # optional ã§æªçµå1484 # optional で未結合 1523 1485 f.print( "\t (0) /* not joined */\n" ) 1524 1486 end … … 1527 1489 end 1528 1490 1529 #=== optional ãªå¼ã³å£ãçµåããã¦ããããã¹ãããã³ã¼ãã®çæï¼ç縮形ï¼1491 #=== optional な呼び口が結合されているかテストするコードの生成(短縮形) 1530 1492 def gen_ph_test_optional_call_port_abbrev f 1531 1493 b_comment = false … … 1534 1496 next if p.get_port_type != :CALL 1535 1497 next if ! p.is_optional? 1536 # next if p.is_omit? # omit ã§ã test ã³ã¼ãã¯çæãã1498 # next if p.is_omit? # omit でも test コードは生成する 1537 1499 1538 1500 if b_comment == false then … … 1550 1512 end 1551 1513 1552 #=== CELLCB ã¸ã®ãã¤ã³ã¿ãå¾ããã¯ããåºå1553 # ã»ã«ã¿ã¤ããããã¸åºå1514 #=== CELLCB へのポインタを得るマクロを出力 1515 # セルタイプヘッダへ出力 1554 1516 def gen_ph_get_cellcb f 1555 1517 f.printf( TECSMsg.get( :GCB_comment ), "#_GCB_#" ) 1556 1518 if ( ! has_CB? && ! has_INIB? ) || @singleton then 1557 1519 f.print( "#define #{@global_name}_GET_CELLCB(idx) ((void *)0)\n" ) 1558 elsif @idx_is_id_act then # mikan åä¸ã®ã»ã«ã®å ´åã®æé©å, idx_is_id ã§ãªãå ´å1520 elsif @idx_is_id_act then # mikan 単一のセルの場合の最適化, idx_is_id でない場合 1559 1521 f.print( "#define #{@global_name}_GET_CELLCB(idx) (#{@global_name}_CB_tab[(idx) - #{@global_name}_ID_BASE])\n" ) 1560 1522 else … … 1563 1525 end 1564 1526 1565 #=== CELLCB ã¸ã®ãã¤ã³ã¿ãå¾ããã¯ãï¼ç縮形ï¼ãåºå1566 # ã»ã«ã¿ã¤ããããã¸åºå1527 #=== CELLCB へのポインタを得るマクロ(短縮形)を出力 1528 # セルタイプヘッダへ出力 1567 1529 def gen_ph_get_cellcb_abbrev f 1568 1530 f.printf( TECSMsg.get( :GCBA_comment ), "#_GCBA_#" ) … … 1580 1542 end 1581 1543 1582 #=== attribute, var ãã¢ã¯ã»ã¹ãããã¯ããåºå1583 # ã»ã«ã¿ã¤ããããã¸åºå1544 #=== attribute, var をアクセスするマクロを出力 1545 # セルタイプヘッダへ出力 1584 1546 def gen_ph_attr_access f 1585 1547 if @n_attribute_rw > 0 || @n_attribute_ro > 0 then … … 1591 1553 next if a.is_omit? 1592 1554 1593 # mikan const_value ã®å ´å1555 # mikan const_value の場合 1594 1556 f.print( "#define " ) 1595 1557 if @singleton then … … 1601 1563 f.printf( "%-20s", "#{@global_name}_ATTR_#{a.get_name}" ) 1602 1564 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name})\n" ) 1603 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1565 # mikan ここでは cell ではなく celltype の名前 1604 1566 else 1605 1567 if ! a.is_rw? && has_CB? && has_INIB? then … … 1632 1594 end 1633 1595 1634 # mikan const_value ã®å ´å1596 # mikan const_value の場合 1635 1597 f.print( "#define " ) 1636 1598 if @singleton then 1637 1599 f.printf( "%-20s", "#{@global_name}_GET_#{a.get_name}()" ) 1638 1600 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name})\n" ) 1639 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1601 # mikan ここでは cell ではなく celltype の名前 1640 1602 else 1641 1603 f.printf( "%-20s", "#{@global_name}_GET_#{a.get_name}(p_that)" ) … … 1648 1610 f.printf( "%-20s", "#{@global_name}_SET_#{a.get_name}(val)" ) 1649 1611 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name} = (val))\n" ) 1650 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1612 # mikan ここでは cell ではなく celltype の名前 1651 1613 else 1652 1614 f.printf( "%-20s", "#{@global_name}_SET_#{a.get_name}(p_that,val)" ) … … 1680 1642 end 1681 1643 1682 # mikan const_value ã®å ´å1644 # mikan const_value の場合 1683 1645 f.print( "#define " ) 1684 1646 if @singleton then 1685 1647 f.printf( "%-20s", "#{@global_name}_VAR_#{v.get_name}" ) 1686 1648 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{v.get_name})\n" ) 1687 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1649 # mikan ここでは cell ではなく celltype の名前 1688 1650 else 1689 1651 f.printf( "%-20s", "#{@global_name}_VAR_#{v.get_name}(p_that)" ) … … 1696 1658 next if v.is_omit? 1697 1659 1698 # mikan const_value ã®å ´å1660 # mikan const_value の場合 1699 1661 f.print( "#define " ) 1700 1662 if @singleton then 1701 1663 f.printf( "%-20s", "#{@global_name}_GET_#{v.get_name}()" ) 1702 1664 f.print( "\t(#{@global_name}_SINGLE_CELL_CB.#{v.get_name})\n" ) 1703 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1665 # mikan ここでは cell ではなく celltype の名前 1704 1666 else 1705 1667 f.printf( "%-20s", "#{@global_name}_GET_#{v.get_name}(p_that)" ) … … 1711 1673 f.printf( "%-20s", "#{@global_name}_SET_#{v.get_name}(val)" ) 1712 1674 f.print( "\t(#{@global_name}_SINGLE_CELL_CB.#{v.get_name}=(val))\n" ) 1713 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1675 # mikan ここでは cell ではなく celltype の名前 1714 1676 else 1715 1677 f.printf( "%-20s", "#{@global_name}_SET_#{v.get_name}(p_that,val)" ) … … 1721 1683 end 1722 1684 1723 #=== attribute/var ã¢ã¯ã»ã¹ãã¯ãï¼ç縮形ï¼ã³ã¼ãã®çæ1685 #=== attribute/var アクセスマクロ(短縮形)コードの生成 1724 1686 def gen_ph_attr_access_abbrev f 1725 1687 if @n_attribute_rw > 0 || @n_attribute_ro > 0 then … … 1730 1692 next if a.is_omit? 1731 1693 1732 # mikan const_value ã®å ´å1694 # mikan const_value の場合 1733 1695 f.print( "#define " ) 1734 1696 f.printf( "%-20s", "ATTR_#{a.get_name}" ) … … 1748 1710 next if v.is_omit? 1749 1711 1750 # mikan const_value ã®å ´å1712 # mikan const_value の場合 1751 1713 f.print( "#define " ) 1752 1714 f.printf( "%-20s", "VAR_#{v.get_name}" ) … … 1809 1771 delim = "" 1810 1772 1811 # é¢æ°åã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãã VMT ã®é¢æ°åãæé©åï¼åãå£é¢æ° or åãå£ãã£ã¹ã¯ãªãã¿)1773 # 関数名の出力(標準:受け口ディスクリプタから VMT の関数名、最適化:受け口関数 or 受け口ディスクリプタ) 1812 1774 if ! p.is_VMT_useless? then 1813 # æ¨æºã³ã¼ã1775 # 標準コード 1814 1776 if @singleton then 1815 1777 f.print( "\t #{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}" ) … … 1819 1781 f.print( "#{subsc}->VMT->#{fun.get_name}__T( \\\n" ) 1820 1782 else 1821 # æé©åã³ã¼ã (optimize) # VMT ä¸è¦1783 # 最適化コード (optimize) # VMT 不要 1822 1784 p2 = p.get_real_callee_port 1823 1785 if p2 then 1824 1786 ct = p2.get_celltype 1825 1787 if p.is_skelton_useless? then 1826 # åãå£é¢æ°ãç´æ¥å¼åºã1788 # 受け口関数を直接呼出す 1827 1789 f.print( "\t #{ct.get_global_name}_#{p2.get_name}_#{fun.get_name}( \\\n" ) 1828 1790 else 1829 # åãå£ã¹ã±ã«ãã³é¢æ°ãç´æ¥å¼åºã1791 # 受け口スケルトン関数を直接呼出す 1830 1792 f.print( "\t #{ct.get_global_name}_#{p2.get_name}_#{fun.get_name}_skel( \\\n" ) 1831 1793 # print "skelton: #{@name} #{ct.get_global_name}_#{p2.get_name}\n" 1832 1794 end 1833 1795 else 1834 # optional ã§æªçµå1796 # optional で未結合 1835 1797 f.print( "\t ((#{fun.get_declarator.get_type.get_type.get_type_str} (*)()" ) 1836 1798 f.print( "#{fun.get_declarator.get_type.get_type.get_type_str_post})0)()\n" ) … … 1842 1804 end 1843 1805 1844 b_join = true # optional ã§çµåãã¦ããªãå ´å false 1845 1846 # åãå£æ 1847 å ±ã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãæé©åï¼IDX ãªã©) 1806 b_join = true # optional で結合していない場合 false 1807 1808 # 受け口情報の出力(標準:受け口ディスクリプタ、最適化:IDX など) 1848 1809 if ! p.is_skelton_useless? && ! p.is_cell_unique? then 1849 # æ¨æºã³ã¼ã1810 # 標準コード 1850 1811 if @singleton then 1851 1812 f.print( "\t #{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}#{subsc}" ) … … 1856 1817 end 1857 1818 else 1858 # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦1859 c2 = p.get_real_callee_cell # å¯ä¸ã®ã»ã«(ã§ãªãå ´åããããè¤æ°ã»ã«ãããå ´å)1860 p2 = p.get_real_callee_port # å¯ä¸ã®ãã¼ã(ã§ãªãå ´åã¯ããªã)1819 # 最適化コード (optimize) # スケルトン不要 1820 c2 = p.get_real_callee_cell # 唯一のセル(でない場合もある、複数セルがある場合) 1821 p2 = p.get_real_callee_port # 唯一のポート(でない場合は、ない) 1861 1822 if p2 then 1862 ct = p2.get_celltype # å¼ã³å 1863 ã®ã»ã«ã¿ã¤ã 1823 ct = p2.get_celltype # 呼び先のセルタイプ 1864 1824 if ! ct.is_singleton? then 1865 1825 if ct.has_CB? || ct.has_INIB? then … … 1868 1828 f.print( "\t #{name_array[7]}" ) 1869 1829 else 1870 # CELLCB IDX ã渡ã (æ¨æºã³ã¼ãã¨åãã ããæ±ãåã¯ç°ãªã)1871 # p.is_skelton_useless? == true/false ã¨ãã«åã1830 # CELLCB IDX を渡す (標準コードと同じだが、扱う型は異なる) 1831 # p.is_skelton_useless? == true/false ともに同じ 1872 1832 f.print( "\t (p_that)#{inib}->#{p.get_name}#{subsc}" ) 1873 1833 end … … 1880 1840 end 1881 1841 else 1882 # optional ã§æªçµå1842 # optional で未結合 1883 1843 b_join = false 1884 1844 end … … 1897 1857 end 1898 1858 1899 #=== send/receive ã§åãåã£ãã¡ã¢ãªé åã dealloc ãããã¯ãã³ã¼ã1859 #=== send/receive で受け取ったメモリ領域を dealloc するマクロコード 1900 1860 #f:: File 1901 #b_undef:: bool : true = #undef ã³ã¼ãã®çæ, false = #define ã³ã¼ãã®çæ1861 #b_undef:: bool : true = #undef コードの生成, false = #define コードの生成 1902 1862 def gen_ph_dealloc_code( f, append_name, b_undef = false ) 1903 1863 b_msg = false … … 1906 1866 1907 1867 p.each_param{ |port, fd, par| 1908 case par.get_direction # å¼æ°ã®æ¹åæå®å(in, out, inout, send, receive )1868 case par.get_direction # 引数の方向指定子 (in, out, inout, send, receive ) 1909 1869 when :SEND 1910 1870 # next if port.get_port_type == :CALL … … 1923 1883 end 1924 1884 1925 # ãã¼ãå é¢æ°å ãã©ã¡ã¼ã¿å1885 # ポート名 関数名 パラメータ名 1926 1886 dealloc_func_name = "#{port.get_name}_#{fd.get_name}_#{par.get_name}_dealloc" 1927 1887 dealloc_macro_name = dealloc_func_name.upcase … … 1962 1922 @port.each { |p| 1963 1923 next if p.get_port_type != :CALL 1964 # next if p.is_omit? å¼ã³åºãã¨ã¨ã©ã¼ãèµ·ããã³ã¼ããçæ1924 # next if p.is_omit? 呼び出すとエラーを起こすコードを生成 1965 1925 1966 1926 p.get_signature.get_function_head_array.each{ |fun| … … 2067 2027 f.print( "struct tag_#{@global_name}_CB *" ) 2068 2028 elsif has_INIB? then 2069 # f.print( "struct tag_#{@global_name}_INIB *" ) # const ãåºåãã¦ããªã2029 # f.print( "struct tag_#{@global_name}_INIB *" ) # const を出力していない 2070 2030 f.print( "const struct tag_#{@global_name}_INIB *" ) 2071 2031 else … … 2103 2063 2104 2064 if p.get_array_size then 2105 f.print( "#{delim} int_t subscript" ) # mikan singleton æã® ',' ã®å§æ«2065 f.print( "#{delim} int_t subscript" ) # mikan singleton 時の ',' の始末 2106 2066 delim = "," 2107 2067 end … … 2111 2071 len = items.length 2112 2072 else 2113 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å2073 # ここで nil になるのは、引数なしの時に void がなかった場合 2114 2074 items = [] 2115 2075 len = 0 … … 2132 2092 2133 2093 def gen_ph_ep_skel_prototype f 2134 # åãå£ã¹ã±ã«ãã³é¢æ°ã®ãããã¿ã¤ã宣è¨ãåºå2094 # 受け口スケルトン関数のプロトタイプ宣言を出力 2135 2095 if @n_entry_port >0 then 2136 2096 f.printf( TECSMsg.get( :EPSP_comment ), "#_EPSP_#" ) … … 2139 2099 next if p.get_port_type != :ENTRY 2140 2100 next if p.is_omit? 2141 # if p.is_skelton_useless? || ! p.is_VMT_useless? then # åãå£æé©å2142 if p.is_skelton_useless? then # åãå£æé©å2101 # if p.is_skelton_useless? || ! p.is_VMT_useless? then # 受け口最適化 2102 if p.is_skelton_useless? then # 受け口最適化 2143 2103 # f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" ) 2144 2104 next … … 2159 2119 len = items.length 2160 2120 else 2161 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å2121 # ここで nil になるのは、引数なしの時に void がなかった場合 2162 2122 items = [] 2163 2123 len = 0 … … 2182 2142 2183 2143 if ( $rom )then 2184 # å®æ°é¨ã¯ ROM, å¤æ°é¨ã¯RAM2144 # 定数部は ROM, 変数部は RAM 2185 2145 2186 2146 if has_INIB? then … … 2215 2175 2216 2176 else 2217 # å 2218 ¨ã¦ RAM 2177 # 全て RAM 2219 2178 f.printf( TECSMsg.get( :CCTPO_comment ), "#_CCTPO_#" ) 2220 2179 … … 2230 2189 2231 2190 2232 #=== attribute ã®å宣è¨åºå2233 #inib_cb:: :INIB ã¾ãã¯:CB2191 #=== attribute の型宣言出力 2192 #inib_cb:: :INIB または :CB 2234 2193 def gen_cell_cb_type_attribute( f, inib_cb ) 2235 2194 if inib_cb == :INIB && @n_attribute_ro > 0 then … … 2264 2223 next if v.is_omit? 2265 2224 next if v.get_size_is == nil 2266 next if $rom && inib_cb == :CB # size_is æå®ããããã®ã¯ INIB ã«ã®ã¿åºåãã2225 next if $rom && inib_cb == :CB # size_is 指定されたものは INIB にのみ出力する 2267 2226 2268 2227 f.print " " … … 2273 2232 2274 2233 def gen_cell_cb_type_var f 2275 # å¤æ°ã®åºå2234 # 変数の出力 2276 2235 if @n_var > 0 then 2277 2236 f.print " /* var #_VA_# */ \n" … … 2281 2240 2282 2241 next if v.is_omit? 2283 next if v.get_size_is != nil # size_is æå®ããã var 㯠attribute ã¸åºåãã2242 next if v.get_size_is != nil # size_is 指定された var は attribute へ出力する 2284 2243 2285 2244 f.print " " … … 2295 2254 2296 2255 def gen_cell_cb_type_call_port f 2297 # å¼ã³å£2256 # 呼び口 2298 2257 if @n_call_port >0 then 2299 2258 f.print " /* call port #_TCP_# */ \n" … … 2308 2267 if ! p.is_cell_unique? then 2309 2268 if ! p.is_skelton_useless? then 2310 # æ¨æºå½¢2269 # 標準形 2311 2270 f.print( " struct tag_#{p.get_signature.get_global_name}_VDES #{ptr}const*#{p.get_name;};\n" ) 2312 2271 if p.get_array_size == "[]" then … … 2314 2273 end 2315 2274 else 2316 # æé©å skelton é¢æ°ãå¼åºããªã(åãå£é¢æ°ãç´æ¥å¼åºã) 2317 # å¼ã³å 2318 ã»ã«ã¿ã¤ãã® CB ã® IDX å 2275 # 最適化 skelton 関数を呼出さない(受け口関数を直接呼出す) 2276 # 呼び先セルタイプの CB の IDX 型 2319 2277 if p.get_real_callee_cell then 2320 2278 f.print( " " ) 2321 2279 p.get_real_callee_cell.get_celltype.gen_ph_idx_type f 2322 2280 f.print( " #{ptr}#{p.get_name;};\n" ) 2323 # ç¸äºåç 2324 §ã«åãã¦ãtypedef ããåã使ããªã 2281 # 相互参照に備えて、typedef した型を使わない 2325 2282 # f.print( " #{p.get_real_callee_cell.get_celltype.get_global_name}_IDX #{ptr}#{p.get_name;};\n" ) 2326 2283 if p.get_array_size == "[]" then … … 2328 2285 end 2329 2286 #else 2330 # optional ã§æªçµå2287 # optional で未結合 2331 2288 end 2332 2289 end 2333 2290 # else 2334 # æé©å ä¸ã¤ããã»ã«ããªãå ´åãåãå£ãã£ã¹ã¯ãªãã¿ã¾ãã¯åãå´ã® IDX ã¯å¼ã³å£é¢æ°ãã¯ãã«åãè¾¼ã¾ãã 2335 end 2336 } 2337 end 2338 2339 #=== Celltype#åãå£é 2340 åæ·»æ°ãè¨æ¶ããå¤æ°ã®å®ç¾© 2291 # 最適化 一つしかセルがない場合、受け口ディスクリプタまたは受け側の IDX は呼び口関数マクロに埋め込まれる 2292 end 2293 } 2294 end 2295 2296 #=== Celltype#受け口配列添数を記憶する変数の定義 2341 2297 def gen_cell_cb_type_entry_port f 2342 # å¼ã³å£2298 # 呼び口 2343 2299 if @n_entry_port >0 then 2344 2300 f.print " /* call port #_NEP_# */ \n" … … 2346 2302 2347 2303 @port.each{ |p| 2348 # next if p.is_omit? # åãå£é 2349 åã®åæ°ã¯çç¥ããªã 2304 # next if p.is_omit? # 受け口配列の個数は省略しない 2350 2305 if p.get_port_type == :ENTRY && p.get_array_size == "[]" 2351 2306 f.print( " int_t n_#{p.get_name};\n" ) … … 2389 2344 end 2390 2345 2391 #=== ã¤ãã¬ã¼ã¿ã³ã¼ã (FOREACH_CELL)ã®çæ2392 # singleton ã§ã¯åºåããªã2346 #=== イテレータコード (FOREACH_CELL)の生成 2347 # singleton では出力しない 2393 2348 def gen_ph_foreach_cell f 2394 2349 … … 2431 2386 2432 2387 2433 #=== å¤æ°varåæåã³ã¼ã2388 #=== 変数var初期化コード 2434 2389 # 2435 2390 def gen_ph_cb_initialize_macro f … … 2442 2397 type = v.get_type 2443 2398 if( type.kind_of? PtrType )then 2444 # PtrType 㯠ArrayType ã«ããæ¿ãã2445 2446 # åæååã®è¦ç´ æ°ã¨ãã (å¾ã¯ 0 ã§ãã)2399 # PtrType は ArrayType にすり替える 2400 2401 # 初期化子の要素数とする (後は 0 である) 2447 2402 t2 = ArrayType.new( Expression.create_integer_constant( init.length, nil ) ) 2448 2403 t2.set_type( type.get_type ) … … 2512 2467 2513 2468 # else 2514 # ã»ã«ãä¸ã¤ããªããã°åºåããªã2469 # セルが一つもなければ出力しない 2515 2470 end 2516 2471 … … 2519 2474 2520 2475 def gen_ph_inline f 2521 # inline ãã¼ããä¸ã¤ã§ãããã°ãinline.h ã®include2476 # inline ポートが一つでもあれば、inline.h の include 2522 2477 if @n_entry_port_inline > 0 then 2523 2478 f.printf( TECSMsg.get( :INL_comment ), "#_INL_#" ) … … 2571 2526 next if p.get_port_type != :ENTRY 2572 2527 next if p.is_omit? 2573 if p.is_skelton_useless? # åãå£æé©å2528 if p.is_skelton_useless? # 受け口最適化 2574 2529 f.print( "/* #{p.get_name} : omitted by entry port optimize */\n\n" ) 2575 2530 next … … 2582 2537 f.print( " #{@name}_IDX idx;\n" ) 2583 2538 else 2584 # CB ã INIB ãåå¨ããªã (ã®ã§ãidx ã¨ãã¦æ´æ°ã§åæåãã¦ãã)2539 # CB も INIB も存在しない (ので、idx として整数で初期化しておく) 2585 2540 f.print( " int idx;\n" ) 2586 2541 end … … 2600 2555 next if p.get_port_type != :ENTRY 2601 2556 next if p.is_omit? 2602 if p.is_skelton_useless? then # åãå£æé©å2557 if p.is_skelton_useless? then # 受け口最適化 2603 2558 f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" ) 2604 2559 next … … 2619 2574 len = items.length 2620 2575 else 2621 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å2576 # ここで nil になるのは、引数なしの時に void がなかった場合 2622 2577 items = [] 2623 2578 len = 0 … … 2641 2596 end 2642 2597 2643 if functype.get_type_str == "void" then # mikan "void" ã® typedef ã«æªå¯¾å¿2598 if functype.get_type_str == "void" then # mikan "void" の typedef に未対応 2644 2599 f.print " " 2645 2600 else … … 2684 2639 next if p.get_port_type != :ENTRY 2685 2640 next if p.is_omit? 2686 if p.is_VMT_useless? then # åãå£æé©å2641 if p.is_VMT_useless? then # 受け口最適化 2687 2642 f.print "/* #{p.get_name} : omitted by entry port optimize */\n" 2688 2643 next … … 2710 2665 end 2711 2666 2712 # ãã®ã»ã«ã¿ã¤ãã®ãã¹ã¦ã®ã»ã«ã«ã¤ãã¦2667 # このセルタイプのすべてのセルについて 2713 2668 @ordered_cell_list.each{ |c| 2714 if c.is_generate? then # çæ対象ãï¼2669 if c.is_generate? then # 生成対象か? 2715 2670 2716 2671 f = fs[ c.get_region.get_domain_root ] 2717 2672 2718 # çµåã®ãªã¹ã(NamedList)2673 # 結合のリスト (NamedList) 2719 2674 jl = c.get_join_list 2720 2675 2721 # å 2722 ¨ã¦ã®çµåãªã¹ãã«ã¤ã㦠2676 # 全ての結合リストについて 2723 2677 jl.get_items.each{ |j| 2724 2678 2725 # 左辺ã®å®ç¾©ãå¾ã2679 # 左辺の定義を得る 2726 2680 definition = j.get_definition 2727 2681 2728 # å¼ã³å£ã§ã¯ãªãï¼ãï¼å±æ§ï¼2682 # 呼び口ではない? (属性) 2729 2683 next unless definition.instance_of? Port 2730 2684 2731 port = find j.get_name # celltype ã® Port (ãã¡ãã«æé©åæ 2732 å ±ããã) 2733 # port = definition # definition 㯠composite ã® Port ãå¾ããããã¨ããã 2685 port = find j.get_name # celltype の Port (こちらに最適化情報がある) 2686 # port = definition # definition は composite の Port が得られることがある 2734 2687 next if port.is_cell_unique? 2735 2688 next if port.is_omit? 2736 2689 2737 # é 2738 åè¦ç´ ãå¾ãï¼åãå£é 2739 åã§ãªããã° nil ãè¿ãï¼ 2690 # 配列要素を得る(受け口配列でなければ nil が返る) 2740 2691 am = j.get_array_member2 2741 2692 2742 # å¼ã³å£é 2743 åã? 2693 # 呼び口配列か? 2744 2694 if am then 2745 2695 i = 0 … … 2748 2698 if j then 2749 2699 if am[i].get_cell.get_celltype == self then 2750 # åãã»ã«ã¿ã¤ãã¸çµåãã¦ããå ´å(VDES ã§ã¯ type conflict ã«ãªã)2700 # 同じセルタイプへ結合している場合(VDES では type conflict になる) 2751 2701 p = am[i].get_rhs_port 2752 2702 des_type = "const struct tag_#{@global_name}_#{p.get_name}_DES" … … 2755 2705 end 2756 2706 2757 # å³è¾ºã¯åãå£é 2758 åãï¼ 2707 # 右辺は受け口配列か? 2759 2708 if j.get_rhs_subscript then 2760 2709 2761 # åãå£ã®é 2762 åæ·»æ° 2710 # 受け口の配列添数 2763 2711 subscript = j.get_rhs_subscript 2764 2712 … … 2773 2721 end 2774 2722 #else if j == nil 2775 # optioanl ã§é 2776 åè¦ç´ ãåæåããã¦ããªã 2723 # optioanl で配列要素が初期化されていない 2777 2724 end 2778 2725 i += 1 … … 2780 2727 else 2781 2728 if j.get_cell.get_celltype == self then 2782 # åãã»ã«ã¿ã¤ãã¸çµåãã¦ããå ´å(VDES ã§ã¯ type conflict ã«ãªã)2729 # 同じセルタイプへ結合している場合(VDES では type conflict になる) 2783 2730 p = j.get_rhs_port 2784 2731 des_type = "const struct tag_#{@global_name}_#{p.get_name}_DES" … … 2788 2735 2789 2736 if j.get_rhs_subscript then 2790 # åãå£é 2791 å 2737 # 受け口配列 2792 2738 subscript = j.get_rhs_subscript 2793 2739 f.printf( "extern %s %s%d;\n", … … 2801 2747 end 2802 2748 end 2803 # mikan cell ã® namespace æªå¯¾å¿ãJoin 㧠Cell ãªãã¸ã§ã¯ããå¼å½ã¦ããå¿ 2804 è¦ãã 2749 # mikan cell の namespace 未対応、Join で Cell オブジェクトを引当ておく必要あり 2805 2750 } 2806 2751 … … 2812 2757 def gen_cell_ep_vdes_array fs 2813 2758 if @n_cell_gen >0 then 2814 fs.each{ |r, f| f.printf( TECSMsg.get( :CPA_comment ), "#_CPA_#" ) } # mikan å¼ã³å£é 2815 åãç¡ãå ´åãåºã¦ãã¾ã 2759 fs.each{ |r, f| f.printf( TECSMsg.get( :CPA_comment ), "#_CPA_#" ) } # mikan 呼び口配列が無い場合も出てしまう 2816 2760 end 2817 2761 … … 2824 2768 definition = j.get_definition 2825 2769 next unless definition.instance_of? Port 2826 # port = definition # definition 㯠composite ã® Port ãå¾ããããã¨ããã 2827 port = find j.get_name # celltype ã® Port (ãã¡ãã«æé©åæ 2828 å ±ããã) 2770 # port = definition # definition は composite の Port が得られることがある 2771 port = find j.get_name # celltype の Port (こちらに最適化情報がある) 2829 2772 next if port.is_cell_unique? 2830 2773 next if port.is_omit? … … 2832 2775 am = j.get_array_member2 2833 2776 if am then 2834 # 左辺ã¯é 2835 å 2777 # 左辺は配列 2836 2778 2837 2779 if ! port.is_skelton_useless? then … … 2842 2784 else 2843 2785 2844 # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©åã®å ´åããã®é 2845 åã¯åç 2846 §ãããªã 2847 # mikan ãã®ã±ã¼ã¹ããã¹ãããã¦ããªã 2786 # スケルトン関数不要最適化の場合、この配列は参照されない 2787 # mikan このケースがテストされていない 2848 2788 f.printf( "const %s_IDX %s_%s[] = {\n", 2849 # "#{j.get_celltype.get_global_name}", # å³è¾º composite ã«å¯¾å¿ã§ããªã2789 # "#{j.get_celltype.get_global_name}", # 右辺 composite に対応できない 2850 2790 "#{j.get_rhs_cell.get_celltype.get_global_name}", 2851 2791 "#{c.get_global_name}", … … 2864 2804 2865 2805 if j then 2866 # åä¸ã»ã«ã¿ã¤ãã®çµåã®å ´åãVDES åã¸ã®ãã£ã¹ããå¿ 2867 è¦ 2806 # 同一セルタイプの結合の場合、VDES 型へのキャストが必要 2868 2807 if j.get_rhs_cell.get_celltype == self then 2869 2808 definition = j.get_definition … … 2875 2814 2876 2815 if j.get_rhs_subscript then 2877 # å³è¾ºé 2878 åã®å ´å(æé©åã¯ãªã) 2816 # 右辺配列の場合(最適化はない) 2879 2817 subscript = j.get_rhs_subscript 2880 2818 f.printf( " %s%d,\n", … … 2885 2823 2886 2824 else 2887 # å³è¾ºéé 2888 åã®å ´å */ 2825 # 右辺非配列の場合 */ 2889 2826 if ! port.is_skelton_useless? then 2890 2827 f.printf( " %s,\n", … … 2897 2834 end 2898 2835 else 2899 # optional ã§å¼ã³å£é 2900 åè¦ç´ ãåæåããã¦ããªã 2836 # optional で呼び口配列要素が初期化されていない 2901 2837 f.printf( " 0,\n" ) 2902 2838 end 2903 2839 # } 2904 2840 end 2905 # mikan cell ã® namespace æªå¯¾å¿ãJoin 㧠Cell ãªãã¸ã§ã¯ããå¼å½ã¦ããå¿ 2906 è¦ãã 2841 # mikan cell の namespace 未対応、Join で Cell オブジェクトを引当ておく必要あり 2907 2842 f.print "};\n" 2908 2843 end … … 2914 2849 end 2915 2850 2916 #=== CB ãåæåããããã°ã©ã ã®çæ2851 #=== CB を初期化するプログラムの生成 2917 2852 def gen_cell_cb_initialize_code f 2918 2853 if ! need_CB_initializer? … … 2946 2881 end 2947 2882 2948 # === CB/INIB ã®å¤ã§åæåãããå¤æ°ã®åºå2883 # === CB/INIB の外で初期化される変数の出力 2949 2884 def gen_cell_cb_out_init fs 2950 2885 2951 # ã»ã«ããªããã°ãåºåããªã2886 # セルがなければ、出力しない 2952 2887 if @n_cell_gen == 0 then 2953 2888 return … … 2956 2891 fs.each{ |r, f| f.printf( TECSMsg.get( :AVAI_comment ), "#_AVAI_#" ) } 2957 2892 2958 # attribute, var ã®ãã¤ã³ã¿åã®åç 2959 §ããé 2960 åãçæ 2893 # attribute, var のポインタ型の参照する配列を生成 2961 2894 @ordered_cell_list.each{ |c| 2962 2895 next if ! c.is_generate? … … 2968 2901 jl = c.get_join_list 2969 2902 2970 # attribute, var ã®ãã¤ã³ã¿å¤æ°ãé 2971 åã«ããåæåãããå ´åã®ãé 2972 åãåºå 2903 # attribute, var のポインタ変数が配列により初期化される場合の、配列を出力 2973 2904 av_list = ct.get_attribute_list + ct.get_var_list 2974 2905 if av_list.length != 0 then … … 2986 2917 2987 2918 if size then 2988 # å¼ãè©ä¾¡ãã(attribute, var ã«å«ã¾ããå¤æ°ãåç 2989 §å¯è½) 2919 # 式を評価する(attribute, var に含まれる変数を参照可能) 2990 2920 sz = size.eval_const( c.get_join_list, c.get_celltype.get_name_list ) 2991 # å¼ãçæããªãã (å¤æ°ãå«ã¾ãªãå½¢ã«ãã) ä¸å®å 2992 ¨ãªå½¢ã§ Token ãçæ (ã¨ã©ã¼çºçããªããã) 2921 # 式を生成しなおす (変数を含まない形にする) 不完全な形で Token を生成 (エラー発生しないから) 2993 2922 size = Expression.new( [:INTEGER_CONSTANT, Token.new(sz, nil, 0, 0)] ) 2994 2923 array_type = ArrayType.new( size ) … … 3004 2933 # name_array[3]: cell_CB_INIT 3005 2934 if !( $ram_initializer && a.get_kind == :VAR ) then 3006 # -R (ram initializer 使ç¨) ã®å ´å var ã¯åæåã³ã¼ããåºåããªã2935 # -R (ram initializer 使用) の場合 var は初期化コードを出力しない 3007 2936 if( init )then 3008 2937 str = " = #{gen_cell_cb_init( f, c, name_array, array_type, init, a.get_identifier, 1, true )}" … … 3022 2951 end 3023 2952 3024 #=== var ã®åæå¤ã® ROM é¨ã¸ã®2953 #=== var の初期値の ROM 部への 3025 2954 def gen_cell_var_init f 3026 # var ã®{ }ã§å²ã¾ããåæå¤æå®ãããã調ã¹ã2955 # var の{ }で囲まれた初期値指定があるか調べる 3027 2956 n_init = 0 3028 2957 @var.each { |v| … … 3041 2970 3042 2971 if( type.kind_of? PtrType )then 3043 # PtrType 㯠ArrayType ã«ããæ¿ãã3044 3045 # åæååã®è¦ç´ æ°ã ãã¨ããï¼å¾ã¯0)2972 # PtrType は ArrayType にすり替える 2973 2974 # 初期化子の要素数だけとする(後は 0) 3046 2975 t2 = ArrayType.new( Expression.create_integer_constant( init.length, nil ) ) 3047 2976 t2.set_type( type.get_type ) … … 3049 2978 end 3050 2979 3051 c = @ordered_cell_list[0] # 仮㮠cell (å®éã«ã¯ä½¿ãããªã)2980 c = @ordered_cell_list[0] # 仮の cell (実際には使われない) 3052 2981 name_array = get_name_array( c ) 3053 2982 # f.print "const #{type0.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type0.get_type_str_post} = " 3054 2983 f.print "const #{type.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type.get_type_str_post} = " 3055 2984 if type.kind_of? StructType then 3056 # celltype ã® default ã®åæå¤ãã2985 # celltype の default の初期値あり 3057 2986 str = gen_cell_cb_init( f, c, name_array, type, init, v.get_identifier, 1, true ) 3058 2987 elsif( type.kind_of?( PtrType ) || type.kind_of?( ArrayType ) ) then 3059 2988 str = "{ " 3060 2989 type = type.get_type 3061 # mikan ãã¤ã³ã¿ã§ã¯ãªããé 3062 ååã¨ããªãã¨ããã¤ã³ã¿å¤æ°ã®é åã®åãæãã 2990 # mikan ポインタではなく、配列型としないと、ポインタ変数の領域の分、損する 3063 2991 init.each { |i| 3064 2992 str += gen_cell_cb_init( f, c, name_array, type, i, v.get_identifier, 1, true ) … … 3117 3045 3118 3046 unless @singleton then 3119 # 1 ã¤ã® cell INIB ã®çµãã3047 # 1 つの cell INIB の終わり 3120 3048 if @idx_is_id_act then 3121 3049 f.print( "};\n\n" ) … … 3135 3063 end 3136 3064 3137 # RAM initializer ã使ç¨ããªããã¾ã㯠ROM åããªã3065 # RAM initializer を使用しない、または ROM 化しない 3138 3066 if $ram_initializer == false || $rom == false then 3139 3067 if @singleton then … … 3177 3105 3178 3106 unless @singleton then 3179 # 1 ã¤ã® cell CB ã®çµãã3107 # 1 つの cell CB の終わり 3180 3108 if @idx_is_id_act then 3181 3109 f.print( "};\n\n" ) … … 3215 3143 f.print "/* ID to INIB table #_INTAB_# */\n" 3216 3144 @ordered_cell_list.each{ |c| 3217 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # çæ対象ãã¤ãã«ã¼ã以å¤ã3145 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # 生成対象かつ、ルート以外か 3218 3146 name_array = get_name_array( c ) 3219 3147 print_indent( f, indent + 1 ) … … 3224 3152 f.print "#{@global_name}_INIB *#{@global_name}_INIB_tab[] ={\n" 3225 3153 @ordered_cell_list.each{ |c| 3226 if c.is_generate? then # çæ対象ãï¼3154 if c.is_generate? then # 生成対象か? 3227 3155 name_array = get_name_array( c ) 3228 3156 print_indent( f, indent + 1 ) … … 3235 3163 f.print "/* ID to CB table #_CBTAB_# */\n" 3236 3164 @ordered_cell_list.each{ |c| 3237 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # çæ対象ãã¤ãã«ã¼ã以å¤ã3165 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # 生成対象かつ、ルート以外か 3238 3166 name_array = get_name_array( c ) 3239 3167 print_indent( f, indent + 1 ) … … 3244 3172 f.print "#{@global_name}_CB *#{@global_name}_CB_tab[] ={\n" 3245 3173 @ordered_cell_list.each{ |c| 3246 if c.is_generate? then # çæ対象ãï¼3174 if c.is_generate? then # 生成対象か? 3247 3175 name_array = get_name_array( c ) 3248 3176 print_indent( f, indent + 1 ) … … 3256 3184 3257 3185 3258 #=== name_array ãçæ3186 #=== name_array を生成 3259 3187 # IN: cell : Cell 3260 # index : CB, INIB é 3261 åã®æ·»æ° 3188 # index : CB, INIB 配列の添数 3262 3189 # RETURN: name_array 3263 3190 # name_array[0] = @name # celltype name 3264 3191 # name_array[1] = cell.get_name # cell name 3265 3192 # name_array[2] = cell_CB_name # cell_CB_name 3266 # name_array[3] = cell_CB_INIT # cell_CB_INIT # CB ã®å¤å´ã§åæåãå¿ 3267 è¦ãªé 3268 åã®åå 3193 # name_array[3] = cell_CB_INIT # cell_CB_INIT # CB の外側で初期化が必要な配列の名前 3269 3194 # name_array[4] = cell_CB_proto # CB name for prototype 3270 3195 # name_array[5] = cell_INIB # INIB name … … 3305 3230 3306 3231 if ! has_CB? && ! has_INIB? then 3307 cell_CBP = "NULL" # CB ã INIB ããªããã° NULL ã«ç½®æ3232 cell_CBP = "NULL" # CB も INIB もなければ NULL に置換 3308 3233 else 3309 3234 cell_CBP = "&#{cell_CB_name}" … … 3326 3251 end 3327 3252 3328 #=== attribute 㨠size_is æå®ããã var (ãã¤ã³ã¿)ã®åæåãã¼ã¿ãåºå3253 #=== attribute と size_is 指定された var (ポインタ)の初期化データを出力 3329 3254 # 3330 # ROM åãµãã¼ãã®æç¡ãããã³åºå対象ã CB ã INIB ãã«ããåºåãããå 3331 容ãç°ãªã 3255 # ROM 化サポートの有無、および出力対象が CB か INIB かにより出力される内容が異なる 3332 3256 def gen_cell_cb_attribute( cell, indent, f, name_array, cb_inib ) 3333 3257 ct = self … … 3339 3263 f.print "/* attribute(RO) */ \n" 3340 3264 elsif $rom then # && cb_inib == CB 3341 # CB 㧠rw ã¨var3265 # CB で rw と var 3342 3266 return if @n_attribute_rw == 0 3343 3267 print_indent( f, indent + 1 ) 3344 3268 f.print "/* attribute(RW) */ \n" 3345 3269 else # cb_inib == CB && $rom == false 3346 # CB ã«å 3347 ¨é¨ 3270 # CB に全部 3348 3271 return if @n_attribute_rw == 0 && @n_attribute_ro == 0 && @n_var_size_is == 0 3349 3272 print_indent( f, indent + 1 ) … … 3355 3278 next if a.is_omit? 3356 3279 if cb_inib == :INIB && a.is_rw? == true then 3357 # $rom == true ã§ãããããã¸æ¥ãªã3280 # $rom == true でしか、ここへ来ない 3358 3281 next 3359 3282 elsif cb_inib == :CB && $rom && ! a.is_rw? then … … 3363 3286 j = jl.get_item( a.get_identifier ) 3364 3287 if j then 3365 # cell ã®åæå¤æå®ãã3288 # cell の初期値指定あり 3366 3289 gen_cell_cb_init( f, cell, name_array, a.get_type, j.get_rhs, a.get_identifier, indent + 1 ) 3367 3290 elsif a.get_initializer then 3368 # celltype ã® default ã®åæå¤ãã3291 # celltype の default の初期値あり 3369 3292 gen_cell_cb_init( f, cell, name_array, a.get_type, a.get_initializer, a.get_identifier, indent + 1 ) 3370 3293 else 3371 # åæå¤æªæå®3294 # 初期値未指定 3372 3295 gen_cell_cb_init( f, cell, name_array, a.get_type, nil, a.get_identifier, indent + 1 ) 3373 3296 end … … 3375 3298 @var.each{ |v| 3376 3299 next if v.is_omit? 3377 next if v.get_size_is == nil # size_is æå®ãããå ´å attribute ã®ä¸é¨ã¨ãã¦åºå3300 next if v.get_size_is == nil # size_is 指定がある場合 attribute の一部として出力 3378 3301 3379 3302 if v.get_initializer && $ram_initializer == false then 3380 3303 gen_cell_cb_init( f, cell, name_array, v.get_type, v.get_initializer, v.get_identifier, indent + 1 ) 3381 3304 else 3382 # åæå¤æªæå® ã¾ã㯠RAM initializer 使ç¨3305 # 初期値未指定 または RAM initializer 使用 3383 3306 gen_cell_cb_init( f, cell, name_array, v.get_type, nil, v.get_identifier, indent + 1 ) 3384 3307 end … … 3386 3309 end 3387 3310 3388 #=== var ã®åæåãã¼ã¿ãåºå3311 #=== var の初期化データを出力 3389 3312 def gen_cell_cb_var( cell, indent, f, name_array ) 3390 3313 jl = cell.get_join_list … … 3396 3319 3397 3320 next if v.is_omit? 3398 next if v.get_size_is # size_is æå®ãããå ´å attribute ã®ä¸é¨ã¨ãã¦åºå3321 next if v.get_size_is # size_is 指定がある場合 attribute の一部として出力 3399 3322 3400 3323 if v.get_initializer && $ram_initializer == false then 3401 3324 gen_cell_cb_init( f, cell, name_array, v.get_type, v.get_initializer, v.get_identifier, indent + 1 ) 3402 3325 else 3403 # åæå¤æªæå® ã¾ã㯠RAM initializer 使ç¨3326 # 初期値未指定 または RAM initializer 使用 3404 3327 gen_cell_cb_init( f, cell, name_array, v.get_type, nil, v.get_identifier, indent + 1 ) 3405 3328 end … … 3413 3336 end 3414 3337 3415 #=== å¼ã³å£ã®åæåã³ã¼ãã®çæ3338 #=== 呼び口の初期化コードの生成 3416 3339 def gen_cell_cb_call_port( cell, indent, f, name_array ) 3417 3340 jl = cell.get_join_list … … 3424 3347 next if p.get_port_type != :CALL 3425 3348 next if p.is_omit? 3426 next if p.is_cell_unique? # æé©åï¼åä¸ã»ã«ã§å¼ã³å£ãã¯ãã«åãè¾¼ã¾ããï¼3349 next if p.is_cell_unique? # 最適化(単一セルで呼び口マクロに埋め込まれる) 3427 3350 3428 3351 j = jl.get_item( p.get_name ) … … 3431 3354 # debug 3432 3355 if j == nil then 3433 # optional å¼ã³å£3356 # optional 呼び口 3434 3357 # cdl_error( "H1003 internal error: cell \'$1\' port \'$2\': initializer not found\n" , cell.get_name, p.get_name ) 3435 3358 # exit( 1 ) 3436 3359 f.printf( "%-40s /* #_CCP5_# */\n", "0," ) 3437 3360 if p.get_array_size == "[]" then 3438 # æ·»æ°çç¥ã®å¼ã³å£é 3439 å 3361 # 添数省略の呼び口配列 3440 3362 print_indent( f, indent + 1 ) 3441 3363 f.printf( "%-40s /* %s #_CCP6_# */\n", "0,", "length of #{p.get_name} (n_#{p.get_name})" ) … … 3446 3368 am = j.get_array_member2 3447 3369 if am then 3448 # å¼ã³å£é 3449 åã®å ´å 3370 # 呼び口配列の場合 3450 3371 f.printf( "%-40s /* #_CCP3_# */\n", "#{cell.get_global_name}_#{j.get_name}," ) 3451 3372 if p.get_array_size == "[]" then 3452 # æ·»æ°çç¥ã®å¼ã³å£é 3453 å 3373 # 添数省略の呼び口配列 3454 3374 print_indent( f, indent + 1 ) 3455 3375 f.printf( "%-40s /* %s #_CCP4_# */\n", "#{am.length},", "length of #{p.get_name} (n_#{p.get_name})" ) 3456 3376 end 3457 3377 else 3458 # åä¸ã»ã«ã¿ã¤ãã®çµåã®å ´åãVDES åã¸ã®ãã£ã¹ããå¿ 3459 è¦ 3378 # 同一セルタイプの結合の場合、VDES 型へのキャストが必要 3460 3379 #print "CCP0/CCP1 #{p.get_name}, #{j.get_rhs_cell.get_celltype.get_name}, #{@name}\n" 3461 3380 if j.get_rhs_cell.get_celltype == self then … … 3467 3386 3468 3387 if j.get_rhs_subscript then 3469 # åãå£é 3470 åã®å ´å 3388 # 受け口配列の場合 3471 3389 subscript = j.get_rhs_subscript 3472 3390 f.printf( "%-40s /* %s #_CCP0_# */\n", … … 3475 3393 p.get_name ) 3476 3394 else 3477 # å¼ã³å£é 3478 åã§ããåãå£é 3479 åã§ããªã 3395 # 呼び口配列でも、受け口配列でもない 3480 3396 if ! p.is_skelton_useless? then 3481 3397 f.printf( "%-40s /* %s #_CCP1_# */\n", … … 3483 3399 p.get_name ) 3484 3400 else 3485 # ã¹ã±ã«ãã³ä¸è¦æé©åï¼CB (INIB) ã¸ã®ãã¤ã³ã¿ãåãè¾¼ãï¼ 3486 c = j.get_rhs_cell # å¼ã³å 3487 ã»ã« 3488 ct = c.get_celltype # å¼ã³å 3489 ã»ã«ã¿ã¤ã 3401 # スケルトン不要最適化(CB (INIB) へのポインタを埋め込む) 3402 c = j.get_rhs_cell # 呼び先セル 3403 ct = c.get_celltype # 呼び先セルタイプ 3490 3404 if ct.has_INIB? || ct.has_CB? then 3491 name_array = ct.get_name_array( c ) # å¼ã³å 3492 ã»ã«ã¿ã¤ã㧠name_array ãå¾ã 3405 name_array = ct.get_name_array( c ) # 呼び先セルタイプで name_array を得る 3493 3406 f.printf( "%-40s /* %s #_CCP2_# */\n", "#{name_array[7]},", p.get_name ) 3494 3407 else 3495 # å¼ã³å 3496 㯠CB ã INIB ãæããªãï¼NULL ã«åæåï¼ 3408 # 呼び先は CB も INIB も持たない(NULL に初期化) 3497 3409 f.printf( "%-40s /* %s #_CCP2_# */\n", "0,", p.get_name ) 3498 3410 end … … 3505 3417 end 3506 3418 3507 #=== åãå£ã®åæåã³ã¼ãã®çæ3419 #=== 受け口の初期化コードの生成 3508 3420 def gen_cell_cb_entry_port( cell, indent, f, name_array ) 3509 3421 jl = cell.get_join_list … … 3514 3426 f.print "/* entry port #_EP_# */ \n" 3515 3427 @port.each{ |p| 3516 # next if p.is_omit? # åãå£é 3517 åã®åæ°ã¯çç¥ããªã 3428 # next if p.is_omit? # 受け口配列の個数は省略しない 3518 3429 if p.get_port_type == :ENTRY && p.get_array_size == "[]" 3519 3430 print_indent( f, indent + 1 ) … … 3524 3435 end 3525 3436 3526 #=== ã»ã«ã® attribute ã®åæå¤ãåºå3437 #=== セルの attribute の初期値を出力 3527 3438 # 3528 #f_get_str:: true ã®å ´åãæååãè¿ããfalse ã®å ´åããã¡ã¤ã« f ã«åºåããï¼ 3529 # æååãè¿ãã¨ããæ«å°¾ã« ',' ã¯å«ã¾ããªãï¼ 3530 # ãã¡ã¤ã«ã¸åºåããã¨ããæ«å°¾ã« ',' ãåºåãããï¼æ§é ä½è¦ç´ ãé 3531 åè¦ç´ ã®åæå¤ãåºåãã㨠',' ãäºéã«åºåãããï¼ 3532 # ãã ãç¾ç¶ã§ã¯ããã¡ã¤ã«ã¸åºåãããã¨ã¯ãªã 3439 #f_get_str:: true の場合、文字列を返す、false の場合、ファイル f に出力する. 3440 # 文字列を返すとき、末尾に ',' は含まれない. 3441 # ファイルへ出力するとき、末尾に ',' が出力される.構造体要素、配列要素の初期値を出力すると ',' が二重に出力される. 3442 # ただし現状では、ファイルへ出力することはない 3533 3443 # 3534 3444 def gen_cell_cb_init( f, cell, name_array, type, init, identifier, indent, f_get_str = false ) … … 3544 3454 3545 3455 if f_get_str then 3546 # åæå¤æªæå®3456 # 初期値未指定 3547 3457 if type.kind_of?( BoolType ) then 3548 3458 str = "false" # formerly tecs_false … … 3568 3478 return str 3569 3479 else 3570 # åæå¤æªæå®3480 # 初期値未指定 3571 3481 if type.kind_of?( BoolType ) then 3572 3482 f.print " " * indent … … 3602 3512 end 3603 3513 3604 # ãã®ã¡ã½ãã㯠Celltype ã®ãã®ã§ããå¿ 3605 è¦ã¯ç¡ãï¼ä¸ã«ç¶ãã®ã§ããã«ç½®ãï¼ 3606 # åæå¤æå®ãã 3514 # このメソッドは Celltype のものである必要は無い(上に続くのでここに置く) 3515 # 初期値指定あり 3607 3516 if type.kind_of?( BoolType ) then 3608 3517 if init.instance_of?( C_EXP ) then … … 3670 3579 3671 3580 len.times { 3672 next if ! init[i] # mikan ãã®å¦ç½®ã¯é©åï¼3581 next if ! init[i] # mikan この処置は適切? 3673 3582 if f_get_str then 3674 3583 str += gen_cell_cb_init( f, cell, name_array, at, init[i], "#{identifier}[#{i}]", indent + 1, f_get_str ) … … 3752 3661 end 3753 3662 3754 #== é¢æ°ãã¼ãã«ã®å¤é¨åç 3755 § 3663 #== 関数テーブルの外部参照 3756 3664 def gen_cell_extern_mt fs 3757 3665 fs.each{ |r, f| … … 3768 3676 end 3769 3677 3770 #=== åãå£ãã£ã¹ã¯ãªãã¿ã®å®ç¾©ãçæ3678 #=== 受け口ディスクリプタの定義を生成 3771 3679 def gen_cell_ep_des fs 3772 3680 if @n_cell_gen >0 then … … 3789 3697 next if p.get_port_type != :ENTRY 3790 3698 next if p.is_omit? 3791 if p.is_skelton_useless? # åãå£æé©ån ep_opt3699 if p.is_skelton_useless? # 受け口最適化n ep_opt 3792 3700 f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" ) 3793 3701 next … … 3800 3708 3801 3709 if len != nil then 3802 # åãå£é 3803 åã®å ´å 3710 # 受け口配列の場合 3804 3711 i = 0 3805 3712 while i < len … … 3882 3789 return if @b_reuse && ! $generate_all_template 3883 3790 if ! ( @plugin && @plugin.gen_ep_func? ) then 3884 return if $generate_no_template # $generate_all_template ããåªå 3885 ããã 3886 3887 # åèã¨ãã¦åºåãããã³ãã¬ã¼ããã¡ã¤ã«ã§ãããã¨ã示ãããã« "_templ" ãä»å ãã 3791 return if $generate_no_template # $generate_all_template より優先される 3792 3793 # 参考として出力するテンプレートファイルであることを示すために "_templ" を付加する 3888 3794 fname = "#{$gen}/#{@global_name}_templ.#{$c_suffix}" 3889 3795 else 3890 # Plugin ã«ããçæãããã»ã«ã¿ã¤ãã«ã¤ãã¦ã¯ãååçã«ãã³ãã¬ã¼ãã§ã¯ãªãã 3891 # ä¿®æ£ä¸è¦ãªã»ã«ã¿ã¤ãã®å®è£ 3892 ã³ã¼ããçæããï¼ 3893 # ãã®ããããã¡ã¤ã«åã« _temp ãä»å ããªã 3796 # Plugin により生成されたセルタイプについては、原則的にテンプレートではなく、 3797 # 修正不要なセルタイプの実装コードを生成する. 3798 # このため、ファイル名に _temp を付加しない 3894 3799 fname = "#{$gen}/#{@global_name}.#{$c_suffix}" 3895 3800 end … … 3906 3811 gen_template_attr_access f 3907 3812 gen_template_cp_fun f 3908 # gen_template_types f # 0805503 追å ãã¦ã¿ããããã£ã±ãããã3813 # gen_template_types f # 0805503 追加してみたが、やっぱりやめる 3909 3814 f.print( " *\n * #[</PREAMBLE>]# */\n\n" ) 3910 3815 f.printf TECSMsg.get( :PAC_comment ), "#_PAC_#" … … 3912 3817 gen_template_private_header f 3913 3818 if ( @plugin ) then 3914 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã3819 # このメソッドの引数は plugin.rb の説明を見よ 3915 3820 @plugin.gen_preamble( f, @singleton, @name, @global_name ) 3916 3821 end … … 3921 3826 3922 3827 if ( @plugin ) then 3923 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã3828 # このメソッドの引数は plugin.rb の説明を見よ 3924 3829 @plugin.gen_postamble( f, @singleton, @name, @global_name ) 3925 3830 end … … 4075 3980 next if p.get_port_type != :ENTRY 4076 3981 next if p.is_omit? 4077 next if b_inline && ! p.is_inline? # inline ãã¼ã4078 next if ! b_inline && p.is_inline? # é inline ãã¼ã3982 next if b_inline && ! p.is_inline? # inline ポート 3983 next if ! b_inline && p.is_inline? # 非 inline ポート 4079 3984 4080 3985 inline_prefix = "" … … 4133 4038 len = items.length 4134 4039 else 4135 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å4040 # ここで nil になるのは、引数なしの時に void がなかった場合 4136 4041 items = [] 4137 4042 len = 0 … … 4153 4058 4154 4059 if ( @plugin && @plugin.gen_ep_func? ) then 4155 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4060 # このメソッドの引数は plugin.rb の説明を見よ 4156 4061 @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 ) 4157 4062 … … 4200 4105 if ! ( @plugin && @plugin.gen_ep_func? ) then 4201 4106 return if @b_reuse && ! $generate_all_template 4202 return if $generate_no_template # $generate_all_template ããåªå 4203 ããã 4204 4205 # åèã¨ãã¦åºåãããã³ãã¬ã¼ããã¡ã¤ã«ã§ãããã¨ã示ãããã« "_templ" ãä»å ãã 4107 return if $generate_no_template # $generate_all_template より優先される 4108 4109 # 参考として出力するテンプレートファイルであることを示すために "_templ" を付加する 4206 4110 fname = "#{$gen}/#{@global_name}_inline_templ.#{$h_suffix}" 4207 4111 else 4208 # Plugin ã«ããçæãããã»ã«ã¿ã¤ãã«ã¤ãã¦ã¯ãååçã«ãã³ãã¬ã¼ãã§ã¯ãªãã 4209 # ä¿®æ£ä¸è¦ãªã»ã«ã¿ã¤ãã®å®è£ 4210 ã³ã¼ããçæããï¼ 4211 # ãã®ããããã¡ã¤ã«åã« _temp ãä»å ããªã 4112 # Plugin により生成されたセルタイプについては、原則的にテンプレートではなく、 4113 # 修正不要なセルタイプの実装コードを生成する. 4114 # このため、ファイル名に _temp を付加しない 4212 4115 fname = "#{$gen}/#{@global_name}_inline.#{$h_suffix}" 4213 4116 end … … 4232 4135 4233 4136 if ( @plugin ) then 4234 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4137 # このメソッドの引数は plugin.rb の説明を見よ 4235 4138 @plugin.gen_postamble( f, @singleton, @name, @global_name ) 4236 4139 end … … 4249 4152 if fa.get_name == :write then 4250 4153 4251 # åå¾ã® " ãåãé¤ã4154 # 前後の " を取り除く 4252 4155 # file_name = fa.get_file_name.sub( /^\"(.*)\"$/, "\\1" ) 4253 4156 file_name = CDLString.remove_dquote fa.get_file_name 4254 4157 format = CDLString.remove_dquote fa.get_format 4255 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # åã® " ãåãé¤ã4256 # format = format.sub( /(.*)\"\z/, "\\1" ) # å¾ã® " ãåãé¤ã4158 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # 前の " を取り除く 4159 # format = format.sub( /(.*)\"\z/, "\\1" ) # 後の " を取り除く 4257 4160 format = format.gsub( /\\\n/, "\n" ) # \\\n => \n 4258 4161 4259 4162 4260 # mikan 以ä¸ã¯ subst_name ã§ç½®æããããã«å¤æ´ãã¹ã4261 file_name = file_name.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4262 file_name = file_name.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4263 format = format.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4264 format = format.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4265 format = format.gsub( /\$\$/, "\$" ) # $$ ã $ ã«ç½®æ4163 # mikan 以下は subst_name で置換するように変更すべき 4164 file_name = file_name.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ をセルタイプ名に置換 4165 file_name = file_name.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ をセルタイプ名に置換 4166 format = format.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ をセルタイプ名に置換 4167 format = format.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ をセルタイプ名に置換 4168 format = format.gsub( /\$\$/, "\$" ) # $$ を $ に置換 4266 4169 4267 4170 if file_name[0] != ?/ then … … 4275 4178 puts( format ) 4276 4179 end 4277 # format ä¸ã® \n, \r, \t, \f 㨠\" ãªã©ãç½®æ4180 # format 中の \n, \r, \t, \f と \" などを置換 4278 4181 fmt = CDLString.escape format 4279 4182 cfg_file.print( fmt ) … … 4292 4195 @ordered_cell_list.each{ |c| 4293 4196 4294 # cell ã®ãããã¿ã¤ã宣è¨ãªãç¡è¦4197 # cell のプロトタイプ宣言なら無視 4295 4198 next if ! c.is_generate? 4296 4199 … … 4301 4204 if fa.get_name == :write then 4302 4205 4303 # åå¾ã® " ãåãé¤ã4206 # 前後の " を取り除く 4304 4207 # file_name = fa.get_file_name.sub( /^\"(.*)\"$/, "\\1" ) 4305 4208 file_name = CDLString.remove_dquote fa.get_file_name 4306 4209 file_name = subst_name( file_name, name_array ) 4307 # format = fa.get_format.sub( /^\"(.*)\"$/, "\\1" ) # åå¾ã® "" ãåãé¤ã4210 # format = fa.get_format.sub( /^\"(.*)\"$/, "\\1" ) # 前後の "" を取り除く 4308 4211 format = CDLString.remove_dquote fa.get_format 4309 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # åã® " ãåãé¤ã4310 # format = format.sub( /(.*)\"\z/, "\\1" ) # å¾ã® " ãåãé¤ã4212 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # 前の " を取り除く 4213 # format = format.sub( /(.*)\"\z/, "\\1" ) # 後の " を取り除く 4311 4214 format = format.gsub( /\\\n/, "\n" ) # \\\n => \n 4312 4215 … … 4319 4222 end 4320 4223 4321 na = [] # ã·ã³ãã«ã attribute ã®å¤ã«ç½®ãæããå¾ã®å¼æ°4224 na = [] # シンボルを attribute の値に置き換えた後の引数 4322 4225 if arg_list then 4323 4226 arg_list.each { |a| 4324 4227 case a[0] 4325 when :STRING_LITERAL # æååå®æ°4326 # s = a[1].sub( /^\"(.*)\"$/, "\\1" ) # åå¾ã® "" ãåãé¤ã4228 when :STRING_LITERAL # 文字列定数 4229 # s = a[1].sub( /^\"(.*)\"$/, "\\1" ) # 前後の "" を取り除く 4327 4230 s = CDLString.remove_dquote a[1] 4328 4231 s = subst_name( s, name_array ) … … 4331 4234 na << s 4332 4235 when :IDENTIFIER 4333 param_name = a[1] # èå¥åï¼å±æ§ã®ååï¼4236 param_name = a[1] # 識別子(属性の名前) 4334 4237 attr = self.find( param_name ) 4335 init = attr.get_initializer # celltype ã§æå®ãããåæå¤4336 4337 # cell ã® join ã®ãªã¹ãããååãæ¢ã4238 init = attr.get_initializer # celltype で指定された初期値 4239 4240 # cell の join のリストから名前を探す 4338 4241 j = c.get_join_list.get_item( param_name ) 4339 if j then # param_name ã® cell ã®ã¸ã§ã¤ã³ãããã 4340 init = j.get_rhs # cell ã§æå®ãããåæå¤ãåªå 4341 4242 if j then # param_name の cell のジョインがあるか 4243 init = j.get_rhs # cell で指定された初期値を優先 4342 4244 end 4343 4245 … … 4345 4247 # file,cell, name_array, type, init, identifier, indent, f_get_str 4346 4248 4347 # str = str.sub( /^\"(.*)\"$/, "\\1" ) # åå¾ã® "" ãåãé¤ã mikan ããã§ç½®æã§ããï¼4249 # str = str.sub( /^\"(.*)\"$/, "\\1" ) # 前後の "" を取り除く mikan ここで置換でよい? 4348 4250 str = CDLString.remove_dquote str 4349 4251 na << str … … 4363 4265 end 4364 4266 4365 # format ä¸ã® \n, \r, \t, \f 㨠\" ãªã©ãç½®æ4267 # format 中の \n, \r, \t, \f と \" などを置換 4366 4268 fmt = CDLString.escape format 4367 4269 cfg_file.printf( fmt, *na ) … … 4387 4289 return if $generate_no_template 4388 4290 4389 # Makefile.templ ã®çæï¼è¿½è¨ï¼4291 # Makefile.templ の生成(追記) 4390 4292 4391 4293 f = AppFile.open( "#{$gen}/Makefile.templ" ) … … 4395 4297 4396 4298 EOT 4397 # ãã®çæè¦åã¯2ç¹ã§æå³ããªã4398 # ã»$(GEN_DIR) ã« .o ãçæããã«ã¼ã«ããªã4399 # ã»ãã³ãã¬ã¼ãã³ã¼ãããã®ã¾ã¾ãã«ãããã®ã¯ç´ãããã4299 # この生成規則は2点で意味がない 4300 # ・$(GEN_DIR) に .o を生成するルールがない 4301 # ・テンプレートコードをそのままビルドするのは紛らわしい 4400 4302 # # Celltype: #{@name} 4401 4303 # $(GEN_DIR)/#{@global_name}_tecsgen.o : $(GEN_DIR)/#{@global_name}_tecsgen.#{$c_suffix} … … 4414 4316 headers = [ "$(GEN_DIR)/#{@global_name}_tecsgen.#{$h_suffix}", "$(GEN_DIR)/#{@global_name}_factory.#{$h_suffix}", "$(GEN_DIR)/global_tecsgen.#{$h_suffix}" ] 4415 4317 4416 # inline åãå£ãæã¤ãï¼4318 # inline 受け口を持つか? 4417 4319 if @n_entry_port_inline > 0 then 4418 4320 headers << "#{@global_name}_inline.#{$h_suffix}" 4419 4321 end 4420 4322 4421 # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®ããã4323 # 呼び口または受け口のシグニチャのヘッダ 4422 4324 @port.each { |p| 4423 4325 next if p.is_omit? … … 4444 4346 end 4445 4347 4446 #=== decl ç¨ã® dealloc ã³ã¼ããçæ 4447 #b_reset:: Bool: ãªã»ããç¨ã® dealloc ã³ã¼ãã®çæ (NULL ãã¤ã³ã¿ã®å ´å dealloc ããªã) 4448 # mikan string 修飾ããããã¤ã³ã¿ã®å 4449 ã«ãã¤ã³ã¿ãæ¥ãªãã¨ä»®å®ããã¤ã³ã¿åãæã¤æ§é ä½ã®å¯è½æ§ãæé¤ãã¦ããªã 4450 # ãã®ã¡ã½ããã§ã¯ãè¡ãåºåããç´åã« " \\\n" ãåºåããè¡æ«ã§æ¹è¡æåãåºåããªã 4348 #=== decl 用の dealloc コードを生成 4349 #b_reset:: Bool: リセット用の dealloc コードの生成 (NULL ポインタの場合 dealloc しない) 4350 # mikan string 修飾されたポインタの先にポインタが来ないと仮定。ポインタ型を持つ構造体の可能性を排除していない 4351 # このメソッドでは、行を出力する直前に " \\\n" を出力し、行末で改行文字を出力しない 4451 4352 def gen_dealloc_code_for_type( f, type, dealloc_func_name, pre, name, post, level, b_reset, count_str = nil ) 4452 4353 type = type.get_original_type … … 4477 4378 post2 = "" 4478 4379 type2 = md.get_type.get_original_type 4479 if type2.kind_of? PtrType then # mikan typedef ãããå4380 if type2.kind_of? PtrType then # mikan typedef された型 4480 4381 if type2.get_count then 4481 4382 count_str = type2.get_count.to_str( members_decl, pre2, post2 ) … … 4550 4451 end 4551 4452 4552 # å¼ã³å£ã®çµåå 4553 ã®ã»ã«ã¿ã¤ãã®ãããï¼æé©åã®å ´åã®ã¿ï¼ 4554 # çµåå 4555 ã®åãå£ã inline ã®å ´åãinline ãããã 4453 # 呼び口の結合先のセルタイプのヘッダ(最適化の場合のみ) 4454 # 結合先の受け口が inline の場合、inline ヘッダも 4556 4455 @port.each { |p| 4557 4456 next if p.get_port_type != :CALL … … 4559 4458 4560 4459 if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then 4561 # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©4460 # 最適化コード (optimize) # スケルトン不要など 4562 4461 p2 = p.get_real_callee_port 4563 4462 if p2 then … … 4569 4468 headers += ct.get_depend_header_list_( celltype_list ) 4570 4469 #else 4571 # optional ã§æªçµå4470 # optional で未結合 4572 4471 end 4573 4472 end … … 4577 4476 4578 4477 4579 #=== $id$, $ct$, $cb$, $idx$ ç½®æ4478 #=== $id$, $ct$, $cb$, $idx$ 置換 4580 4479 # 4581 # str ã«ä»¥ä¸ã®ç½®æãè¡ã4582 #- $ct$ â ã»ã«ã¿ã¤ãå(ct)4583 #- $cell$ â ã»ã«å(cell) cell ã nil ãªãã°3ã¤ã®ç½®æã¯è¡ãããªã4584 #- $cb$ â CB ã® C è¨èªå(cb)4585 #- $cbp$ â CB ã¸ã®ãã¤ã³ã¿(cbp)4586 #- $cb_proto$ â CB ã® C è¨èªåãããã¿ã¤ã宣è¨ç¨(cb_proto)4587 #- $id$ âct_cell4588 #- $idx$ âidx4589 #- $ID$ â id (æ´æ°ã®çªå·)4590 #- $ct_global$ â ã»ã«ã¿ã¤ãå(ct)4591 #- $cell_global$ â ã»ã«å(cell) cell ã nil ãªãã°3ã¤ã®ç½®æã¯è¡ãããªã4592 #- $$ â$4480 # str に以下の置換を行う 4481 #- $ct$ ⇒ セルタイプ名(ct) 4482 #- $cell$ ⇒ セル名(cell) cell が nil ならば3つの置換は行われない 4483 #- $cb$ ⇒ CB の C 言語名(cb) 4484 #- $cbp$ ⇒ CB へのポインタ(cbp) 4485 #- $cb_proto$ ⇒ CB の C 言語名プロトタイプ宣言用(cb_proto) 4486 #- $id$ ⇒ ct_cell 4487 #- $idx$ ⇒ idx 4488 #- $ID$ ⇒ id (整数の番号) 4489 #- $ct_global$ ⇒ セルタイプ名(ct) 4490 #- $cell_global$ ⇒ セル名(cell) cell が nil ならば3つの置換は行われない 4491 #- $$ ⇒ $ 4593 4492 def subst_name( str, name_array ) 4594 4493 ct = name_array[0] # celltype name 4595 4494 cell = name_array[1] # cell name 4596 4495 cb = name_array[2] # cell CB name 4597 cb_init = name_array[3] # cell CB INIT, ããã¯ç½®æã«ä½¿ãããªã4496 cb_init = name_array[3] # cell CB INIT, これは置換に使われない 4598 4497 cb_proto = name_array[4] # cell CB name for prototype 4599 4498 id = name_array[6] # cell ID … … 4615 4514 str = str.gsub( /(^|[^\$])\$cell_global\$/, "\\1#{cell_global}" ) 4616 4515 end 4617 str = str.gsub( /\$\$/, "\$" ) # $$ ã $ ã«ç½®æ4516 str = str.gsub( /\$\$/, "\$" ) # $$ を $ に置換 4618 4517 4619 4518 return str … … 4622 4521 end 4623 4522 4624 # Appendable File ï¼è¿½è¨å¯è½ãã¡ã¤ã«ï¼4523 # Appendable File(追記可能ファイル) 4625 4524 class AppFile 4626 # éãããã¡ã¤ã«ã®ãªã¹ã4525 # 開いたファイルのリスト 4627 4526 @@file_name_list = {} 4628 4527 … … 4641 4540 end 4642 4541 4643 # æ¢ã«éãã¦ãããï¼4542 # 既に開いているか? 4644 4543 if @@file_name_list[ name ] then 4645 4544 #2.0 4646 4545 mode = "a" + mode 4647 # 追è¨ã¢ã¼ãã§éã4546 # 追記モードで開く 4648 4547 file = File.open( real_name, mode ) 4649 4548 else 4650 4549 #2.0 4651 4550 mode = "w" + mode 4652 # æ°è¦ã¢ã¼ãã§éãï¼æ¢ã«ããã°ããµã¤ãºãï¼ã«ããï¼4551 # 新規モードで開く(既にあれば、サイズを0にする) 4653 4552 file = File.open( real_name, mode ) 4654 4553 @@file_name_list[ name ] = true 4655 4554 end 4656 # File ã¯ã©ã¹ã®ãªãã¸ã§ã¯ããè¿ã4555 # File クラスのオブジェクトを返す 4657 4556 return file 4658 4557 end -
Property svn:mime-type
changed from
Note:
See TracChangeset
for help on using the changeset viewer.