Changeset 321 for EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core
- Timestamp:
- Aug 23, 2017, 9:27:43 AM (7 years ago)
- Location:
- EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/C_parser.tab.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 102 102 comment = false 103 103 104 # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµããã誤ãåé¡ã®å¯¾ç104 # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策 105 105 TECS_LANG::set_kcode_binary 106 106 107 # 800U, 0xffLL ãªã© (æ´æ°ãªãã©ã«ã«å 108 ±éã®ä¿®é£¾å) 107 # 800U, 0xffLL など (整数リテラルに共通の修飾子) 109 108 integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?" 110 109 … … 121 120 if comment 122 121 case line 123 # ã³ã¡ã³ãçµäº122 # コメント終了 124 123 when /\A\*\// 125 124 comment = false … … 129 128 else 130 129 case line 131 # 空ç½ãããªããã»ã¹ãã£ã¬ã¯ãã£ã130 # 空白、プリプロセスディレクティブ 132 131 when /\A\s+/ 133 132 ; 134 # èå¥å133 # 識別子 135 134 when /\A[a-zA-Z_]\w*/ 136 135 word = $& 137 136 @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)] 138 # 16 é²æ°å®æ°137 # 16 進数定数 139 138 when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/ 140 139 @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)] 141 # 8 é²æ°å®æ°140 # 8 進数定数 142 141 when /\A0[0-7]+#{integer_qualifier}/ 143 142 @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)] 144 # æµ®åå°æ°å®æ°143 # 浮動小数定数 145 144 when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/ 146 145 @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)] 147 # æ´æ°å®æ°146 # 整数定数 148 147 when /\A\d+#{integer_qualifier}/ 149 148 # when /\A\d+/ 150 149 @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)] 151 # æå150 # 文字 152 151 when /\A'(?:[^'\\]|\\.)'/ 153 152 @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)] 154 # æåå155 # "#include #include #include \"../systask/logtask.cfg\" æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã153 # 文字列 154 # "#include #include #include \"../systask/logtask.cfg\" 最後の " 忘れ)で無限ループ 156 155 # when /\A"(?:[^"\\]+|\\.)*"/ 157 when /\A"(?:[^"\\]|\\.)*"/ # ããã¯ãã¾ãè¡ãããã156 when /\A"(?:[^"\\]|\\.)*"/ # これはうまく行くようだ 158 157 @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)] 159 # è¡ã³ã¡ã³ã158 # 行コメント 160 159 when /\A\/\/.*$/ 161 # èªã¿é£ã°ãã ã162 # ã³ã¡ã³ãéå§160 # 読み飛ばすだけ 161 # コメント開始 163 162 when /\A\/\*/ 164 163 comment = true … … 189 188 } 190 189 191 # çµäºã®å°190 # 終了の印 192 191 @q << nil 193 192 … … 216 215 end 217 216 218 # TYPE_NAME ãã¼ã¯ã³ã¸ç½®ãæã217 # TYPE_NAME トークンへ置き換え 219 218 if @b_no_type_name == false 220 219 if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then … … 223 222 end 224 223 225 if $debug then # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç)224 if $debug then # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生) 226 225 locale = @@current_locale[@@generator_nest] 227 226 if token then … … 252 251 @@n_warning = 0 253 252 254 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼253 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切) 255 254 def self.error( msg ) 256 255 @@n_error += 1 … … 264 263 end 265 264 266 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼265 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切) 267 266 def self.warning( msg ) 268 267 @@n_warning += 1 … … 1676 1675 module_eval(<<'.,.,', 'C_parser.y.rb', 237) 1677 1676 def _reduce_70(val, _values, result) 1678 result = CIntType.new( -3 ) # storage class ã¯ç¡è¦1677 result = CIntType.new( -3 ) # storage class は無視 1679 1678 1680 1679 result … … 1695 1694 module_eval(<<'.,.,', 'C_parser.y.rb', 247) 1696 1695 def _reduce_73(val, _values, result) 1697 result = val[1] # storage class ã¯ç¡è¦1696 result = val[1] # storage class は無視 1698 1697 1699 1698 result -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/C_parser.y.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : C_parser.y.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 40 class C_parser 56 41 rule 57 # ãããã¬ãã«ã®æ§æè¦ç´ ã¯C_parser42 # トップレベルの構文要素は C_parser 58 43 all: C_parser 59 44 60 45 # Expr 61 ########################## å¼ ########################## 62 # K&Rã®ææ³(ããã°ã©ãã³ã°è¨èªC 第2ç ä»é²)ã¨ä¸é¨ç°ãªã 63 # argument_expression_list(é¢æ°å¼æ°), assignment_expression(代å 64 ¥)ããªã 65 # å¼ã® result ã¯ããã¹ã¦é 66 åã§ç¬¬ä¸è¦ç´ ãèå¥ã·ã³ãã«ã第äºè¦ç´ 以ä¸ãå¼æ° 46 ########################## 式 ########################## 47 # K&Rの文法(プログラミング言語C 第2版 付録)と一部異なる 48 # argument_expression_list(関数引数), assignment_expression(代入)がない 49 # 式の result は、すべて配列で第一要素が識別シンボル、第二要素以下が引数 67 50 68 51 primary_expression 69 52 : namespace_identifier 70 53 { result = [ :IDENTIFIER, val[0] ] } #1ok 71 # : IDENTIFIER # mikan namespace ã¸ã®å¯¾å¿54 # : IDENTIFIER # mikan namespace への対応 72 55 # { result = [ :IDENTIFIER, val[0] ] } 73 56 # | TRUE … … 96 79 { result << val[1] } 97 80 98 # é¢æ°å¼ã³åºãã¨å¾ç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®åããªã81 # 関数呼び出しと後置インクリメント、デクリメント演算子がない 99 82 postfix_expression 100 83 : primary_expression … … 107 90 | postfix_expression '->' IDENTIFIER 108 91 { result = [ :OP_REF, val[0], val[2] ] } 109 | postfix_expression '++' { result = val[0] } # ++, -- ã¯ç¡è¦ãã92 | postfix_expression '++' { result = val[0] } # ++, -- は無視する 110 93 | postfix_expression '--' { result = val[0] } 111 94 … … 116 99 117 100 118 # åç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®åããªã101 # 前置インクリメント、デクリメント演算子がない 119 102 unary_expression 120 103 : postfix_expression … … 125 108 | SIZEOF '(' type_name ')' 126 109 { result = [ :OP_SIZEOF_TYPE, val[1] ] } 127 | '++' unary_expression { result = val[1] } # ++, -- ã¯ç¡è¦ãã110 | '++' unary_expression { result = val[1] } # ++, -- は無視する 128 111 | '--' unary_expression { result = val[1] } 129 112 … … 213 196 214 197 215 # ã³ã³ãæ¼ç®åã使ããªã198 # コンマ演算子が使えない 216 199 expression 217 200 : conditional_expression … … 238 221 239 222 # Types 240 ########################## 宣è¨##########################241 # 宣è¨ãK&Rã¨ä¸é¨ç°ãªã242 243 # declaration ã¯ã»ã«ã®å±æ§ã§ä½¿ããã244 # K&R ã¨ã®éã: storage classãæå®ã§ããªããåãçç¥ã§ããªã223 ########################## 宣言 ########################## 224 # 宣言もK&Rと一部異なる 225 226 # declarationはセルの属性で使われる 227 # K&Rとの違い: storage classが指定できない、型が省略できない 245 228 declaration 246 229 : declaration_specifiers init_declarator_list ';' 247 230 # : type_specifier_qualifier_list init_declarator_list ';' 248 231 249 # declaration_specifiers ã¯é¢æ°ã®ãã©ã¡ã¼ã¿ã§ä½¿ããããã250 # type_specifier_qualifier_list ã§ååãããããªã232 # declaration_specifiersは関数のパラメータで使われるが、 233 # type_specifier_qualifier_listで十分かもしれない 251 234 252 235 declaration_specifiers 253 236 : storage_class 254 237 { 255 result = CIntType.new( -3 ) # storage class ã¯ç¡è¦238 result = CIntType.new( -3 ) # storage class は無視 256 239 } 257 240 | type_specifier … … 263 246 | storage_class declaration_specifiers 264 247 { 265 result = val[1] # storage class ã¯ç¡è¦248 result = val[1] # storage class は無視 266 249 } 267 250 | type_specifier declaration_specifiers … … 292 275 | DOUBLE { set_no_type_name true; result = CFloatType.new(-64) } 293 276 | BOOL { set_no_type_name true; result = CBoolType.new } 294 | struct_specifier { set_no_type_name true; result = val[0] } # set_no_type_name true 㯠struct_tag ã§ãå¼ã°ãã295 | union_specifier { set_no_type_name true; result = CVoidType.new } # void ã宣è¨ãããã¨ãã296 | enum_specifier { set_no_type_name true; result = CVoidType.new } # void ã宣è¨ãããã¨ãã277 | struct_specifier { set_no_type_name true; result = val[0] } # set_no_type_name true は struct_tag でも呼ばれる 278 | union_specifier { set_no_type_name true; result = CVoidType.new } # void が宣言されたとする 279 | enum_specifier { set_no_type_name true; result = CVoidType.new } # void が宣言されたとする 297 280 | TYPE_NAME { set_no_type_name true; result = CDefinedType.new( val[0].val ) } 298 281 … … 314 297 } 315 298 316 # mikan K&R ã®struct_or_union_specifierã«ç¸å½ããããunionã¯ä½¿ããªã, bit field ã«ã対å¿ããªã299 # mikan K&Rのstruct_or_union_specifierに相当するが、unionは使えない, bit field にも対応しない 317 300 struct_specifier # mikan 318 301 : STRUCT struct_tag '{' … … 333 316 result = val[1] 334 317 } 335 | STRUCT struct_tag # mikan struct_tag 㯠namespace 対å¿ãå¿ 336 è¦ 318 | STRUCT struct_tag # mikan struct_tag は namespace 対応が必要 337 319 { 338 320 StructType.set_define( false ) … … 352 334 } 353 335 354 # ãã¤ã³ã¿ä¿®é£¾åã追å336 # ポインタ修飾子を追加 355 337 struct_declaration 356 338 : declaration_specifiers struct_declarator_list ';' … … 365 347 result = val[1] 366 348 } 367 | union_specifier ';' # ç¡å368 | struct_specifier ';' # ç¡å369 370 371 372 # K&R ã®specifier_qualifier_listã¨åã373 # ååãã¾ãããããã£ãã®ã§type_ãä»ãã349 | union_specifier ';' # 無名 350 | struct_specifier ';' # 無名 351 352 353 354 # K&Rのspecifier_qualifier_listと同じ 355 # 名前がまぎらわしかったのでtype_を付けた 374 356 type_specifier_qualifier_list 375 357 : type_specifier … … 395 377 { result << val[2] } 396 378 397 # ããããã£ã¼ã«ãã¯ä½¿ããªã379 # ビットフィールドは使えない 398 380 struct_declarator 399 381 : declarator … … 404 386 : UNION union_tag '{' union_declaration_list '}' 405 387 | UNION '{' union_declaration_list '}' 406 | UNION union_tag # mikan struct_tag 㯠namespace 対å¿ãå¿ 407 è¦ 388 | UNION union_tag # mikan struct_tag は namespace 対応が必要 408 389 409 390 union_declaration_list … … 416 397 union_declaration 417 398 : declaration_specifiers union_declarator_list ';' 418 | union_specifier ';' # ç¡å419 | struct_specifier ';' # ç¡å399 | union_specifier ';' # 無名 400 | struct_specifier ';' # 無名 420 401 421 402 union_declarator_list … … 423 404 | union_declarator_list ',' union_declarator 424 405 425 # ããããã£ã¼ã«ãã¯ä½¿ããªã406 # ビットフィールドは使えない 426 407 union_declarator 427 408 : declarator … … 429 410 430 411 431 # enum ã®ç¨®é¡ã追å412 # enumの種類を追加 432 413 enum_specifier # mikan 433 414 : enum_type '{' enumerator_list '}' … … 462 443 } 463 444 | direct_declarator 464 | pointer TYPE_NAME # é¢æ°ãã¤ã³ã¿ã® typedef ãäºéå®ç¾©ã®å ´å445 | pointer TYPE_NAME # 関数ポインタの typedef が二重定義の場合 465 446 { 466 447 result = Decl.new( val[1].val ) … … 490 471 } 491 472 492 # | direct_declarator '(' identifier_list ')' # ããã¯ä½ã®ããã«å¿ 493 è¦ï¼ 060211 473 # | direct_declarator '(' identifier_list ')' # これは何のために必要? 060211 494 474 | direct_declarator '(' ')' 495 475 { … … 524 504 : parameter_list 525 505 | parameter_list ',' '.' '.' '.' 526 # mikan å¯å¤é·ãã©ã¡ã¼ã¿, ... ã®éã®ã¹ãã¼ã¹ã許ãããï¼ææãï¼506 # mikan 可変長パラメータ, ... の間のスペースが許される(手抜き) 527 507 528 508 parameter_list … … 532 512 # { 533 513 # val[0].add_param( val[2] ) 534 # # result = val[0] ä¸è¦514 # # result = val[0] 不要 535 515 # } 536 516 537 517 538 # ãã©ã¡ã¼ã¿ä¿®é£¾åã追å518 # パラメータ修飾子を追加 539 519 parameter_declaration 540 520 : declaration_specifiers declarator … … 545 525 # } 546 526 547 # 以ä¸ã¯ã¨ã©ã¼ã¨ãã548 # | declaration_specifiers # ä»®å¼æ°ãªãã¯ãã¨ããããæ±ããªã060210527 # 以下はエラーとする 528 # | declaration_specifiers # 仮引数なしは、とりあえず扱わない 060210 549 529 # { 550 530 # unless val[0].kind_of?( VoidType ) then … … 553 533 # result = nil 554 534 # } 555 | declaration_specifiers abstract_declarator # ä»®å¼æ°ãªã556 | declaration_specifiers # ä»®å¼æ°ãªã557 558 559 #identifier_list # 060211 ä¸ç¨ã«ãªã£ã535 | declaration_specifiers abstract_declarator # 仮引数なし 536 | declaration_specifiers # 仮引数なし 537 538 539 #identifier_list # 060211 不用になった 560 540 # : IDENTIFIER 561 541 # | identifier_list ',' IDENTIFIER … … 587 567 | direct_abstract_declarator '(' parameter_type_list ')' 588 568 589 # assignment_expression ãconstant_expressionã«å¤æ´569 # assignment_expressionをconstant_expressionに変更 590 570 initializer # mikan 591 571 : constant_expression … … 610 590 611 591 612 ########################## ããããã¯CDLç¬èª##########################613 614 # ãããã¬ãã«ã®æ§æè¦å592 ########################## ここからはCDL独自 ########################## 593 594 #トップレベルの構文規則 615 595 C_parser 616 596 : … … 628 608 | declaration 629 609 | ';' 630 | error # ã¨ã©ã¼å復ãã¤ã³ã610 | error # エラー回復ポイント 631 611 632 612 typedef … … 826 806 comment = false 827 807 828 # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµããã誤ãåé¡ã®å¯¾ç808 # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策 829 809 TECS_LANG::set_kcode_binary 830 810 831 # 800U, 0xffLL ãªã© (æ´æ°ãªãã©ã«ã«å 832 ±éã®ä¿®é£¾å) 811 # 800U, 0xffLL など (整数リテラルに共通の修飾子) 833 812 integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?" 834 813 … … 845 824 if comment 846 825 case line 847 # ã³ã¡ã³ãçµäº826 # コメント終了 848 827 when /\A\*\// 849 828 comment = false … … 853 832 else 854 833 case line 855 # 空ç½ãããªããã»ã¹ãã£ã¬ã¯ãã£ã834 # 空白、プリプロセスディレクティブ 856 835 when /\A\s+/ 857 836 ; 858 # èå¥å837 # 識別子 859 838 when /\A[a-zA-Z_]\w*/ 860 839 word = $& 861 840 @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)] 862 # 16 é²æ°å®æ°841 # 16 進数定数 863 842 when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/ 864 843 @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)] 865 # 8 é²æ°å®æ°844 # 8 進数定数 866 845 when /\A0[0-7]+#{integer_qualifier}/ 867 846 @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)] 868 # æµ®åå°æ°å®æ°847 # 浮動小数定数 869 848 when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/ 870 849 @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)] 871 # æ´æ°å®æ°850 # 整数定数 872 851 when /\A\d+#{integer_qualifier}/ 873 852 # when /\A\d+/ 874 853 @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)] 875 # æå854 # 文字 876 855 when /\A'(?:[^'\\]|\\.)'/ 877 856 @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)] 878 # æåå879 # "#include #include #include \"../systask/logtask.cfg\" æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã857 # 文字列 858 # "#include #include #include \"../systask/logtask.cfg\" 最後の " 忘れ)で無限ループ 880 859 # when /\A"(?:[^"\\]+|\\.)*"/ 881 when /\A"(?:[^"\\]|\\.)*"/ # ããã¯ãã¾ãè¡ãããã860 when /\A"(?:[^"\\]|\\.)*"/ # これはうまく行くようだ 882 861 @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)] 883 # è¡ã³ã¡ã³ã862 # 行コメント 884 863 when /\A\/\/.*$/ 885 # èªã¿é£ã°ãã ã886 # ã³ã¡ã³ãéå§864 # 読み飛ばすだけ 865 # コメント開始 887 866 when /\A\/\*/ 888 867 comment = true … … 913 892 } 914 893 915 # çµäºã®å°894 # 終了の印 916 895 @q << nil 917 896 … … 940 919 end 941 920 942 # TYPE_NAME ãã¼ã¯ã³ã¸ç½®ãæã921 # TYPE_NAME トークンへ置き換え 943 922 if @b_no_type_name == false 944 923 if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then … … 947 926 end 948 927 949 if $debug then # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç)928 if $debug then # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生) 950 929 locale = @@current_locale[@@generator_nest] 951 930 if token then … … 976 955 @@n_warning = 0 977 956 978 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼957 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切) 979 958 def self.error( msg ) 980 959 @@n_error += 1 … … 988 967 end 989 968 990 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼969 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切) 991 970 def self.warning( msg ) 992 971 @@n_warning += 1 -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/bnf.tab.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 94 94 } 95 95 96 # æå®å '[]' å 97 ã§ã®ã¿ä½¿ç¨ã§ãããã¼ã¯ã¼ã 96 # 指定子 '[]' 内でのみ使用できるキーワード 98 97 RESERVED2 = { 99 98 # specifier … … 112 111 # port (entry) 113 112 'inline' => :INLINE, 114 'ref_desc' => :REF_DESC, # call ãå¯113 'ref_desc' => :REF_DESC, # call も可 115 114 116 115 # port (call) … … 156 155 } 157 156 158 # å帰çãªãã¼ãµã®ããã®ã¹ã¿ãã¯157 # 再帰的なパーサのためのスタック 159 158 @@generator_nest = -1 160 159 @@generator_stack = [] 161 160 @@current_locale = [] 162 161 163 # import_C ä¸ã§ãã162 # import_C 中である 164 163 @@import_C = false 165 164 166 # ãã¹ã¦ã®æ§æ解æãå®äºãã165 # すべての構文解析が完了した 167 166 @@b_end_all_parse = false 168 167 169 168 def self.parse( file_name, plugin = nil, b_reuse = false ) 170 # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èªã¿è¾¼ã)169 # パーサインスタンスを生成(別パーサで読み込む) 171 170 parser = Generator.new 172 171 173 # plugin ãã import ããã¦ããå ´åã® plugin è¨å®172 # plugin から import されている場合の plugin 設定 174 173 parser.set_plugin plugin 175 174 176 # reuse ãã©ã°ãè¨å®175 # reuse フラグを設定 177 176 parser.set_reuse b_reuse 178 177 179 # cdl ããã¼ã¹178 # cdl をパース 180 179 parser.parse( [file_name] ) 181 180 182 # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã181 # 終期化 パーサスタックを戻す 183 182 parser.finalize 184 183 end … … 200 199 def self.get_plugin 201 200 if @@generator_stack[@@generator_nest] then 202 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil201 # tecsgen 引数の cdl が import される場合は nil 203 202 return @@generator_stack[@@generator_nest].get_plugin 204 203 else … … 217 216 def self.is_reuse? 218 217 if @@generator_stack[@@generator_nest] then 219 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil218 # tecsgen 引数の cdl が import される場合は nil 220 219 return @@generator_stack[@@generator_nest].is_reuse? 221 220 else … … 247 246 b_in_string = false 248 247 249 # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµããã誤ãåé¡ã®å¯¾ç248 # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策 250 249 TECS_LANG::set_kcode_binary 251 250 … … 257 256 TECSIO.foreach(file) {|line| 258 257 col = 1 259 # line.rstrip! æ¹è¡å«ãæååãæ±ãããã«ãªã£ãã®ã§ãããã§ç©ºç½ãåãé¤ããªããªã£ã258 # line.rstrip! 改行含む文字列を扱うようになったので、ここで空白を取り除けなくなった 260 259 261 260 until line.empty? … … 263 262 if b_in_comment 264 263 case line 265 # ã³ã¡ã³ãçµäº264 # コメント終了 266 265 when /\A\*\// 267 266 b_in_comment = false 268 267 when /\A./ 269 268 ; 270 when /\s+/ # line.rstrip! ãæ¢ãããã \n ãªã©ã®ç©ºç½æåã¨ã¾ã£ã¡ããã«ã¼ã«ãå¿ 271 è¦ã«ãªã£ã 269 when /\s+/ # line.rstrip! を止めたため \n などの空白文字とまっちするルールが必要になった 272 270 ; 273 271 end … … 277 275 @q << [:STRING_LITERAL, Token.new(string, file, lineno, col)] 278 276 b_in_string = false 279 elsif line =~ /\A.*\\\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã277 elsif line =~ /\A.*\\\n/ # 改行 \n は '.' にマッチしない 280 278 string += $& 281 elsif line =~ /\A.*\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã279 elsif line =~ /\A.*\n/ # 改行 \n は '.' にマッチしない 282 280 string += line 283 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå)281 # この位置では error メソッドは使えない (token 読出し前) 284 282 puts "error: #{file} line #{lineno}: string literal has newline without escape" 285 283 @@n_error += 1 … … 287 285 else 288 286 case line 289 # 空ç½ãããªããã»ã¹ãã£ã¬ã¯ãã£ã287 # 空白、プリプロセスディレクティブ 290 288 when /\A\s+/ 291 289 ; 292 # èå¥å290 # 識別子 293 291 when /\A[a-zA-Z_]\w*/ 294 292 word = $& 295 293 @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)] 296 # 16 é²æ°å®æ°294 # 16 進数定数 297 295 when /\A0x[0-9A-Fa-f]+/ 298 296 @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)] 299 # 8 é²æ°å®æ°297 # 8 進数定数 300 298 when /\A0[0-7]+/ 301 299 @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)] 302 # æµ®åå°æ°å®æ°300 # 浮動小数定数 303 301 when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/ 304 302 @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)] 305 # æ´æ°å®æ°303 # 整数定数 306 304 when /\A\d+/ 307 305 @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)] 308 # æåå®æ°306 # 文字定数 309 307 when /\A'(?:[^'\\]|\\.)'/ 310 308 @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)] 311 # æåå312 # "#include #include #include \"../systask/logtask.cfg\" æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã309 # 文字列 310 # "#include #include #include \"../systask/logtask.cfg\" 最後の " 忘れ)で無限ループ 313 311 # when /\A"(?:[^"\\]+|\\.)*"/ 314 when /\A"(?:[^"\\]|\\.)*"/ # ããã¯ãã¾ãè¡ãããã312 when /\A"(?:[^"\\]|\\.)*"/ # これはうまく行くようだ 315 313 @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)] 316 # æåå (æ¹è¡ãã)314 # 文字列 (改行あり) 317 315 when /\A"(?:[^"\\]|\\.)*\\\n$/ 318 316 string = $& 319 317 b_in_string = true 320 # æåå (æ¹è¡ãã, escape ãªã)318 # 文字列 (改行あり, escape なし) 321 319 when /\A("(?:[^"\\]|\e\.)*)\n$/ 322 320 string = $1 + "\\\n" 323 321 b_in_string = true 324 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå) # mikan cdl_error ã§ã¯ãªã322 # この位置では error メソッドは使えない (token 読出し前) # mikan cdl_error ではない 325 323 puts "error: #{file} line #{lineno}: string literal has newline without escape" 326 324 @@n_error += 1 327 # å±±æ¬å¼§ã§å²ã¾ããæåå325 # 山括弧で囲まれた文字列 328 326 when /\A<[0-9A-Za-z_\. \/]+>/ # AB: angle bracke 329 327 @q << [:AB_STRING_LITERAL, Token.new($&, file, lineno, col)] 330 # è¡ã³ã¡ã³ã328 # 行コメント 331 329 when /\A\/\/.*$/ 332 # èªã¿é£ã°ãã ã333 # ã³ã¡ã³ãéå§330 # 読み飛ばすだけ 331 # コメント開始 334 332 when /\A\/\*/ 335 333 b_in_comment = true 336 # '>>', '<<' ãªã©334 # '>>', '<<' など 337 335 when /\A>>/, /\A<</, /\A==/, /\A!=/, /\A\&\&/, /\A\|\|/ 338 336 @q << [$&, Token.new($&, file, lineno, col)] 339 337 when /\A::/, /\A=>/, /\A<=/, /\A>=/ 340 338 @q << [$&, Token.new($&, file, lineno, col)] 341 # '(', ')' ãªã©ä¸æåã®è¨å·ãã¾ãã¯æªç¥ã®è¨å·339 # '(', ')' など一文字の記号、または未知の記号 342 340 when /\A./ 343 341 @q << [$&, Token.new($&, file, lineno, col)] … … 363 361 } 364 362 365 # çµäºã®å°363 # 終了の印 366 364 @q << nil 367 365 … … 383 381 384 382 if token[0] == :IDENTIFIER then 385 # TYPE_NAME ãã¼ã¯ã³ã¸ç½®æã383 # TYPE_NAME トークンへ置換え 386 384 if Namespace.is_typename?( token[1].val ) then 387 385 token[0] = :TYPE_NAME 388 386 elsif @in_specifier && RESERVED2[ token[1].val.to_s ] then 389 # æå®åãã¼ã¯ã¼ãï¼ '[', ']' å 390 ã§ã®ã¿æå¹) 387 # 指定子キーワード( '[', ']' 内でのみ有効) 391 388 token[0] = RESERVED2[ token[1].val.to_s ] 392 389 end 393 390 end 394 391 395 if $debug then # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç)392 if $debug then # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生) 396 393 locale = @@current_locale[@@generator_nest] 397 394 if token then … … 424 421 @@n_warning = 0 425 422 426 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼423 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切) 427 424 def self.error( msg, *arg ) 428 425 locale = nil … … 434 431 435 432 msg = TECSMsg.get_error_message( msg ) 436 # $1, $2, ... ã arg ã§ç½®æ433 # $1, $2, ... を arg で置換 437 434 count = 1 438 435 arg.each{ |a| … … 442 439 } 443 440 444 # import_C ã®ä¸ã§ã®ã¨ã©ã¼ï¼441 # import_C の中でのエラー? 445 442 if @@import_C then 446 443 C_parser.error( msg ) 447 444 else 448 445 449 # Node ã®è¨æ¶ãã ä½ç½® (locale) ã使ç¨ããå ´åãå¤æ´ä»¥åã«æ¯ã¹ã450 # åé¡çºçç®æã¨ç°ãªãä½ç½®ã«ã¨ã©ã¼ãåºããããæ§æ解æä¸ã®ã¨ã©ã¼451 # ã¯ã解æä¸ã®ä½ç½®ãåºåããï¼(new_XXX 㧠owner ãåè¦ç´ ã®ãã§ã452 # ã¯ããã㨠owner ã®è¡çªå·ãåºã¦ãã¾ãç¹ã§ããããçãã¦ãã)446 # Node の記憶する 位置 (locale) を使用した場合、変更以前に比べ、 447 # 問題発生箇所と異なる位置にエラーが出るため、構文解析中のエラー 448 # は、解析中の位置を出力する.(new_XXX で owner が子要素のチェッ 449 # クをすると owner の行番号が出てしまう点で、ずれが生じている) 453 450 454 451 if @@b_end_all_parse == false || locale == nil then … … 463 460 end 464 461 465 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼462 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切) 466 463 def self.warning( msg, *arg ) 467 464 locale = nil … … 473 470 474 471 msg = TECSMsg.get_warning_message( msg ) 475 # $1, $2, ... ã arg ã§ç½®æ472 # $1, $2, ... を arg で置換 476 473 count = 1 477 474 arg.each{ |a| … … 481 478 } 482 479 483 # import_C ã®ä¸ã§ã®ã¦ã©ã¼ãã³ã°ï¼480 # import_C の中でのウォーニング? 484 481 if @@import_C then 485 482 C_parser.warning( msg ) … … 508 505 end 509 506 510 #=== '[' specifier å§ã507 #=== '[' specifier 始め 511 508 def set_in_specifier 512 509 # p "set_in_specifier" … … 514 511 end 515 512 516 #=== ']' specifier çµãã513 #=== ']' specifier 終わり 517 514 def unset_in_specifier 518 515 # p "unset_in_specifier" … … 520 517 end 521 518 522 # statement_specifier ã¯æ§æ解ééä¸ã§åç 523 §ããããã 519 # statement_specifier は構文解釈途中で参照したいため 524 520 @@statement_specifier_stack = [] 525 521 def self.add_statement_specifier( ss ) … … 538 534 end 539 535 540 #=== ãã¹ã¦ã®æ§æ解æãå®äºãããã¨ãå ±å536 #=== すべての構文解析が完了したことを報告 541 537 def self.end_all_parse 542 538 @@b_end_all_parse = true … … 2264 2260 module_eval(<<'.,.,', 'bnf.y.rb', 76) 2265 2261 def _reduce_13(val, _values, result) 2266 # é£æ¥ããæååã1ã¤ã®æååã«ã¾ã¨ãã2262 # 連接した文字列を1つの文字列にまとめる 2267 2263 str = "\"" + val[0].val.gsub( /\"(.*)\"/, "\\1" ) + val[1].val.gsub( /\"(.*)\"/, "\\1" ) + "\"" 2268 2264 result = Token.new( str, val[0].file, val[0].lineno, val[0].col ) … … 3159 3155 def _reduce_153(val, _values, result) 3160 3156 val[0].add_param( val[2] ) 3161 # result = val[0] ä¸è¦3157 # result = val[0] 不要 3162 3158 3163 3159 result … … 3314 3310 result = val[1] 3315 3311 else 3316 # ã¨ã©ã¼ï¼ä»®ã§ val[0] ãè¿ã3312 # エラー:仮で val[0] を返す 3317 3313 result = val[0] 3318 3314 end … … 3458 3454 obj = val[3] 3459 3455 if obj.kind_of?( Cell ) || obj.kind_of?( Signature ) || obj.kind_of?( Celltype ) || obj.kind_of?( CompositeCelltype )then 3460 # cell, signature 以å¤ã¯ãæå®åãç½®ããªã3456 # cell, signature 以外は、指定子を置けない 3461 3457 else 3462 Generator.get_statement_specifier # ã¯ãªã¢3458 Generator.get_statement_specifier # クリア 3463 3459 Generator.error( "G1009 unexpected specifier" ) 3464 3460 end … … 3831 3827 val[1].check 3832 3828 else 3833 # mikan é¢æ°ã®é 3834 åã以ä¸ã®ã¡ãã»ã¼ã¸ã«ãªã 3829 # mikan 関数の配列も以下のメッセージになる 3835 3830 Generator.error( "G1010 Not function" ) 3836 3831 result = nil … … 3887 3882 def _reduce_264(val, _values, result) 3888 3883 if val[3].kind_of? Port then 3889 val[3].set_specifier val[1] # è¨å®é åºãã3884 val[3].set_specifier val[1] # 設定順序あり 3890 3885 Celltype.new_port( val[3] ) 3891 3886 else 3892 # Port 以å¤ã§ã¯æå®åã¯ã¨ã©ã¼3887 # Port 以外では指定子はエラー 3893 3888 Generator.error( "G1012 $1 : cannot put specifier here" , val[1] ) 3894 3889 end … … 4095 4090 def _reduce_297(val, _values, result) 4096 4091 val[3].each{ |i| # i:Decl 4097 i.set_kind( :ATTRIBUTE ) # è¨å®é åºãã4092 i.set_kind( :ATTRIBUTE ) # 設定順序あり 4098 4093 i.set_specifier_list( [val[1]] ) 4099 4094 i.check … … 4177 4172 def _reduce_308(val, _values, result) 4178 4173 val[3].each{ |i| # i:Decl 4179 i.set_kind( :VAR ) # è¨å®é åºãã4174 i.set_kind( :VAR ) # 設定順序あり 4180 4175 i.set_specifier_list( [val[1]] ) 4181 4176 i.check … … 4458 4453 def _reduce_353(val, _values, result) 4459 4454 if val[0].kind_of?( Port ) then 4460 CompositeCelltype.new_port( val[0] ) # é 4461 延ãã¦ç»é² 4455 CompositeCelltype.new_port( val[0] ) # 遅延して登録 4462 4456 end 4463 4457 … … 4469 4463 def _reduce_354(val, _values, result) 4470 4464 if val[3].kind_of?( Port ) then 4471 # port ä»¥å¤ val[3] ã«æå¹ãªå¤ãå 4472 ¥ã£ã¦ããªãã®ã§ã以ä¸ã®ã¡ã½ãããé©ç¨ã§ããªã 4473 # ç¾ç¶ port, cell 以å¤ã¯æå®åãåãä»ããªã 4474 # ï¼ãããå°æ¥ä»ã®æãæå®åãåãä»ããå¯è½æ§ãããã®ã§ããã®ä½ç½®ã«è¨è¿°ããï¼ 4465 # port 以外 val[3] に有効な値が入っていないので、以下のメソッドを適用できない 4466 # 現状 port, cell 以外は指定子を受け付けない 4467 # (しかし将来他の文も指定子を受け付ける可能性があるので、この位置に記述する) 4475 4468 val[3].set_specifier( Generator.get_statement_specifier ) 4476 CompositeCelltype.new_port( val[3] ) # é 4477 延ãã¦ç»é² (set_specifier å¾) 4469 CompositeCelltype.new_port( val[3] ) # 遅延して登録 (set_specifier 後) 4478 4470 elsif val[3].kind_of?( Cell ) then 4479 # Cell.end_of_parse ã«ã¦è¨å®4471 # Cell.end_of_parse にて設定 4480 4472 else 4481 Generator.get_statement_specifier # ã¯ãªã¢4473 Generator.get_statement_specifier # クリア 4482 4474 Generator.error( "G1013 unexpected specifier" ) 4483 4475 end … … 4756 4748 if obj.kind_of?( Cell ) then 4757 4749 else 4758 Generator.get_statement_specifier # ã¯ãªã¢4750 Generator.get_statement_specifier # クリア 4759 4751 Generator.error( "G9999 unexpected specifier" ) 4760 4752 end … … 4854 4846 4855 4847 4856 # ãã¡ã¤ã« => INCLUDE("header")ã®é 4857 å 4848 # ファイル => INCLUDE("header")の配列 4858 4849 Include = Hash.new {|hash, key| hash[key] = []} 4859 4850 … … 4909 4900 4910 4901 #= TECSIO 4911 # Ruby2.0(1.9) 対å¿ã«ä¼´ãå°å 4912 ¥ããã¯ã©ã¹ 4913 # SJIS 以å¤ã§ã¯ãASCII-8BIT ã¨ãã¦å 4914 ¥åãã 4902 # Ruby2.0(1.9) 対応に伴い導入したクラス 4903 # SJIS 以外では、ASCII-8BIT として入力する 4915 4904 class TECSIO 4916 def self.foreach(file) # ãããã¯å¼æ° { |line| } 4917 pr = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°ã pr ã«ä»£å 4918 ¥ 4905 def self.foreach(file) # ブロック引数 { |line| } 4906 pr = Proc.new # このメソッドのブロック引数を pr に代入 4919 4907 if $b_no_kcode then 4920 4908 msg = "E".encode $Ruby19_File_Encode 4921 4909 if( $Ruby19_File_Encode == "Shift_JIS" ) 4922 4910 4923 # Shift JIS ã¯ããã£ãã Windows-31J ã¨ãã¦èªã¿è¾¼ã¾ããShift_JIS ã«å¤æãããï¼4924 # ã³ã¡ã³ãçã«å«ã¾ãã SJIS ã«ä¸é©åãªæåã³ã¼ã㯠'?' ã¾ã㯠REPLACEMENT CHARACTER ã«å¤æãããï¼4925 # EUC ã UTF-8 ã§è¨è¿°ããã CDL ãæ··å¨ãã¦ãã¦ããRuby ä¾å¤ãçºçãããã¨ãªãå¦çãé²ãããã¨ãã§ããï¼4926 # æåã³ã¼ãæå®ã SJIS ã§ãã£ã¦ãæååãªãã©ã«ã®ä¸ã«ãæåã³ã¼ããSJIS 以å¤ã®é ASCII ãå«ã¾ãã¦ããå ´åã4927 # Ruby 1.8 ã® tecsgen ã§ã¯æåã³ã¼ãæå®ã«å½±é¿ãªãå¦çããããã®ããRuby 1.9 以éã§ã¯ '?' ã«ç½®ãæããå¯è½æ§ãããï¼4911 # Shift JIS は、いったん Windows-31J として読み込ませ、Shift_JIS に変換させる. 4912 # コメント等に含まれる SJIS に不適切な文字コードは '?' または REPLACEMENT CHARACTER に変換される. 4913 # EUC や UTF-8 で記述された CDL が混在していても、Ruby 例外が発生することなく処理を進めることができる. 4914 # 文字コード指定が SJIS であって、文字列リテラルの中に、文字コードがSJIS 以外の非 ASCII が含まれている場合、 4915 # Ruby 1.8 の tecsgen では文字コード指定に影響なく処理されたものが、Ruby 1.9 以降では '?' に置き換わる可能性がある. 4928 4916 4929 4917 mode = "r:Windows-31J" … … 4949 4937 end 4950 4938 4951 #=== æåã³ã¼ããç¸éããå ´åä¸è´ããã4952 # msg 㨠str ã®æåã³ã¼ããç¸éããå ´åãstr ã msg ã®æåã³ã¼ãã«å¤æãã4953 # å¤æä¸å¯ã®æåã³ã¼ã㯠'?' (utf-8 ã®å ´å U+FFFD (REPLACEMENT CHARACTER )) ã«å¤æ4939 #=== 文字コードが相違する場合一致させる 4940 # msg と str の文字コードが相違する場合、str を msg の文字コードに変換する 4941 # 変換不可の文字コードは '?' (utf-8 の場合 U+FFFD (REPLACEMENT CHARACTER )) に変換 4954 4942 # 4955 # ãã®ã¡ã½ããã¯ãã¨ã©ã¼ã¡ãã»ã¼ã¸åºåã§ã使ç¨ããã¦ãããã¨ã«æ³¨æï¼4943 # このメソッドは、エラーメッセージ出力でも使用されていることに注意. 4956 4944 # 4957 4945 #msg_enc::Encode | String 4958 4946 def self.str_code_convert( msg, str ) 4959 4947 if $b_no_kcode == false then 4960 return str # Ruby V1.8 ã¾ã§4948 return str # Ruby V1.8 まで 4961 4949 end 4962 4950 if msg.encoding != str.encoding then 4963 option = { :invalid => :replace, :undef => :replace } # ä¾å¤ãçºçãããã'?' ã«å¤æãã(utf-8 ã¯0xfffd)4951 option = { :invalid => :replace, :undef => :replace } # 例外を発生させず、'?' に変換する(utf-8 は 0xfffd) 4964 4952 # return str.encode( msg.encoding, option ) 4965 4953 str = str.encode( "utf-8", option ) -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/bnf.y.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 : bnf.y.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 40 class Generator 56 41 rule 57 # ãããã¬ãã«ã®æ§æè¦ç´ ã¯component_description42 # トップレベルの構文要素はcomponent_description 58 43 all: component_description 59 44 60 45 # Expr 61 ########################## å¼ ########################## 62 # K&Rã®ææ³(ããã°ã©ãã³ã°è¨èªC 第2ç ä»é²)ã¨ä¸é¨ç°ãªã 63 # argument_expression_list(é¢æ°å¼æ°), assignment_expression(代å 64 ¥)ããªã 65 # å¼ã® result ã¯ããã¹ã¦é 66 åã§ç¬¬ä¸è¦ç´ ãèå¥ã·ã³ãã«ã第äºè¦ç´ 以ä¸ãå¼æ° 46 ########################## 式 ########################## 47 # K&Rの文法(プログラミング言語C 第2版 付録)と一部異なる 48 # argument_expression_list(関数引数), assignment_expression(代入)がない 49 # 式の result は、すべて配列で第一要素が識別シンボル、第二要素以下が引数 67 50 68 51 primary_expression … … 92 75 | string_literal_list STRING_LITERAL 93 76 { 94 # é£æ¥ããæååã1ã¤ã®æååã«ã¾ã¨ãã77 # 連接した文字列を1つの文字列にまとめる 95 78 str = "\"" + val[0].val.gsub( /\"(.*)\"/, "\\1" ) + val[1].val.gsub( /\"(.*)\"/, "\\1" ) + "\"" 96 79 result = Token.new( str, val[0].file, val[0].lineno, val[0].col ) 97 80 } 98 81 99 # é¢æ°å¼ã³åºãã¨å¾ç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®åããªã82 # 関数呼び出しと後置インクリメント、デクリメント演算子がない 100 83 postfix_expression 101 84 : primary_expression … … 107 90 { result = [ :OP_REF, val[0], val[2] ] } 108 91 109 # åç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®åããªã92 # 前置インクリメント、デクリメント演算子がない 110 93 unary_expression 111 94 : postfix_expression … … 202 185 203 186 204 # ã³ã³ãæ¼ç®åã使ããªã187 # コンマ演算子が使えない 205 188 expression 206 189 : conditional_expression … … 227 210 228 211 # Types 229 ########################## 宣è¨##########################230 # 宣è¨ãK&Rã¨ä¸é¨ç°ãªã231 232 # declaration ã¯ã»ã«ã®å±æ§ã§ä½¿ããã233 # K&R ã¨ã®éã: storage classãæå®ã§ããªããåãçç¥ã§ããªã212 ########################## 宣言 ########################## 213 # 宣言もK&Rと一部異なる 214 215 # declarationはセルの属性で使われる 216 # K&Rとの違い: storage classが指定できない、型が省略できない 234 217 declaration 235 218 : type_specifier_qualifier_list init_declarator_list ';' … … 241 224 } 242 225 243 # declaration_specifiers ã¯é¢æ°ã®ãã©ã¡ã¼ã¿ã§ä½¿ããããã244 # type_specifier_qualifier_list ã§ååãããããªã226 # declaration_specifiersは関数のパラメータで使われるが、 227 # type_specifier_qualifier_listで十分かもしれない 245 228 # Oyama 246 # const, volatile ã¯åç¬ã§åã«ãªããªãã®ã§å¤å½¢ 247 # const 㨠volatile ãåå± 248 ãããã¨ã¯ãªãã®ã§ãç¹°è¿ãæå®ã§ããªãããã«ãã 249 # type_specifier ãç¹°è¿ãæå®ã§ããå¿ 250 è¦ã¯ãªã (singed ãªã©åç¬ã§åã«ã¯ãªããªã) 229 # const, volatile は単独で型にならないので変形 230 # const と volatile が同居することはないので、繰返し指定できないようにした 231 # type_specifier も繰返し指定できる必要はない (singed など単独で型にはならない) 251 232 declaration_specifiers 252 233 : type_specifier … … 268 249 { val[0].set_initializer( val[2] ) } 269 250 270 # INT8 ããä¸ã¯K&Rã«ãªã251 # INT8から下はK&Rにない 271 252 # Oyama 272 # signed, unsigned ã¯åç¬ã§åã«ãªããªãã®ã§ãæ§æè¦ç´ ã¨ãã¦åé¢253 # signed, unsigned は単独で型にならないので、構文要素として分離 273 254 type_specifier 274 255 : VOID { result = VoidType.new } … … 278 259 | enum_specifier 279 260 | TYPE_NAME { result = DefinedType.new( val[0].val ) } 280 # | IDENTIFIER { result = DefinedType.new( val[0].val ) } # reduce/reduce conflict ãèµ·ãã£ã¦ãã¾ã261 # | IDENTIFIER { result = DefinedType.new( val[0].val ) } # reduce/reduce conflict が起こってしまう 281 262 | sign_int_type 282 263 | char_type … … 373 354 } 374 355 375 sign # TECS ã§ã¯ signed, unsigned åç¬ã§ã¯åã«ã§ããªã356 sign # TECS では signed, unsigned 単独では型にできない 376 357 : SIGNED { result = :SIGNED } 377 358 | UNSIGNED { result = :UNSIGNED } 378 359 379 # result[0] :CHAR ãªã©ã®ãã¼ã¯ã³ãresult[1] :CONST, :VOLATILE ãªã©360 # result[0] :CHAR などのトークン、result[1] :CONST, :VOLATILE など 380 361 sign_int_type 381 362 : sign int_type … … 386 367 | int_type 387 368 388 # K&R ã®struct_or_union_specifierã«ç¸å½ããããunionã¯ä½¿ããªã369 # K&Rのstruct_or_union_specifierに相当するが、unionは使えない 389 370 struct_specifier # mikan 390 371 : STRUCT struct_tag '{' … … 405 386 result = val[1] 406 387 } 407 | STRUCT struct_tag # mikan struct_tag 㯠namespace 対å¿ãå¿ 408 è¦ 388 | STRUCT struct_tag # mikan struct_tag は namespace 対応が必要 409 389 { 410 390 StructType.set_define( false ) … … 421 401 { result = StructType.new( val[0].val ) } 422 402 423 # ãã¤ã³ã¿ä¿®é£¾åã追å403 # ポインタ修飾子を追加 424 404 struct_declaration 425 405 : type_specifier_qualifier_list struct_declarator_list ';' … … 456 436 457 437 458 # K&R ã®specifier_qualifier_listã¨åã459 # ååãã¾ãããããã£ãã®ã§type_ãä»ãã438 # K&Rのspecifier_qualifier_listと同じ 439 # 名前がまぎらわしかったのでtype_を付けた 460 440 type_specifier_qualifier_list 461 # Oyama type_specifier ãç¹°ãè¿ãã¦æå®ãããã¨ã¯ãªããªã£ã (sign_int_type ã¨ããããï¼441 # Oyama type_specifier を繰り返して指定することはなくなった (sign_int_type としたため) 462 442 # : type_specifier type_specifier_qualifier_list 463 443 : type_specifier … … 467 447 result = val[1] 468 448 } 469 # mikan Oyama type_qualifier ã ãã§ã¯åæå®ã«ãªããªã : æ§æã¨ã©ã¼ã¨ãããããæå³ã¨ã©ã¼ã¨ããæ¹ã親å449 # mikan Oyama type_qualifier だけでは型指定にならない : 構文エラーとするより、意味エラーとした方が親切 470 450 # | type_qualifier 471 451 … … 477 457 { result << val[2] } 478 458 479 # ããããã£ã¼ã«ãã¯ä½¿ããªã459 # ビットフィールドは使えない 480 460 struct_declarator 481 461 : declarator 482 462 483 # enum ã®ç¨®é¡ã追å463 # enumの種類を追加 484 464 enum_specifier # mikan 485 465 : enum_type '{' enumerator_list '}' … … 535 515 result = val[0] 536 516 } 537 # | direct_declarator '(' identifier_list ')' # ããã¯ä½ã®ããã«å¿ 538 è¦ï¼ 060211 517 # | direct_declarator '(' identifier_list ')' # これは何のために必要? 060211 539 518 | direct_declarator '(' ')' 540 519 { … … 569 548 : parameter_list 570 549 | parameter_list ',' '...' 571 # mikan å¯å¤é·ãã©ã¡ã¼ã¿550 # mikan 可変長パラメータ 572 551 573 552 parameter_list … … 577 556 { 578 557 val[0].add_param( val[2] ) 579 # result = val[0] ä¸è¦580 } 581 582 583 # ãã©ã¡ã¼ã¿ä¿®é£¾åã追å558 # result = val[0] 不要 559 } 560 561 562 # パラメータ修飾子を追加 584 563 parameter_declaration 585 564 # : spec_L parameter_specifier_list spec_R declaration_specifiers declarator … … 592 571 } 593 572 594 # 以ä¸ã¯ã¨ã©ã¼ã¨ãã595 | declaration_specifiers declarator # parameter_specifier ãªãã¯æ±ããªã573 # 以下はエラーとする 574 | declaration_specifiers declarator # parameter_specifier なしは扱わない 596 575 { 597 576 Generator.error( "G1001 need specifier for \'$1\'" , val[1].get_name ) 598 577 result = nil 599 578 } 600 | declaration_specifiers # ä»®å¼æ°ãªãã¯ãã¨ããããæ±ããªã060210579 | declaration_specifiers # 仮引数なしは、とりあえず扱わない 060210 601 580 { 602 581 unless val[0].instance_of?( VoidType ) then … … 605 584 result = nil 606 585 } 607 # | '[' parameter_specifier_list ']' declaration_specifiers # å060210608 | parameter_specifier_list_bracket declaration_specifiers # å060210586 # | '[' parameter_specifier_list ']' declaration_specifiers # 同 060210 587 | parameter_specifier_list_bracket declaration_specifiers # 同 060210 609 588 { 610 589 unless val[1].instance_of?( VoidType ) then … … 647 626 result = val[1] 648 627 else 649 # ã¨ã©ã¼ï¼ä»®ã§ val[0] ãè¿ã628 # エラー:仮で val[0] を返す 650 629 result = val[0] 651 630 end 652 631 } 653 # mikan abstract_declarator ã pointer 以å¤ã§ã¯ãã¾ãåããªããã¨ãããã '*' CAST ã®ã¿æã£ã632 # mikan abstract_declarator が pointer 以外ではうまく動かない、とりあえず '*' CAST のみ救った 654 633 655 634 abstract_declarator # mikan … … 660 639 direct_abstract_declarator 661 640 : '(' abstract_declarator ')' 662 { result = val[1] } # é¢æ°ãã¤ã³ã¿åãæã641 { result = val[1] } # 関数ポインタ型を救う 663 642 | '[' ']' 664 643 { … … 699 678 } 700 679 701 # assignment_expression ãconstant_expressionã«å¤æ´680 # assignment_expressionをconstant_expressionに変更 702 681 initializer # mikan 703 682 : constant_expression … … 723 702 724 703 725 ########################## ããããã¯CDLç¬èª##########################726 727 # ãããã¬ãã«ã®æ§æè¦å728 # ã³ã³ãã¼ãã³ãè¨è¿°704 ########################## ここからはCDL独自 ########################## 705 706 #トップレベルの構文規則 707 #コンポーネント記述 729 708 component_description 730 709 : component_description specified_statement … … 738 717 obj = val[3] 739 718 if obj.kind_of?( Cell ) || obj.kind_of?( Signature ) || obj.kind_of?( Celltype ) || obj.kind_of?( CompositeCelltype )then 740 # cell, signature 以å¤ã¯ãæå®åãç½®ããªã719 # cell, signature 以外は、指定子を置けない 741 720 else 742 Generator.get_statement_specifier # ã¯ãªã¢721 Generator.get_statement_specifier # クリア 743 722 Generator.error( "G1009 unexpected specifier" ) 744 723 end 745 724 } 746 # ããã¨åãè¨è¿°ã composite_celltype ã«ããã725 # これと同じ記述が composite_celltype にもある 747 726 748 727 statement … … 760 739 | import_C 761 740 | signature_plugin 762 | error # ã¨ã©ã¼å復ãã¤ã³ã741 | error # エラー回復ポイント 763 742 764 743 … … 799 778 | IDENTIFIER '[' constant_expression ']' '.' IDENTIFIER '.' IDENTIFIER '=' initializer 800 779 { result = [ :NORMAL_ALLOC, val[0], val[2], val[5], val[7], val[9] ] } 801 # mikan å°æ¥çãªæ¡å¼µ ('*' ã§ã¾ã¨ãã¦æå®å¯è½ã¨ãã)780 # mikan 将来的な拡張 ('*' でまとめて指定可能とする) 802 781 # | IDENTIFIER '.' IDENTIFIER '.' '*' '=' initializer 803 782 # { result = [ val[0], val[ ], val[ ], val[ ] ] } … … 824 803 825 804 const_statement 826 : declaration # å®æ°å®ç¾©805 : declaration # 定数定義 827 806 { 828 807 val[0].each { |decl| … … 879 858 } 880 859 } 881 # mikan typedef_specifier æªå¦ç½®860 # mikan typedef_specifier 未処置 882 861 883 862 … … 899 878 : IDENTIFIER 900 879 {result = Namespace.new(val[0].val)} 901 # namespace ã¤ã³ã¹ã¿ã³ã¹ã« statement ãè¨æ¶ãããããããã§çæ880 # namespace インスタンスに statement を記憶させるためここで生成 902 881 903 882 statement_list … … 911 890 { result = val[0].append!( val[2].val ) } 912 891 913 # ã·ã°ããã£892 #シグニチャ 914 893 signature 915 894 : SIGNATURE signature_name '{' function_head_list '}' ';' … … 920 899 {result = Signature.new( val[0].val ) } 921 900 922 function_head_list # result: function_head ã®é 923 å 901 function_head_list # result: function_head の配列 924 902 # : function_head 925 903 # { result = NamedList.new( val[0], "function" ) } … … 938 916 val[1].check 939 917 else 940 # mikan é¢æ°ã®é 941 åã以ä¸ã®ã¡ãã»ã¼ã¸ã«ãªã 918 # mikan 関数の配列も以下のメッセージになる 942 919 Generator.error( "G1010 Not function" ) 943 920 result = nil … … 955 932 956 933 957 # ã»ã«ã¿ã¤ã934 #セルタイプ 958 935 celltype 959 936 : CELLTYPE celltype_name '{' celltype_statement_list '}' ';' … … 981 958 { 982 959 if val[3].kind_of? Port then 983 val[3].set_specifier val[1] # è¨å®é åºãã960 val[3].set_specifier val[1] # 設定順序あり 984 961 Celltype.new_port( val[3] ) 985 962 else 986 # Port 以å¤ã§ã¯æå®åã¯ã¨ã©ã¼963 # Port 以外では指定子はエラー 987 964 Generator.error( "G1012 $1 : cannot put specifier here" , val[1] ) 988 965 end … … 995 972 | require 996 973 | factory 997 # | error # ã¨ã©ã¼å復ãã¤ã³ã (#513 ç¡éã«ã¼ãã«é¥ãã±ã¼ã¹ãããã®ã§ãããã§ã®ã¨ã©ã¼å復ã¯åããã)974 # | error # エラー回復ポイント (#513 無限ループに陥るケースがあるので、ここでのエラー回復は取りやめ) 998 975 999 976 celltype_statement_specifier_list … … 1012 989 1013 990 alloc_list2 1014 : alloc2 { result = [ val[0] ] } # åãå£ã®ã¢ãã±ã¼ã¿æå® 1015 | alloc { result = [ val[0] ] } # å 1016 é¨ã»ã«ã®ã¢ãã±ã¼ã¿æå® 991 : alloc2 { result = [ val[0] ] } # 受け口のアロケータ指定 992 | alloc { result = [ val[0] ] } # 内部セルのアロケータ指定 1017 993 | alloc_list2 ',' alloc2 { result << val[2] } 1018 994 | alloc_list2 ',' alloc { result << val[2] } 1019 995 1020 996 alloc2 1021 : IDENTIFIER '.' IDENTIFIER '=' initializer # å 1022 é¨ã¢ãã±ã¼ã¿ (ãããã©åãã¢ãã±ã¼ã¿)æå® 997 : IDENTIFIER '.' IDENTIFIER '=' initializer # 内部アロケータ (デバドラ向きアロケータ)指定 1023 998 { result = [ :INTERNAL_ALLOC, val[0].val, val[2].val, val[4] ] } 1024 | IDENTIFIER '.' IDENTIFIER '<=' initializer # å¤æ®µãªã¬ã¼ã¢ãã«åãã¢ãã±ã¼ã¿æå®999 | IDENTIFIER '.' IDENTIFIER '<=' initializer # 多段リレーモデル向きアロケータ指定 1025 1000 { result = [ :RELAY_ALLOC, val[0].val, val[2].val, val[4] ] } 1026 1001 1027 1002 1028 # å¼ã³å£ãåãå£1003 #呼び口、受け口 1029 1004 port 1030 1005 : port_type namespace_signature_name port_name ';' … … 1052 1027 1053 1028 1054 # å±æ§1029 #属性 1055 1030 attribute 1056 1031 : ATTRIBUTE '{' attribute_declaration_list '}' ';' … … 1076 1051 { 1077 1052 val[3].each{ |i| # i:Decl 1078 i.set_kind( :ATTRIBUTE ) # è¨å®é åºãã1053 i.set_kind( :ATTRIBUTE ) # 設定順序あり 1079 1054 i.set_specifier_list( [val[1]] ) 1080 1055 i.check … … 1095 1070 : STRING_LITERAL 1096 1071 1097 #å 1098 é¨å¤æ° 1072 #内部変数 1099 1073 var 1100 1074 : VAR '{' var_declaration_list '}' ';' … … 1118 1092 { 1119 1093 val[3].each{ |i| # i:Decl 1120 i.set_kind( :VAR ) # è¨å®é åºãã1094 i.set_kind( :VAR ) # 設定順序あり 1121 1095 i.set_specifier_list( [val[1]] ) 1122 1096 i.check … … 1128 1102 : SIZE_IS '(' expression ')' { result = [:SIZE_IS,val[2]] } 1129 1103 1130 # ãªã¯ã¯ã¤ã¢1104 # リクワイア 1131 1105 require 1132 1106 : REQUIRE namespace_identifier '.' IDENTIFIER';' # mikan namespace #1 … … 1139 1113 } 1140 1114 1141 # ãã¡ã¯ããª1115 #ファクトリ 1142 1116 factory 1143 1117 : factory_head '{' factory_function_list '}' ';' … … 1148 1122 1149 1123 factory_function_list 1150 : # 空1124 : # 空 1151 1125 | factory_function_list factory_function 1152 1126 … … 1160 1134 : IDENTIFIER 1161 1135 1162 arg_list # factory ã® write é¢æ°ã®ç¬¬ä¸å¼æ°ä»¥é1136 arg_list # factory の write 関数の第三引数以降 1163 1137 : IDENTIFIER 1164 1138 { result = [ [ :IDENTIFIER, val[0].val ] ] } … … 1170 1144 { result << [ :STRING_LITERAL, val[2].val ] } 1171 1145 1172 # ã»ã«çæ1146 #セル生成 1173 1147 cell 1174 1148 : CELL namespace_celltype_name cell_name '{' … … 1176 1150 join_list '}' ';' 1177 1151 { result = Cell.end_of_parse true } 1178 | CELL namespace_celltype_name cell_name ';' # oyama ãããã¿ã¤ã宣è¨1152 | CELL namespace_celltype_name cell_name ';' # oyama プロトタイプ宣言 1179 1153 { result = Cell.end_of_parse false } 1180 1154 … … 1188 1162 1189 1163 join_list 1190 : # 空è¡0610071164 : # 空行 061007 1191 1165 | join_list specified_join 1192 1166 | join_list reverse_join … … 1231 1205 Cell.new_join( result, true ) 1232 1206 } 1233 | cae_name '=' initializer ';' # åæååï¼ '{', '}' ãå¯1207 | cae_name '=' initializer ';' # 初期化子: '{', '}' も可 1234 1208 { 1235 1209 result = Join.new( val[0].val, nil, val[2] ) … … 1275 1249 : constant_expression 1276 1250 1277 # è¤å種1251 #複合種 1278 1252 composite_celltype 1279 1253 : COMPOSITE composite_celltype_name '{' composite_celltype_statement_list '}' ';' … … 1295 1269 { 1296 1270 if val[0].kind_of?( Port ) then 1297 CompositeCelltype.new_port( val[0] ) # é 1298 延ãã¦ç»é² 1271 CompositeCelltype.new_port( val[0] ) # 遅延して登録 1299 1272 end 1300 1273 } … … 1302 1275 { 1303 1276 if val[3].kind_of?( Port ) then 1304 # port ä»¥å¤ val[3] ã«æå¹ãªå¤ãå 1305 ¥ã£ã¦ããªãã®ã§ã以ä¸ã®ã¡ã½ãããé©ç¨ã§ããªã 1306 # ç¾ç¶ port, cell 以å¤ã¯æå®åãåãä»ããªã 1307 # ï¼ãããå°æ¥ä»ã®æãæå®åãåãä»ããå¯è½æ§ãããã®ã§ããã®ä½ç½®ã«è¨è¿°ããï¼ 1277 # port 以外 val[3] に有効な値が入っていないので、以下のメソッドを適用できない 1278 # 現状 port, cell 以外は指定子を受け付けない 1279 # (しかし将来他の文も指定子を受け付ける可能性があるので、この位置に記述する) 1308 1280 val[3].set_specifier( Generator.get_statement_specifier ) 1309 CompositeCelltype.new_port( val[3] ) # é 1310 延ãã¦ç»é² (set_specifier å¾) 1281 CompositeCelltype.new_port( val[3] ) # 遅延して登録 (set_specifier 後) 1311 1282 elsif val[3].kind_of?( Cell ) then 1312 # Cell.end_of_parse ã«ã¦è¨å®1283 # Cell.end_of_parse にて設定 1313 1284 else 1314 Generator.get_statement_specifier # ã¯ãªã¢1285 Generator.get_statement_specifier # クリア 1315 1286 Generator.error( "G1013 unexpected specifier" ) 1316 1287 end … … 1322 1293 | internal_cell 1323 1294 | export_join 1324 # | error # ã¨ã©ã¼å復ãã¤ã³ã (#513 ç¡éã«ã¼ãã«é¥ãã±ã¼ã¹ãããã®ã§ãããã§ã®ã¨ã©ã¼å復ã¯åããã)1295 # | error # エラー回復ポイント (#513 無限ループに陥るケースがあるので、ここでのエラー回復は取りやめ) 1325 1296 1326 1297 composite_celltype_statement_specifier_list … … 1345 1316 } 1346 1317 1347 # å±æ§1318 #属性 1348 1319 composite_attribute 1349 1320 : ATTRIBUTE '{' composite_attribute_declaration_list '}' ';' … … 1376 1347 1377 1348 internal_join_list 1378 : # 空è¡0610071349 : # 空行 061007 1379 1350 | internal_join_list specified_join 1380 1351 | internal_join_list external_join 1381 1352 1382 external_join # cell å 1383 ã«è¨è¿°ããå¼ã³å£ã®å¤é¨çµå 1353 external_join # cell 内に記述する呼び口の外部結合 1384 1354 : internal_cell_elem_name '=>' COMPOSITE '.' export_name ';' 1385 1355 { Cell.external_join( val[0].val, val[4].val, true ) } 1386 1356 | internal_cell_elem_name '=>' export_name ';' 1387 1357 { Cell.external_join( val[0].val, val[2].val, false ) } 1388 # 以åã®ææ³ã§ã¯ãå¼ã³å£å´ã cell ã®å¤ã«è¨è¿°ãã¦ãã 1389 # ãã®æã®å®è£ 1390 ã 1391 1392 export_join # cell å¤ã«è¨è¿°ããåãå£ã®å¤é¨çµå 1358 # 以前の文法では、呼び口側も cell の外に記述していた 1359 # その時の実装を 1360 1361 export_join # cell 外に記述する受け口の外部結合 1393 1362 : export_name '=>' internal_ref_cell_name '.' internal_cell_elem_name ';' 1394 1363 { … … 1411 1380 : IDENTIFIER 1412 1381 1413 # ãªã¼ã¸ã§ã³1382 # リージョン 1414 1383 region 1415 1384 : spec_L region_specifier_list spec_R REGION region_name '{' region_statement '}' ';' … … 1426 1395 : IN_THROUGH '(' plugin_name ',' plugin_arg ')' 1427 1396 { Region.new_in_through( val[2].val, val[4].val ) } 1428 | IN_THROUGH '(' ')' # in 許å¯1397 | IN_THROUGH '(' ')' # in 許可 1429 1398 { Region.new_in_through } 1430 1399 | OUT_THROUGH '(' plugin_name ',' plugin_arg ')' 1431 1400 { Region.new_out_through( val[2].val, val[4].val ) } 1432 | OUT_THROUGH '(' ')' # out 許å¯1401 | OUT_THROUGH '(' ')' # out 許可 1433 1402 { Region.new_out_through() } 1434 1403 | TO_THROUGH '(' namespace_region_name ',' plugin_name ',' plugin_arg ')' 1435 1404 { Region.new_to_through( val[2], val[4].val, val[6].val ) } 1436 | TO_THROUGH '('namespace_region_name ')' # to 許å¯1405 | TO_THROUGH '('namespace_region_name ')' # to 許可 1437 1406 { Region.new_to_through( val[2], nil, nil ) } 1438 1407 | NODE … … 1461 1430 if obj.kind_of?( Cell ) then 1462 1431 else 1463 Generator.get_statement_specifier # ã¯ãªã¢1432 Generator.get_statement_specifier # クリア 1464 1433 Generator.error( "G9999 unexpected specifier" ) 1465 1434 end … … 1480 1449 namespace_region_name 1481 1450 : :IDENTIFIER 1482 { result = [ val[0].val ] } # mikan é 1483 åã§ããå¿ 1484 è¦ã¯ãªã 1451 { result = [ val[0].val ] } # mikan 配列である必要はない 1485 1452 # : namespace_identifier 1486 1453 1487 # æå®åã®æ¬å¼§ (in, out ãªã©ã®ãã¼ã¯ã¼ãåãæ¿ãã®ããåé¢)1454 # 指定子の括弧 (in, out などのキーワード切り替えのため分離) 1488 1455 spec_L 1489 1456 : '[' { set_in_specifier } … … 1620 1587 } 1621 1588 1622 # æå®å '[]' å 1623 ã§ã®ã¿ä½¿ç¨ã§ãããã¼ã¯ã¼ã 1589 # 指定子 '[]' 内でのみ使用できるキーワード 1624 1590 RESERVED2 = { 1625 1591 # specifier … … 1638 1604 # port (entry) 1639 1605 'inline' => :INLINE, 1640 'ref_desc' => :REF_DESC, # call ãå¯1606 'ref_desc' => :REF_DESC, # call も可 1641 1607 1642 1608 # port (call) … … 1682 1648 } 1683 1649 1684 # å帰çãªãã¼ãµã®ããã®ã¹ã¿ãã¯1650 # 再帰的なパーサのためのスタック 1685 1651 @@generator_nest = -1 1686 1652 @@generator_stack = [] 1687 1653 @@current_locale = [] 1688 1654 1689 # import_C ä¸ã§ãã1655 # import_C 中である 1690 1656 @@import_C = false 1691 1657 1692 # ãã¹ã¦ã®æ§æ解æãå®äºãã1658 # すべての構文解析が完了した 1693 1659 @@b_end_all_parse = false 1694 1660 1695 1661 def self.parse( file_name, plugin = nil, b_reuse = false ) 1696 # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èªã¿è¾¼ã)1662 # パーサインスタンスを生成(別パーサで読み込む) 1697 1663 parser = Generator.new 1698 1664 1699 # plugin ãã import ããã¦ããå ´åã® plugin è¨å®1665 # plugin から import されている場合の plugin 設定 1700 1666 parser.set_plugin plugin 1701 1667 1702 # reuse ãã©ã°ãè¨å®1668 # reuse フラグを設定 1703 1669 parser.set_reuse b_reuse 1704 1670 1705 # cdl ããã¼ã¹1671 # cdl をパース 1706 1672 parser.parse( [file_name] ) 1707 1673 1708 # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã1674 # 終期化 パーサスタックを戻す 1709 1675 parser.finalize 1710 1676 end … … 1726 1692 def self.get_plugin 1727 1693 if @@generator_stack[@@generator_nest] then 1728 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil1694 # tecsgen 引数の cdl が import される場合は nil 1729 1695 return @@generator_stack[@@generator_nest].get_plugin 1730 1696 else … … 1743 1709 def self.is_reuse? 1744 1710 if @@generator_stack[@@generator_nest] then 1745 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil1711 # tecsgen 引数の cdl が import される場合は nil 1746 1712 return @@generator_stack[@@generator_nest].is_reuse? 1747 1713 else … … 1773 1739 b_in_string = false 1774 1740 1775 # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµããã誤ãåé¡ã®å¯¾ç1741 # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策 1776 1742 TECS_LANG::set_kcode_binary 1777 1743 … … 1783 1749 TECSIO.foreach(file) {|line| 1784 1750 col = 1 1785 # line.rstrip! æ¹è¡å«ãæååãæ±ãããã«ãªã£ãã®ã§ãããã§ç©ºç½ãåãé¤ããªããªã£ã1751 # line.rstrip! 改行含む文字列を扱うようになったので、ここで空白を取り除けなくなった 1786 1752 1787 1753 until line.empty? … … 1789 1755 if b_in_comment 1790 1756 case line 1791 # ã³ã¡ã³ãçµäº1757 # コメント終了 1792 1758 when /\A\*\// 1793 1759 b_in_comment = false 1794 1760 when /\A./ 1795 1761 ; 1796 when /\s+/ # line.rstrip! ãæ¢ãããã \n ãªã©ã®ç©ºç½æåã¨ã¾ã£ã¡ããã«ã¼ã«ãå¿ 1797 è¦ã«ãªã£ã 1762 when /\s+/ # line.rstrip! を止めたため \n などの空白文字とまっちするルールが必要になった 1798 1763 ; 1799 1764 end … … 1803 1768 @q << [:STRING_LITERAL, Token.new(string, file, lineno, col)] 1804 1769 b_in_string = false 1805 elsif line =~ /\A.*\\\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã1770 elsif line =~ /\A.*\\\n/ # 改行 \n は '.' にマッチしない 1806 1771 string += $& 1807 elsif line =~ /\A.*\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã1772 elsif line =~ /\A.*\n/ # 改行 \n は '.' にマッチしない 1808 1773 string += line 1809 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå)1774 # この位置では error メソッドは使えない (token 読出し前) 1810 1775 puts "error: #{file} line #{lineno}: string literal has newline without escape" 1811 1776 @@n_error += 1 … … 1813 1778 else 1814 1779 case line 1815 # 空ç½ãããªããã»ã¹ãã£ã¬ã¯ãã£ã1780 # 空白、プリプロセスディレクティブ 1816 1781 when /\A\s+/ 1817 1782 ; 1818 # èå¥å1783 # 識別子 1819 1784 when /\A[a-zA-Z_]\w*/ 1820 1785 word = $& 1821 1786 @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)] 1822 # 16 é²æ°å®æ°1787 # 16 進数定数 1823 1788 when /\A0x[0-9A-Fa-f]+/ 1824 1789 @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)] 1825 # 8 é²æ°å®æ°1790 # 8 進数定数 1826 1791 when /\A0[0-7]+/ 1827 1792 @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)] 1828 # æµ®åå°æ°å®æ°1793 # 浮動小数定数 1829 1794 when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/ 1830 1795 @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)] 1831 # æ´æ°å®æ°1796 # 整数定数 1832 1797 when /\A\d+/ 1833 1798 @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)] 1834 # æåå®æ°1799 # 文字定数 1835 1800 when /\A'(?:[^'\\]|\\.)'/ 1836 1801 @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)] 1837 # æåå1838 # "#include #include #include \"../systask/logtask.cfg\" æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã1802 # 文字列 1803 # "#include #include #include \"../systask/logtask.cfg\" 最後の " 忘れ)で無限ループ 1839 1804 # when /\A"(?:[^"\\]+|\\.)*"/ 1840 when /\A"(?:[^"\\]|\\.)*"/ # ããã¯ãã¾ãè¡ãããã1805 when /\A"(?:[^"\\]|\\.)*"/ # これはうまく行くようだ 1841 1806 @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)] 1842 # æåå (æ¹è¡ãã)1807 # 文字列 (改行あり) 1843 1808 when /\A"(?:[^"\\]|\\.)*\\\n$/ 1844 1809 string = $& 1845 1810 b_in_string = true 1846 # æåå (æ¹è¡ãã, escape ãªã)1811 # 文字列 (改行あり, escape なし) 1847 1812 when /\A("(?:[^"\\]|\e\.)*)\n$/ 1848 1813 string = $1 + "\\\n" 1849 1814 b_in_string = true 1850 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå) # mikan cdl_error ã§ã¯ãªã1815 # この位置では error メソッドは使えない (token 読出し前) # mikan cdl_error ではない 1851 1816 puts "error: #{file} line #{lineno}: string literal has newline without escape" 1852 1817 @@n_error += 1 1853 # å±±æ¬å¼§ã§å²ã¾ããæåå1818 # 山括弧で囲まれた文字列 1854 1819 when /\A<[0-9A-Za-z_\. \/]+>/ # AB: angle bracke 1855 1820 @q << [:AB_STRING_LITERAL, Token.new($&, file, lineno, col)] 1856 # è¡ã³ã¡ã³ã1821 # 行コメント 1857 1822 when /\A\/\/.*$/ 1858 # èªã¿é£ã°ãã ã1859 # ã³ã¡ã³ãéå§1823 # 読み飛ばすだけ 1824 # コメント開始 1860 1825 when /\A\/\*/ 1861 1826 b_in_comment = true 1862 # '>>', '<<' ãªã©1827 # '>>', '<<' など 1863 1828 when /\A>>/, /\A<</, /\A==/, /\A!=/, /\A\&\&/, /\A\|\|/ 1864 1829 @q << [$&, Token.new($&, file, lineno, col)] 1865 1830 when /\A::/, /\A=>/, /\A<=/, /\A>=/ 1866 1831 @q << [$&, Token.new($&, file, lineno, col)] 1867 # '(', ')' ãªã©ä¸æåã®è¨å·ãã¾ãã¯æªç¥ã®è¨å·1832 # '(', ')' など一文字の記号、または未知の記号 1868 1833 when /\A./ 1869 1834 @q << [$&, Token.new($&, file, lineno, col)] … … 1889 1854 } 1890 1855 1891 # çµäºã®å°1856 # 終了の印 1892 1857 @q << nil 1893 1858 … … 1909 1874 1910 1875 if token[0] == :IDENTIFIER then 1911 # TYPE_NAME ãã¼ã¯ã³ã¸ç½®æã1876 # TYPE_NAME トークンへ置換え 1912 1877 if Namespace.is_typename?( token[1].val ) then 1913 1878 token[0] = :TYPE_NAME 1914 1879 elsif @in_specifier && RESERVED2[ token[1].val.to_s ] then 1915 # æå®åãã¼ã¯ã¼ãï¼ '[', ']' å 1916 ã§ã®ã¿æå¹) 1880 # 指定子キーワード( '[', ']' 内でのみ有効) 1917 1881 token[0] = RESERVED2[ token[1].val.to_s ] 1918 1882 end 1919 1883 end 1920 1884 1921 if $debug then # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç)1885 if $debug then # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生) 1922 1886 locale = @@current_locale[@@generator_nest] 1923 1887 if token then … … 1950 1914 @@n_warning = 0 1951 1915 1952 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼1916 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切) 1953 1917 def self.error( msg, *arg ) 1954 1918 locale = nil … … 1960 1924 1961 1925 msg = TECSMsg.get_error_message( msg ) 1962 # $1, $2, ... ã arg ã§ç½®æ1926 # $1, $2, ... を arg で置換 1963 1927 count = 1 1964 1928 arg.each{ |a| … … 1968 1932 } 1969 1933 1970 # import_C ã®ä¸ã§ã®ã¨ã©ã¼ï¼1934 # import_C の中でのエラー? 1971 1935 if @@import_C then 1972 1936 C_parser.error( msg ) 1973 1937 else 1974 1938 1975 # Node ã®è¨æ¶ãã ä½ç½® (locale) ã使ç¨ããå ´åãå¤æ´ä»¥åã«æ¯ã¹ã1976 # åé¡çºçç®æã¨ç°ãªãä½ç½®ã«ã¨ã©ã¼ãåºããããæ§æ解æä¸ã®ã¨ã©ã¼1977 # ã¯ã解æä¸ã®ä½ç½®ãåºåããï¼(new_XXX 㧠owner ãåè¦ç´ ã®ãã§ã1978 # ã¯ããã㨠owner ã®è¡çªå·ãåºã¦ãã¾ãç¹ã§ããããçãã¦ãã)1939 # Node の記憶する 位置 (locale) を使用した場合、変更以前に比べ、 1940 # 問題発生箇所と異なる位置にエラーが出るため、構文解析中のエラー 1941 # は、解析中の位置を出力する.(new_XXX で owner が子要素のチェッ 1942 # クをすると owner の行番号が出てしまう点で、ずれが生じている) 1979 1943 1980 1944 if @@b_end_all_parse == false || locale == nil then … … 1989 1953 end 1990 1954 1991 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼1955 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切) 1992 1956 def self.warning( msg, *arg ) 1993 1957 locale = nil … … 1999 1963 2000 1964 msg = TECSMsg.get_warning_message( msg ) 2001 # $1, $2, ... ã arg ã§ç½®æ1965 # $1, $2, ... を arg で置換 2002 1966 count = 1 2003 1967 arg.each{ |a| … … 2007 1971 } 2008 1972 2009 # import_C ã®ä¸ã§ã®ã¦ã©ã¼ãã³ã°ï¼1973 # import_C の中でのウォーニング? 2010 1974 if @@import_C then 2011 1975 C_parser.warning( msg ) … … 2034 1998 end 2035 1999 2036 #=== '[' specifier å§ã2000 #=== '[' specifier 始め 2037 2001 def set_in_specifier 2038 2002 # p "set_in_specifier" … … 2040 2004 end 2041 2005 2042 #=== ']' specifier çµãã2006 #=== ']' specifier 終わり 2043 2007 def unset_in_specifier 2044 2008 # p "unset_in_specifier" … … 2046 2010 end 2047 2011 2048 # statement_specifier ã¯æ§æ解ééä¸ã§åç 2049 §ããããã 2012 # statement_specifier は構文解釈途中で参照したいため 2050 2013 @@statement_specifier_stack = [] 2051 2014 def self.add_statement_specifier( ss ) … … 2064 2027 end 2065 2028 2066 #=== ãã¹ã¦ã®æ§æ解æãå®äºãããã¨ãå ±å2029 #=== すべての構文解析が完了したことを報告 2067 2030 def self.end_all_parse 2068 2031 @@b_end_all_parse = true … … 2072 2035 2073 2036 2074 # ãã¡ã¤ã« => INCLUDE("header")ã®é 2075 å 2037 # ファイル => INCLUDE("header")の配列 2076 2038 Include = Hash.new {|hash, key| hash[key] = []} 2077 2039 … … 2127 2089 2128 2090 #= TECSIO 2129 # Ruby2.0(1.9) 対å¿ã«ä¼´ãå°å 2130 ¥ããã¯ã©ã¹ 2131 # SJIS 以å¤ã§ã¯ãASCII-8BIT ã¨ãã¦å 2132 ¥åãã 2091 # Ruby2.0(1.9) 対応に伴い導入したクラス 2092 # SJIS 以外では、ASCII-8BIT として入力する 2133 2093 class TECSIO 2134 def self.foreach(file) # ãããã¯å¼æ° { |line| } 2135 pr = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°ã pr ã«ä»£å 2136 ¥ 2094 def self.foreach(file) # ブロック引数 { |line| } 2095 pr = Proc.new # このメソッドのブロック引数を pr に代入 2137 2096 if $b_no_kcode then 2138 2097 msg = "E".encode $Ruby19_File_Encode 2139 2098 if( $Ruby19_File_Encode == "Shift_JIS" ) 2140 2099 2141 # Shift JIS ã¯ããã£ãã Windows-31J ã¨ãã¦èªã¿è¾¼ã¾ããShift_JIS ã«å¤æãããï¼2142 # ã³ã¡ã³ãçã«å«ã¾ãã SJIS ã«ä¸é©åãªæåã³ã¼ã㯠'?' ã¾ã㯠REPLACEMENT CHARACTER ã«å¤æãããï¼2143 # EUC ã UTF-8 ã§è¨è¿°ããã CDL ãæ··å¨ãã¦ãã¦ããRuby ä¾å¤ãçºçãããã¨ãªãå¦çãé²ãããã¨ãã§ããï¼2144 # æåã³ã¼ãæå®ã SJIS ã§ãã£ã¦ãæååãªãã©ã«ã®ä¸ã«ãæåã³ã¼ããSJIS 以å¤ã®é ASCII ãå«ã¾ãã¦ããå ´åã2145 # Ruby 1.8 ã® tecsgen ã§ã¯æåã³ã¼ãæå®ã«å½±é¿ãªãå¦çããããã®ããRuby 1.9 以éã§ã¯ '?' ã«ç½®ãæããå¯è½æ§ãããï¼2100 # Shift JIS は、いったん Windows-31J として読み込ませ、Shift_JIS に変換させる. 2101 # コメント等に含まれる SJIS に不適切な文字コードは '?' または REPLACEMENT CHARACTER に変換される. 2102 # EUC や UTF-8 で記述された CDL が混在していても、Ruby 例外が発生することなく処理を進めることができる. 2103 # 文字コード指定が SJIS であって、文字列リテラルの中に、文字コードがSJIS 以外の非 ASCII が含まれている場合、 2104 # Ruby 1.8 の tecsgen では文字コード指定に影響なく処理されたものが、Ruby 1.9 以降では '?' に置き換わる可能性がある. 2146 2105 2147 2106 mode = "r:Windows-31J" … … 2167 2126 end 2168 2127 2169 #=== æåã³ã¼ããç¸éããå ´åä¸è´ããã2170 # msg 㨠str ã®æåã³ã¼ããç¸éããå ´åãstr ã msg ã®æåã³ã¼ãã«å¤æãã2171 # å¤æä¸å¯ã®æåã³ã¼ã㯠'?' (utf-8 ã®å ´å U+FFFD (REPLACEMENT CHARACTER )) ã«å¤æ2128 #=== 文字コードが相違する場合一致させる 2129 # msg と str の文字コードが相違する場合、str を msg の文字コードに変換する 2130 # 変換不可の文字コードは '?' (utf-8 の場合 U+FFFD (REPLACEMENT CHARACTER )) に変換 2172 2131 # 2173 # ãã®ã¡ã½ããã¯ãã¨ã©ã¼ã¡ãã»ã¼ã¸åºåã§ã使ç¨ããã¦ãããã¨ã«æ³¨æï¼2132 # このメソッドは、エラーメッセージ出力でも使用されていることに注意. 2174 2133 # 2175 2134 #msg_enc::Encode | String 2176 2135 def self.str_code_convert( msg, str ) 2177 2136 if $b_no_kcode == false then 2178 return str # Ruby V1.8 ã¾ã§2137 return str # Ruby V1.8 まで 2179 2138 end 2180 2139 if msg.encoding != str.encoding then 2181 option = { :invalid => :replace, :undef => :replace } # ä¾å¤ãçºçãããã'?' ã«å¤æãã(utf-8 ã¯0xfffd)2140 option = { :invalid => :replace, :undef => :replace } # 例外を発生させず、'?' に変換する(utf-8 は 0xfffd) 2182 2141 # return str.encode( msg.encoding, option ) 2183 2142 str = str.encode( "utf-8", option ) -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/componentobj.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 : componentobj.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 40 # STAGE: 56 # ãã®ã¡ã³ããã³ã¹ç¶æ³ã¯ãããããªã 57 # B bnf.y.rb ããå¼åºããã 58 # P parse 段éã§å¼åºãããï¼bnf.y.rb ããç´æ¥å¼åºãããããã§ã¯ãªãããæ§ææ¨çæãè¡ãï¼ 59 # S P ã®ä¸ããå¼åºãããããæ§ææ¨çæããããã§ã¯ãªãæå³ãã§ãã¯ãã 60 # G ã³ã¼ãçæï¼ãã®æ®µéã§ãæ§ææ¨ã¯å®å 61 ¨ã§ããï¼ä¸å®å 62 ¨ãªãã¨ã©ã¼ã§æã¡ãããã¦ããï¼ 63 # factory ã®ç¬¬ä¸å¼æ° "format" ã®å¾ãã®å¼æ° 64 65 # mikan 以ä¸ã¯ ruby ã® mix in ã§å®ç¾ã§ãããããããªã 66 # Nestable ãç¶æ¿ããå ´åãã¯ã©ã¹å¤æ°ã¯ Nestable ã®ãã®ãå 67 ±æãããï¼å¥ã«ãããã£ãï¼ 41 # このメンテナンス状況はよろしくない 42 # B bnf.y.rb から呼出される 43 # P parse 段階で呼出される(bnf.y.rb から直接呼出されるわけではないが、構文木生成を行う) 44 # S P の中から呼出されるが、構文木生成するわけではなく意味チェックする 45 # G コード生成(この段階で、構文木は完全である.不完全ならエラーで打ちきられている) 46 # factory の第一引数 "format" の後ろの引数 47 48 # mikan 以下は ruby の mix in で実現できるかもしれない 49 # Nestable を継承した場合、クラス変数は Nestable のものが共有される(別にしたかった) 68 50 # class Nestable 69 51 # @@nest_stack_index = -1 … … 90 72 # @name:: Symbol 91 73 # @global_name:: Symbol 92 # @function_head_list:: NamedList : FuncHead ã®ã¤ã³ã¹ã¿ã³ã¹ãè¦ç´ 93 # @func_name_to_id:: {String} : é¢æ°åãæ·»åã¨ããé 94 å㧠id ãè¨æ¶ããï¼id 㯠signature ã®åºç¾é çª (1ããå§ã¾ã) 95 # @context:: string : ã³ã³ããã¹ãå 96 # @b_callback:: bool: callback : ã³ã¼ã«ããã¯ç¨ã®ã·ã°ãã㣠97 # @b_deviate:: bool: deviate : é¸è±ï¼pointer level mismatch ãåºããªãï¼ 98 # @b_checked_as_allocator_signature:: bool: ã¢ãã±ã¼ã¿ã·ã°ããã£ã¨ãã¦ãã§ãã¯æ¸ã¿ 99 # @b_empty:: Bool: 空(é¢æ°ãä¸ã¤ããªãç¶æ 100 ) 74 # @function_head_list:: NamedList : FuncHead のインスタンスが要素 75 # @func_name_to_id:: {String} : 関数名を添字とする配列で id を記憶する.id は signature の出現順番 (1から始まる) 76 # @context:: string : コンテキスト名 77 # @b_callback:: bool: callback : コールバック用のシグニチャ 78 # @b_deviate:: bool: deviate : 逸脱(pointer level mismatch を出さない) 79 # @b_checked_as_allocator_signature:: bool: アロケータシグニチャとしてチェック済み 80 # @b_empty:: Bool: 空(関数が一つもない状態) 101 81 102 82 @@nest_stack_index = -1 … … 119 99 120 100 # STAGE: P 121 # ãã®ã¡ã½ãã㯠parse ä¸ã®ã¿å¼ã³åºããã101 # このメソッドは parse 中のみ呼び出される 122 102 def self.get_current 123 103 @@current_object … … 130 110 @name = name 131 111 Namespace.new_signature( self ) 132 set_namespace_path # @NamespacePath ã®è¨å®112 set_namespace_path # @NamespacePath の設定 133 113 if "#{Namespace.get_global_name}" == "" then 134 114 @global_name = @name … … 152 132 @function_head_list = function_head_list 153 133 154 # id ãå²ä»ãã134 # id を割付ける 155 135 id = 1 156 136 function_head_list.get_items.each{ |f| … … 166 146 end 167 147 168 #=== Signature# signature ã®æå®åãè¨å®148 #=== Signature# signature の指定子を設定 169 149 # STAGE: B 170 150 #spec_list:: [ [ :CONTEXT, String ], ... ] 171 151 # s[0] s[1] 172 152 def set_specifier_list( spec_list ) 173 return if spec_list == nil # 空ãªãã°ä½ãããªã153 return if spec_list == nil # 空ならば何もしない 174 154 175 155 spec_list.each { |s| … … 216 196 end 217 197 218 #=== Signature# é¢æ°åãã signature å 219 ã® id ãå¾ã 198 #=== Signature# 関数名から signature 内の id を得る 220 199 def get_id_from_func_name func_name 221 200 @func_name_to_id[ func_name ] 222 201 end 223 202 224 #=== Signature# context ãå¾ã225 # context æååãè¿ã"task", "non-task", "any"226 # æªæå®æã®ããã©ã«ãã¨ã㦠task ãè¿ã203 #=== Signature# context を得る 204 # context 文字列を返す "task", "non-task", "any" 205 # 未指定時のデフォルトとして task を返す 227 206 def get_context 228 207 if @context then … … 233 212 end 234 213 235 #=== Signature# signaure ã®ãã¹ã¦ã®é¢æ°ã®ãã¹ã¦ã®ãã©ã¡ã¼ã¿ããã©ã 236 #block:: ãããã¯ãå¼æ°ã«åã 237 # ãããã¯ã¯2ã¤ã®å¼æ°ãåãåã Decl, ParamDecl ( Decl: é¢æ°ããã ) 238 # Port ã¯ã©ã¹ã«ã each_param ãããï¼åãåãï¼ 239 def each_param # ãããã¯å¼æ° { |func_decl, param_decl| } 240 fha = get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 241 å 242 return if fha == nil # nil ãªãææ³ã¨ã©ã¼ã§æå¹å¤ãè¨å®ãããªãã£ã 243 244 pr = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°ã pr ã«ä»£å 245 ¥ 246 fha.each{ |fh| # fh: FuncHead # é¢æ°é 247 åä¸ã®åé¢æ°é é¨ 248 fd = fh.get_declarator # fd: Decl (é¢æ°é é¨ããDeclarotorãå¾ã) 249 if fd.is_function? then # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼ 250 fd.get_type.get_paramlist.get_items.each{ |par| # ãã¹ã¦ã®ãã©ã¡ã¼ã¿ã«ã¤ã㦠214 #=== Signature# signaure のすべての関数のすべてのパラメータをたどる 215 #block:: ブロックを引数に取る 216 # ブロックは2つの引数を受け取る Decl, ParamDecl ( Decl: 関数ヘッダ ) 217 # Port クラスにも each_param がある(同じ働き) 218 def each_param # ブロック引数 { |func_decl, param_decl| } 219 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 220 return if fha == nil # nil なら文法エラーで有効値が設定されなかった 221 222 pr = Proc.new # このメソッドのブロック引数を pr に代入 223 fha.each{ |fh| # fh: FuncHead # 関数配列中の各関数頭部 224 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 225 if fd.is_function? then # fd が関数でなければ、すでにエラー 226 fd.get_type.get_paramlist.get_items.each{ |par| # すべてのパラメータについて 251 227 pr.call( fd, par ) 252 228 } … … 255 231 end 256 232 257 #=== Signature# æ£å½ãªã¢ãã±ã¼ã¿ ã·ã°ããã£ããã¹ããã258 # alloc, dealloc é¢æ°ãæã¤ãã©ããã第ä¸å¼ãæ°ããããããæ´æ°ããã¤ã³ã¿ã第äºå¼ãæ°ãããã¤ã³ã¿ã¸ã®ãã¤ã³ã¿ããªã233 #=== Signature# 正当なアロケータ シグニチャかテストする 234 # alloc, dealloc 関数を持つかどうか、第一引き数がそれぞれ、整数、ポインタ、第二引き数が、ポインタへのポインタ、なし 259 235 def is_allocator? 260 236 261 # ä¸åã ããã§ãã¯ãã237 # 一回だけチェックする 262 238 if @b_checked_as_allocator_signature == true then 263 239 return true … … 265 241 @b_checked_as_allocator_signature = true 266 242 267 fha = get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 268 å 269 if fha == nil then # nil ãªãææ³ã¨ã©ã¼ã§æå¹å¤ãè¨å®ãããªãã£ã 243 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 244 if fha == nil then # nil なら文法エラーで有効値が設定されなかった 270 245 return false 271 246 end 272 247 273 248 found_alloc = false; found_dealloc = false 274 fha.each{ |fh| # fh: FuncHead # é¢æ°é 275 åä¸ã®åé¢æ°é é¨ 276 fd = fh.get_declarator # fd: Decl (é¢æ°é é¨ããDeclarotorãå¾ã) 277 if fd.is_function? then # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼ 249 fha.each{ |fh| # fh: FuncHead # 関数配列中の各関数頭部 250 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 251 if fd.is_function? then # fd が関数でなければ、すでにエラー 278 252 func_name = fd.get_name.to_sym 279 253 if func_name == :alloc then … … 284 258 ! params[0].get_type.get_original_type.kind_of?( IntType ) || 285 259 params[0].get_direction != :IN then 286 # 第ä¸å¼æ°ã int åã§ãªã260 # 第一引数が int 型でない 287 261 if ! params[0].instance_of?( ParamDecl ) || 288 262 ! params[0].get_type.kind_of?( PtrType ) || … … 290 264 params[0].get_type.get_type.get_type.kind_of?( PtrType ) || 291 265 params[0].get_direction != :OUT then 292 # 第ä¸å¼æ°ããã¤ã³ã¿åã§ããªã266 # 第一引数がポインタ型でもない 293 267 cdl_error3( @locale, "S1003 $1: \'alloc\' 1st parameter neither [in] integer type nor [out] double pointer type", @name ) 294 268 end … … 298 272 params[1].get_type.get_type.get_type.kind_of?( PtrType ) || 299 273 params[0].get_direction != :IN then 300 # ( 第ä¸å¼æ°ãæ´æ°ã§) 第äºå¼æ°ããã¤ã³ã¿ã§ãªã274 # (第一引数が整数で) 第二引数がポインタでない 301 275 cdl_error3( @locale, "S1004 $1: \'alloc\' 2nd parameter not [in] double pointer" , @name ) 302 276 end … … 313 287 params[0].get_direction != :IN then 314 288 cdl_error3( @locale, "S1006 $1: \'dealloc\' 1st parameter not [in] pointer type" , @name ) 315 # elsif params[1] != nil then # 第äºå¼ãæ°ã¯ãã§ãã¯ããªã289 # elsif params[1] != nil then # 第二引き数はチェックしない 316 290 # cdl_error3( @locale, "S1007 Error message is changed to empty" ) 317 291 # cdl_error3( @locale, "S1007 $1: \'dealloc\' cannot has 2nd parameter" , @name ) … … 335 309 end 336 310 337 #== Signature# å¼æ°ã§åç 338 §ããã¦ãã Descriptor åã®ãªã¹ããä½æãã 339 #RETURN:: Hash { Signature => ParamDecl }: è¤æ°ã® ParamDecl ããåç 340 §ããã¦ããå ´åãæå¾ã®ãã®ããè¿ããªã 311 #== Signature# 引数で参照されている Descriptor 型のリストを作成する 312 #RETURN:: Hash { Signature => ParamDecl }: 複数の ParamDecl から参照されている場合、最後のものしか返さない 341 313 def get_descriptor_list 342 314 desc_list = { } 343 315 # p "has_desc #{@name}" 344 fha = get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 345 å 346 if fha == nil then # nil ã®å ´åãèªå·±åç 347 §ã«ããã±ã¼ã¹ã¨ä»®å® 316 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 317 if fha == nil then # nil の場合、自己参照によるケースと仮定 348 318 return desc_list 349 319 end 350 320 fha.each{ |fh| 351 fd = fh.get_declarator # fd: Decl ( é¢æ°é é¨ããDeclarotorãå¾ã)352 if fd.is_function? then # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼321 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 322 if fd.is_function? then # fd が関数でなければ、すでにエラー 353 323 params = fd.get_type.get_paramlist.get_items 354 324 if params then … … 369 339 end 370 340 371 #=== Signature# å¼æ°ã« Descriptor ããããï¼341 #=== Signature# 引数に Descriptor があるか? 372 342 def has_descriptor? 373 343 # p "has_desc #{@name}" 374 fha = get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 375 å 376 if fha == nil then # nil ã®å ´åãèªå·±åç 377 §ã«ããã±ã¼ã¹ã¨ä»®å® 344 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 345 if fha == nil then # nil の場合、自己参照によるケースと仮定 378 346 return true 379 347 end 380 348 fha.each{ |fh| 381 fd = fh.get_declarator # fd: Decl ( é¢æ°é é¨ããDeclarotorãå¾ã)382 if fd.is_function? then # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼349 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 350 if fd.is_function? then # fd が関数でなければ、すでにエラー 383 351 params = fd.get_type.get_paramlist.get_items 384 352 if params then … … 399 367 end 400 368 401 #=== Signature# ã³ã¼ã«ããã¯ãï¼402 # æå®å callback ãæå®ããã¦ããã°true369 #=== Signature# コールバックか? 370 # 指定子 callback が指定されていれば true 403 371 def is_callback? 404 372 @b_callback 405 373 end 406 374 407 #=== Signature# é¸è±ãï¼408 # æå®å deviate ãæå®ããã¦ããã°true375 #=== Signature# 逸脱か? 376 # 指定子 deviate が指定されていれば true 409 377 def is_deviate? 410 378 @b_deviate 411 379 end 412 380 413 #=== Signature# 空ãï¼381 #=== Signature# 空か? 414 382 def is_empty? 415 383 @b_empty 416 384 end 417 385 418 #=== Signature# Push Pop Allocator ãå¿ 419 è¦ãï¼ 420 # Transparent RPC ã®å ´å oneway ã㤠in ã®é 421 å(size_is, count_is, string ã®ããããã§ä¿®é£¾ï¼ããã 386 #=== Signature# Push Pop Allocator が必要か? 387 # Transparent RPC の場合 oneway かつ in の配列(size_is, count_is, string のいずれかで修飾)がある 422 388 def need_PPAllocator?( b_opaque = false ) 423 fha = get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 424 å 389 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 425 390 fha.each{ |fh| 426 391 fd = fh.get_declarator … … 457 422 # @factory_list:: Factory[] 458 423 # @ct_factory_list:: Factory[] : celltype factory 459 # @cell_list:: Cell[] : å®ç¾©ã®ã¿ (V1.0.0.2 以é)424 # @cell_list:: Cell[] : 定義のみ (V1.0.0.2 以降) 460 425 # @singleton:: bool 461 426 # @idx_is_id:: bool 462 427 # @idx_is_id_act:: bool: actual value 463 428 # @active:: bool 464 # @b_reuse:: bool : reuse æå®ãã㦠import ããã(template ä¸è¦)465 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin ã¯çæå¾ã«è¿½å ããã429 # @b_reuse:: bool : reuse 指定されて import された(template 不要) 430 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 466 431 # 467 432 # @n_attribute_ro:: int >= 0 none specified … … 470 435 # @n_var:: int >= 0 471 436 # @n_var_size_is:: int >= 0 # of [size_is] specified vars # mikan count_is 472 # @n_var_omit:: int >= 0 # of [omit] specified vars # mikan var ã® omit ã¯æï¼437 # @n_var_omit:: int >= 0 # of [omit] specified vars # mikan var の omit は有? 473 438 # @n_var_init:: int >= 0 # of vars with initializer 474 439 # @n_call_port:: int >= 0 475 440 # @n_call_port_array:: int >= 0 476 # @n_call_port_omitted_in_CB:: int >= 0 æé©åã§çç¥ãããå¼ã³å£441 # @n_call_port_omitted_in_CB:: int >= 0 最適化で省略される呼び口 477 442 # @n_entry_port:: int >= 0 478 443 # @n_entry_port_array:: int >= 0 479 444 # @n_entry_port_inline:: int >= 0 480 # @n_cell_gen:: int >= 0 çæããã»ã«ã®æ°ï¼ã³ã¼ãçæã®é ã§ç®åºããï¼æå³è§£æ段éã§ã¯åç 481 §ä¸å¯ 482 # @id_base:: Integer : cell ã® ID ã®æå°å¤(æ大å¤ã¯ @id_base + @n_cell) 445 # @n_cell_gen:: int >= 0 生成するセルの数.コード生成の頭で算出する.意味解析段階では参照不可 446 # @id_base:: Integer : cell の ID の最小値(最大値は @id_base + @n_cell) 483 447 # 484 # @b_cp_optimized:: bool : å¼ã³å£æé©åå®æ½485 # @plugin:: PluginObject ãã®ã»ã«ã¿ã¤ãããã©ã°ã¤ã³ã«ããçæããã CDL ããçæãããå ´åã«æå¹ã486 # generate ã®æå®ã¯ @generate ã«ãã©ã°ã¤ã³ãä¿æããã448 # @b_cp_optimized:: bool : 呼び口最適化実施 449 # @plugin:: PluginObject このセルタイプがプラグインにより生成された CDL から生成された場合に有効。 450 # generate の指定は @generate にプラグインが保持される 487 451 # 488 # @included_header:: Hash : include ãããããããã¡ã¤ã« 489 # @domain_roots::Hash { DomainTypeName(Symbol) => [ Region ] } ãã¡ã¤ã³ã¿ã¤ãå㨠Region ã®é 490 å (optimize.rb ã§è¨å®) 491 # ã«ã¼ããªã¼ã¸ã§ã³ã¯ãã¡ã¤ã³åããnil 452 # @included_header:: Hash : include されたヘッダファイル 453 # @domain_roots::Hash { DomainTypeName(Symbol) => [ Region ] } ドメインタイプ名と Region の配列 (optimize.rb で設定) 454 # ルートリージョンはドメイン名が nil 492 455 493 456 include PluginModule … … 553 516 554 517 @plugin = Generator.get_plugin 555 # plugin ã®å ´å PluginObject ãè¿ããã 556 # å 557 ã® Generator ããå¼åºããã Generator ã®ä¸ã§ãã¼ã¹ããã³æå³ãã§ãã¯ããã¦ãã 518 # plugin の場合 PluginObject が返される 519 # 元の Generator から呼出された Generator の中でパースおよび意味チェックされている 558 520 559 521 # if @plugin then 560 # # plugin çæãããã»ã«ã¿ã¤ãã¯åå©ç¨ã§ã¯ãªã #833 ä¸å 561 ·åä¿®æ£ 522 # # plugin 生成されるセルタイプは再利用ではない #833 不具合修正 562 523 # @b_reuse = false 563 524 # else … … 573 534 574 535 Namespace.new_celltype( self ) 575 set_namespace_path # @NamespacePath ã®è¨å®536 set_namespace_path # @NamespacePath の設定 576 537 set_specifier_list( Generator.get_statement_specifier ) 577 538 … … 589 550 end 590 551 591 #== Celltype#ãã¡ã¤ã³ã«ã¼ããè¿ã 592 # @domain_roots ã®èª¬æãåç 593 § 552 #== Celltype#ドメインルートを返す 553 # @domain_roots の説明を参照 594 554 def get_domain_roots 595 555 @domain_roots … … 598 558 # Celltype# end_of_parse 599 559 def end_of_parse 600 # å±æ§ã»å¤æ°ã®ãã§ãã¯560 # 属性・変数のチェック 601 561 check_attribute 602 562 603 # ã¢ãã±ã¼ã¿å¼ã³å£ãå 604 é¨çæ 563 # アロケータ呼び口を内部生成 605 564 generate_allocator_port 606 565 607 # ãªã¬ã¼ã¢ãã±ã¼ã¿ãå 608 é¨ã¢ãã±ã¼ã¿ã®è¨å® 566 # リレーアロケータ、内部アロケータの設定 609 567 @port.each { |p| 610 568 p.set_allocator_instance … … 666 624 end 667 625 if a.get_initializer then 668 # ç»é²å¾ã«ãã§ãã¯ãã¦ãåé¡ãªãï¼attr ãåç 669 §ã§ããªãã®ã§ãèªå·±åç 670 §ããªãï¼ 626 # 登録後にチェックしても問題ない(attr を参照できないので、自己参照しない) 671 627 a.get_type.check_init( @locale, a.get_identifier, a.get_initializer, :ATTRIBUTE ) 672 628 end … … 674 630 end 675 631 676 #=== Celltype# celltype ã® attribute/var ã®ãã§ãã¯632 #=== Celltype# celltype の attribute/var のチェック 677 633 # STAGE: S 678 634 # 679 # ãã®ã¡ã½ãã㯠celltype ã®ãã¼ã¹ãå®äºããæç¹ã§å¼åºãããï¼635 # このメソッドは celltype のパースが完了した時点で呼出される. 680 636 def check_attribute 681 # attribute ã® size_is æå®ã妥å½ããã§ãã¯637 # attribute の size_is 指定が妥当かチェック 682 638 (@attribute+@var).each{ |a| 683 639 if a.get_size_is then 684 640 if ! a.get_type.kind_of?( PtrType ) then 685 # size_is ããã¤ã³ã¿å以å¤ã«æå®ããã641 # size_is がポインタ型以外に指定された 686 642 cdl_error( "S1011 $1: size_is specified for non-pointer type" , a.get_identifier ) 687 643 else 688 644 689 # åç 690 §ããå¤æ°ãåå¨ããè¨ç®å¯è½ãªåããã§ãã¯ãã 691 size = a.get_size_is.eval_const( @name_list ) # C_EXP ã®å¯è½æ§ãã 645 # 参照する変数が存在し、計算可能な型かチェックする 646 size = a.get_size_is.eval_const( @name_list ) # C_EXP の可能性あり 692 647 init = a.get_initializer 693 648 if init then 694 649 if ! init.instance_of?( Array ) then 695 # åæååãé 696 åã§ã¯ãªã 650 # 初期化子が配列ではない 697 651 cdl_error( "S1012 $1: unsuitable initializer, need array initializer" , a.get_identifier ) 698 652 elsif size.kind_of?( Integer ) && size < init.length then 699 # size_is æå®ãããåæ°ãããåæååã®é 700 åè¦ç´ ãå¤ã 653 # size_is 指定された個数よりも初期化子の配列要素が多い 701 654 cdl_error( "S1013 $1: too many initializer, $2 for $3" , a.get_identifier, init.length, size ) 702 # elsif a.get_size_is.eval_const( nil ) == nil # C_EXP ã®å¯è½æ§ãã655 # elsif a.get_size_is.eval_const( nil ) == nil # C_EXP の可能性あり 703 656 end 704 657 … … 710 663 ( a.get_initializer.instance_of?( Expression ) && 711 664 a.get_initializer.eval_const2(@name_list).instance_of?( Array ) ) then 712 # size_is æå®ããã¦ããªããã¤ã³ã¿ã Array ã§åæåããã¦ããããã¨ã©ã¼665 # size_is 指定されていないポインタが Array で初期化されていたら、エラー 713 666 cdl_error( "S1159 $1: non-size_is pointer cannot be initialized with array initializer" , a.get_identifier ) 714 667 end … … 722 675 end 723 676 724 #=== Celltype# ã¢ãã±ã¼ã¿å¼ã³å£ãçæ725 # send, receive å¼æ°ã®ã¢ãã±ã¼ã¿ãå¼åºãããã®å¼ã³å£ãçæ677 #=== Celltype# アロケータ呼び口を生成 678 # send, receive 引数のアロケータを呼出すための呼び口を生成 726 679 def generate_allocator_port 727 680 @port.each { |port| 728 # ãã¼ãã®ãã¹ã¦ã®ãã©ã¡ã¼ã¿ã辿ã681 # ポートのすべてのパラメータを辿る 729 682 port.each_param { |port, fd, par| 730 case par.get_direction # å¼æ°ã®æ¹åæå®å(in, out, inout, send, receive )683 case par.get_direction # 引数の方向指定子 (in, out, inout, send, receive ) 731 684 when :SEND, :RECEIVE 732 685 if par.get_allocator then 733 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # ã¢ãã±ã¼ã¿å¼ã³å£ã®åå734 # ãã¼ãå é¢æ°å ãã©ã¡ã¼ã¿å735 # alloc_sig_path = [ par.get_allocator.get_name ] # mikan Namespace ã¢ãã±ã¼ã¿å¼ã³å£ã®ã·ã°ããã£#1686 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # アロケータ呼び口の名前 687 # ポート名 関数名 パラメータ名 688 # alloc_sig_path = [ par.get_allocator.get_name ] # mikan Namespace アロケータ呼び口のシグニチャ #1 736 689 alloc_sig_path = par.get_allocator.get_namespace_path 737 array_size = port.get_array_size # å¼ã³å£ã¾ãã¯åãå£é 738 åã®ãµã¤ãº 739 created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # å¼ã³å£ãçæ 690 array_size = port.get_array_size # 呼び口または受け口配列のサイズ 691 created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # 呼び口を生成 740 692 created_port.set_allocator_port( port, fd, par ) 741 693 if port.is_optional? then … … 745 697 created_port.set_omit 746 698 end 747 new_port( created_port ) # ã»ã«ã¿ã¤ãã«æ°ããå¼ã³å£ã追å699 new_port( created_port ) # セルタイプに新しい呼び口を追加 748 700 # else 749 701 # already error "not found or not signature" in class ParamDecl … … 762 714 end 763 715 764 #=== Celltype# æ°ããå 765 é¨å¤æ° 716 #=== Celltype# 新しい内部変数 766 717 #var:: [Decl] 767 718 def new_var( var ) … … 776 727 @name_list.add_item( i ) 777 728 778 # size_is æå®ãããé 779 å? mikan count_is 729 # size_is 指定された配列? mikan count_is 780 730 if i.get_size_is then 781 731 @n_var_size_is += 1 … … 793 743 end 794 744 795 #=== Celltype# celltype ã®æå®åãè¨å®745 #=== Celltype# celltype の指定子を設定 796 746 def set_specifier_list( spec_list ) 797 747 return if spec_list == nil … … 822 772 823 773 def new_require( ct_or_cell_nsp, ep_name, cp_name ) 824 # Require: set_owner ãããã®ããªã774 # Require: set_owner するものがない 825 775 obj = Namespace.find( ct_or_cell_nsp ) #1 826 776 if obj.instance_of? Celltype then 827 # Celltype åã§æå®777 # Celltype 名で指定 828 778 ct = obj 829 779 elsif obj.instance_of? Cell then 830 # Cell åã§æå®780 # Cell 名で指定 831 781 ct = obj.get_celltype 832 782 elsif obj == nil then … … 839 789 840 790 if( ! ct.is_singleton? ) then 841 # ã·ã³ã°ã«ãã³ã§ã¯ãªã791 # シングルトンではない 842 792 cdl_error( "S1018 $1 : not singleton cell" , obj.get_name ) 843 793 end 844 794 845 # åãå£ãæ¢ã795 # 受け口を探す 846 796 obj2 = ct.find( ep_name ) 847 797 if( ( ! obj2.instance_of? Port ) || obj2.get_port_type != :ENTRY ) then … … 854 804 855 805 if obj2.get_signature == nil then 856 # signature ãæªå®ç¾©ï¼æ¢ã«ã¨ã©ã¼806 # signature が未定義:既にエラー 857 807 return 858 808 end … … 860 810 require_call_port_prefix = :_require_call_port 861 811 if cp_name == nil then 862 # é¢æ°åéè¤ãã§ãã¯812 # 関数名重複チェック 863 813 @require.each{ |req| 864 814 unless req[0].to_s =~ /^#{require_call_port_prefix}/ then 865 next # ååããã® require ã¯é¢æ°åéè¤ãã§ãã¯ããªã815 next # 名前ありの require は関数名重複チェックしない 866 816 end 867 817 port = req[2] 868 818 if port.get_signature == obj2.get_signature then 869 # åã signature ï¼ãã¹ã¦åãé¢æ°åãæã¤ï¼åå¥ã«åºãã®ã§ã¯ãªããã¾ã¨ãã¦ã¨ã©ã¼ã¨ãã819 # 同じ signature (すべて同じ関数名を持つ)個別に出すのではなく、まとめてエラーとする 870 820 cdl_error( "S1021 $1 : require cannot have same signature with \'$2\'" , obj2.get_name, port.get_name ) 871 821 next 872 822 end 873 823 port.get_signature.get_function_head_array.each{ |f| 874 # mikan ããã¯ãnamedList ããã®æ¤ç´¢ã«ãªããªãã®ï¼ï¼å¹çãæªãï¼824 # mikan ここは、namedList からの検索にならないの?(効率が悪い) 875 825 obj2.get_signature.get_function_head_array.each{ |f2| 876 826 if( f.get_name == f2.get_name ) then … … 888 838 b_has_name = true 889 839 end 890 # require ã追å840 # require を追加 891 841 @require << [ cp_name, obj, obj2 ] # [ lhs:cp_name, rhs:Celltype, rhs:Port ] 892 842 893 # require port ã追å (å¼ã³å£ã¨ãã¦è¿½å ããããã ã require ãã»ãããã¦ãã)843 # require port を追加 (呼び口として追加する。ただし require をセットしておく) 894 844 port = Port.new( cp_name, obj2.get_signature.get_namespace_path, :CALL ) 895 845 port.set_require( b_has_name ) … … 913 863 end 914 864 915 #=== Celltype# ã»ã«ã¿ã¤ããã©ã°ã¤ã³ (generate æå®å)865 #=== Celltype# セルタイププラグイン (generate 指定子) 916 866 def celltype_plugin 917 867 … … 927 877 928 878 begin 929 eval( eval_str ) # plugin ãçæ879 eval( eval_str ) # plugin を生成 930 880 plugin_object.set_locale @locale 931 881 @generate[ 2 ] = plugin_object … … 939 889 end 940 890 941 #=== Celltype# celltype ã«æ°ãã cell ã追å891 #=== Celltype# celltype に新しい cell を追加 942 892 #cell:: Cell 943 # æ°ããã»ã«ãã»ã«ã¿ã¤ãã«è¿½å ï¼944 # ã»ã«ã®æ§æ解éã®æå¾ã§ãã®ã¡ã½ããå¼åºãããï¼945 # ã·ã³ã°ã«ãã³ã»ã«ãåã linkunit ã«è¤æ°ãªãããã§ãã¯893 # 新しいセルをセルタイプに追加. 894 # セルの構文解釈の最後でこのメソドを呼出される. 895 # シングルトンセルが同じ linkunit に複数ないかチェック 946 896 def new_cell( cell ) 947 # Celltype ã§ã¯ Cell ã® set_owner ããªã948 # ã·ã³ã°ã«ãã³ã§ããããã¿ã¤ã宣è¨ã§ãªãå ´åãã³ã¼ãçæ対象ãªã¼ã¸ã§ã³ã®å ´å897 # Celltype では Cell の set_owner しない 898 # シングルトンで、プロトタイプ宣言でない場合、コード生成対象リージョンの場合 949 899 if @singleton then 950 900 @cell_list.each{ |c| … … 960 910 end 961 911 962 #=== Celltype# ã»ã«ã¿ã¤ã㯠INIB ãæã¤ãï¼963 # ã»ã«ã¿ã¤ãã INIB ãæã¤ãã©ãããå¤å®ãã964 # $rom == false ã®ã¨ã: INIB ãæããªãï¼ ï¼ãã¹ã¦ã¯ CB ã«ç½®ãããï¼965 # $rom == true ã®ã¨ããINIB ã«ç½®ããããã®ãä¸ã¤ã§ãåå¨ããã° INIB ãæã¤966 # INIB ã«ç½®ããããã®ã¯967 # attribute (omit ã®ãã®ã¯é¤ãï¼ç¾ä»æ§ã§ã¯ rw ã®ãã®ã¯ãªã)968 # size_is ãä¼´ãvar969 # å¼ã³å£ï¼ãã ããæé©åã§ä¸è¦ã¨ãªããã®ã¯é¤ãï¼912 #=== Celltype# セルタイプは INIB を持つか? 913 # セルタイプが INIB を持つかどうかを判定する 914 # $rom == false のとき: INIB を持たない. (すべては CB に置かれる) 915 # $rom == true のとき、INIB に置かれるものが一つでも存在すれば INIB を持つ 916 # INIB に置かれるものは 917 # attribute (omit のものは除く.現仕様では rw のものはない) 918 # size_is を伴う var 919 # 呼び口(ただし、最適化で不要となるものは除く) 970 920 def has_INIB? 971 921 # print "name=#{@name} @n_attribute_ro=#{@n_attribute_ro} @n_var_size_is=#{@n_var_size_is} @n_call_port=#{@n_call_port} @n_call_port_omitted_in_CB=#{@n_call_port_omitted_in_CB} @n_entry_port_array_ns=#{@n_entry_port_array_ns}\n" … … 974 924 end 975 925 976 #=== Celltype# ã»ã«ã¿ã¤ã㯠CB ãæã¤ãï¼977 # $rom == true ã®ã¨ããããã®ãã®ãç½®ãããï¼ãããã®ä¸ã¤ã§ãåå¨ããã° CB ãæã¤978 # size_is ãæå®ããã¦ããªãvar979 # rw æå®ããã attribute (ç¾ä»æ§ã§ã¯åå¨ããªã)980 # $rom == false ã®ã¨ããããã®ãã®ãç½®ãããï¼ãããã®ä¸ã¤ã§ãåå¨ããã° CB ãæã¤926 #=== Celltype# セルタイプは CB を持つか? 927 # $rom == true のとき、いかのものが置かれる.それらの一つでも存在すれば CB を持つ 928 # size_is が指定されていない var 929 # rw 指定された attribute (現仕様では存在しない) 930 # $rom == false のとき、いかのものが置かれる.それらの一つでも存在すれば CB を持つ 981 931 # attribute 982 932 # var 983 # å¼ã³å£ï¼ãã ããæé©åã§ä¸è¦ã¨ãªããã®ã¯é¤ãï¼933 # 呼び口(ただし、最適化で不要となるものは除く) 984 934 def has_CB? 985 935 if $rom then … … 991 941 end 992 942 993 #=== Celltype# SET_CB_INIB_POINTER, INITIALIZE_CB ãå¿ 994 è¦ã 943 #=== Celltype# SET_CB_INIB_POINTER, INITIALIZE_CB が必要か 995 944 def need_CB_initializer? 996 945 @n_var_init > 0 || has_CB? 997 946 end 998 947 999 #=== Celltype# érequire ã®çµåãçæãã948 #=== Celltype# 逆require の結合を生成する 1000 949 def create_reverse_require_join cell 1001 950 @port.each{ |p| … … 1004 953 end 1005 954 1006 #=== Celltype# singleton ã»ã«ãå¾ã 1007 #region:: Region : singleton ãæ¢ã Region 1008 # è·é¢ãæãè¿ããã®ãè¿ã 1009 # mikan æ¬å½ã¯ region ã®ç¯å²ã® singleton ãæ¢ãå¿ 1010 è¦ããã 955 #=== Celltype# singleton セルを得る 956 #region:: Region : singleton を探す Region 957 # 距離が最も近いものを返す 958 # mikan 本当は region の範囲の singleton を探す必要がある 1011 959 def get_singleton_cell region 1012 960 cell = nil 1013 dist = 999999999 # mikan å¶éå¤ï¼ããã¯ååãããã»ã©ãã«ã¤ãï¼1014 # require: celltype ã§æå®961 dist = 999999999 # mikan 制限値(これは十分すぎるほどデカイが) 962 # require: celltype で指定 1015 963 @cell_list.each{ |c| 1016 # å°éå¯è½ã§æãè¿ãã»ã«ãæ¢ãï¼è¤æ°ã® singleton ããããããããªãï¼964 # 到達可能で最も近いセルを探す(複数の singleton があるかもしれない) 1017 965 d = region.distance( c.get_region ) 1018 966 #debug … … 1033 981 end 1034 982 1035 #=== Celltype# ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãå¾ã983 #=== Celltype# セルタイププラグインを得る 1036 984 def get_celltype_plugin 1037 985 if @generate then … … 1052 1000 end 1053 1001 1054 #=== Celltype# ã¢ã¯ãã£ãã§ã¯ãªãã1055 # ãã®ã¡ã½ããã§ã¯ active ã®ä»ã« factory (singleton ã«ããã¦ã¯ FACTORYãå«ã)ããªããã° inactive ã¨ãã1002 #=== Celltype# アクティブではないか 1003 # このメソッドでは active の他に factory (singleton においては FACTORYを含む)がなければ inactive とする 1056 1004 def is_inactive? 1057 1005 if @active == false && @factory_list.length == 0 && … … 1074 1022 end 1075 1023 1076 #=== Celltype# ã³ã¼ãçæããå¿ 1077 è¦ããããå¤å® 1078 # ã»ã«ã®åæ°ã 0 ãªãã»ã«ã¿ã¤ãã³ã¼ãã¯çæä¸è¦ 1024 #=== Celltype# コード生成する必要があるか判定 1025 # セルの個数が 0 ならセルタイプコードは生成不要 1079 1026 def need_generate? 1080 1027 @n_cell_gen > 0 1081 1028 end 1082 1029 1083 #=== Celltype# require å¼ã³å£ã®çµåãè¡ã1030 #=== Celltype# require 呼び口の結合を行う 1084 1031 # STAGE: S 1085 # ã»ã«ã¿ã¤ãã® require å¼ã³å£ã«ã¤ãã¦ãçµåãè¡ã1086 # ã»ã«ãçæãããªãããã§ãã¯ãè¡ã1032 # セルタイプの require 呼び口について、結合を行う 1033 # セルが生成されないかチェックを行う 1087 1034 def set_require_join 1088 1035 @require.each{ |req| … … 1100 1047 end 1101 1048 1102 #=== Celltype# inline åãå£ãããªããï¼1103 # åãå£ãç¡ãå ´åããã¹ã¦ã®åãå£ã inline ã¨ã¯ããªã1049 #=== Celltype# inline 受け口しかないか? 1050 # 受け口が無い場合、すべての受け口が inline とはしない 1104 1051 def is_all_entry_inline? 1105 1052 @n_entry_port == @n_entry_port_inline && @n_entry_port > 0 … … 1140 1087 # @n_var:: int >= 0 1141 1088 # @n_var_size_is:: int >= 0 # of [size_is] specified cells # mikan count_is 1142 # @n_var_omit:: int >= 0 # of [omit] specified cells # mikan var ã® omit ã¯æï¼1089 # @n_var_omit:: int >= 0 # of [omit] specified cells # mikan var の omit は有? 1143 1090 # @n_call_port:: int >= 0 1144 1091 # @n_call_port_array:: int >= 0 1145 # @n_call_port_omitted_in_CB:: int >= 0 æé©åã§çç¥ãããå¼ã³å£1092 # @n_call_port_omitted_in_CB:: int >= 0 最適化で省略される呼び口 1146 1093 # @n_entry_port:: int >= 0 1147 1094 # @n_entry_port_array:: int >= 0 1148 1095 (indent+1).times { print " " } 1149 1096 puts "@n_entry_port_inline #{@n_entry_port_inline}" 1150 # @n_cell:: int >= 0 ã³ã¼ãçæã®é ã§ç®åºããï¼æå³è§£æ段éã§ã¯åç 1151 §ä¸å¯ 1152 # @id_base:: Integer : cell ã® ID ã®æå°å¤(æ大å¤ã¯ @id_base + @n_cell) 1097 # @n_cell:: int >= 0 コード生成の頭で算出する.意味解析段階では参照不可 1098 # @id_base:: Integer : cell の ID の最小値(最大値は @id_base + @n_cell) 1153 1099 1154 1100 end … … 1156 1102 1157 1103 class Cell < NSBDNode # < Nestable 1158 # @name:: Symbol : composite celltype ã®å 1159 å´ã®ã¤ã³ã¹ã¿ã³ã¹ã§ã¯å¤ã®ã»ã« 1160 # @global_name:: Symbol : C ã§ä½¿ããååï¼namespace ãå«ãï¼ 1161 # @local_name:: str : cell celltype name { ... } ã® name 1104 # @name:: Symbol : composite celltype の内側のインスタンスでは外のセル 1105 # @global_name:: Symbol : C で使える名前(namespace を含む) 1106 # @local_name:: str : cell celltype name { ... } の name 1162 1107 # @celltype:: Celltype | CompositeCelltype 1163 1108 # @join_list:: NamedList … … 1166 1111 # @b_prototype:: bool: prototype specified in current parsing cell. (@b_defined is used to determine whether definition done) 1167 1112 # @b_duplicate:: bool: definition duplicate 1168 # @b_checked:: bool: set_definition_join ãæ¸ãã§ããå ´åtrue1169 # @require_joined_list:: {cp_name=>true}: set_require_join ãæ¸ãã§ããå¼ã³å£ã¯true1113 # @b_checked:: bool: set_definition_join が済んでいる場合 true 1114 # @require_joined_list:: {cp_name=>true}: set_require_join が済んでいる呼び口は true 1170 1115 # @f_ref:: refercenced from others 1171 # @entry_array_max_subscript:: { @port=>Integer } : åãå£é 1172 åã®é 1173 åæ·»æ°ã®æ大å¤ï¼æ·»æ°ç¡ãåãå£é 1174 å対å¿ï¼ 1116 # @entry_array_max_subscript:: { @port=>Integer } : 受け口配列の配列添数の最大値(添数無し受け口配列対応) 1175 1117 # @plugin:: Plugin: avialble if cell is generated by plugin generated cdl code. 1176 # @referenced_port_list:: { Port => Integer } : åãå£ã®åç 1177 §æ° 1178 # ãã¹ã¦ã®æå³è§£æ(through, compositeå±é)ãçµãã£ãå¾ã«è¨å®ãã 1179 # érequire ãã¼ãã«å¯¾ãã¦è¤æ°ã®çµåããªãããã§ãã¯ãã 1180 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin ã¯çæå¾ã«è¿½å ããã 1118 # @referenced_port_list:: { Port => Integer } : 受け口の参照数 1119 # すべての意味解析(through, composite展開)が終わった後に設定する 1120 # 逆require ポートに対して複数の結合がないかチェックする 1121 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 1181 1122 # 1182 # composite ã®ããã¤ã³ã¹ã¿ã³ã¹å¤æ°1123 # composite のためインスタンス変数 1183 1124 # @in_composite:: bool : true if in composite celltype 1184 1125 # @compositecelltypejoin_list:: NamedList : item= CompositeCelltypeJoin ( if @in_composite ) 1185 1126 # @f_cloned:: bool : true if cloned (instantiate of composite consist cell) 1186 # @my_clone:: Cell : Composite cell 㧠in_composite = true ã®å ´åã®ã¿æå¹ï¼ç´åã® clone ãä¸æè¨æ¶ï¼ 1187 # @cell_list:: Cell[local_name] : Composite cell 㧠clone ããå¾ã®ãªã¹ã cell_list 1188 # @cell_list2:: [ Cell ] : Composite cell 㧠clone ããå¾ã®ãªã¹ã cell_list 1189 # @cell_list2 㯠composite å 1190 ã§ã®åºç¾é 1127 # @my_clone:: Cell : Composite cell で in_composite = true の場合のみ有効(直前の clone を一時記憶) 1128 # @cell_list:: Cell[local_name] : Composite cell で clone した後のリスト cell_list 1129 # @cell_list2:: [ Cell ] : Composite cell で clone した後のリスト cell_list 1130 # @cell_list2 は composite 内での出現順 1191 1131 # 1192 # region ã®ããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°1193 # @region:: Region ( å±ããregion)1132 # region のためのインスタンス変数 1133 # @region:: Region (属するregion) 1194 1134 # 1195 # allocator ã®ããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°1135 # allocator のためのインスタンス変数 1196 1136 # @alloc_list:: [ [ NORMAL_ALLOC, ep_name, func_name, param_name, expr ], ... ] 1197 # åãå£å´ã®ã¢ãã±ã¼ã¿ã¸ã®çµåãè¨æ¶ã以ä¸ã®ã¡ã½ããã§è¿½å ããã1198 # set_specifier ⦠cell å®ç¾©æã«ã¢ãã±ã¼ã¿æå®ããã¦ããå ´å1199 # create_relay_allocator_join ⦠ãªã¬ã¼ã¢ãã±ã¼ã¿ã®å ´å1137 # 受け口側のアロケータへの結合を記憶。以下のメソッドで追加される 1138 # set_specifier … cell 定義時にアロケータ指定されている場合 1139 # create_relay_allocator_join … リレーアロケータの場合 1200 1140 # 1201 # ID ã®ããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°ï¼optimize.rb ã«ã¦è¨å®ï¼1202 # @id:: Integer : ã³ã¼ãçæç´åã«è¨å® (ãããã¿ã¤ã宣è¨ã®å ´å㯠-1 ã®ã¾ã¾æ¾ç½®)1203 # @id_specified::Integer : æå®ãããid1141 # ID のためのインスタンス変数(optimize.rb にて設定) 1142 # @id:: Integer : コード生成直前に設定 (プロトタイプ宣言の場合は -1 のまま放置) 1143 # @id_specified::Integer : 指定された id 1204 1144 # @restrict_list::{ entry_name => { func_name, [ region_name, ... ] } } 1205 1145 1206 1146 =begin 1207 # Cell ã¯ã©ã¹ã¯ã以ä¸ã®ãã®ãæ±ã 1208 # 1)æ®éã®ã»ã« 1209 # 2)composite ã»ã«ã¿ã¤ãã®ã»ã« 1210 # 3)composite ã»ã«ã¿ã¤ãã®å 1211 å´ã®ã»ã« (@in_composite) # composite ã®å 1212 å´ã® composite ã»ã«ã¿ã¤ãã®ã»ã«ããã 1147 # Cell クラスは、以下のものを扱う 1148 # 1)普通のセル 1149 # 2)composite セルタイプのセル 1150 # 3)composite セルタイプの内側のセル (@in_composite) # composite の内側の composite セルタイプのセルもある 1213 1151 # 1214 # 2) 㯠CellOfComposite ã¯ã©ã¹ã¨ãã¦åããã»ãããããããããªã 1215 # expand (composite ã»ã«ã®å±é) 㯠CellOfComposite ã«ã®ã¿å¿ 1216 è¦ãªã¡ã½ããã§ãã 1217 # get_real_cell, get_real_port ãªã© @celltype.instance_of?( CompositeCelltype ) ã®å¤å®ããªããã£ãããã 1218 # ãã ãåé¢ãã¦ããã¡ã³ããã³ã¹ãã¹ãç¯å²ãåãé¢ããã¦ãã¾ããå¿ãããããªãåé¡ã¨ã®ãã¬ã¼ããªããã 1152 # 2) は CellOfComposite クラスとして分けたほうがよいかもしれない 1153 # expand (composite セルの展開) は CellOfComposite にのみ必要なメソッドである 1154 # get_real_cell, get_real_port など @celltype.instance_of?( CompositeCelltype ) の判定がなくすっきりする 1155 # ただ、分離しても、メンテナンスすべき範囲が切り離されてしまい、忘れやすくなる問題とのトレードオフかも 1219 1156 # 1220 # 3) 㯠CellInCompoiste ã¯ã©ã¹ã¨ãã¦åããã»ãããããããããªã 1221 # @in_composite ã§å¤å®ãã¦ããå¦çãåãé¢ãã (ä¸è¨ 2) ãããåé¢ã¯å®¹æã§ã¯ãªã) 1222 # clone_for_composite 㯠CellInCompoiste ã«ã®ã¿å¿ 1223 è¦ãªã¡ã½ããã§ãã 1224 # ãã ããclone å¾ã« Cell, CellOfComposite ã«å¤åããå¿ 1225 è¦ãããã®ã§ãclone ã§ã¯ãªã new ããå®è£ 1226 ã«å¤æ´ããå¿ 1227 è¦ããã 1157 # 3) は CellInCompoiste クラスとして分けたほうがよいかもしれない 1158 # @in_composite で判定している処理を切り離せる (上記 2) よりも分離は容易ではない) 1159 # clone_for_composite は CellInCompoiste にのみ必要なメソッドである 1160 # ただし、clone 後に Cell, CellOfComposite に変化する必要があるので、clone ではなく new する実装に変更する必要がある 1228 1161 # 1229 1162 =end … … 1235 1168 @@current_object = nil 1236 1169 1237 # å®ç¾©ããããã¹ã¦ã®ã»ã«ï¼åºç¾é . namespace ã«å½±é¿ãããªãï¼ 1238 @@cell_list = [] # composite ã®å 1239 é¨ã®ã»ã«ãå«ã¾ãªã 1240 @@cell_list2 = [] # composite ã®å 1241 é¨ã®ã»ã«ãå«ã (å 1242 ã®ã»ã«ãå«ã) 1243 # æå³è§£æå¾ make_cell_list2 ã«ã¦è¨å®ããã 1170 # 定義されたすべてのセル(出現順. namespace に影響されない) 1171 @@cell_list = [] # composite の内部のセルを含まない 1172 @@cell_list2 = [] # composite の内部のセルを含む (元のセルを含む) 1173 # 意味解析後 make_cell_list2 にて設定される 1244 1174 1245 1175 def self.push … … 1258 1188 1259 1189 1260 # composite 㧠clone ããããã®ï¼åå«ã¾ã§å«ãï¼ 1261 # Join.change_rhs_port ã«ã¦ CompoisteCelltype å 1262 ã® Join ã®çµåå 1263 ãå¤æ´ããéã«ä½¿ç¨ 1190 # composite で clone されたもの(子孫まで含む) 1191 # Join.change_rhs_port にて CompoisteCelltype 内の Join の結合先を変更する際に使用 1264 1192 @@cloned_cell_list = {} 1265 ### mikan BUG @@cloned_cell_list 㯠composite ã®é層ãã¨ã«è¨æ¶ãã¦ããªããããåãååãå 1266 é¨ã«ç¾ããã¨ããã¾ãåä½ããªã 1267 # change_rhs_port ã®å®è£ 1268 ã¯ããããªåããã©ããã¨ãããå¿ 1269 è¦ã¯ãªãã£ããå³è¾ºã«ç¾ããã»ã«åã«ã¯ãcomposite ã®ã»ã«åãåã«ã¤ãªããã ãã§ããã£ã 1193 ### mikan BUG @@cloned_cell_list は composite の階層ごとに記憶していないため、同じ名前が内部に現れると、うまく動作しない 1194 # change_rhs_port の実装は、こんな回りくどいことをする必要はなかった。右辺に現れるセル名には、composite のセル名を前につなげるだけでよかった 1270 1195 1271 1196 def initialize( ct_path, in_composite = false ) … … 1273 1198 @region = Region.get_current 1274 1199 1275 # celltype ã®plugin/åå¨ããã§ãã¯1200 # celltype のplugin/存在をチェック 1276 1201 object = Namespace.find( ct_path ) #1 1277 1202 if object == nil then 1278 # mikan celltype ã®ååãä¸å®å 1279 ¨ "::ct1ct2" ã«ãªã 1203 # mikan celltype の名前が不完全 "::ct1ct2" になる 1280 1204 cdl_error( "S1027 \'$1\' celltype not found" , ct_path.get_path_str ) 1281 1205 elsif ! object.instance_of?( Celltype ) && ! object.instance_of?( CompositeCelltype ) then 1282 # mikan celltype ã®ååãä¸å®å 1283 ¨ 1206 # mikan celltype の名前が不完全 1284 1207 cdl_error( "S1028 \'$1\' not celltype" , ct_path.get_path_str ) 1285 1208 else … … 1329 1252 end 1330 1253 1331 # ãã®æç¹ã§ã¯ãããã¿ã¤ãããå®ç¾©ãåããªãããèªå·±åç 1332 §ã®ããã«ç»é² 1333 # set_f_def ã§å度ç»é²ããªãã 1334 # Celltype ã¸ã®ç»é²ã¯ãend_of_parse ã§è¡ã 1254 # この時点ではプロトタイプか、定義か分らないが、自己参照のために登録 1255 # set_f_def で再度登録しなおす 1256 # Celltype への登録は、end_of_parse で行う 1335 1257 if @in_composite then 1336 1258 cell_prev = CompositeCelltype.find( name ) … … 1339 1261 end 1340 1262 else 1341 # cell_prev = Namespace.find( [ name ] ) # 親ã¾ã§æãã«ãã1263 # cell_prev = Namespace.find( [ name ] ) # 親まで捜しにいく 1342 1264 cell_prev = Namespace.get_current.find( name ) 1343 1265 if cell_prev == nil then 1344 1266 Namespace.new_cell( self ) 1345 set_namespace_path # @NamespacePath ã®è¨å®1267 set_namespace_path # @NamespacePath の設定 1346 1268 end 1347 1269 end … … 1350 1272 if ! cell_prev.instance_of?( Cell ) then 1351 1273 cdl_error( "S1029 $1 mismatch with previous one" , name ) 1352 # celltype ãä¸è´ãã¦ããã?1274 # celltype が一致しているか ? 1353 1275 elsif get_celltype != cell_prev.get_celltype then 1354 1276 cdl_error( "S1030 $1: celltype mismatch with previous one" , name ) 1355 1277 else 1356 # region ãä¸è´ãã¦ããã?1278 # region が一致しているか? 1357 1279 if ! cell_prev.get_region.equal? get_region then 1358 1280 cdl_error( "S1031 $1 region \'$2\' mismatch with previous one \'$3\'" , name, @region.get_name, cell_prev.get_region.get_name ) … … 1360 1282 1361 1283 @@current_object = cell_prev 1362 # ãã®æç¹ã§ã¯ãã¾ã ãããã¿ã¤ã宣è¨ãå®ç¾©ãåããªã1363 # 以åãå®ç¾©ã§ãã£ã¦ãä»åãå®ç¾©ã®å ´åãéè¤ã¨ã©ã¼ã§ãã1284 # この時点では、まだプロトタイプ宣言か定義か分らない 1285 # 以前が定義であって、今回も定義の場合、重複エラーである 1364 1286 end 1365 1287 end … … 1371 1293 dbgPrint "Cell new_cell: #{@global_name} #{@in_composite} #{self}\n" 1372 1294 1373 # å 1374 é¨ã¢ãã±ã¼ã¿ã @alloc_list ã«è¿½å 1295 # 内部アロケータを @alloc_list に追加 1375 1296 if @celltype.instance_of? CompositeCelltype then 1376 1297 @celltype.get_internal_allocator_list.each{ |cell, cp_internal_name, port_name, fd_name, par_name, ext_alloc_ent| 1377 1298 nsp = NamespacePath.new( @name, false ) 1378 rhs = Expression.new( [:OP_DOT, [:IDENTIFIER, nsp], Token.new( ext_alloc_ent.to_s.to_sym, nil, nil, nil ) ] ) #1 æ§æ解æ段éãªã®ã§ locale ä¸è¦1299 rhs = Expression.new( [:OP_DOT, [:IDENTIFIER, nsp], Token.new( ext_alloc_ent.to_s.to_sym, nil, nil, nil ) ] ) #1 構文解析段階なので locale 不要 1379 1300 1380 1301 @alloc_list << [:NORMAL_ALLOC,port_name,nil,fd_name,par_name,rhs] … … 1384 1305 end 1385 1306 1386 #=== Cell# cell ã®å®ç¾©1387 # æ¬ä½(join)ã®å®ç¾©ã®ç´åã«å¼ã³åºããã1307 #=== Cell# cell の定義 1308 # 本体(join)の定義の直前に呼び出される 1388 1309 def self.new_def 1389 1310 @@current_object.new_def 1390 1311 end 1391 1312 1392 #=== Cell# cell ã®å®ç¾©1393 # æ¬ä½(join)ã®å®ç¾©ã®ç´åã«å¼ã³åºããã1394 # ãã®ã¡ã½ãã㯠cell tCelltype Cell { }; '{', '}' ã®é¨åãããå ´åã«å¼åºããã1313 #=== Cell# cell の定義 1314 # 本体(join)の定義の直前に呼び出される 1315 # このメソッドは cell tCelltype Cell { }; '{', '}' の部分がある場合に呼出される 1395 1316 def new_def 1396 1317 set_specifier_list( Generator.get_statement_specifier ) 1397 1318 1398 # prototype æå®åãªãã1319 # prototype 指定子ないか 1399 1320 if ! @b_prototype then 1400 # äºéå®ç¾©ã®ãã§ãã¯1321 # 二重定義のチェック 1401 1322 if @b_defined == true then 1402 1323 cdl_error( "S1032 $1: duplicate cell" , @name ) 1403 1324 dbgPrint "previous: #{@prev_locale[0]}: line #{@prev_locale[1]} '#{@name}' defined here\n" 1404 1325 1405 # ã»ã«ã®éè¤å®ç¾©ã¨ã©ã¼ã®å¦ç½®1406 # åã®å®ç¾©ã¯æ¨ã¦ã1326 # セルの重複定義エラーの処置 1327 # 前の定義は捨てる 1407 1328 @join_list = NamedList.new( nil, "in cell '#{@name}'" ) 1408 1329 end … … 1417 1338 end 1418 1339 1419 #=== Cell# æ°ããçµåããã§ãã¯1340 #=== Cell# 新しい結合をチェック 1420 1341 # STAGE: P 1421 1342 # 1422 #join:: Join : æ°ããçµå1423 #b_regular:: bool : é常ã®å ´æ (bnf.y.rb)ãããªãã° true, ãã以å¤(allocator, require) ã§ã¯false1343 #join:: Join : 新しい結合 1344 #b_regular:: bool : 通常の場所 (bnf.y.rb)からならば true, それ以外(allocator, require) では false 1424 1345 def new_join( join, b_regular = false ) 1425 1346 join.set_owner self 1426 1347 1427 # composite ã®æ°ææ³å¯¾å¿ï¼ 1428 # composite ã®ä¸ã®ã»ã«ã§ãattribute ã®å®ç¾©ã§ããå ´å 1429 # cell å 1430 ã® attr_ext = composite.attr; æ§æãå¦ç 1348 # composite の新文法対応. 1349 # composite の中のセルで、attribute の定義である場合 1350 # cell 内の attr_ext = composite.attr; 構文を処理 1431 1351 if @in_composite then 1432 1352 if @celltype then 1433 if @celltype.find(join.get_name).instance_of?( Decl ) then # mikan a::b ã§æå®ããã¦ãããã®ãã¨ã©ã¼ã«ãªããªããã1353 if @celltype.find(join.get_name).instance_of?( Decl ) then # mikan a::b で指定されていたものがエラーにならないかも 1434 1354 rhs = join.get_rhs 1435 1355 if rhs.instance_of? Expression then 1436 1356 ele = rhs.get_elements 1437 if( ele[0]==:IDENTIFIER )then # attr = attr_ext ï¼å³è¾ºåé 1438 ï¼ãï¼ #1 1439 if( CompositeCelltype.has_attribute?(ele[1].get_name ) )then # mikan a::b.ePort ãã¨ã©ã¼ã«ãªããªããã 1440 ident = ele[1].get_name # å³è¾ºã¯ attributeï¼ 1357 if( ele[0]==:IDENTIFIER )then # attr = attr_ext (右辺単項)か? #1 1358 if( CompositeCelltype.has_attribute?(ele[1].get_name ) )then # mikan a::b.ePort がエラーにならないかも 1359 ident = ele[1].get_name # 右辺は attribute. 1441 1360 else 1442 # å³è¾ºã¯ attribute ã«ãªãã®ã§ããã°ãå®æ°ã®ã¯ã1443 # å®æ°ã¯ä¸ã¸æ¸¡ã (cell ã® join ã«ãã)1361 # 右辺は attribute にないのであれば、定数のはず 1362 # 定数は下へ渡す (cell の join にする) 1444 1363 ident = nil 1445 1364 end 1446 1365 else 1447 if join.get_rhs.eval_const2(nil) == nil then # å®æ°å¼ã§ã¯ãªããï¼1448 # å³è¾ºããåä¸ã®ã·ã³ãã«ã§ãªãå ´åãç¾ç¶ã¯æ±ããªã1366 if join.get_rhs.eval_const2(nil) == nil then # 定数式ではないか? 1367 # 右辺が、単一のシンボルでない場合、現状は扱えない 1449 1368 cdl_error( "S1033 rhs expression is not supported. Only attribute is permitted on current version." ) 1450 1369 return 1451 1370 else 1452 # å®æ°ã¯ä¸ã¸æ¸¡ã (cell ã® join ã«ãã)1371 # 定数は下へ渡す (cell の join にする) 1453 1372 ident = nil 1454 1373 end … … 1456 1375 1457 1376 if ident then 1458 # attr = attr; ã®ãããªåç 1459 §ã¯ã¨ã©ã¼ (a = composite.a ã¨ããå¿ 1460 è¦ããã) 1377 # attr = attr; のような参照はエラー (a = composite.a とする必要がある) 1461 1378 if @celltype.find( ident ) then 1462 1379 cdl_error( "S1034 $1 : cannot refer to $2\'s attribute here. Use \'composite.$3\' to refer to composite celltype\'s" , ident, @celltype.get_name, ident ) … … 1464 1381 end 1465 1382 elsif rhs.instance_of? Array then 1466 if rhs[0] == :COMPOSITE then # å³è¾ºã¯ composite.attr ã®å½¢å¼1383 if rhs[0] == :COMPOSITE then # 右辺は composite.attr の形式 1467 1384 ident = rhs[1].to_sym 1468 1385 else 1469 ident = nil # å³è¾ºã¯ { 10, -10 } ã®å½¢å¼1386 ident = nil # 右辺は { 10, -10 } の形式 1470 1387 end 1471 1388 else 1472 ident = nil # å³è¾ºã¯ C_EXP ã®å½¢å¼1389 ident = nil # 右辺は C_EXP の形式 1473 1390 end 1474 1391 1475 # ident ãè¦ã¤ãã£ãï¼å³è¾ºã¯åä¸ã® identï¼1392 # ident が見つかった(右辺は単一の ident) 1476 1393 if ident then 1477 # composite ã®æ§ææ³ã®æ§æå¦çã¸æ¸¡ãï¼ã»ã«å¤ã® attr_ext = Cell.attr; æ§æã®å¦çã«æ¸¡ã1394 # composite の旧文法の構文処理へ渡す.セル外の attr_ext = Cell.attr; 構文の処理に渡す 1478 1395 # export_name, internal_cell_name, internal_cell_elem_name 1479 decl = CompositeCelltype.new_join( ident, @name, join.get_name, :ATTRIBUTE ) # mikan a::b.ePort ãã¨ã©ã¼ã«ãªããªããã1396 decl = CompositeCelltype.new_join( ident, @name, join.get_name, :ATTRIBUTE ) # mikan a::b.ePort がエラーにならないかも 1480 1397 if ! decl.instance_of? Decl then 1481 1398 return … … 1485 1402 return 1486 1403 end 1487 # 以ä¸ã®æ§ææ³å®è£ 1488 ã«æ¸¡ãï¼ 1489 # æ§ææ³ã§ã¯ cell ã«åæå¤ãä¸ãããã¨ã§ãcomposite ã§å±æ§ã®åæå¤ãæå®ãããã¨ãã§ãã 1490 # attribute ã§æå®ãããåæå¤ã cell ã®å±æ§ã¨ãã¦å¦çããã 1404 # 以下の旧文法実装に渡す. 1405 # 旧文法では cell に初期値を与えることで、composite で属性の初期値を指定することができた 1406 # attribute で指定された初期値を cell の属性として処理させる 1491 1407 join.change_rhs( ini ) 1492 1408 else 1493 # ident ããªãï¼å®æ°å¼1409 # ident がない.定数式 1494 1410 end 1495 1411 else 1496 # celltype ã®å±æ§ã¨ãã¦ããã® join ã®ååããªã1497 # 以ä¸ã® join.set_definition ã®ä¸ã§ã¨ã©ã¼ã¨ãªã1412 # celltype の属性として、この join の名前がない 1413 # 以下の join.set_definition の中でエラーとなる 1498 1414 end 1499 1415 else 1500 return # celltype ããªãï¼ãã§ã«ã¨ã©ã¼1416 return # celltype がない.すでにエラー 1501 1417 end 1502 1418 elsif join.get_rhs.instance_of? Array then 1503 1419 rhs = join.get_rhs 1504 1420 if rhs[0] == :COMPOSITE then 1505 # composite ã®ä¸ã§ãªãã®ã« attr = composite.attr ã使ããã1421 # composite の中でないのに attr = composite.attr が使われた 1506 1422 cdl_error( "S1035 composite : cannot specify out of composite celltype definition" ) 1507 1423 return … … 1509 1425 end 1510 1426 1511 # ä»¥ä¸ composite ææ³å¤æ´åããããå¦ç1512 1513 # æ¢ã«å·¦è¾ºãåãååã®åæåãåå¨ãããï¼1514 j = @join_list.get_item( join.get_name ) # mikan NamespacePath ããã¹ãæã£ã¦ãã1515 if j.instance_of? Join then # mikan ããã§ã¯ j ã Join or Nil 以å¤ã¯ããªãã¯ã1427 # 以下 composite 文法変更前からある処理 1428 1429 # 既に左辺が同じ名前の初期化が存在するか? 1430 j = @join_list.get_item( join.get_name ) # mikan NamespacePath がパスを持っている 1431 if j.instance_of? Join then # mikan ここでは j が Join or Nil 以外は、ないはず 1516 1432 1517 1433 # debug 1518 1434 dbgPrint "add_array_member: #{@name} port: #{j.get_port_name} rhs: #{j.get_rhs}, #{join.get_port_name} #{join.get_rhs}\n" 1519 # å¼ã³å£é 1520 åï¼ã§ããã¨ä»®å®ãã¦ï¼è¦ç´ ã追å 1435 # 呼び口配列(であると仮定して)要素を追加 1521 1436 j.add_array_member join 1522 1437 … … 1526 1441 end 1527 1442 1528 # if get_owner then # error S1030 çºçæ get_owner ãè¦ã¤ãããªãã¦ä¾å¤ã«ãªã1443 # if get_owner then # error S1030 発生時 get_owner が見つからなくて例外になる 1529 1444 # dbgPrint "Cell#new_join: #{get_owner.get_name}.#{@name}\n" 1530 1445 # else … … 1540 1455 end 1541 1456 1542 #=== Cell. æ°ããéçµå1457 #=== Cell.新しい逆結合 1543 1458 def self.new_reverse_join( reverse_join ) 1544 1459 @@current_object.new_reverse_join( reverse_join ) 1545 1460 end 1546 1461 1547 #=== Cell# æ°ããéçµå1462 #=== Cell#新しい逆結合 1548 1463 def new_reverse_join( reverse_join ) 1549 1464 dbgPrint( "new_reverse_join name=#{reverse_join.get_name}\n") … … 1570 1485 end 1571 1486 1572 #=== Cell# éçµåããçµåãçæ1487 #=== Cell#逆結合から結合を生成 1573 1488 # STAGE: S 1574 1489 def create_reverse_join … … 1580 1495 # @reverse_join_list.get_items.each{ |rj| 1581 1496 @reverse_join_list.each{ |rj| 1582 # éçµåã®æ 1583 å ±ãå¾ã 1497 # 逆結合の情報を得る 1584 1498 ep_name = rj.get_name 1585 1499 ep_subscript, cp_cell_nsp, cp_name, cp_subscript = rj.get_rhs_cell_and_port 1586 1500 1587 # å¼ã³å£å´ã®ã»ã«ã¨ããã®ã»ã«ã¿ã¤ã1501 # 呼び口側のセルと、そのセルタイプ 1588 1502 cell = Namespace.find cp_cell_nsp 1589 1503 if ! cell.instance_of? Cell then … … 1616 1530 end 1617 1531 1618 #=== Cell# cell å 1619 ã«è¨è¿°ããå¼ã³å£ã®å¤é¨çµå 1620 # internal_cell_elem_name:: string : å¼ã³å£å 1621 # export_name:: string: composite ã®å¤é¨ã«å 1622 ¬éããå¼ã³å£å 1623 # å¼ã³å£ãå¤é¨çµåããï¼ 1624 # ãã®ã¡ã½ããã¯ãcomposite ã®ä¸ã® cell ã§ããå¼ã°ããªãï¼ 1532 #=== Cell# cell 内に記述する呼び口の外部結合 1533 # internal_cell_elem_name:: string : 呼び口名 1534 # export_name:: string: composite の外部に公開する呼び口名 1535 # 呼び口を外部結合する. 1536 # このメソッドは、composite の中の cell でしか呼ばれない. 1625 1537 def external_join( internal_cell_elem_name, export_name, b_composite ) 1626 1538 1627 # cCall => composite.cCall; ã§ã¯ãªããï¼1539 # cCall => composite.cCall; ではないか? 1628 1540 if( b_composite == false )then 1629 # cCall => cCall; ã®ãããªå ´å1541 # cCall => cCall; のような場合 1630 1542 if @celltype.find( export_name ) then 1631 1543 cdl_error( "S1036 $1 : cannot refer to $2\'s here. Use \'composite.$3\' to refer to composite celltype\'s" , export_name, @celltype.get_name, export_name ) 1632 1544 end 1633 1545 end 1634 # composite ã®æ§ææ³ã«ããããcell å¤ã® cCall = Cell.cCall; ã®æ§æå¦çã«æ¸¡ã1546 # composite の旧文法における、cell 外の cCall = Cell.cCall; の構文処理に渡す 1635 1547 CompositeCelltype.new_join( export_name, @name, internal_cell_elem_name, :CALL ) 1636 1548 end … … 1644 1556 1645 1557 def end_of_parse f_def 1646 if @b_prototype then # prototype æå®åãã£ãã?1647 f_def = false # ãããã¿ã¤ã宣è¨ã¨ãã1558 if @b_prototype then # prototype 指定子あったか? 1559 f_def = false # プロトタイプ宣言とする 1648 1560 @b_prototype = false 1649 1561 end 1650 1562 if f_def == false then 1651 # cell tCelltype Cell; ã®å½¢å¼ã®å ´å1652 # f_def == true ã®å ´å new_def ã§ãå¼åºããã1563 # cell tCelltype Cell; の形式の場合 1564 # f_def == true の場合 new_def で、呼出される 1653 1565 set_specifier_list( Generator.get_statement_specifier ) 1654 1566 end … … 1660 1572 end 1661 1573 1662 #=== Cell# ãããã¿ã¤ã宣è¨(false)ãå®ç¾©(true)ããè¨å®1663 # ãã®ã¡ã½ããã¯æ§æ解éã®æå¾ã«å¼åºããã1574 #=== Cell# プロトタイプ宣言(false)か定義(true)かを設定 1575 # このメソッドは構文解釈の最後に呼出される 1664 1576 #f_def:: bool false if prototype, true if definition 1665 1577 def set_f_def f_def … … 1680 1592 @f_ref = true 1681 1593 1682 # composite ã®å 1683 é¨ã»ã«ãåç 1684 §ããããã¨ã«ãã 1685 # ä»ã®ã¨ããåé¡ãªãããæªåç 1686 §ã§ããã¹ããã®ã¾ã§åç 1687 §ããããã¨ã«ãªã 1594 # composite の内部セルを参照されたことにする 1595 # 今のところ問題ないが、未参照であるべきものまで参照されたことになる 1688 1596 if @cell_list then 1689 1597 @cell_list.each{ |cn,cell| … … 1693 1601 end 1694 1602 1695 #=== Cell# cell ã®æå®åãè¨å®1603 #=== Cell# cell の指定子を設定 1696 1604 # STAGE: B 1697 1605 # 1698 # bnf.y.rb ã®statement_specifiler_list1606 # bnf.y.rb の statement_specifiler_list 1699 1607 #spec_list:: [ :ALLOCATOR, [ [ :NORMAL_ALLOC, ep_name, subscript, func_name, param_name, expr ], ... ] ] 1700 1608 # s[0] s[1] a[0] a[1] a[2] a[3] a[4] a[5] 1701 # ã»ã«ã«æå®ãããã¢ãã±ã¼ã¿æå®å 1702 # a[1] ã® subscript ã¯ãã®ã¡ã½ããã®ä¸ã§ Expression ãã Integer ã«è©ä¾¡ããã 1703 # åãå£å´ã«çæãããã¢ãã±ã¼ã¿å¼ã³å£ã®çµåãå 1704 é¨çæãã 1705 # å¼ã³å£å´ã¯ Port ã® create_allocator_join ã«ã¦çæ 1706 # ãªã¬ã¼ã¢ãã±ã¼ã¿ã®å ´å create_relay_allocator_join ã«ã¦çæã 1609 # セルに指定されたアロケータ指定子 1610 # a[1] の subscript はこのメソッドの中で Expression から Integer に評価される 1611 # 受け口側に生成されるアロケータ呼び口の結合を内部生成する 1612 # 呼び口側は Port の create_allocator_join にて生成 1613 # リレーアロケータの場合 create_relay_allocator_join にて生成す 1707 1614 def set_specifier_list( spec_list ) 1708 return if spec_list == nil # 空ãªãã°ä½ãããªã1615 return if spec_list == nil # 空ならば何もしない 1709 1616 1710 1617 dbgPrint( "set_spec_list: #{@name}\n" ) 1711 b_generate = false # generate ãæå®ããã1618 b_generate = false # generate が指定された 1712 1619 1713 1620 spec_list.each{ |s| 1714 1621 case s[0] # statement_specifier 1715 1622 when :ALLOCATOR # [allocator(ePort.func.param=allocCell.eA,ePort.func2.param=allocCell.eA)] 1716 s[1].each { |a| # alloc_list : allocator ã®å 1717 é¨ã® ',' ã§åºåãããé¨åã®é 1718 å 1719 cp_name = :"#{a[0+1]}_#{a[2+1]}_#{a[3+1]}" # ã¢ãã±ã¼ã¿å¼ã³å£ã®ååï¼'=' ã®å·¦è¾ºã '.' ã«å¤ã㦠'_' ã§é£çµ 1623 s[1].each { |a| # alloc_list : allocator の内部の ',' で区切られた部分の配列 1624 cp_name = :"#{a[0+1]}_#{a[2+1]}_#{a[3+1]}" # アロケータ呼び口の名前:'=' の左辺を '.' に変えて '_' で連結 1720 1625 # p "#{a[0]} #{a[0+1]} #{a[2+1]} #{a[3+1]} #{cp_name}" 1721 1626 if a[1+1] then … … 1725 1630 subscript = nil 1726 1631 end 1727 # ã¢ãã±ã¼ã¿å¼ã³å£ã®çµåãçæ1728 join = Join.new( cp_name, subscript, a[4+1] ) # æ§æ解æ段éãªã®ã§ locale ä¸è¦1632 # アロケータ呼び口の結合を生成 1633 join = Join.new( cp_name, subscript, a[4+1] ) # 構文解析段階なので locale 不要 1729 1634 dbgPrint( "new allocator join #{cp_name} #{subscript} #{a[4+1]}\n" ) 1730 1635 Cell.new_join( join ) … … 1772 1677 def get_allocator_list 1773 1678 1774 # æå³ãã§ãã¯(set_definition)ããã¦ããªãï¼1775 # relay ã¢ãã±ã¼ã¿ã®å ´åãã»ã«ã®æå³ãã§ãã¯ãè¡ããã¦ããªãã¨ã@alloc_list ãå®æããªã1679 # 意味チェック(set_definition)されていない? 1680 # relay アロケータの場合、セルの意味チェックが行われていないと、@alloc_list が完成しない 1776 1681 if @b_checked == false then 1777 1682 set_definition_join … … 1784 1689 end 1785 1690 1786 #=== id æå®åã®å¤ãè¨å®1787 # ãã®ã¡ã½ããã¯ããã©ã°ã¤ã³ã§ cell ã®çæé åºãå¶å¾¡ãããå ´åã®ããã«è¨ãã1788 # é常㮠id æå®åã§ã¯ä½¿ã£ã¦ããªã1691 #=== id 指定子の値を設定 1692 # このメソッドは、プラグインで cell の生成順序を制御したい場合のために設けた 1693 # 通常の id 指定子では使っていない 1789 1694 def set_specified_id id 1790 1695 if Integer( id ) != id || id <= 0 then … … 1797 1702 end 1798 1703 1799 #=== Cell# ã»ã«ã¿ã¤ããã©ã°ã¤ã³ (generate æå®å)1704 #=== Cell# セルタイププラグイン (generate 指定子) 1800 1705 def cell_plugin 1801 1706 … … 1811 1716 1812 1717 begin 1813 eval( eval_str ) # plugin ãçæ1718 eval( eval_str ) # plugin を生成 1814 1719 plugin_object.set_locale @locale 1815 1720 @generate[ 2 ] = plugin_object … … 1827 1732 end 1828 1733 1829 #=== Cell# cell ã composite ã»ã«ã¿ã¤ãã®ã»ã«ç¨ã« clone ãã 1830 #name:: string : 親 cell ã®åå (cell tComposite cell1 ã§ã® cell1) 1831 #global_name:: string : 親 cell ã® global_name 1832 #join_array:: Join[] : composite ã® cell ã® join ã§ããã® cell ã«å¯¾å¿ãããã® 1833 #ct_name:: string : 親ã»ã«ã®ã»ã«ã¿ã¤ãå 1834 #region:: Region : å 1835 ã®ã»ã«ãå±ãã region 1836 #ãã®ã¡ã½ãã㯠CompositeCelltype ã® expand ããå¼åºããã 1734 #=== Cell# cell を composite セルタイプのセル用に clone する 1735 #name:: string : 親 cell の名前 (cell tComposite cell1 での cell1) 1736 #global_name:: string : 親 cell の global_name 1737 #join_array:: Join[] : composite の cell の join で、この cell に対応するもの 1738 #ct_name:: string : 親セルのセルタイプ名 1739 #region:: Region : 元のセルが属する region 1740 #このメソッドは CompositeCelltype の expand から呼出される 1837 1741 def clone_for_composite( name, global_name, namespacePath, join_array, ct_name, region, plugin, locale ) 1838 1742 … … 1843 1747 @@cloned_cell_list[ self ] = @my_clone 1844 1748 1845 # clone ããã»ã«ã®å 1846 é¨ã«æã¤ååæ 1847 å ±ã調æ´ãã 1749 # clone したセルの内部に持つ名前情報を調整する 1848 1750 1849 1751 @my_clone.set_cloned( name, global_name, namespacePath, join_array, ct_name, region, plugin, locale ) 1850 1752 1851 # @celltype == nil ã¯ä»¥åã«ã»ã«ã¿ã¤ãæªå®ç¾©ã¨ã©ã¼1753 # @celltype == nil は以前にセルタイプ未定義エラー 1852 1754 if @b_defined == true && @celltype != nil then 1853 1755 if @celltype.instance_of?( Celltype ) then 1854 # celltype ã«ç»é²ï¼ã³ã¼ãçæã®å¯¾è±¡ã¨ãªãï¼1756 # celltype に登録(コード生成の対象となる) 1855 1757 @celltype.new_cell( @my_clone ) 1856 1758 end … … 1860 1762 end 1861 1763 1862 #=== Cell# clone ãããã»ã«ã®å 1863 é¨ã«æã¤ååæ 1864 å ±ã調æ´ãã 1865 #name:: string : 親 cell ã®åå (cell tComposite cell1 ã§ã® cell1) 1866 #global_name:: string : 親 cell ã® global_name 1867 #join_array:: Join[] : composite ã® cell ã® join ã§ããã® cell ã«å¯¾å¿ãããã® 1868 #parent_ct_name:: string : 親ã»ã«ã®ã»ã«ã¿ã¤ãåï¼composite ã»ã«ã¿ã¤ãï¼ 1869 # ãã®ã¡ã½ããã¯ããä¸ã® clone_for_composite ããå¼åºãããclone ãããã»ã«ãæ´ãã 1764 #=== Cell# clone されたセルの内部に持つ名前情報を調整する 1765 #name:: string : 親 cell の名前 (cell tComposite cell1 での cell1) 1766 #global_name:: string : 親 cell の global_name 1767 #join_array:: Join[] : composite の cell の join で、この cell に対応するもの 1768 #parent_ct_name:: string : 親セルのセルタイプ名(composite セルタイプ) 1769 # このメソッドはすぐ上の clone_for_composite から呼出され、clone されたセルを整える 1870 1770 def set_cloned( name, global_name, namespacePath, join_array, parent_ct_name, region, plugin, locale ) 1871 1771 … … 1884 1784 @f_cloned = true 1885 1785 1886 # Namespace.new_cell( self ) # mikan namespace 対å¿1887 region.new_cell( self ) # mikan namespace ã« cell ãç½®ããªããã¨ãä»®å®1888 1889 # join_list : NamedList ã® clone ãä½ã1786 # Namespace.new_cell( self ) # mikan namespace 対応 1787 region.new_cell( self ) # mikan namespace に cell を置けないことを仮定 1788 1789 # join_list : NamedList の clone を作る 1890 1790 if @celltype then 1891 1791 dbgPrint "set_cloned: #{@celltype.get_name} #{@name} #{region.get_name}\n" … … 1900 1800 @cell_list2 = [] 1901 1801 1902 # ãã®ã»ã«ã®ã°ãã¼ãã«åãä¸ãã1903 # C_EXP ã®$id$ ç½®æã¯ãã®ã»ã«ã®ååã«ãªã1802 # このセルのグローバル名を与える 1803 # C_EXP の$id$ 置換はこのセルの名前になる 1904 1804 join_array.each { |j| 1905 1805 @join_list.change_item j 1906 1806 } 1907 1807 1908 # clone ãããã¨ããã»ã«ã composit ã»ã«ã¿ã¤ãï¼1808 # clone しようとするセルが composit セルタイプ? 1909 1809 if @celltype.instance_of?( CompositeCelltype ) then 1910 # composite cell ãå帰çã«å±é1810 # composite cell を再帰的に展開 1911 1811 @cell_list, @cell_list2 = @celltype.expand( @name, @global_name, @NamespacePath, @join_list, @region, @plugin, @locale ) 1912 1812 end … … 1914 1814 end 1915 1815 1916 #=== Cell# clone ããã cell ã® join_list ã®å³è¾ºã®å¤æ´1917 # å¼ã³å£ã®å³è¾ºã® cell ãä»ã® clone ããã cell ã«ç½®æã1816 #=== Cell# clone された cell の join_list の右辺の変更 1817 # 呼び口の右辺の cell を他の clone された cell に置換え 1918 1818 def change_rhs_port 1919 1819 … … 1927 1827 if @celltype.instance_of?( CompositeCelltype ) then 1928 1828 1929 # å 1930 ¥ãåã®ã»ã«ã«ã¤ãã¦ãå¤æ´ 1829 # 入れ子のセルについても変更 1931 1830 @cell_list.each{ |name,c| 1932 1831 c.change_rhs_port … … 1967 1866 end 1968 1867 1969 #=== Cell# çæãããã»ã«ãï¼1970 # æé©åãã³ã¼ãçæä¸ã«ã対象ã¨ãªã region ã«å±ããå ´å true ãè¿ã1868 #=== Cell# 生成されるセルか? 1869 # 最適化、コード生成中に、対象となる region に属する場合 true を返す 1971 1870 def is_generate? 1972 1871 if $generating_region == nil then 1973 # æ§æ解éãæå³è§£æ段éã§å¼ã°ããã¨ä¾å¤çºç1872 # 構文解釈、意味解析段階で呼ばれると例外発生 1974 1873 raise "is_generate? called before optimizing" 1975 1874 end … … 1983 1882 end 1984 1883 1985 #=== Cell# composite å 1986 é¨ã®è¤è£½ãããã»ã«ãï¼ 1987 # composite å®ç¾©ã®å 1988 é¨ã®ã»ã« (@in_composite = true) ã§ã¯ãªã 1884 #=== Cell# composite 内部の複製されたセルか? 1885 # composite 定義の内部のセル (@in_composite = true) ではない 1989 1886 def is_cloned? 1990 1887 @f_cloned 1991 1888 end 1992 1889 1993 #=== Cell# composite å 1994 é¨ã®ã»ã«ãï¼ 1890 #=== Cell# composite 内部のセルか? 1995 1891 def is_in_composite? 1996 1892 @in_composite 1997 1893 end 1998 1894 1999 # composite cell ã® port ã«å¯¾å¿ããå 2000 é¨ã® cell ã® port ã®ååï¼ãªã³ã¯æã«å¿ 2001 è¦ãªååï¼ 1895 # composite cell の port に対応する内部の cell の port の名前(リンク時に必要な名前) 2002 1896 def get_real_global_name port_name 2003 1897 if @celltype.instance_of?( CompositeCelltype ) then … … 2027 1921 end 2028 1922 2029 #=== Cell# ã»ã«ã®åãå£ port_name ã«å¯¾ããå®éã®ã»ã«åãåãå£åã '_' ã§é£çµ2030 # namespace å + '_' + ã»ã«å + '_' + åãå£å ï¼ãã®ã»ã«ã composite ãªãã°å±éå¾ã®ã»ã«åãåãå£åï¼1923 #=== Cell# セルの受け口 port_name に対する実際のセル名、受け口名を '_' で連結 1924 # namespace 名 + '_' + セル名 + '_' + 受け口名 (このセルが composite ならば展開後のセル名、受け口名) 2031 1925 def get_real_global_port_name port_name 2032 1926 2033 # composite ãï¼1927 # composite か? 2034 1928 if @celltype.instance_of?( CompositeCelltype ) then 2035 1929 … … 2042 1936 } 2043 1937 2044 # ã»ã«ã¿ã¤ãå 2045 㧠port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçæ段éã§ã¯å¿ 2046 ãè¦ã¤ããï¼ 1938 # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる) 2047 1939 cj = @celltype.find_export( port_name ) 2048 1940 … … 2050 1942 dbgPrint " composite join name: #{cj.get_name} cell: #{cj.get_cell_name} cell elem: #{cj.get_cell_elem_name}\n" 2051 1943 2052 # composite ã®å 2053 é¨ã®ã»ã«ã«å¯¾ãå帰çã« get_real_global_port_name ãé©ç¨ 1944 # composite の内部のセルに対し再帰的に get_real_global_port_name を適用 2054 1945 name = @cell_list[ "#{cj.get_cell_name}" ].get_real_global_port_name( cj.get_cell_elem_name ) 2055 1946 return name … … 2063 1954 end 2064 1955 2065 #=== Cell# PORT (celltype ã®å®ç¾©) ãå¾ã1956 #=== Cell# PORT (celltype の定義) を得る 2066 1957 def get_real_port( port_name ) 2067 1958 2068 # composite ãï¼1959 # composite か? 2069 1960 if @celltype.instance_of?( CompositeCelltype ) then 2070 1961 2071 # ã»ã«ã¿ã¤ãå 2072 㧠port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçæ段éã§ã¯å¿ 2073 ãè¦ã¤ããï¼ 1962 # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる) 2074 1963 cj = @celltype.find_export( port_name ) 2075 1964 2076 # composite ã®å 2077 é¨ã®ã»ã«ã«å¯¾ãå帰çã« get_real_port ãé©ç¨ 1965 # composite の内部のセルに対し再帰的に get_real_port を適用 2078 1966 port = @cell_list[ "#{cj.get_cell_name}" ].get_real_port( cj.get_cell_elem_name ) 2079 1967 return port … … 2084 1972 end 2085 1973 2086 #=== Cell# cell ãå¾ã2087 # composite ã§ãªããã°èªåèªèº«ãè¿ã1974 #=== Cell# cell を得る 1975 # composite でなければ自分自身を返す 2088 1976 def get_real_cell( port_name ) 2089 1977 2090 # composite ãï¼1978 # composite か? 2091 1979 if @celltype.instance_of?( CompositeCelltype ) then 2092 1980 2093 # ã»ã«ã¿ã¤ãå 2094 㧠port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçæ段éã§ã¯å¿ 2095 ãè¦ã¤ããï¼ 1981 # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる) 2096 1982 cj = @celltype.find_export( port_name ) 2097 1983 2098 # composite ã®å 2099 é¨ã®ã»ã«ã«å¯¾ãå帰çã« get_real_port ãé©ç¨ 1984 # composite の内部のセルに対し再帰的に get_real_port を適用 2100 1985 cell = @cell_list[ "#{cj.get_cell_name}" ].get_real_cell( cj.get_cell_elem_name ) 2101 1986 return cell … … 2107 1992 2108 1993 2109 #=== Cell# åãå£ã®port ã®åç 2110 §ã«ã¦ã³ããã¢ãããã 2111 #port_name:: Symbol : ãã¼ãå 1994 #=== Cell# 受け口のport の参照カウントをアップする 1995 #port_name:: Symbol : ポート名 2112 1996 def port_referenced port 2113 1997 if @referenced_port_list[ port ] then … … 2117 2001 end 2118 2002 2119 # composite ãï¼2003 # composite か? 2120 2004 if @celltype.instance_of?( CompositeCelltype ) then 2121 2005 2122 # ã»ã«ã¿ã¤ãå 2123 㧠port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçæ段éã§ã¯å¿ 2124 ãè¦ã¤ããï¼ 2006 # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる) 2125 2007 cj = @celltype.find_export( port.get_name ) 2126 2008 2127 2009 dbgPrint " port_referenced: #{@celltype.get_name} #{@name} cj=#{cj&&(cj.get_name)||"nil"}\n" 2128 2010 2129 if cj then # æ¢ã«ã¨ã©ã¼ 2130 # composite ã®å 2131 é¨ã®ã»ã«ã«å¯¾ãå帰çã« get_real_port ãé©ç¨ 2011 if cj then # 既にエラー 2012 # composite の内部のセルに対し再帰的に get_real_port を適用 2132 2013 cell = @cell_list[ "#{cj.get_cell_name}" ] 2133 2014 if cell && cell.get_celltype then … … 2181 2062 end 2182 2063 2183 #=== Cell# åãå£é 2184 åã®æ·»æ°ã®æ大å¤ãè¨å® 2064 #=== Cell# 受け口配列の添数の最大値を設定 2185 2065 def set_entry_port_max_subscript( port, num ) 2186 2066 dbgPrint( "set_entry_port_max_subscript: #{@name}.#{port.get_name}: #{num}\n" ) … … 2193 2073 end 2194 2074 2195 #=== Cell# composite ã®å 2196 å´ã»ã«ã®åãå£é 2197 åã®æ·»æ°ã®æ大å¤ãè¨å® 2075 #=== Cell# composite の内側セルの受け口配列の添数の最大値を設定 2198 2076 def set_entry_inner_port_max_subscript( port, num ) 2199 if @cell_list == nil then # mikan ããã£ã¦åé¡ãªãï¼ 2200 return # ãããã¿ã¤ã宣è¨ããããã¦ããªãã¦ãå 2201 å´ã»ã«ãå±éããã¦ããªã 2202 end 2203 2204 # composite ã®å 2205 å´ã®ã»ã«ã«ä¼æ 2077 if @cell_list == nil then # mikan これって問題ない? 2078 return # プロトタイプ宣言しかされていなくて、内側セルが展開されていない 2079 end 2080 2081 # composite の内側のセルに伝播 2206 2082 if @celltype.instance_of? CompositeCelltype then 2207 2083 cj = @celltype.find_export port.get_name … … 2217 2093 end 2218 2094 2219 #=== Cell# åãå£é 2220 åã®æ·»æ°ã®æ大å¤ãè¿ã 2221 # é·ã㯠+1 ãã 2222 # 1ã¤ããªãå ´å㯠-1 ãè¿ã 2095 #=== Cell# 受け口配列の添数の最大値を返す 2096 # 長さは +1 する 2097 # 1つもない場合は -1 を返す 2223 2098 def get_entry_port_max_subscript( port ) 2224 2099 subscript = @entry_array_max_subscript[port] … … 2229 2104 end 2230 2105 2231 #=== Cell# ãªã¬ã¼ã¢ãã±ã¼ã¿ã®çµåãçæ2106 #=== Cell# リレーアロケータの結合を生成 2232 2107 # STAGE: S 2233 # å¼ã³å£å´ã®çµåãå 2234 ã«åãå£å´ã®çµåãçæ 2108 # 呼び口側の結合を元に受け口側の結合を生成 2235 2109 def create_relay_allocator_join 2236 2110 2237 # celltype ããªããã°ãã§ãã¯ããªãï¼æ¢ã«ã¨ã©ã¼ï¼2111 # celltype がなければチェックしない(既にエラー) 2238 2112 return if @celltype == nil 2239 2113 2240 # relay allocator ãçæ2114 # relay allocator を生成 2241 2115 @celltype.get_port_list.each { |p| 2242 2116 ail = p.get_allocator_instance … … 2244 2118 dbgPrint "create_relay_allocator_join: #{@name}, #{p.get_name}\n" 2245 2119 if p.get_array_size then 2246 # mikan relay allocator ã array ã«å¯¾å¿ã§ãã¦ãããã®ã§ã¯ï¼2120 # mikan relay allocator が array に対応できてもよいのでは? 2247 2121 cdl_error( "S1040 array not supported for relay allocator" ) 2248 2122 next … … 2252 2126 if ai2[0] == :RELAY_ALLOC then 2253 2127 dbgPrint "create_relay_allocator_join: #{@name}, #{name}\n" 2254 # å¼ã³å£å´ã®çµåãåãåºã2128 # 呼び口側の結合を取り出す 2255 2129 ja = @join_list.get_item( :"#{ai2[3]}_#{ai2[4]}_#{ai2[5]}" ) 2256 2130 if ja == nil then 2257 # è¦ã¤ãããªãå ´å2131 # 見つからない場合 2258 2132 found = false 2259 2133 2260 # composite å 2261 ã§å¤é¨ã«çµåããã¦ããã 2134 # composite 内で外部に結合されているか 2262 2135 if @in_composite then 2263 2136 @compositecelltypejoin_list.get_items.each { |cj| … … 2276 2149 cdl_error( "S1041 \'$1_$2_$3\': not joined. cannot create internal join for relay allocator" , ai2[3], ai2[4], ai2[5] ) 2277 2150 print( " In cell #{get_name}\n" ) 2278 # join ãæªçµåã§ãããã¨ã®ã¨ã©ã¼ã¯äºåº¦ã§ã(S1043)2151 # join が未結合であることのエラーは二度でる (S1043) 2279 2152 end 2280 next # æã¡åã2153 next # 打ち切る 2281 2154 end 2282 2155 2283 2156 b_export = false 2284 # composite å 2285 ã®ã»ã«ã§ã¨ã¯ã¹ãã¼ãããã¦ããããã§ã㯠2286 # mikan ã¨ã¯ã¹ãã¼ãå´ã¨ããã¡ãå´ã§ããªã¬ã¼å 2287 ãä¸è´ããããã§ãã¯ãå¿ 2288 è¦ 2157 # composite 内のセルでエクスポートされているかチェック 2158 # mikan エクスポート側と、こちら側で、リレー先が一致するかチェックが必要 2289 2159 if @compositecelltypejoin_list then 2290 # export ããã¦ããã調ã¹ã2160 # export されているか調べる 2291 2161 @compositecelltypejoin_list.get_items.each{ |cj| 2292 # å±æ§å㨠composite ã® export ããååã¯ä¸è´ããã2162 # 属性名と composite の export する名前は一致するか 2293 2163 if p.get_name == cj.get_cell_elem_name then 2294 2164 print "export : #{p.get_name}\n" 2295 b_export = true # å±æ§ã¯ export ããã¦ããã®ã§ãã¨ããããæªåæåã¨ã¯ããªã2165 b_export = true # 属性は export されているので、とりあえず未初期化とはしない 2296 2166 break 2297 2167 end … … 2300 2170 end 2301 2171 2302 # mikan é 2303 å 2172 # mikan 配列 2304 2173 am = nil 2305 2174 if am then … … 2308 2177 subscript = ja2.get_subscript 2309 2178 if b_export == false then 2310 # CompositeCelltype ã®å ´åãå 2311 å´ã®ã»ã«ã§çæããã 2179 # CompositeCelltype の場合、内側のセルで生成させる 2312 2180 join = Join.new( :"#{p.get_name}_#{ai2[1]}_#{ai2[2]}", subscript, rhs, @loacle ) 2313 2181 # p ( "#{p.get_name}_#{ai2[1]}_#{ai2[2]}", subscript, rhs ) 2314 2182 new_join( join ) 2315 2183 join.set_definition( @celltype.find(join.get_name) ) 2316 # mikan relay mismatch ãã§ãã¯ãã§ãã¦ããªãï¼ä¸æ¹ãåç 2317 §ï¼ 2184 # mikan relay mismatch チェックができていない(下方を参照) 2318 2185 end 2319 2186 @alloc_list << [ :NORMAL_ALLOC, p.get_name, subscript, ai2[1], ai2[2], rhs ] … … 2321 2188 else 2322 2189 if b_export == false then 2323 # CompositeCelltype ã®å ´åãå 2324 å´ã®ã»ã«ã§çæããã 2190 # CompositeCelltype の場合、内側のセルで生成させる 2325 2191 join = Join.new( :"#{p.get_name}_#{ai2[1]}_#{ai2[2]}", nil, ja.get_rhs, @locale ) 2326 2192 new_join( join ) … … 2332 2198 "#{p.get_name}_#{ai2[1]}_#{ai2[2]}", 2333 2199 "#{ai2[3]}_#{ai2[4]}_#{ai2[5]}" ) 2334 # æ¬å½ã¯ composite ã®å¼ã³å£ã¨åãå£ã®éã§è¡ãã¹ãã ããå 2335 é¨ã§å¤æ®µæ¥ç¶ããã¦ããå ´å 2200 # 本当は composite の呼び口と受け口の間で行うべきだが、内部で多段接続されている場合 2336 2201 else 2337 2202 dbgPrint "relay success: #{p.get_name}_#{ai2[1]}_#{ai2[2]}=>#{ai2[3]}_#{ai2[4]}_#{ai2[5]} #{jr.get_rhs_cell2.get_name}.#{jr.get_rhs_port2} \n" … … 2348 2213 end 2349 2214 2350 #=== Cell# @@cell_list2 ãä½ã 2351 # @@cell_list2 ã¯ãåºç¾é ã« composite å 2352 ãå«ãã»ã«ã®ãªã¹ã 2215 #=== Cell# @@cell_list2 を作る 2216 # @@cell_list2 は、出現順に composite 内を含むセルのリスト 2353 2217 def self.make_cell_list2 2354 2218 @@cell_list.each{ |c| … … 2358 2222 end 2359 2223 2360 #=== Cell# @@cell_list2 ãå¾ã 2361 # composite å 2362 ãå«ã (compositeãå«ã) 2363 # æå³è§£æå¾ã«ä½æããã 2224 #=== Cell# @@cell_list2 を得る 2225 # composite 内を含む (compositeも含む) 2226 # 意味解析後に作成される 2364 2227 def self.get_cell_list2 2365 2228 @@cell_list2 2366 2229 end 2367 2230 2368 #=== Cell# @@cell_list ãå¾ã2369 #composite ã®ä¸ãå«ã¾ãªã2231 #=== Cell# @@cell_list を得る 2232 #composite の中を含まない 2370 2233 def self.get_cell_list 2371 2234 @@cell_list 2372 2235 end 2373 2236 2374 #=== Cell# reverse_join ãçæãã2237 #=== Cell# reverse_join を生成する 2375 2238 def self.create_reverse_join 2376 2239 @@cell_list.each{ |c| … … 2384 2247 end 2385 2248 2386 #=== Cell# reverse_require_join ãçæãã2249 #=== Cell# reverse_require_join を生成する 2387 2250 def self.create_reverse_require_join 2388 2251 @@cell_list2.each{ |c| … … 2390 2253 # if c.is_generate? then 2391 2254 if ct then 2392 # self ã¸ã®å¼ã³å£å´ã®çµåãçæ2255 # self への呼び口側の結合を生成 2393 2256 ct.create_reverse_require_join c 2394 2257 end … … 2397 2260 end 2398 2261 2399 #=== Cell# åãå£ã®port ã®åç 2400 §ã«ã¦ã³ããè¨å®ãã 2401 # self ã¯å¼ã³å 2402 ã®ã»ã« 2403 # å¼ã³å 2404 ã»ã«ã®åãå£ã®åç 2405 §ã«ã¦ã³ããã¢ãããã 2262 #=== Cell# 受け口のport の参照カウントを設定する 2263 # self は呼び元のセル 2264 # 呼び先セルの受け口の参照カウントをアップする 2406 2265 def set_port_reference_count 2407 2266 @join_list.get_items.each { |j| 2408 2267 if j.get_definition.instance_of? Port then 2409 2268 am = j.get_array_member2 2410 if am then # å¼ã³å£é 2411 å 2269 if am then # 呼び口配列 2412 2270 am.each { |j2| 2413 next if j2 == nil # optional ã§ä¸é¨ãæ¬ è½ãã¦ããã±ã¼ã¹2271 next if j2 == nil # optional で一部が欠落しているケース 2414 2272 cell = j2.get_rhs_cell2 2415 next if cell == nil # å³è¾ºãè¦ã¤ãããªãã£ãï¼æ¢ã«ã¨ã©ã¼2273 next if cell == nil # 右辺が見つからなかった.既にエラー 2416 2274 port = cell.get_celltype.find( j2.get_rhs_port2 ) 2417 2275 dbgPrint( "set_port_reference_count: #{@name}.#{j2.get_name} => #{cell.get_name}.#{port.get_name}\n") … … 2420 2278 else 2421 2279 cell = j.get_rhs_cell2 2422 next if cell == nil # å³è¾ºãè¦ã¤ãããªãã£ãï¼æ¢ã«ã¨ã©ã¼2280 next if cell == nil # 右辺が見つからなかった.既にエラー 2423 2281 port = cell.get_celltype.find( j.get_rhs_port2 ) 2424 2282 dbgPrint( "set_port_reference_count: #{@name}.#{j.get_name} => #{cell.get_name}.#{port.get_name}\n") … … 2429 2287 end 2430 2288 2431 #=== Cell# çµå(Join)ã®ãã§ãã¯2432 # Join ã¯å¼ã³å£ã®çµåã¾ã㯠attribute ã®åæå2289 #=== Cell# 結合(Join)のチェック 2290 # Join は呼び口の結合または attribute の初期化 2433 2291 # 2434 # mikan ãã®ã¡ã½ããã¯ã以ä¸ã®ï¼ã¤ã®ãã§ãã¯ãããªãããåå²ããã»ããããé©åãªé·ãã®ã¡ã½ããã«ãªã 2435 # ã»ãªã¬ã¼ã¢ãã±ã¼ã¿ã®çæ => create_relay_allocator_join 2436 # ã»æªçµåã®å¼ã³å£ã®ãã§ã㯠2437 # ã»ãã¤ã³ã¿åãé 2438 åã§åæåãããå ´åã®ãã§ã㯠2439 # ã»æªåæåã®å±æ§ã®ãã§ã㯠2292 # mikan このメソッドは、以下の4つのチェックからなるが、分割したほうがより適切な長さのメソッドになる 2293 # ・リレーアロケータの生成 => create_relay_allocator_join 2294 # ・未結合の呼び口のチェック 2295 # ・ポインタ型が配列で初期化される場合のチェック 2296 # ・未初期化の属性のチェック 2440 2297 def check_join 2441 2298 2442 # celltype ããªããã°ãã§ãã¯ããªãï¼æ¢ã«ã¨ã©ã¼ï¼2299 # celltype がなければチェックしない(既にエラー) 2443 2300 return if @celltype == nil 2444 2301 return if @b_defined == false 2445 return if @f_cloned == true # å 2446 é¨ã»ã«ã«ã¤ãã¦ã¯ãcomposite ã®å®ç¾©æã«ãã§ãã¯ããã¦ãã 2302 return if @f_cloned == true # 内部セルについては、composite の定義時にチェックされている 2447 2303 2448 2304 # debug … … 2452 2308 # end 2453 2309 2454 # æªçµåã®å¼ã³å£ã®ãã§ãã¯2310 # 未結合の呼び口のチェック 2455 2311 @celltype.get_port_list.each { |p| 2456 2312 2457 # å¼ã³å£ã§ãªããã°ããã§ãã¯ããªã2313 # 呼び口でなければ、チェックしない 2458 2314 next if p.get_port_type != :CALL 2459 2315 … … 2461 2317 dbgPrint "check_join: #{@name} #{get_celltype.get_name} #{p.get_name}\n" 2462 2318 2463 # çµåãªã¹ãã®ä¸ããå¼ã³å£åã«ä¸è´ãããã®ãåãã ã2319 # 結合リストの中から呼び口名に一致するものを取りだす 2464 2320 j = @join_list.get_item( p.get_name ) 2465 2321 2466 2322 if j == nil then 2467 # æªçµåã®å¼ã³å£ 2468 2469 # composite celltype ã®å 2470 é¨ã®å ´åãcomposite celltype ã export ããå¼ã³å£ã«çµåããã¦ãããæ¢ã 2323 # 未結合の呼び口 2324 2325 # composite celltype の内部の場合、composite celltype が export する呼び口に結合されているか探す 2471 2326 found = false 2472 2327 if @in_composite then 2473 # composite celltype ã® export ãããã®ãã¹ã¦ããæ¢ã2474 # ï¼export ãããã®ã®å³è¾ºå¤ããæ¢ãããã« get_item ã§ã¯ãã¡ï¼2328 # composite celltype の export するものすべてから探す 2329 # (export するものの右辺値から探すために get_item ではダメ) 2475 2330 @compositecelltypejoin_list.get_items.each{ |cj| 2476 # å¼ã³å£å㨠composite ã® export ããååã¯ä¸è´ããã2331 # 呼び口名と composite の export する名前は一致するか 2477 2332 if p.get_name == cj.get_cell_elem_name then 2478 2333 found = true … … 2481 2336 end 2482 2337 2483 # å¼ã³å£é 2484 åã®å ´å optional ã§å 2485 ¨ã¦ã®è¦ç´ ãåæåãããªãå ´åã«ãããã¸æ¥ã 2338 # 呼び口配列の場合 optional で全ての要素が初期化されない場合に、ここへ来る 2486 2339 if ! found && ! p.is_require? && ! p.is_optional? then 2487 2340 if ! p.is_allocator_port? then … … 2492 2345 end 2493 2346 elsif p.get_array_size.kind_of? Integer then 2494 # æ·»æ°ããå¼ã³å£é 2495 åã®å ´åããã¹ã¦ã®æ·»æ°è¦ç´ ãåæåããã¦ããããã§ãã¯ãã 2347 # 添数あり呼び口配列の場合、すべての添数要素が初期化されているかチェックする 2496 2348 2497 2349 am = j.get_array_member2 2498 2350 if( am )then 2499 # join ã¯é 2500 å 2501 2502 # å¼ã³å£é 2503 åå®ç¾©ã§ã®é 2504 åã®å¤§ãã 2351 # join は配列 2352 2353 # 呼び口配列定義での配列の大きさ 2505 2354 length = p.get_array_size 2506 2355 2507 # é 2508 åã®å¤§ãããå¼ã³å£é 2509 åå®ç¾©ã¨çµåå®ç¾©ã§ä¸è´ãããï¼ 2356 # 配列の大きさが呼び口配列定義と結合定義で一致するか? 2510 2357 if am.length != length then 2511 2358 if ! p.is_optional? || am.length >= length then 2512 # optional ã®å ´åãè¦ç´ æ°ãå°ãªãããã®ã¯OK2359 # optional の場合、要素数が少なすぎるのは OK 2513 2360 cdl_error( "S1044 $1: array initializer too many or few, $2 for $3" , p.get_name, am.length, length ) 2514 2361 end 2515 2362 2516 # am ã®è¦ç´ ã« nil ã追å ãã¦ãã (#_CPA_# ã®ã³ã¼ãçææããã®é 2517 åè¦ç´ æ°åçæ) 2363 # am の要素に nil を追加しておく (#_CPA_# のコード生成時、この配列要素数分生成) 2518 2364 i = am.length 2519 2365 while i < length … … 2523 2369 end 2524 2370 2525 # # é 2526 åè¦ç´ ã®æãããªãããã§ã㯠2527 # if am.length < length then # æºããªãå ´åæ¢ã«ã¨ã©ã¼ã ãè¦ç´ ã®ããç¯å²ã§ãã§ã㯠2371 # # 配列要素の抜けがないかチェック 2372 # if am.length < length then # 満たない場合既にエラーだが要素のある範囲でチェック 2528 2373 # length = am.length 2529 2374 # end … … 2535 2380 end 2536 2381 else 2537 # çæãããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯2382 # 生成されないリージョンへの結合かチェック 2538 2383 if ! @in_composite then 2539 2384 am[i].check_region2 … … 2544 2389 2545 2390 # else 2546 # join ãéé 2547 åã§ããã°ãæ¢ã«ã¨ã©ã¼ 2391 # join が非配列であれば、既にエラー 2548 2392 end 2549 2393 elsif j.get_array_member then 2550 # æ·»æ°ãªãå¼ã³å£é 2551 åã®å ´å 2394 # 添数なし呼び口配列の場合 2552 2395 am = j.get_array_member2 2553 2396 length = am.length … … 2562 2405 end 2563 2406 2564 # çæãããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯2407 # 生成されないリージョンへの結合かチェック 2565 2408 if ! @in_composite then 2566 2409 am.each { |join| … … 2571 2414 end 2572 2415 else 2573 # å¼ã³å£ï¼»é 2574 åãã§ãªãå ´å 2575 2576 # çæãããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ã㯠2416 # 呼び口[配列」でない場合 2417 2418 # 生成されないリージョンへの結合かチェック 2577 2419 if ! @in_composite then 2578 2420 j.check_region2 … … 2582 2424 } 2583 2425 2584 # ãã¤ã³ã¿åãé 2585 åã§åæåãããå ´åã®ãã§ã㯠2426 # ポインタ型が配列で初期化される場合のチェック 2586 2427 (@celltype.get_attribute_list+@celltype.get_var_list).each { |a| 2587 2428 if a.get_size_is then 2588 2429 2589 2430 if a.instance_of? CompositeCelltypeJoin then 2590 # æ¢ã«ã¨ã©ã¼ã«ãªã£ã¦ãã2431 # 既にエラーになっている 2591 2432 # cdl_error( "S1047 size_is pointer cannot be exposed for composite attribute" ) 2592 2433 next … … 2598 2439 size = a.get_size_is.eval_const( @join_list, @celltype.get_name_list ) 2599 2440 a.get_type.set_scs( a.get_size_is, nil, nil, nil, false ) 2600 if( ! size.kind_of? Integer )then # C_EXP ã®å¯è½æ§ãã2601 # mikan å¤åããã§ã®ã¨ã©ã¼çºçã¯ä¸è¦ãeval_const ã®ä¸ã§å¤æ°ãåå¨ããªããåãä¸é©åãªã©ã®ã¨ã©ã¼ã«ãªãã¯ã2441 if( ! size.kind_of? Integer )then # C_EXP の可能性あり 2442 # mikan 多分ここでのエラー発生は不要、eval_const の中で変数が存在しない、型が不適切などのエラーになるはず 2602 2443 cdl_error( "S1049 $1: size_is arg not constant" , a.get_name ) 2603 2444 else … … 2615 2456 end 2616 2457 else 2617 # size_is å¼æ°ãã»ã«ã§æå®ããã¦ãã¦ãåæååãã»ã«ã¿ã¤ãã§æå®ããã¦ããã±ã¼ã¹ã®ãã§ãã¯2458 # size_is 引数がセルで指定されていて、初期化子がセルタイプで指定されているケースのチェック 2618 2459 ini = a.get_initializer 2619 2460 if ini.instance_of? Expression … … 2630 2471 else 2631 2472 if ! a.instance_of? CompositeCelltypeJoin then 2632 # composite 㯠size_is æå®ã§ããªã2473 # composite は size_is 指定できない 2633 2474 if a.get_type.kind_of?( PtrType ) then 2634 2475 j = @join_list.get_item( a.get_identifier ) 2635 2476 if j && j.get_rhs.instance_of?( Array ) then 2636 ## size_is æå®ããã¦ããªããã¤ã³ã¿ã Array ã§åæåããã¦ããããã¨ã©ã¼ã¨ãã2477 ## size_is 指定されていないポインタが Array で初期化されていたら、エラーとする 2637 2478 cdl_error( "S1169 $1: non-size_is pointer cannot be initialized with array initializer" , a.get_identifier ) 2638 2479 end … … 2642 2483 } 2643 2484 2644 # æªåæåã®å±æ§ããã§ãã¯2485 # 未初期化の属性をチェック 2645 2486 @celltype.get_attribute_list.each { |a| 2646 2487 b_init = false 2647 2488 # self.show_tree 1 2648 if a.get_initializer then # ã»ã«ã¿ã¤ãã§åæåããã¦ãã2489 if a.get_initializer then # セルタイプで初期化されている 2649 2490 b_init = true 2650 # @in_composite 㧠export ããã¦ããå ´åã«ã¯ããã®åæå¤ã¯ä½¿ãããªã2651 # export ããã¦ãããããªãã«é¢ããããåæåããã¦ãããã¨ãä¿è¨¼ããã2652 elsif @join_list.get_item( a.get_name ) then # ã»ã«ã§åæåããã¦ãã2491 # @in_composite で export されている場合には、この初期値は使われない 2492 # export されている、いないに関わらず、初期化されていることが保証される 2493 elsif @join_list.get_item( a.get_name ) then # セルで初期化されている 2653 2494 b_init = true 2654 2495 elsif @in_composite && @compositecelltypejoin_list then 2655 # å±æ§ã export ããã¦ããã調ã¹ããexport ããã¦ããã°æªåæåã¨ã¯ããªã2656 # mikan ãªãã¢ãµã¼ã2496 # 属性が export されているか調べる。export されていれば未初期化とはしない 2497 # mikan リニアサーチ 2657 2498 @compositecelltypejoin_list.get_items.each{ |cj| 2658 # å±æ§å㨠composite ã® export ããååã¯ä¸è´ããã2499 # 属性名と composite の export する名前は一致するか 2659 2500 if a.get_name.to_sym == cj.get_cell_elem_name.to_sym then 2660 b_init = true # å±æ§ã¯ export ããã¦ããã®ã§ãã¨ããããæªåæåã¨ã¯ããªã2501 b_init = true # 属性は export されているので、とりあえず未初期化とはしない 2661 2502 end 2662 2503 } 2663 2504 if b_init then 2664 # size_is ã®å¼æ°ããããããããã§ãã¯ãã 2665 # å 2666 é¨ã»ã«ã® size_is ãã¨ã¯ã¹ãã¼ããã size_is ã¨ãããããããã§ãã¯ãã 2667 # å 2668 é¨ã»ã«ã¨ã¨ã¯ã¹ãã¼ãã§ååãå¤ãã¦ããå¯è½æ§ãããã®ã§ãå 2669 é¨ã»ã«ã® size_is ã®ååãå¤æããä¸ã§ãã§ãã¯ãã 2505 # size_is の引数がマッチするかチェックする 2506 # 内部セルの size_is をエクスポートする size_is とマッチするかチェックする 2507 # 内部セルとエクスポートで名前を変えている可能性があるので、内部セルの size_is の名前を変換した上でチェックする 2670 2508 if a.get_size_is then 2671 2509 ### p "attr: get_size_is" … … 2673 2511 if cj.get_port_decl.instance_of? Decl then 2674 2512 ### p "attr: get_size_is 2" 2675 # cj_size_is ã¯ãå¤é¨å 2676 ¬éããã attr ã® size_is 2513 # cj_size_is は、外部公開される attr の size_is 2677 2514 cj_size_is = cj.get_port_decl.get_size_is 2678 2515 if cj_size_is == nil then … … 2683 2520 remain = exprs 2684 2521 inner_to_export = {} 2685 ### exprs ã«å«ã¾ããèå¥åãæãåºãã対å¿ãã export ãããååãæ¢ã2522 ### exprs に含まれる識別子を抜き出し、対応する export される名前を探す 2686 2523 while remain != "" && remain != nil 2687 2524 ### p "remain ", remain 2688 remain =~ /([^\w]*)([_A-Za-z][\w\d]*)/ # å¤æ°åæååãåãåºã2525 remain =~ /([^\w]*)([_A-Za-z][\w\d]*)/ # 変数名文字列を取り出す 2689 2526 if $2 == nil then 2690 2527 break … … 2693 2530 remain = $' 2694 2531 ### p exprs, $1, $2, $' 2695 # size_is ã«å«ã¾ããå¤æ°ã¯ãcomposite 㧠export ããã¦ããã2532 # size_is に含まれる変数は、composite で export されているか 2696 2533 cj2 = nil 2697 2534 @compositecelltypejoin_list.get_items.each{ |cj2t| … … 2706 2543 if cj2.get_port_decl.instance_of? Decl then 2707 2544 decl2 = cj2.get_port_decl 2708 # å 2709 é¨ã®ååã¨å¤é¨ã®ååã®å¯¾å¿é¢ä¿ãè¨æ¶ 2545 # 内部の名前と外部の名前の対応関係を記憶 2710 2546 inner_to_export[arg_name] = decl2.get_name 2711 # else cj2 㯠Port (æ¢ã«ã¨ã©ã¼)2547 # else cj2 は Port (既にエラー) 2712 2548 end 2713 2549 end 2714 # å 2715 é¨ã®ååãå¤é¨ã®ååã§ç½®æ 2550 # 内部の名前を外部の名前で置換 2716 2551 inner_to_export.each{ |arg_name, exp_name| 2717 2552 ### p "changing #{arg_name}=>#{exp_name}" 2718 2553 # exprs.gsub!( Regexp.new("#{arg_name}[^0-9A-Za-z_]"), exp_name.to_s ) 2719 exprs.gsub!( Regexp.new("#{arg_name}(\\W)"), exp_name.to_s+"\\1" ) # æååæ«å°¾ã«ãªãã±ã¼ã¹2720 exprs.gsub!( Regexp.new("#{arg_name}\\Z"), exp_name.to_s ) # æååæ«å°¾ã«ããã±ã¼ã¹2554 exprs.gsub!( Regexp.new("#{arg_name}(\\W)"), exp_name.to_s+"\\1" ) # 文字列末尾にないケース 2555 exprs.gsub!( Regexp.new("#{arg_name}\\Z"), exp_name.to_s ) # 文字列末尾にあるケース 2721 2556 } 2722 2557 ### p "changed: #{exprs} #{cj_size_is.to_s}" … … 2724 2559 cdl_error( "S1172 \'$1\' size_is argument mismatch with exporting one \'$2\'", a.get_name, cj.get_name ) 2725 2560 end 2726 # else cj 㯠Port (æ¢ã«ã¨ã©ã¼)2561 # else cj は Port (既にエラー) 2727 2562 end 2728 2563 end … … 2737 2572 end 2738 2573 2739 #=== Cell# é require ããã§ãã¯ãã 2740 # é require æå®ãããåãå£ã«è¤æ°ã®çµåããªãããã§ãã¯ãã 2741 # composite ã®å 2742 é¨ã»ã« (f_cloned=true) ããã§ãã¯ãã 2574 #=== Cell# 逆 require をチェックする 2575 # 逆 require 指定された受け口に複数の結合がないかチェックする 2576 # composite の内部セル (f_cloned=true) もチェックする 2743 2577 def check_reverse_require 2744 # celltype ããªããã°ãã§ãã¯ããªãï¼æ¢ã«ã¨ã©ã¼ï¼2578 # celltype がなければチェックしない(既にエラー) 2745 2579 return if @celltype == nil 2746 2580 return if @b_defined == false 2747 2581 2748 2582 # p "check reverse require #{@name}" 2749 # érequire æå®ãããåãå£ã«è¤æ°ã®çµåããªãããã§ãã¯2583 # 逆require 指定された受け口に複数の結合がないかチェック 2750 2584 @referenced_port_list.each{ |port,count| 2751 2585 # p port.class, count … … 2757 2591 end 2758 2592 2759 #=== Cell# require å¼ã³å£ã®çµåãè¡ã2593 #=== Cell# require 呼び口の結合を行う 2760 2594 # STAGE: S 2761 #cp_name:: Symbol : å¼ã³å£å2762 #cell_or_t:: Celltype|Cell : celltype ã® require ã®å³è¾ºã§æå®ãããã»ã«ã¿ã¤ãã¾ãã¯ã»ã«2763 #port:: Port : celltype ã® Port ãªãã¸ã§ã¯ã2595 #cp_name:: Symbol : 呼び口名 2596 #cell_or_t:: Celltype|Cell : celltype の require の右辺で指定されたセルタイプまたはセル 2597 #port:: Port : celltype の Port オブジェクト 2764 2598 def set_require_join( cp_name, cell_or_ct, port ) 2765 2599 2766 # set_require_join ã¯2度å¼ã³åºããã2767 # 2 度ç®ã¯ post ã³ã¼ããçæããå¾ ##### ãã£ããè¦åããï¼éè¤ã¨ã©ã¼ãè¦éãï¼2600 # set_require_join は2度呼び出される 2601 # 2度目は post コードを生成した後 ##### いったん見合わせ(重複エラーを見逃す) 2768 2602 # if @require_joined_list[ cp_name ] then 2769 2603 # return … … 2782 2616 end 2783 2617 else 2784 # require: cell ã§æå®2618 # require: cell で指定 2785 2619 cell = cell_or_ct 2786 2620 if @region.distance( cell.get_region ) == nil then … … 2792 2626 cdl_warning( "W1003 $1 : require call port overridden in $2" , cp_name, @name ) 2793 2627 else 2794 # require ã® join ãçæ(å¼ã³å£ã®çµå)2628 # require の join を生成(呼び口の結合) 2795 2629 # rhs = Expression.new( [ :OP_DOT, [ :IDENTIFIER, Token.new( cell.get_name, nil, nil, nil ) ], 2796 2630 nsp = NamespacePath.new( cell.get_name, false, cell.get_namespace ) … … 2805 2639 end 2806 2640 2807 #=== Cell# Join ã® definition ã®è¨å®ã¨ãã§ãã¯2641 #=== Cell# Join の definition の設定とチェック 2808 2642 # STAGE: S 2809 2643 def set_definition_join 2810 return if @celltype == nil # æ¢ã«ã¨ã©ã¼ï¼æã¡åã2811 return if @b_defined == false # ãããã¿ã¤ã宣è¨ã®ã¿2812 return if @b_checked == true # æ¢ã«è¨å®ï¼ãã§ãã¯ï¼æ¸ã¿2644 return if @celltype == nil # 既にエラー:打ち切る 2645 return if @b_defined == false # プロトタイプ宣言のみ 2646 return if @b_checked == true # 既に設定(チェック)済み 2813 2647 2814 2648 dbgPrint "set_definition_join in #{@name}\n" 2815 2649 2816 # relay allocator ããã©ã£ã¦åå 2817 ¥ããªããããå 2818 é 㧠@b_checked ã true ã«ãã 2650 # relay allocator をたどって再入しないよう、先頭で @b_checked を true にする 2819 2651 @b_checked = true 2820 2652 … … 2822 2654 check_restrict_list 2823 2655 2824 # compoiste ã»ã«ã®ã¯ãã¼ã³ããããã®ã¯ãset_definition ä¸è¦ 2825 # å 2826 ã® join ã¯æ¢ã« definition ããã¦ãã 2827 # å 2828 ã®ã»ã«ã«ããã¦ã代å 2829 ¥ãã§ãã¯ããã¦ããã®ã§ãäºéã«ãã§ãã¯(throughé©ç¨)ããã¦ãã¾ã 2656 # compoiste セルのクローンされたものは、set_definition 不要 2657 # 元の join は既に definition されている 2658 # 元のセルにおいて、代入チェックされているので、二重にチェック(through適用)されてしまう 2830 2659 @join_list.get_items.each{ |join| 2831 2660 dbgPrint " set_definition_join: checking #{@name}.#{join.get_name}\n" … … 2833 2662 port = @celltype.find(join.get_name) 2834 2663 join.get_array_member2.each { |am| 2835 if am == nil then # æªçµåã®å ´åãã¨ã©ã¼ãã§ãã¯ã¯check_join2664 if am == nil then # 未結合の場合、エラーチェックは check_join 2836 2665 if port && ! port.is_optional? then 2837 # ãã¹ãç¨ã«ã¨ã©ã¼ã¡ãã»ã¼ã¸åºå2666 # テスト用にエラーメッセージ出力 2838 2667 # cdl_error( "TEMPORAL set_definition_join: uninitialized array member" ) 2839 2668 end … … 2848 2677 end 2849 2678 2850 # ãªã¬ã¼ join 㯠through ãã©ã°ã¤ã³çæå¾ã«ããã§ããªã 2851 # through å¾ã«çµåå 2852 ãå 2853 ¥ãæ¿ãããã 2679 # リレー join は through プラグイン生成後にしかできない 2680 # through 後に結合先が入れ替えられる 2854 2681 create_relay_allocator_join 2855 2682 2856 # composite ã»ã«ã®å±é2683 # composite セルの展開 2857 2684 if ! @in_composite && ! @f_cloned && @celltype.instance_of?( CompositeCelltype ) then 2858 # composite ã»ã«ã¿ã¤ãå 2859 ã® composite ã¯å±éããªã 2860 # compoiste ã»ã«å±éä¸ã® composite ã¯å±éããªã (CompositeCelltype::expand å 2861 ã§å帰çã« expnad) 2685 # composite セルタイプ内の composite は展開しない 2686 # compoiste セル展開中の composite は展開しない (CompositeCelltype::expand 内で再帰的に expnad) 2862 2687 expand 2863 2688 end 2864 2689 2865 # celltype ã« generate ãæå®ããããã¦ããã2690 # celltype に generate が指定されされているか 2866 2691 celltype_plugin = @celltype.get_celltype_plugin 2867 2692 if celltype_plugin then … … 2875 2700 end 2876 2701 2877 #=== Cell# composite ã»ã«ã®å±é2878 # ãã®ã»ã«ã composite ã»ã«ã¿ã¤ã2702 #=== Cell# composite セルの展開 2703 # このセルが composite セルタイプ 2879 2704 def expand 2880 2705 … … 2882 2707 dbgPrint "expanding #{@name} #{@celltype.get_name}\n" 2883 2708 2884 # å±éãããã»ã«ã®ãªã¹ã2709 # 展開されたセルのリスト 2885 2710 @@cloned_cell_list = {} 2886 2711 2887 # composite celltype ã® cell ãå±é2712 # composite celltype の cell を展開 2888 2713 @cell_list, @cell_list2 = @celltype.expand( @name, @global_name, @NamespacePath, @join_list, @region, @plugin, @locale ) 2889 2714 2890 # ãããã¿ã¤ããåç 2891 §ããã¦ããå ´åãåãåç 2892 §ããã¦ãããã¨ã«ãã 2715 # プロトタイプが参照されている場合、子も参照されていることにする 2893 2716 if @f_ref then 2894 2717 dbgPrint "expand: set_f_ref\n" … … 2896 2719 end 2897 2720 2898 # å¼ã³å£ã®å³è¾ºã®ã»ã«ã clone ãããã®ã«å¤æ´2721 # 呼び口の右辺のセルを clone したものに変更 2899 2722 self.change_rhs_port 2900 2723 2901 # ãããã¿ã¤ã宣è¨ã§è¨å®ããã¦ãããã®ãåæ ãã2724 # プロトタイプ宣言で設定されていたものを反映する 2902 2725 @entry_array_max_subscript.each{ |port,name| 2903 2726 set_entry_inner_port_max_subscript( port, name ) … … 2905 2728 end 2906 2729 2907 #=== Cell#restrict ã追å2730 #=== Cell#restrict を追加 2908 2731 def add_restrict( entry_name, func_name, region_name_list ) 2909 2732 if @restrict_list[ entry_name ] then … … 2994 2817 puts "entry array #{port.get_name}: max subscript=#{num}" 2995 2818 } 2996 if @cell_list then # ãã㧠@cell_list ã nil ãªã®ã¯Bug2819 if @cell_list then # ここで @cell_list が nil なのは Bug 2997 2820 (indent+1).times { print " " } 2998 2821 puts "cloned cell list:" … … 3018 2841 subscript = "" 3019 2842 end 3020 # ã¢ãã±ã¼ã¿å¼ã³å£ã®çµåãçæ2843 # アロケータ呼び口の結合を生成 3021 2844 (indent+2).times { print " " } 3022 2845 puts "#{cp_name}#{subscript} = #{a[4+1]}" … … 3042 2865 # @real_singleton:: bool : has singleton cell in this composite celltype 3043 2866 # @real_active:: bool : has active cell in this composite celltype 3044 # @name_list:: NamedList item: Decl (attribute), Port ã¨ã¯ã¹ãã¼ãå®ç¾©2867 # @name_list:: NamedList item: Decl (attribute), Port エクスポート定義 3045 2868 # @internal_allocator_list:: [ [cell, internal_cp_name, port_name, func_name, param_name, ext_alloc_ent], ... ] 3046 2869 … … 3082 2905 3083 2906 Namespace.new_compositecelltype( self ) 3084 set_namespace_path # @NamespacePath ã®è¨å®2907 set_namespace_path # @NamespacePath の設定 3085 2908 3086 2909 @port_list = [] … … 3098 2921 def end_of_parse 3099 2922 3100 # singleton ã«é¢ãããã§ãã¯2923 # singleton に関するチェック 3101 2924 if @b_singleton && @real_singleton == nil then 3102 2925 cdl_warning( "W1004 $1 : specified singleton but has no singleton in this celltype" , @name ) … … 3107 2930 end 3108 2931 3109 # active ã«é¢ãããã§ãã¯2932 # active に関するチェック 3110 2933 if @b_active && @real_active == nil then 3111 2934 cdl_error( "S1054 $1 : specified active but has no active in this celltype" , @name ) … … 3114 2937 end 3115 2938 3116 # @allocator_instance ãè¨å®ãã2939 # @allocator_instance を設定する 3117 2940 @name_list.get_items.each{ |n| 3118 2941 if n.instance_of? Port then … … 3121 2944 } 3122 2945 3123 # ãªã¬ã¼ã¢ãã±ã¼ã¿ã® entry å´2946 # リレーアロケータの entry 側 3124 2947 @port_list.each{ |p| 3125 2948 if p.get_port_type == :ENTRY then … … 3135 2958 end 3136 2959 } 3137 # mikan relay ãæ£ããæãã¦ããããã§ãã¯ããã¦ããªã3138 3139 # æå³è§£æ2960 # mikan relay が正しく抜けているかチェックされていない 2961 2962 # 意味解析 3140 2963 @cell_list.get_items.each{ |c| 3141 2964 c.set_definition_join 3142 2965 } 3143 2966 3144 # cell ã®æªçµåã®å¼ã³å£ããªãããã§ãã¯2967 # cell の未結合の呼び口がないかチェック 3145 2968 @cell_list.get_items.each{ |c| 3146 2969 c.check_join … … 3148 2971 } 3149 2972 3150 # å¼ã³å£ã®çµåã«ã¤ãã¦ãexport ã¨å 3151 é¨çµåã®ä¸¡æ¹ããªãããã§ã㯠3152 # ãªã¬ã¼ã¢ãã±ã¼ã¿ãå 3153 é¨ã¢ãã±ã¼ã¿ã®è¨å® 2973 # 呼び口の結合について、export と内部結合の両方がないかチェック 2974 # リレーアロケータ、内部アロケータの設定 3154 2975 @port_list.each{ |p| 3155 2976 p.check_dup_init 3156 2977 } 3157 2978 3158 # ãã¹ã¦ã®ã¨ã¯ã¹ãã¼ãå®ç¾©ã«å¯¾å¿ããå¼ã³å£ãåãå£ãå±æ§ãåå¨ããããã§ãã¯2979 # すべてのエクスポート定義に対応した呼び口、受け口、属性が存在するかチェック 3159 2980 @name_list.get_items.each{ |n| 3160 2981 if( @export_name_list.get_item( n.get_name ) == nil )then … … 3163 2984 } 3164 2985 3165 # å 3166 é¨ã¢ãã±ã¼ã¿ãè¨å®ãã 2986 # 内部アロケータを設定する 3167 2987 @internal_allocator_list.each{ |cell, cp_internal_name, port_name, fd_name, par_name, ext_alloc_ent| 3168 2988 res = ext_alloc_ent.get_allocator_rhs_elements( :INTERNAL_ALLOC ) … … 3195 3015 cell.set_owner self # Cell (in_omposite) 3196 3016 @cell_list.add_item( cell ) 3197 if cell.get_celltype then # nil ãªãã°ããã§ã«ã»ã«ã¿ã¤ããªãã¨ã©ã¼3017 if cell.get_celltype then # nil ならば、すでにセルタイプなしエラー 3198 3018 if cell.get_celltype.is_singleton? then 3199 3019 @real_singleton = cell … … 3213 3033 end 3214 3034 3215 #=== CompositeCelltype# CompositeCelltypeJoin ãä½æ3035 #=== CompositeCelltype# CompositeCelltypeJoin を作成 3216 3036 # STAGE: B 3217 #export_name:: Symbol : å¤é¨ã«å 3218 ¬éããåå 3219 #internal_cell_name:: Symbol : å 3220 é¨ã»ã«å 3221 #internal_cell_elem_name:: Symbol : å 3222 é¨ã»ã«ã®è¦ç´ åï¼å¼ã³å£åãåãå£åãå±æ§åã®ããããï¼ 3223 #type:: :CALL, :ENTRY, :ATTRIBUTE ã®ããããï¼æ§æè¦ç´ ã¨ãã¦ããã¹ããã®ï¼ 3224 #RETURN:: Decl | Port : ã¨ã¯ã¹ãã¼ãå®ç¾© 3225 # new_join 㯠3226 # cCall => composite.cCall; (ã»ã«å 3227 ) 3228 # attr = composite.attr; (ã»ã«å 3229 ) 3230 # composite.eEnt => cell2.eEnt; (ã»ã«å¤) 3231 # ã®æ§æè¦ç´ ã®åºç¾ã«å¯¾ãã¦å¼ã³åºããã 3037 #export_name:: Symbol : 外部に公開する名前 3038 #internal_cell_name:: Symbol : 内部セル名 3039 #internal_cell_elem_name:: Symbol : 内部セルの要素名(呼び口名、受け口名、属性名のいずれか) 3040 #type:: :CALL, :ENTRY, :ATTRIBUTE のいずれか(構文要素としてあるべきもの) 3041 #RETURN:: Decl | Port : エクスポート定義 3042 # new_join は 3043 # cCall => composite.cCall; (セル内) 3044 # attr = composite.attr; (セル内) 3045 # composite.eEnt => cell2.eEnt; (セル外) 3046 # の構文要素の出現に対して呼び出される 3232 3047 def new_join( export_name, internal_cell_name, 3233 3048 internal_cell_elem_name, type ) … … 3242 3057 3243 3058 celltype = cell.get_celltype 3244 return if celltype == nil # celltype == nil ãªããã§ã«ã¨ã©ã¼ 3245 3246 # å 3247 é¨ã»ã«ã®ã»ã«ã¿ã¤ããã対å¿è¦ç´ ãæ¢ã 3248 # ãã®ã¡ã½ããã¯ãæ§æä¸ãå¼ã³å£ãåãå£ãå±æ§ãè¨è¿°ã§ããç®æããå¼åºããã 3249 # æ§æä¸ã®å¼åºãä½ç½®ï¼è¨è¿°ä½ç½®ï¼ã¨ãè¦ç´ ã対å¿ãããã®ããã§ã㯠3059 return if celltype == nil # celltype == nil ならすでにエラー 3060 3061 # 内部セルのセルタイプから対応要素を探す 3062 # このメソッドは、構文上、呼び口、受け口、属性が記述できる箇所から呼出される 3063 # 構文上の呼出し位置(記述位置)と、要素が対応したものかチェック 3250 3064 obj = celltype.find( internal_cell_elem_name ) 3251 3065 if obj.instance_of?( Decl ) then … … 3255 3069 elsif type != :ATTRIBUTE then 3256 3070 cdl_error( "S1059 \'$1\' : exporting attribute. write in cell or use \'=\' to export attribute" , export_name ) 3257 # return 次ã®ã¨ã©ã¼ãé¿ããããã«å¦çç¶è¡ããä»ãå ãã¦ã¿ã3071 # return 次のエラーを避けるために処理続行し、付け加えてみる 3258 3072 end 3259 3073 elsif obj.instance_of?( Port ) then 3260 3074 if obj.get_port_type != type then 3261 3075 cdl_error( "S1060 \'$1\' : port type mismatch. $2 type is allowed here." , export_name, type ) 3262 # return 次ã®ã¨ã©ã¼ãé¿ããããã«å¦çç¶è¡ããä»ãå ãã¦ã¿ã3076 # return 次のエラーを避けるために処理続行し、付け加えてみる 3263 3077 end 3264 3078 else … … 3268 3082 end 3269 3083 3270 # ã¨ã¯ã¹ãã¼ãå®ç¾©ã¨ä¸è´ãããã©ãããã§ãã¯3084 # エクスポート定義と一致するかどうかチェック 3271 3085 obj2 = @name_list.get_item( export_name ) 3272 3086 if( obj2 == nil )then … … 3284 3098 elsif obj.get_signature != obj2.get_signature then 3285 3099 if obj.get_signature != nil && obj2.get_signature != nil then 3286 # nil ãªãã°æ¢ã«ã¨ã©ã¼ãªã®ã§å ±åããªã3100 # nil ならば既にエラーなので報告しない 3287 3101 cdl_error( "S1066 $1 : signature \'$2\' mismatch with previous definition \'$3\'" , export_name, obj.get_signature.get_name, obj2.get_signature.get_name ) 3288 3102 end … … 3309 3123 if obj.instance_of?( Decl ) then 3310 3124 # attribute 3311 # # å 3312 é¨ããå¤é¨ã¸è¤æ°ã®çµåããªãããã§ã㯠3125 # # 内部から外部へ複数の結合がないかチェック 3313 3126 # found = false 3314 3127 # @attr_list.each{ |a| … … 3323 3136 else 3324 3137 # call/entry port 3325 # # å 3326 é¨ããå¤é¨ã¸è¤æ°ã®çµåããªãããã§ã㯠3138 # # 内部から外部へ複数の結合がないかチェック 3327 3139 # found = false 3328 3140 # @port_list.each{ |port| … … 3337 3149 end 3338 3150 3339 # join ã @export_name_list ã«ç»é²ï¼éè¤ãã§ãã¯ã¨ã¨ãã«ï¼å¾ã§è¡ããã CompositeCelltypeJoin ã® clone ã«åããï¼3151 # join を @export_name_list に登録(重複チェックとともに,後で行われる CompositeCelltypeJoin の clone に備える) 3340 3152 if obj.instance_of?( Decl ) && @export_name_list.get_item( export_name ) then 3341 # æ¢ã«åå¨ããã追å ããªããæ°ä»æ§ã§ã¯ã@export_name_list ã«åãååãå«ã¾ãããã¨ãããã3153 # 既に存在する。追加しない。新仕様では、@export_name_list に同じ名前が含まれることがある。 3342 3154 elsif obj.instance_of?( Port ) && obj.get_port_type == :CALL && @export_name_list.get_item( export_name ) then 3343 # æ¢ã«åå¨ããã追å ããªããæ°ä»æ§ã§ã¯ã@export_name_list ã«åãååãå«ã¾ãããã¨ãããã3155 # 既に存在する。追加しない。新仕様では、@export_name_list に同じ名前が含まれることがある。 3344 3156 else 3345 3157 @export_name_list.add_item( join ) 3346 3158 end 3347 3159 3348 # export ãããã¼ãã«å«ã¾ãã send/receive ãã©ã¡ã¼ã¿ã®ã¢ãã±ã¼ã¿(allocator)å¼ã³å£ãã»ã«ã¨çµå3160 # export するポートに含まれる send/receive パラメータのアロケータ(allocator)呼び口をセルと結合 3349 3161 if obj2.instance_of? Port then 3350 3162 obj2.each_param{ |port, fd, par| 3351 case par.get_direction # å¼æ°ã®æ¹åæå®å(in, out, inout, send, receive )3163 case par.get_direction # 引数の方向指定子 (in, out, inout, send, receive ) 3352 3164 when :SEND, :RECEIVE 3353 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # ã¢ãã±ã¼ã¿å¼ã³å£ã®åå3354 # ãã¼ãå é¢æ°å ãã©ã¡ã¼ã¿å3165 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # アロケータ呼び口の名前 3166 # ポート名 関数名 パラメータ名 3355 3167 cp_internal_name = :"#{internal_cell_elem_name}_#{fd.get_name}_#{par.get_name}" 3356 3168 3357 # ãªã¬ã¼ã¢ãã±ã¼ã¿ or å 3358 é¨ã¢ãã±ã¼ã¿æå®ããªããã¦ããå ´åãã¢ãã±ã¼ã¿å¼ã³å£ã追å ããªã 3359 # ãã®æç¹ã§ã¯ get_allocator_instance ã§ã¯å¾ãããªããã tmp ãå¾ã 3169 # リレーアロケータ or 内部アロケータ指定がなされている場合、アロケータ呼び口を追加しない 3170 # この時点では get_allocator_instance では得られないため tmp を得る 3360 3171 if port.get_allocator_instance_tmp then 3361 3172 found = false … … 3365 3176 3366 3177 if s[0] == :INTERNAL_ALLOC then 3367 # å 3368 é¨ã¢ãã±ã¼ã¿ã®å ´å # mikan ããã¯å 3369 é¨ã®ã»ã«ã«ç´çµãããå¤é¨ã®ãã¼ãã«æ¹ããã¹ã 3178 # 内部アロケータの場合 # mikan これは内部のセルに直結する。外部のポートに改めるべき 3370 3179 @internal_allocator_list << [ cell, cp_internal_name, port.get_name, fd.get_name, par.get_name, s[3] ] 3371 3180 end … … 3377 3186 end 3378 3187 3379 # å¤é¨ã¢ãã±ã¼ã¿ã®å ´å3188 # 外部アロケータの場合 3380 3189 new_join( cp_name, internal_cell_name, cp_internal_name, :CALL ) 3381 3190 end … … 3383 3192 end 3384 3193 3385 # ã¨ã¯ã¹ãã¼ãå®ç¾©ãè¿ã3194 # エクスポート定義を返す 3386 3195 return obj2 3387 3196 end … … 3405 3214 @name_list.add_item port 3406 3215 3407 # export ãããã¼ãã«å«ã¾ãã send/receive ãã©ã¡ã¼ã¿ã®ã¢ãã±ã¼ã¿å¼ã³å£ã® export ãçæãã¦ãã¼ãã«è¿½å 3408 # ãã®æç¹ã§ã¯å 3409 é¨ã¢ãã±ã¼ã¿ãã©ããå¤æã§ããªãã®ã§ãã¨ããããçæãã¦ãã 3216 # export するポートに含まれる send/receive パラメータのアロケータ呼び口の export を生成してポートに追加 3217 # この時点では内部アロケータかどうか判断できないので、とりあえず生成しておく 3410 3218 port.each_param { |port, fd, par| 3411 case par.get_direction # å¼æ°ã®æ¹åæå®å(in, out, inout, send, receive )3219 case par.get_direction # 引数の方向指定子 (in, out, inout, send, receive ) 3412 3220 when :SEND, :RECEIVE 3413 #### ãªã¬ã¼ã¢ãã±ã¼ã¿ or å 3414 é¨ã¢ãã±ã¼ã¿æå®ããªããã¦ããå ´åãã¢ãã±ã¼ã¿å¼ã³å£ã追å ããªã 3415 # å 3416 é¨ã¢ãã±ã¼ã¿æå®ããªããã¦ããå ´åãã¢ãã±ã¼ã¿å¼ã³å£ã追å ããªã 3417 # ãã®æç¹ã§ã¯ get_allocator_instance ã§ã¯å¾ãããªããã tmp ãå¾ã 3221 #### リレーアロケータ or 内部アロケータ指定がなされている場合、アロケータ呼び口を追加しない 3222 # 内部アロケータ指定がなされている場合、アロケータ呼び口を追加しない 3223 # この時点では get_allocator_instance では得られないため tmp を得る 3418 3224 if port.get_allocator_instance_tmp then 3419 3225 found = false … … 3430 3236 3431 3237 if par.get_allocator then 3432 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # ã¢ãã±ã¼ã¿å¼ã³å£ã®åå 3433 # ãã¼ãå é¢æ°å ãã©ã¡ã¼ã¿å 3434 alloc_sig_path = [ par.get_allocator.get_name ] # mikan Namespace ã¢ãã±ã¼ã¿å¼ã³å£ã®ã·ã°ãã㣠3435 array_size = port.get_array_size # å¼ã³å£ã¾ãã¯åãå£é 3436 åã®ãµã¤ãº 3437 created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # å¼ã³å£ãçæ 3238 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # アロケータ呼び口の名前 3239 # ポート名 関数名 パラメータ名 3240 alloc_sig_path = [ par.get_allocator.get_name ] # mikan Namespace アロケータ呼び口のシグニチャ 3241 array_size = port.get_array_size # 呼び口または受け口配列のサイズ 3242 created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # 呼び口を生成 3438 3243 created_port.set_allocator_port( port, fd, par ) 3439 3244 if port.is_omit? then 3440 3245 created_port.set_omit 3441 3246 end 3442 new_port( created_port ) # ã»ã«ã¿ã¤ãã«æ°ããå¼ã³å£ã追å3247 new_port( created_port ) # セルタイプに新しい呼び口を追加 3443 3248 # else 3444 3249 # already error … … 3457 3262 attribute.each { |a| 3458 3263 a.set_owner self # Decl (CompositeCelltype) 3459 # V1.1.0.10 composite ã® attr ã® size_is ã¯å¯ã¨ãªã£ã3264 # V1.1.0.10 composite の attr の size_is は可となった 3460 3265 # if a.get_size_is then 3461 3266 # cdl_error( "S1070 $1: size_is pointer cannot be exposed for composite attribute" , a.get_name ) … … 3468 3273 end 3469 3274 3470 #=== CompositeCelltype# érequire ã®çµåãçæãã3275 #=== CompositeCelltype# 逆require の結合を生成する 3471 3276 def create_reverse_require_join cell 3472 3277 @name_list.get_items.each{ |n| … … 3493 3298 return @name_list.get_item( name ) 3494 3299 3495 # å¾æ¥ä»æ§3300 # 従来仕様 3496 3301 # cj = @export_name_list.get_item( name ) 3497 3302 #p "#{name}, #{cj.get_port_decl}" … … 3503 3308 end 3504 3309 3505 #=== CompositeCelltype# export ãã CompositeCelltypeJoin ãå¾ã3310 #=== CompositeCelltype# export する CompositeCelltypeJoin を得る 3506 3311 #name:: string: 3507 # attribute ã®å ´åãåãååã«å¯¾ãè¤æ°åå¨ããå¯è½æ§ãããããæåã®ãã®ããè¿ããªã3312 # attribute の場合、同じ名前に対し複数存在する可能性があるが、最初のものしか返さない 3508 3313 def find_export name 3509 3314 return @export_name_list.get_item( name ) 3510 3315 end 3511 3316 3512 #=== CompositeCelltype# composite celltype ã® cell ãå±é3513 #name:: string: Composite cell ã®åå3514 #global_name:: string: Composite cell ã® global name (C è¨èªå)3515 #join_list:: NamedList : Composite cell ã«å¯¾ãã Join ã®NamedList3317 #=== CompositeCelltype# composite celltype の cell を展開 3318 #name:: string: Composite cell の名前 3319 #global_name:: string: Composite cell の global name (C 言語名) 3320 #join_list:: NamedList : Composite cell に対する Join の NamedList 3516 3321 #RETURN: 3517 3322 # [ { name => cell }, [ cell, ... ] ] 3518 # æ»ãå¤ å㯠ååâcloneãããå 3519 é¨ã»ã«ãå¾ã㯠composite ã®åºç¾é ã®ãªã¹ã 3323 # 戻り値 前は 名前⇒cloneされた内部セル、後ろは composite の出現順のリスト 3520 3324 def expand( name, global_name, namespacePath, join_list, region, plugin, locale ) 3521 3325 … … 3526 3330 } 3527 3331 3528 # å±é㧠clone ãããã»ã«ã®ãªã¹ããå³è¾ºã¯ Cell (composite ã®å ´å composite 㪠cell ã®clone)3332 # 展開で clone されたセルのリスト、右辺は Cell (composite の場合 composite な cell の clone) 3529 3333 clone_cell_list = {} 3530 3334 clone_cell_list2 = [] 3531 3335 3532 # composite å 3533 é¨ã®ãã¹ã¦ã® cell ã«ã¤ã㦠3336 # composite 内部のすべての cell について 3534 3337 @cell_list.get_items.each { |c| 3535 3338 … … 3537 3340 dbgPrint "expand : cell #{c.get_name}\n" 3538 3341 3539 # Join ã®é 3540 å 3342 # Join の配列 3541 3343 ja = [] 3542 3344 3543 # CompositeCelltype ã export ããå¼ã³å£ãåãå£ãå±æ§ã®ãªã¹ãã«ã¤ãã¦3345 # CompositeCelltype が export する呼び口、受け口、属性のリストについて 3544 3346 # @export_name_list.get_items.each{ |cj| # cj: CompositeCelltypeJoin 3545 # æ°ä»æ§ã§ã¯ã@export_name_list ã«å 3546 ¥ã£ã¦ããªã attr ããããã 3347 # 新仕様では、@export_name_list に入っていない attr がありうる 3547 3348 (@port_list+@attr_list).each{ |cj| # cj: CompositeCelltypeJoin 3548 3349 … … 3550 3351 dbgPrint " cj : #{cj.get_name}\n" 3551 3352 3552 # CompositeCelltypeJoin (export) ã®å¯¾è±¡ã»ã«ãï¼3353 # CompositeCelltypeJoin (export) の対象セルか? 3553 3354 if cj.match?( c ) then 3554 3355 3555 # 対象ã»ã«å 3556 ã® CompositeCelltype ã® export ãã Join (attribute ã¾ã㯠call port) 3356 # 対象セル内の CompositeCelltype の export する Join (attribute または call port) 3557 3357 j = join_list.get_item( cj.get_name ) 3558 3358 … … 3565 3365 3566 3366 if j then 3567 # å¼ã³å£ãå±æ§ã®å ´å3568 # ComositeCell ç¨ã®ãã®(j) ã対象ã»ã«ç¨ã« clone (@through_list ãã³ãã¼ããã)3367 # 呼び口、属性の場合 3368 # ComositeCell 用のもの(j) を対象セル用に clone (@through_list もコピーされる) 3569 3369 # p "expand: cloning Join #{j.get_name} #{@name} #{name}" 3570 3370 jc = j.clone_for_composite( @name, name, locale ) … … 3574 3374 # p "cn #{jc.get_name} #{cj.get_cell_elem_name}" 3575 3375 3576 # 対象ã»ã«ã®å¼ã³å£ã¾ãã¯å±æ§ã®ååã«å¤æ´3376 # 対象セルの呼び口または属性の名前に変更 3577 3377 jc.change_name( cj.get_cell_elem_name ) 3578 3378 3579 # 対象ã»ã«ã«å¯¾ãã Join ã®é 3580 å 3379 # 対象セルに対する Join の配列 3581 3380 ja << jc 3582 3381 end … … 3590 3389 dbgPrint "expand : clone #{name}_#{c.get_name}\n" 3591 3390 3592 # ã»ã«ã® clone ãçæ3391 # セルの clone を生成 3593 3392 # clone_cell_list[ "#{name}_#{c.get_name}" ] = c.clone_for_composite( name, global_name, ja ) 3594 3393 c2 = c.clone_for_composite( name, global_name, namespacePath, ja, @name, region, plugin, locale ) … … 3600 3399 clone_cell_list.each { |nm,c| 3601 3400 dbgPrint " cloned: #{nm} = #{c.get_global_name}\n" 3602 # join ã® owner ã clone ãããã»ã«ã«å¤æ´ããV1.1.0.253401 # join の owner を clone されたセルに変更する V1.1.0.25 3603 3402 c.get_join_list.get_items.each{ |j| 3604 3403 j.set_cloned( clone_cell_list[ "#{c.get_local_name}" ] ) … … 3608 3407 end 3609 3408 3610 #=== CompositeCelltype æå®åãªã¹ãã®è¨å®3409 #=== CompositeCelltype 指定子リストの設定 3611 3410 def set_specifier_list( spec_list ) 3612 3411 return if spec_list == nil … … 3639 3438 3640 3439 def get_var_list 3641 [] # 空ã®é 3642 åãè¿ã 3440 [] # 空の配列を返す 3643 3441 end 3644 3442 … … 3647 3445 end 3648 3446 3649 #== CompositeCelltype# generate æå®åã®æ 3650 å ± 3651 # CompositeCelltype ã«ã¯ generate ãæå®ã§ããªãã®ã§ nil ãè¿ã 3652 # Celltype::@generate ãåç 3653 §ã®ã㨠3447 #== CompositeCelltype# generate 指定子の情報 3448 # CompositeCelltype には generate が指定できないので nil を返す 3449 # Celltype::@generate を参照のこと 3654 3450 def get_celltype_plugin 3655 3451 nil … … 3664 3460 end 3665 3461 3666 #=== CompositeCelltype# ã¢ã¯ãã£ãã§ã¯ãªã 3667 # active ã§ã¯ãªãã«å ããå 3668 ¨ã¦ã®å 3669 é¨ã»ã«ã®ã»ã«ã¿ã¤ãã inactive ã®å ´åã« inactive 3670 # ï¼å 3671 é¨ã®ã»ã«ã active ã¾ã㯠factory ãæã£ã¦ããï¼ 3462 #=== CompositeCelltype# アクティブではない 3463 # active ではないに加え、全ての内部セルのセルタイプが inactive の場合に inactive 3464 # (内部のセルが active または factory を持っている) 3672 3465 def is_inactive? 3673 3466 if @b_active == false then 3674 3467 @cell_list.get_items.each{ |c| 3675 3468 if c.get_celltype && c.get_celltype.is_inactive? == false then 3676 # c.get_celltype == nil ã®å ´åã¯ã»ã«ã¿ã¤ãæªå®ç¾©ã§ãã§ã«ã¨ã©ã¼3469 # c.get_celltype == nil の場合はセルタイプ未定義ですでにエラー 3677 3470 return false 3678 3471 end … … 3714 3507 3715 3508 3716 #== æ§æè¦ç´ ï¼å£ã表ãã¯ã©ã¹ï¼ã»ã«ã¿ã¤ãã®å¼ã³å£ãåãå£ï¼3509 #== 構文要素:口を表すクラス(セルタイプの呼び口、受け口) 3717 3510 class Port < BDNode 3718 3511 # @name:: str … … 3720 3513 # @port_type:: :CALL, :ENTRY 3721 3514 # @array_size:: nil: not array, "[]": sizeless, Integer: sized array 3722 # @reverse_require_cell_path:: NamespacePath : érequireå¼ã³å 3723 ã»ã« mikan namespace (å¼ã³å£ã®ã¿æå®å¯è½) 3724 # @reverse_require_callport_name:: Symbol: érequireå¼ã³å 3725 ã»ã«ã®å¼ã³å£å 3515 # @reverse_require_cell_path:: NamespacePath : 逆require呼び元セル mikan namespace (呼び口のみ指定可能) 3516 # @reverse_require_callport_name:: Symbol: 逆require呼び元セルの呼び口名 3726 3517 # 3727 # set_allocator_port ã«ãã£ã¦è¨å®ãããï¼è¨å®ãããå ´åããã®ãã¼ãã¯ã¢ãã±ã¼ã¿ãã¼ãã§ããã 3728 # @allocator_port:: Port : ãã®å¼ã³å£ãã§ããå 3729 ã¨ãªã£ãå¼ã³å£ã¾ãã¯åãå£ 3730 # @allocator_func_decl:: Decl : ãã®å¼ã³å£ãã§ããå 3731 ã¨ãªã£ãå¼ã³å£ã¾ãã¯åãå£ã®é¢æ° 3732 # @allocator_param_decl:: ParamDecl : ãã®å¼ã³å£ãã§ããå 3733 ã¨ãªã£ãå¼ã³å£ã¾ãã¯åãå£ã®ãã©ã¡ã¼ã¿ 3518 # set_allocator_port によって設定される.設定された場合、このポートはアロケータポートである。 3519 # @allocator_port:: Port : この呼び口ができる元となった呼び口または受け口 3520 # @allocator_func_decl:: Decl : この呼び口ができる元となった呼び口または受け口の関数 3521 # @allocator_param_decl:: ParamDecl : この呼び口ができる元となった呼び口または受け口のパラメータ 3734 3522 # 3735 # set_specifier ã«ãã£ã¦è¨å®ããã(3523 # set_specifier によって設定される( 3736 3524 # @allocator_instance:: Hash : {"func_param" => [ :RELAY_ALLOC, func_name, param_name, rhs_cp_name, rhs_func_name, rhs_param_name ]} 3737 3525 # [:INTERNAL_ALLOC, func_name, param_name, rhs_ep_name ] … … 3739 3527 # function parameter rhs 3740 3528 # 3741 # @b_require:: bool : require ã«ããçæããã call port ã®å ´åtrue3742 # @b_has_name:: bool : require : ååããã®ãªã¯ã¯ã¤ã¢å¼ã³å£3743 # @b_inline:: bool : entry port ã®ã¿3744 # @b_omit:: bool : omit æå®åãæå®ããã (call port ã®ã¿)3745 # @b_optional:: bool : call port ã®ã¿3746 # @b_ref_des:: bool : ref_desc ãã¼ã¯ã¼ããæå®ããã3747 # @b_dynamic:: bool : dynamic ãã¼ã¯ã¼ããæå®ããã (å¼ã³å£ã®ã¿)3529 # @b_require:: bool : require により生成された call port の場合 true 3530 # @b_has_name:: bool : require : 名前ありのリクワイア呼び口 3531 # @b_inline:: bool : entry port のみ 3532 # @b_omit:: bool : omit 指定子が指定された (call port のみ) 3533 # @b_optional:: bool : call port のみ 3534 # @b_ref_des:: bool : ref_desc キーワードが指定された 3535 # @b_dynamic:: bool : dynamic キーワードが指定された (呼び口のみ) 3748 3536 # 3749 3537 # optimize:: 3750 # @celltype:: å±ããã»ã«ã¿ã¤ã3538 # @celltype:: 属するセルタイプ 3751 3539 # 3752 # :CALL ã®å ´åã®æé©å 3753 # @b_VMT_useless:: bool # VMT é¢æ°ãã¼ãã«ã使ç¨ããªã 3754 # @b_skelton_useless:: bool # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã) 3755 # @b_cell_unique:: bool # å¼ã³å 3756 ã¯å¯ä¸ã®ã»ã« 3757 # @only_callee_port:: Port # å¯ä¸ã®å¼ã³å 3758 ãã¼ã 3759 # @only_callee_cell:: Cell # å¯ä¸ã®å¼ã³å 3760 ã»ã« (@b_PEPDES_in_CB_useless = true ã®ææå¹) 3540 # :CALL の場合の最適化 3541 # @b_VMT_useless:: bool # VMT 関数テーブルを使用しない 3542 # @b_skelton_useless:: bool # スケルトン関数不要 (true の時、受け口関数を呼出す) 3543 # @b_cell_unique:: bool # 呼び先は唯一のセル 3544 # @only_callee_port:: Port # 唯一の呼び先ポート 3545 # @only_callee_cell:: Cell # 唯一の呼び先セル (@b_PEPDES_in_CB_useless = true の時有効) 3761 3546 # 3762 # :ENTRY ã®å ´åã®æé©åï¼å¼ã³å£æé©åã¨åãå¤æ°åã使ç¨ï¼3763 # @b_VMT_useless:: bool # VMT é¢æ°ãã¼ãã«ãä¸è¦3764 # @b_skelton_useless:: bool # ã¹ã±ã«ãã³é¢æ°ä¸è¦3547 # :ENTRY の場合の最適化(呼び口最適化と同じ変数名を使用) 3548 # @b_VMT_useless:: bool # VMT 関数テーブルが不要 3549 # @b_skelton_useless:: bool # スケルトン関数不要 3765 3550 3766 3551 def initialize( name, sig_path, port_type, array_size = nil, reverse_require_cell_path = nil, reverse_require_entry_port_name = nil ) … … 3778 3563 @array_size = array_size.eval_const(nil) 3779 3564 else 3780 @array_size = array_size # ããã¯ã¢ãã±ã¼ã¿å¼ã³å£ã®å ´åï¼å 3781 ã®å¼ã³å£ã§æ¢ã«è©ä¾¡æ¸ã¿ï¼ 3565 @array_size = array_size # これはアロケータ呼び口の場合(元の呼び口で既に評価済み) 3782 3566 end 3783 3567 if @array_size == nil then … … 3794 3578 object = Namespace.find( sig_path ) #1 3795 3579 if object == nil then 3796 # mikan signature ã®ååãä¸å®å 3797 ¨ 3580 # mikan signature の名前が不完全 3798 3581 cdl_error( "S1075 \'$1\' signature not found" , sig_path ) 3799 3582 elsif ! object.instance_of?( Signature ) then 3800 # mikan signature ã®ååãä¸å®å 3801 ¨ 3583 # mikan signature の名前が不完全 3802 3584 cdl_error( "S1076 \'$1\' not signature" , sig_path ) 3803 3585 else … … 3806 3588 end 3807 3589 3808 # érequire3590 # 逆require 3809 3591 @reverse_require_cell_path = nil 3810 3592 @reverse_require_entry_port_name = nil … … 3816 3598 @reverse_require_entry_port_name = reverse_require_entry_port_name 3817 3599 3818 # åãå£é 3819 åãï¼ 3600 # 受け口配列か? 3820 3601 if array_size then 3821 3602 cdl_error( "S1153 $1: cannot be entry port array for fixed join port", @name ) 3822 3603 end 3823 3604 3824 # å¼ã³å£ã®ã»ã«ã¿ã¤ããæ¢ã3605 # 呼び口のセルタイプを探す 3825 3606 ct_or_cell = Namespace.find( @reverse_require_cell_path ) #1 3826 3607 if ct_or_cell.instance_of? Cell then … … 3837 3618 3838 3619 if ct == nil then 3839 return # æ¢ã«ã¨ã©ã¼ 3840 end 3841 3842 # æ·»ãåãªãã®å¼ã³å£é 3843 åãï¼ 3620 return # 既にエラー 3621 end 3622 3623 # 添え字なしの呼び口配列か? 3844 3624 port = ct.find( @reverse_require_entry_port_name ) 3845 3625 if port == nil || port.get_port_type != :CALL … … 3863 3643 end 3864 3644 3865 #=== Port# æé©åã«é¢ããå¤æ°ããªã»ãããã3866 # Region ãã¨ã«æé©åã®ãããªãããããããããªã»ãããã3645 #=== Port#最適化に関する変数をリセットする 3646 # Region ごとに最適化のやりなおしをするため、リセットする 3867 3647 def reset_optimize 3868 3648 if @port_type == :CALL then 3869 3649 # call port optimize 3870 @b_VMT_useless = false # VMT ä¸è¦ (true ã®æ VMT ãä»ãããã¨ãªãå¼åºã) 3871 @b_skelton_useless = false # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã) 3872 @b_cell_unique = false # å¯ä¸ã®å¼ã³å 3873 ã»ã« 3874 @only_callee_port = nil # å¯ä¸ã®å¼ã³å 3875 ãã¼ã 3876 @only_callee_cell = nil # å¯ä¸ã®å¼ã³å 3877 ã»ã« 3650 @b_VMT_useless = false # VMT 不要 (true の時 VMT を介することなく呼出す) 3651 @b_skelton_useless = false # スケルトン関数不要 (true の時、受け口関数を呼出す) 3652 @b_cell_unique = false # 唯一の呼び先セル 3653 @only_callee_port = nil # 唯一の呼び先ポート 3654 @only_callee_cell = nil # 唯一の呼び先セル 3878 3655 else 3879 3656 # entry port optimize 3880 3657 if $unopt then 3881 # æé©åãªã3882 @b_VMT_useless = false # VMT ä¸è¦ (true ã®æ VMT ãä»ãããã¨ãªãå¼åºã)3883 @b_skelton_useless = false # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã)3658 # 最適化なし 3659 @b_VMT_useless = false # VMT 不要 (true の時 VMT を介することなく呼出す) 3660 @b_skelton_useless = false # スケルトン関数不要 (true の時、受け口関数を呼出す) 3884 3661 else 3885 # æé©åãã3886 @b_VMT_useless = true # VMT ä¸è¦ (true ã®æ VMT ãä»ãããã¨ãªãå¼åºã)3887 @b_skelton_useless = true # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã)3662 # 最適化あり 3663 @b_VMT_useless = true # VMT 不要 (true の時 VMT を介することなく呼出す) 3664 @b_skelton_useless = true # スケルトン関数不要 (true の時、受け口関数を呼出す) 3888 3665 end 3889 3666 end … … 3914 3691 end 3915 3692 3916 #=== Port# ã¢ãã±ã¼ã¿ãã¼ãã®è¨å® 3917 #port:: Port : send/receive ã®ãã£ãå¼ã³å£ã¾ãã¯åãå£ 3918 #fd:: Decl : é¢æ°ã® declarator 3919 #par:: ParamDecl : send/receive ã®ãã£ãå¼æ° 3920 # ãã®å¼ã³å£ãçæããããã¨ã«ãªã£ãå¼ã³å£ã¾ãã¯åãå£ã®æ 3921 å ±ãè¨å® 3693 #=== Port# アロケータポートの設定 3694 #port:: Port : send/receive のあった呼び口または受け口 3695 #fd:: Decl : 関数の declarator 3696 #par:: ParamDecl : send/receive のあった引数 3697 # この呼び口が生成されるもとになった呼び口または受け口の情報を設定 3922 3698 def set_allocator_port( port, fd, par ) 3923 3699 @allocator_port = port … … 3951 3727 end 3952 3728 3953 #=== Port# require å¼ã³å£ãååãæã¤ï¼3954 # require éå®3729 #=== Port# require 呼び口が名前を持つ? 3730 # require 限定 3955 3731 def has_name? 3956 3732 @b_has_name … … 3965 3741 end 3966 3742 3967 #=== Port# omit æå®ããã¦ãã?3743 #=== Port# omit 指定されている? 3968 3744 def is_omit? 3969 3745 @b_omit || ( @signature && @signature.is_empty? ) … … 3974 3750 end 3975 3751 3976 def set_VMT_useless # VMT é¢æ°ãã¼ãã«ã使ç¨ããªã3752 def set_VMT_useless # VMT 関数テーブルを使用しない 3977 3753 @b_VMT_useless = true 3978 3754 end 3979 3755 3980 def set_skelton_useless # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã)3756 def set_skelton_useless # スケルトン関数不要 (true の時、受け口関数を呼出す) 3981 3757 @b_skelton_useless = true 3982 3758 end 3983 3759 3984 def set_cell_unique # å¼ã³å 3985 ã»ã«ã¯ä¸ã¤ã ã 3760 def set_cell_unique # 呼び先セルは一つだけ 3986 3761 @b_cell_unique = true 3987 3762 end 3988 3763 3989 #=== Port# å¼ã³å£/åãå£ã®æå®åã®è¨å®3990 # inline, allocator ã®æå®3764 #=== Port# 呼び口/受け口の指定子の設定 3765 # inline, allocator の指定 3991 3766 def set_specifier spec_list 3992 3767 spec_list.each { |s| … … 4033 3808 end 4034 3809 4035 #=== Port# ãªã¬ã¼ã¢ãã±ã¼ã¿ãå 4036 é¨ã¢ãã±ã¼ã¿ã®ã¤ã³ã¹ã¿ã³ã¹ãè¨å® 4037 # å¼ã³å£ã®åæ¹åç 4038 §å¯è½ãªããã«ãã»ã«ã¿ã¤ãã®è§£éã®æå¾ã§è¡ã 3810 #=== Port# リレーアロケータ、内部アロケータのインスタンスを設定 3811 # 呼び口の前方参照可能なように、セルタイプの解釈の最後で行う 4039 3812 def set_allocator_instance 4040 3813 if @allocator_instance_tmp == nil then … … 4049 3822 case alloc_type 4050 3823 when :INTERNAL_ALLOC 4051 if ! @owner.instance_of? CompositeCelltype then # ãã¹ãé²ãããã« composite ã§ãªããã°ã¨ãã4052 cdl_error( "S1081 self allocator not supported yet" ) # mikan ããã¯ãµãã¼ãããã¦ããã¯ããè¦èª¿æ»12/1/153824 if ! @owner.instance_of? CompositeCelltype then # ミスを防ぐために composite でなければとした 3825 cdl_error( "S1081 self allocator not supported yet" ) # mikan これはサポートされているはず。要調査 12/1/15 4053 3826 next 4054 3827 end … … 4057 3830 # OK 4058 3831 when :NORMAL_ALLOC 4059 # ããã¸æ¥ãã®ã¯ composite ã®åãå£ã§å³è¾ºã "eEnt.func.param" å½¢å¼ã§æå®ããã¦ããå ´å3832 # ここへ来るのは composite の受け口で右辺が "eEnt.func.param" 形式で指定されていた場合 4060 3833 cdl_error( "S1174 $1 not suitable for lhs, suitable lhs: 'func.param'", "#{ai[1]}.#{ai[3]}.#{ai[4]}" ) 4061 3834 next … … 4064 3837 end 4065 3838 4066 # '=' 左辺(func_name,param_name)ã¯å®å¨ããã?4067 if @signature then # signature = nil ãªãæ¢ã«ã¨ã©ã¼3839 # '=' 左辺(func_name,param_name)は実在するか? 3840 if @signature then # signature = nil なら既にエラー 4068 3841 fh = @signature.get_function_head( ai[1] ) 4069 3842 if fh == nil then … … 4073 3846 decl = fh.get_declarator 4074 3847 if ! decl.is_function? then 4075 next # æ¢ã«ã¨ã©ã¼3848 next # 既にエラー 4076 3849 end 4077 3850 paramdecl = decl.get_type.get_paramlist.find( ai[2] ) … … 4090 3863 end 4091 3864 4092 # éè¤æå®ããªãã?3865 # 重複指定がないか? 4093 3866 if @allocator_instance[ "#{@name}_#{ai[1]}_#{ai[2]}" ] then 4094 3867 cdl_error( "S1085 duplicate allocator specifier for \'$1_$2\'" , ai[1], ai[2] ) 4095 3868 end 4096 3869 4097 # å³è¾ºã®ãã§ãã¯3870 # 右辺のチェック 4098 3871 case alloc_type 4099 3872 when :INTERNAL_ALLOC … … 4105 3878 end 4106 3879 4107 ep_name = ele[1] # ã¢ãã±ã¼ã¿åãå£å3880 ep_name = ele[1] # アロケータ受け口名 4108 3881 ep = @owner.find ep_name.get_path[0] # mikan "a::b" 4109 3882 if ep == nil || ! ep.instance_of?( Port ) || ep.get_port_type != :ENTRY || ! ep.get_signature.is_allocator? then 4110 3883 cdl_error( "S1175 $1 not found or not allocator entry port for $2" , ep_name, ai[1] ) 4111 3884 end 4112 # å³è¾ºãã§ãã¯çµãã3885 # 右辺チェック終わり 4113 3886 # ai2 = [ :INTERNAL_ALLOC, func_name, param_name, rhs_ep_name ] 4114 3887 ai2 = [ ai[0], ai[1], ai[2], ep_name ] … … 4122 3895 # ele[0] ele[1][0] ele[1][1][0] ele[1][1][1] ele[1][2] ele[2] 4123 3896 # name_space_path.Token(1).Token(2) === call_port.func.param 4124 # mikan Expression#analyze_cell_join_expression ã®å¤ç¨®ãä½æãã¦ç½®ãæããã¹ã3897 # mikan Expression#analyze_cell_join_expression の変種を作成して置き換えるべき 4125 3898 4126 3899 cdl_error( "S1176 rhs not in 'call_port.func.param' form for for $1_$2" , ai[1], ai[2] ) # S1086 … … 4128 3901 end 4129 3902 func_name = ele[1][2]; cp_name = ele[1][1][1].get_name; param_name = ele[2].to_sym 4130 cp = @owner.find cp_name # ãªã¬ã¼ããå 4131 ã®å¼ã³å£ 3903 cp = @owner.find cp_name # リレーする先の呼び口 4132 3904 if cp then 4133 # mikan cp ãå¼ã³å£ã§ãããã¨ã®ãã§ãã¯ï¼å±æ§ã®å ´åãããï¼ 4134 # mikan åãå£ããåãå£ã¸ã®ãªã¬ã¼ã¸ã®å¯¾å¿ (å¼ã³å£ããå¼ã³å£ã¸ã®ãªã¬ã¼ã¯ããããªã) <=== ææ³ã«ããããäºé 4135 ï¼å¼ã³å£å´ã§ã¢ãã±ã¼ã¿ã決å®ãããï¼ 3905 # mikan cp が呼び口であることのチェック(属性の場合もある) 3906 # mikan 受け口から受け口へのリレーへの対応 (呼び口から呼び口へのリレーはありえない) <=== 文法にかかわる事項(呼び口側でアロケータが決定される) 4136 3907 sig = cp.get_signature 4137 3908 if sig && @signature then … … 4143 3914 decl = fh.get_declarator 4144 3915 if ! decl.is_function? then 4145 next # æ¢ã«ã¨ã©ã¼3916 next # 既にエラー 4146 3917 end 4147 3918 paramdecl = decl.get_type.get_paramlist.find( param_name ) … … 4162 3933 4163 3934 # else 4164 # sig == nil ãªãã°æ¢ã«ã¨ã©ã¼3935 # sig == nil ならば既にエラー 4165 3936 end 4166 3937 else … … 4173 3944 next 4174 3945 end 4175 # å³è¾ºãã§ãã¯çµãã3946 # 右辺チェック終わり 4176 3947 # ai2 = [ :RELAY_ALLOC, func_name, param_name, rhs_cp_name, rhs_func_name, rhs_param_name ] 4177 3948 ai2 = [ ai[0], ai[1], ai[2], cp_name, func_name, param_name ] … … 4186 3957 end 4187 3958 4188 def is_VMT_useless? # VMT é¢æ°ãã¼ãã«ã使ç¨ããªã3959 def is_VMT_useless? # VMT 関数テーブルを使用しない 4189 3960 @b_VMT_useless 4190 3961 end 4191 3962 4192 def is_skelton_useless? # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã)3963 def is_skelton_useless? # スケルトン関数不要 (true の時、受け口関数を呼出す) 4193 3964 @b_skelton_useless 4194 3965 end 4195 3966 4196 def is_cell_unique? # å¼ã³å 4197 ã®ã»ã«ã¯ä¸ã¤ï¼ 3967 def is_cell_unique? # 呼び先のセルは一つ? 4198 3968 @b_cell_unique 4199 3969 end 4200 3970 4201 #=== Port# åãå£æé©åã®è¨å® 4202 # ãã®åãå£ãåç 4203 §ããå¼ã³å£ã VMT, skelton ãå¿ 4204 è¦ã¨ãã¦ãããã©ãããè¨å® 4205 # ä¸ã¤ã§ãå¼ã³å£ãå¿ 4206 è¦ã¨ãã¦ããï¼ããªãã¡ b_*_useless ã falseï¼å ´åã¯ã 4207 # ãã®åãå£ã®æé©åã false ã¨ãã 3971 #=== Port# 受け口最適化の設定 3972 # この受け口を参照する呼び口が VMT, skelton を必要としているかどうかを設定 3973 # 一つでも呼び口が必要としている(すなわち b_*_useless が false)場合は、 3974 # この受け口の最適化を false とする 4208 3975 def set_entry_VMT_skelton_useless( b_VMT_useless, b_skelton_useless ) 4209 3976 if ! b_VMT_useless then … … 4215 3982 end 4216 3983 4217 #=== Port# å¯ä¸ã®çµåå 4218 ãè¨å® 4219 # æé©åã§ä½¿ç¨ 4220 # b_VMT_useless == true || b_skelton_useless == true ã®æã«è¨å®ããã 4221 # optional ã®å ´å callee_cell, callee_port ã nil ã¨ãªã 3984 #=== Port# 唯一の結合先を設定 3985 # 最適化で使用 3986 # b_VMT_useless == true || b_skelton_useless == true の時に設定される 3987 # optional の場合 callee_cell, callee_port が nil となる 4222 3988 def set_only_callee( callee_port, callee_cell ) 4223 3989 @only_callee_port = callee_port … … 4225 3991 end 4226 3992 4227 #=== Port# å¯ä¸ã®çµåå 4228 ãã¼ããè¿ã(compositeã®å ´åå®ã»ã«) 4229 # optional å¼ã³å£ã§æªçµåã®å ´å nil ãè¿ã 3993 #=== Port# 唯一の結合先ポートを返す(compositeの場合実セル) 3994 # optional 呼び口で未結合の場合 nil を返す 4230 3995 def get_real_callee_port 4231 3996 if @only_callee_cell then … … 4234 3999 end 4235 4000 4236 #=== Port# å¯ä¸ã®çµåå 4237 ã»ã«ãè¿ã(compositeã®å ´åå®ã»ã«) 4238 # optional å¼ã³å£ã§æªçµåã®å ´å nil ãè¿ã 4001 #=== Port# 唯一の結合先セルを返す(compositeの場合実セル) 4002 # optional 呼び口で未結合の場合 nil を返す 4239 4003 def get_real_callee_cell 4240 4004 if @only_callee_cell then … … 4251 4015 end 4252 4016 4253 #=== Port# érequire ã®çµåãçæãã4017 #=== Port# 逆require の結合を生成する 4254 4018 # STAGE: S 4255 4019 def create_reverse_require_join cell … … 4258 4022 end 4259 4023 4260 # å¼ã³å 4261 ã»ã«ãæ¢ã 4024 # 呼び元セルを探す 4262 4025 ct_or_cell = Namespace.find( @reverse_require_cell_path ) # mikan namespace #1 4263 4026 if ct_or_cell.instance_of? Cell then … … 4265 4028 ct = cell2.get_celltype 4266 4029 if ct == nil then 4267 return # æ¢ã«ã¨ã©ã¼4030 return # 既にエラー 4268 4031 end 4269 4032 elsif ct_or_cell.instance_of? Celltype then … … 4275 4038 ct = ct_or_cell 4276 4039 else 4277 # æ¢ã«ã¨ã©ã¼ï¼ç¡è¦4040 # 既にエラー:無視 4278 4041 return 4279 4042 end 4280 4043 4281 # çµåãçæãã4044 # 結合を生成する 4282 4045 dbgPrint "create_reverse_require_join #{cell2.get_name}.#{@reverse_require_entry_port_name}[] = #{cell.get_name}.#{@name}" 4283 4046 nsp = NamespacePath.new( cell.get_name, false, cell.get_namespace ) … … 4291 4054 end 4292 4055 4293 #=== Port# signature ã®ãã¹ã¦ã®é¢æ°ã®ãã¹ã¦ã®ãã©ã¡ã¼ã¿ããã©ã 4294 #block:: ãããã¯ãå¼æ°ã¨ãã¦åã(ruby ã®ææ³ã§æ¸ããªã) 4295 # ãããã¯ã¯3ã¤ã®å¼æ°ãåãåã(Port, Decl, ParamDecl) Decl: é¢æ°ããã 4296 # Signature ã¯ã©ã¹ã«ã each_param ãããï¼åãåãï¼ 4297 def each_param # ãããã¯å¼æ°{ |port, func_decl, param_decl| } 4298 return if @signature == nil # signature æªå®ç¾©ï¼æ¢ã«ã¨ã©ã¼ï¼ 4299 fha = @signature.get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 4300 å 4301 return if fha == nil # nil ãªãææ³ã¨ã©ã¼ã§æå¹å¤ãè¨å®ãããªãã£ã 4302 4303 pr = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°ã pr ã«ä»£å 4304 ¥ 4056 #=== Port# signature のすべての関数のすべてのパラメータをたどる 4057 #block:: ブロックを引数として取る(ruby の文法で書かない) 4058 # ブロックは3つの引数を受け取る(Port, Decl, ParamDecl) Decl: 関数ヘッダ 4059 # Signature クラスにも each_param がある(同じ働き) 4060 def each_param # ブロック引数{ |port, func_decl, param_decl| } 4061 return if @signature == nil # signature 未定義(既にエラー) 4062 fha = @signature.get_function_head_array # 呼び口または受け口のシグニチャの関数配列 4063 return if fha == nil # nil なら文法エラーで有効値が設定されなかった 4064 4065 pr = Proc.new # このメソッドのブロック引数を pr に代入 4305 4066 port = self 4306 fha.each{ |fh| # fh: FuncHead # é¢æ°é 4307 åä¸ã®åé¢æ°é é¨ 4308 fd = fh.get_declarator # fd: Decl (é¢æ°é é¨ããDeclarotorãå¾ã) 4309 if fd.is_function? then # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼ 4310 fd.get_type.get_paramlist.get_items.each{ |par| # ãã¹ã¦ã®ãã©ã¡ã¼ã¿ã«ã¤ã㦠4067 fha.each{ |fh| # fh: FuncHead # 関数配列中の各関数頭部 4068 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 4069 if fd.is_function? then # fd が関数でなければ、すでにエラー 4070 fd.get_type.get_paramlist.get_items.each{ |par| # すべてのパラメータについて 4311 4071 pr.call( port, fd, par ) 4312 4072 } … … 4315 4075 end 4316 4076 4317 #=== Port# érequireæå®ããã¦ããï¼4077 #=== Port# 逆require指定されている? 4318 4078 def is_reverse_required? 4319 4079 @reverse_require_cell_path != nil … … 4357 4117 #== Namespace 4358 4118 # 4359 # root namespace ã ããRegion ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã¨ãã¦çæããã 4360 # root namespace ã¯ãroot region ãå 4361 ¼ãããã 4119 # root namespace だけ、Region クラスのインスタンスとして生成される 4120 # root namespace は、root region を兼ねるため 4362 4121 # 4363 # @cell_list 㯠Region ã®å ´åã«ã®ã¿æ㤠(mikan @cell_list é¢é£ã¯ Region ã«ç§»ãã¹ã)4122 # @cell_list は Region の場合にのみ持つ (mikan @cell_list 関連は Region に移すべき) 4364 4123 # 4365 4124 class Namespace < NSBDNode 4366 # @name:: Symbol # root ã®å ´å"::" (String)4125 # @name:: Symbol # root の場合 "::" (String) 4367 4126 # @global_name:: str 4368 4127 # @name_list:: NamedList Signature,Celltype,CompositeCelltype,Cell,Typedef,Namespace 4369 4128 # @struct_tag_list:: NamedList : StructType 4370 # @namespace_list:: Namespace[] : Region 㯠Namespace ã®åã¯ã©ã¹ã§ãããå«ã¾ãã4129 # @namespace_list:: Namespace[] : Region は Namespace の子クラスであり、含まれる 4371 4130 # @signature_list:: Sginature[] 4372 4131 # @celltype_list:: Celltype[] … … 4374 4133 # @cell_list:: Cell[] 4375 4134 # @typedef_list:: Typedef[] 4376 # @decl_list:: ( Typedef | StructType | EnumType )[] ä¾åé¢ä¿ãããå ´åã«åãã¦ãé çªã©ããã«é 4377 åã«æ ¼ç´ mikan enum 4135 # @decl_list:: ( Typedef | StructType | EnumType )[] 依存関係がある場合に備えて、順番どおりに配列に格納 mikan enum 4378 4136 # @const_decl_list:: Decl[] 4379 # @cache_n_cells:: Integer : get_n_cells ã®çµæããã£ãã·ã¥ãã4380 # @cache_generating_region:: Region : get_n_cells ã®çµæããã£ãã·ã¥ãããã¦ãããªã¼ã¸ã§ã³4381 4382 # mikan namespace ã®push, pop4383 4384 # namespace é層ç¨ã®ã¹ã¿ãã¯4137 # @cache_n_cells:: Integer : get_n_cells の結果をキャッシュする 4138 # @cache_generating_region:: Region : get_n_cells の結果をキャッシュするしているリージョン 4139 4140 # mikan namespace の push, pop 4141 4142 # namespace 階層用のスタック 4385 4143 @@namespace_stack = [] # @@namespace_stack[0] = "::" (generator.rb) 4386 4144 @@namespace_sp = -1 4387 4145 4388 # Generator ãã¹ãç¨ã®ã¹ã¿ã㯠(namespace é層ç¨ã®ã¹ã¿ãã¯ã対æ¯ãã)4146 # Generator ネスト用のスタック (namespace 階層用のスタックを対比する) 4389 4147 @@nest_stack_index = -1 4390 4148 @@nest_stack = [] … … 4392 4150 @@root_namespace = nil 4393 4151 4394 # Generator ãã¹ãç¨ã¹ã¿ãã¯ã® push, pop (ã¯ã©ã¹ã¡ã½ãã)4152 # Generator ネスト用スタックの push, pop (クラスメソッド) 4395 4153 def self.push 4396 4154 dbgPrint "push Namespace\n" … … 4412 4170 end 4413 4171 4414 # namespace é層ç¨ã¹ã¿ãã¯ã® push, pop (ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã)4172 # namespace 階層用スタックの push, pop (インスタンスメソッド) 4415 4173 def push ns 4416 4174 @@namespace_sp += 1 … … 4434 4192 if( name == "::" )then 4435 4193 if( @@root_namespace != nil )then 4436 # root ã¯ä¸åã®ã¿çæã§ãã4194 # root は一回のみ生成できる 4437 4195 raise "try to re-create root namespace" 4438 4196 end … … 4443 4201 if ns.kind_of? Namespace then 4444 4202 dbgPrint "namespace: re-appear #{@name}\n" 4445 # ç»é²æ¸ã¿ namespace ã®åç»é²4203 # 登録済み namespace の再登録 4446 4204 ns.push ns 4447 4205 return … … 4454 4212 end 4455 4213 4456 if @@namespace_sp >= 0 then # root ã¯é¤å¤4214 if @@namespace_sp >= 0 then # root は除外 4457 4215 @@namespace_stack[@@namespace_sp].new_namespace( self ) 4458 4216 end 4459 4217 push self 4460 4218 4461 @global_name = Namespace.get_global_name # stack ç»é²å¾åã4219 @global_name = Namespace.get_global_name # stack 登録後取る 4462 4220 @name_list = NamedList.new( nil, "symbol in namespace '#{@name}'" ) 4463 4221 @struct_tag_list = NamedList.new( nil, "struct tag" ) … … 4474 4232 @cache_generating_region = nil 4475 4233 if @NamespacePath == nil then 4476 # root namespace ã®å ´åã¯è¨å®æ¸ (親 namespace ãè¦ã¤ãããä¾å¤ã«ãªã)4477 set_namespace_path # @NamespacePath ã®è¨å®4234 # root namespace の場合は設定済 (親 namespace が見つからず例外になる) 4235 set_namespace_path # @NamespacePath の設定 4478 4236 end 4479 4237 end … … 4487 4245 end 4488 4246 4489 #=== Namespace:: global_name ãå¾ã4490 # parse ä¸ã®ã¿ãã®ã¡ã½ããã¯ä½¿ãã4247 #=== Namespace:: global_name を得る 4248 # parse 中のみこのメソッドは使える 4491 4249 # STAGE: P 4492 def self.get_global_name # parse ä¸æå¹4250 def self.get_global_name # parse 中有効 4493 4251 if @@namespace_sp <= 0 then 4494 4252 return "" … … 4509 4267 end 4510 4268 4511 #=== Namespace# ã»ã«ã®åæ°ãå¾ã4512 # å region ã linkunit, node æå®ããã¦ããã°ãå«ããªãï¼å¥ã®ãªã³ã¯åä½ï¼4513 # ãããã¿ã¤ã宣è¨ã®ãã®ã®ã¿ã®åæ°ãå«ããªã4514 # mikan namespace ä¸ã« cell ãç½®ããªãä»æ§ã«ãªãã¨ããã®ã¡ã½ãã㯠Region ã®ãã®ã§ãã4515 # mikan ä¸è¨ã®å ´å instance_of? Namespace ã®æ¡ä»¶å¤å®ã¯ä¸è¦ã¨ãªã4269 #=== Namespace#セルの個数を得る 4270 # 子 region が linkunit, node 指定されていれば、含めない(別のリンク単位) 4271 # プロトタイプ宣言のもののみの個数を含めない 4272 # mikan namespace 下に cell を置けない仕様になると、このメソッドは Region のものでよい 4273 # mikan 上記の場合 instance_of? Namespace の条件判定は不要となる 4516 4274 def get_n_cells 4517 4275 if @cache_generating_region == $generating_region then 4518 # ãã®ã¡ã½ããã¯ç¹°ãè¿ãå¼ã³åºããããããçµæããã£ãã·ã¥ãã4276 # このメソッドは繰り返し呼び出されるため、結果をキャッシュする 4519 4277 return @cache_n_cells 4520 4278 end … … 4522 4280 count = 0 4523 4281 @cell_list.each{ |c| 4524 # å®ç¾©ããããã¿ã¤ã宣è¨ã ããã¯ãnew_cell ã®æ®µéã§å¤æã§ããªããããã«ã¦ã³ãããªãã4282 # 定義かプロトタイプ宣言だけかは、new_cell の段階で判断できないため、カウントしなおす 4525 4283 if c.get_f_def == true then 4526 4284 # print "get_n_cells: cell: #{c.get_name}\n" … … 4533 4291 count += ns.get_n_cells 4534 4292 else 4535 # ns 㯠Region ã§ãã4293 # ns は Region である 4536 4294 rt = ns.get_region_type 4537 4295 # print "get_n_cells: region: #{ns.get_name}: #{rt}\n" 4538 4296 if rt == :NODE || rt == :LINKUNIT then 4539 # å¥ã® linkunit ãªã®ã§å ç®ããªã4297 # 別の linkunit なので加算しない 4540 4298 else 4541 4299 count += ns.get_n_cells … … 4549 4307 end 4550 4308 4551 #=== Namespace.find : in_path ã§ç¤ºããããªãã¸ã§ã¯ããæ¢ã4309 #=== Namespace.find : in_path で示されるオブジェクトを探す 4552 4310 #in_path:: NamespacePath 4553 #in_path:: Array : å¤ãå½¢å¼4311 #in_path:: Array : 古い形式 4554 4312 # path [ "::", "ns1", "ns2" ] absolute 4555 4313 # path [ "ns1", "ns2" ] relative … … 4566 4324 if name == "::" then 4567 4325 i = 1 4568 name = path[i] # æ§æçã«å¿ 4569 ãåå¨ 4326 name = path[i] # 構文的に必ず存在 4570 4327 object = @@root_namespace.find( name ) # root 4571 4328 else 4572 # ç¸å¯¾ãã¹4329 # 相対パス 4573 4330 i = 0 4574 4331 object = @@namespace_stack[@@namespace_sp].find_one( name ) # crrent … … 4603 4360 4604 4361 unless object.kind_of?( Namespace ) then 4605 # ã¯ã©ã¹ã¡ã½ããå 4606 㧠cdl_error ãå¼ã³åºããã¨ã¯ã§ããªã 4607 # ã¾ããåæ¹åç 4608 §å¯¾å¿å¾ãæ£ç¢ºãªè¡çªå·ãåºãªãåé¡ãçãã 4362 # クラスメソッド内で cdl_error を呼び出すことはできない 4363 # また、前方参照対応後、正確な行番号が出ない問題も生じる 4609 4364 # cdl_error( "S1092 \'$1\' not namespace" , name ) 4610 # ãã®ã¡ã½ãããã nil ã帰ã£ãå ´å "not found" ãåºãã®ã§ãããã§ã¯åºããªã4365 # このメソッドから nil が帰った場合 "not found" が出るので、ここでは出さない 4611 4366 return nil 4612 4367 end … … 4624 4379 end 4625 4380 4626 #=== Namespace# namespace ããæ¢ããè¦ã¤ãããªããã°è¦ª namespace ããæ¢ã4381 #=== Namespace# namespace から探す。見つからなければ親 namespace から探す 4627 4382 def self.find_one( name ) 4628 4383 return @@namespace_stack[@@namespace_sp].find_one( name ) … … 4632 4387 4633 4388 object = find( name ) 4634 # ããã¯åºãã4389 # これは出すぎ 4635 4390 # dbgPrint "in '#{@name}' find '#{name}' object #{object ? object.class : "Not found"}\n" 4636 4391 … … 4649 4404 4650 4405 def self.find_tag( name ) 4651 # mikan tag : namespace ã® path ã«å¯¾å¿ããªã4652 # namespace ã®ä¸ã«ãã£ã¦ããroot namespace ã«ãããã®ã¨è¦ãªããã4653 # ãã£ã¦ ã«ã¬ã³ã namespace ããæ ¹ã«åãã£ã¦æ¢ã4406 # mikan tag : namespace の path に対応しない 4407 # namespace の中にあっても、root namespace にあるものと見なされる 4408 # よって カレント namespace から根に向かって探す 4654 4409 i = @@namespace_sp 4655 4410 while i >= 0 … … 4727 4482 end 4728 4483 4729 #=== Namespace# åç 4730 §ããã¦ããããæªå®ç¾©ã®ã»ã«ãæ¢ã 4731 # ãããã¿ã¤ã宣è¨ã ãã§å®ç¾©ããã¦ããªãã±ã¼ã¹ãã¨ã©ã¼ã¨ãã 4732 # ååã®æªçµåã»ã«ã«ã¤ãã¦è¦åãã 4484 #=== Namespace# 参照されているが、未定義のセルを探す 4485 # プロトタイプ宣言だけで定義されていないケースをエラーとする 4486 # 受動の未結合セルについて警告する 4733 4487 def check_ref_but_undef 4734 4488 @cell_list.each { |c| 4735 if ! c.get_f_def then # Namespace ã® @cell_list ã«ã¯ãããã¿ã¤ããå«ã¾ããã±ã¼ã¹ãã4489 if ! c.get_f_def then # Namespace の @cell_list にはプロトタイプが含まれるケースあり 4736 4490 if c.get_f_ref then 4737 4491 cdl_error( "S1093 $1 : undefined cell" , c.get_namespace_path.get_path_str ) … … 4753 4507 end 4754 4508 4755 #=== Namespace# ã»ã«ã®åãå£ã®åç 4756 §ã«ã¦ã³ããè¨å®ãã 4509 #=== Namespace# セルの受け口の参照カウントを設定する 4757 4510 def set_port_reference_count 4758 4511 @cell_list.each { |c| … … 4770 4523 4771 4524 def new_structtype( struct ) 4772 # struct.set_owner self # StructType (Namespace) # StructType 㯠BDNode ã§ã¯ãªã4525 # struct.set_owner self # StructType (Namespace) # StructType は BDNode ではない 4773 4526 dup = @struct_tag_list.get_item(struct.get_name) 4774 4527 if dup != nil then 4775 4528 if struct.same? dup then 4776 # åããã®ã typedef ããã4529 # 同じものが typedef された 4777 4530 # p "#{struct.get_name}" 4778 4531 return … … 4798 4551 if typedef_type.get_type_str == dup_type.get_type_str && 4799 4552 typedef_type.get_type_str_post == dup_type.get_type_str_post then 4800 # åããã®ã typedef ããã4801 # ããã¸æ¥ãã®ã¯ C ã§é¢æ°ãã¤ã³ã¿ã typedef ãã¦ããã±ã¼ã¹4802 # 以ä¸ã®ããã«äºéã«å®ç¾©ããã¦ããå ´å㯠type_specifier_qualifier_list ã¨ãã¦æ±ããã4553 # 同じものが typedef された 4554 # ここへ来るのは C で関数ポインタを typedef しているケース 4555 # 以下のように二重に定義されている場合は type_specifier_qualifier_list として扱われる 4803 4556 # typedef long LONG; 4804 4557 # typedef long LONG; 4805 # bnf.y.rb ã§ã¯ declarator ã« TYPE_NAME ã許ããªãã®ã§ãããã¸æ¥ããã¨ã¯ãªã4558 # bnf.y.rb では declarator に TYPE_NAME を許さないので、ここへ来ることはない 4806 4559 # p "#{typedef.get_declarator.get_type.get_type_str} #{typedef.get_name} #{typedef.get_declarator.get_type.get_type_str_post}" 4807 4560 return … … 4844 4597 def new_const_decl( decl ) 4845 4598 decl.set_owner self # Decl (Namespace:const) 4846 if ! decl.is_const? then # const 修飾ãã¦ãããã¨4599 if ! decl.is_const? then # const 修飾さていること 4847 4600 if decl.is_type?( PtrType ) then 4848 4601 cdl_error( "S1094 $1: pointer is not constant. check \'const\'" , decl.get_name ) … … 4852 4605 elsif ! decl.is_type?( IntType ) && ! decl.is_type?( FloatType ) && 4853 4606 ! decl.is_type?( BoolType ) && ! decl.is_type?( PtrType ) then 4854 # IntType, FloatType ã§ãããã¨4607 # IntType, FloatType であること 4855 4608 cdl_error( "S1096 $1: should be int, float, bool or pointer type" , decl.get_name ) 4856 elsif decl.get_initializer == nil then # åæå¤ãæã¤ãã¨4609 elsif decl.get_initializer == nil then # 初期値を持つこと 4857 4610 cdl_error( "S1097 $1: has no initializer" , decl.get_name ) 4858 # elsif decl.get_initializer.eval_const(nil) == nil then #eval_const 㯠check_init ã§å¼åºãããã®ã§äºéãã§ãã¯4859 # # mikan åæå¤ãåã«å¯¾ãé©åã§ãããã¨4611 # elsif decl.get_initializer.eval_const(nil) == nil then #eval_const は check_init で呼出されるので二重チェック 4612 # # mikan 初期値が型に対し適切であること 4860 4613 # cdl_error( "S1098 $1: has unsuitable initializer" , decl.get_name ) 4861 4614 else … … 4879 4632 ### 4880 4633 4881 #=== Namespace# ãã¹ã¦ã®ã»ã«ã® require ãã¼ããè¨å®4634 #=== Namespace# すべてのセルの require ポートを設定 4882 4635 # STAGE: S 4883 4636 def set_require_join … … 4885 4638 ct.set_require_join 4886 4639 } 4887 # ãã¹ã¦ã® namespace ã«ã¤ã㦠require ãã¼ããã»ãã4640 # すべての namespace について require ポートをセット 4888 4641 @namespace_list.each{ |ns| 4889 4642 ns.set_require_join … … 4891 4644 end 4892 4645 4893 #=== Namespace# Join ã¸ã® definition ã®è¨å®ã¨ãã§ãã¯4894 # ã»ã«ã¿ã¤ãã«å±ãããã¹ã¦ã®ã»ã«ã«å¯¾ãã¦å®æ½4646 #=== Namespace# Join への definition の設定とチェック 4647 # セルタイプに属するすべてのセルに対して実施 4895 4648 def set_definition_join 4896 # celltype ã®ã³ã¼ããçæ4649 # celltype のコードを生成 4897 4650 @cell_list.each { |c| 4898 4651 dbgPrint "set_definition_join #{c.get_name}\n" … … 4904 4657 end 4905 4658 4906 #=== Namespace# ã»ã«ã®çµåããã§ãã¯ãã4659 #=== Namespace# セルの結合をチェックする 4907 4660 def check_join 4908 4661 @cell_list.each { |c| … … 4916 4669 end 4917 4670 4918 #== Namespace# ã«ã¼ãã?4919 # ã«ã¼ããã¼ã ã¹ãã¼ã¹ 㨠ã«ã¼ããªã¼ã¸ã§ã³ã¯åã4671 #== Namespace# ルートか? 4672 # ルートネームスペース と ルートリージョンは同じ 4920 4673 def is_root? 4921 4674 @name == "::" 4922 4675 end 4923 4676 4924 #== Namespace# ã«ã¼ããå¾ã4925 # ã«ã¼ããªã¼ã¸ã§ã³ã¨ã«ã¼ããã¼ã ã¹ãã¼ã¹ã¯åããªãã¸ã§ã¯ã4677 #== Namespace# ルートを得る 4678 # ルートリージョンとルートネームスペースは同じオブジェクト 4926 4679 def self.get_root 4927 4680 @@root_namespace … … 4945 4698 # 4946 4699 # available if definition is Port 4947 # @cell_name:: string : å³è¾ºã®ã»ã«ã®åå4948 # @cell:: Cell : å³è¾ºã®ã»ã«4949 # @celltype:: Celltype : å³è¾ºã®ã»ã«ã¿ã¤ã4950 # @port_name:: string : å³è¾ºã®åãå£å4951 # @port:: Port : å³è¾ºã®åãå£4700 # @cell_name:: string : 右辺のセルの名前 4701 # @cell:: Cell : 右辺のセル 4702 # @celltype:: Celltype : 右辺のセルタイプ 4703 # @port_name:: string : 右辺の受け口名 4704 # @port:: Port : 右辺の受け口 4952 4705 # @array_member:: rhs array : available only for first appear in the same name 4953 4706 # @array_member2:: Join array : available only for first appear in the same name 4954 # @rhs_subscript:: nil : not array, >=0: å³è¾ºã®æ·»æ°4707 # @rhs_subscript:: nil : not array, >=0: 右辺の添数 4955 4708 # 4956 4709 4957 4710 # @through_list:: @cp_through_list + @region_through_list 4958 # 以ä¸ã®æ§é ãæã¤ï¼@cp_through_list ã®æ§é ã¯å 4959 ±éï¼ 4960 # @cp_through_list:: å¼ã³å£ã«æå®ããã through 4711 # 以下の構造を持つ(@cp_through_list の構造は共通) 4712 # @cp_through_list:: 呼び口に指定された through 4961 4713 # [ [plugin_name, cell_name, plugin_arg], [plugin_name2, cell_name2, plugin_arg], ... ] 4962 # @region_through_list:: region ã«æå®ãããthrough4714 # @region_through_list:: region に指定された through 4963 4715 # [ [plugin_name, cell_name, plugin_arg, region], [plugin_name2, cell_name2, plugin_arg, region2], ... ] 4964 4716 # 4965 # @through_generated_list:: [Plugin_class object, ...]: @through_list ã«å¯¾å¿4966 # @region_through_generated_list:: [Plugin_class object, ...]: @region_through_list ã«å¯¾å¿4717 # @through_generated_list:: [Plugin_class object, ...]: @through_list に対応 4718 # @region_through_generated_list:: [Plugin_class object, ...]: @region_through_list に対応 4967 4719 # 4968 4720 4969 4721 include PluginModule 4970 4722 4971 #=== Join# åæå 4972 #name:: string: ååï¼å±æ§åãå¼ã³å£åï¼ 4973 #subscript:: Nil=éé 4974 å, -1="[]", N="[N]" 4975 #rhs:: Expression: å³è¾ºã®å¼ 4723 #=== Join# 初期化 4724 #name:: string: 名前(属性名、呼び口名) 4725 #subscript:: Nil=非配列, -1="[]", N="[N]" 4726 #rhs:: Expression: 右辺の式 4976 4727 def initialize( name, subscript, rhs, locale = nil ) 4977 4728 # dbgPrint "Join#new: #{name}, #{subscript} #{rhs.eval_const(nil)}\n" … … 4985 4736 @name = name 4986 4737 if subscript.instance_of?( Expression ) then 4987 #mikan é 4988 åæ·»æ°ãæ´æ°ã§ãããã¨ãæªãã§ã㯠4738 #mikan 配列添数が整数であることを未チェック 4989 4739 @subscript = subscript.eval_const(nil) 4990 4740 if @subscript == nil then … … 4998 4748 @definition = nil 4999 4749 5000 # é 5001 åè¦ç´ ãè¨å® 5002 # æ¬å½ã¯ãååºã®è¦ç´ ã®ã¿è¨å®ããã®ãé©å½ 5003 # new_join 㧠add_array_member ã®ä¸ã§ååºè¦ç´ ã® array_member ã«å¯¾ãè¨å®ãã 4750 # 配列要素を設定 4751 # 本当は、初出の要素のみ設定するのが適当 4752 # new_join で add_array_member の中で初出要素の array_member に対し設定する 5004 4753 if @subscript == -1 then 5005 4754 @array_member = [self] … … 5019 4768 end 5020 4769 5021 #=== Join# 左辺ã«å¯¾å¿ãã celltype ã®å®ç¾©ãè¨å®ããã¨ã¨ãã«ãã§ãã¯ãã4770 #=== Join# 左辺に対応する celltype の定義を設定するとともにチェックする 5022 4771 # STAGE: S 5023 4772 # 5024 # 代å 5025 ¥å¯è½ããã§ãã¯ãã 5026 #definition:: Decl (attribute,varã®æ) ã¾ã㯠Port (callã®æ) ã¾ã㯠nil (definition ãè¦ã¤ãããªãã£ãæ) 4773 # 代入可能かチェックする 4774 #definition:: Decl (attribute,varの時) または Port (callの時) または nil (definition が見つからなかった時) 5027 4775 5028 4776 def set_definition( definition ) … … 5030 4778 dbgPrint "set_definition: #{@owner.get_name}.#{@name} = #{definition.class}\n" 5031 4779 5032 # äºéãã§ãã¯ã®é²æ¢4780 # 二重チェックの防止 5033 4781 if @definition then 5034 # set_definition ãåå¥ã«è¡ãã±ã¼ã¹ã§ãäºéã«è¡ãããå¯è½æ§ãããï¼ç°å¸¸ã§ã¯ãªãï¼5035 # äºéã« set_definition ãå®è¡ããã㨠through ãäºéã«é©ç¨ããã¦ãã¾ã4782 # set_definition を個別に行うケースで、二重に行われる可能性がある(異常ではない) 4783 # 二重に set_definition が実行されると through が二重に適用されてしまう 5036 4784 # cdl_warning( "W9999 $1, internal error: set_definition duplicate", @name ) 5037 4785 return … … 5040 4788 @definition = definition 5041 4789 5042 # mikan 左辺å¤ãå³è¾ºå¤ã®åãã§ãã¯ãªã©4790 # mikan 左辺値、右辺値の型チェックなど 5043 4791 if @definition.instance_of?( Decl ) then 5044 4792 check_var_init 5045 4793 elsif @definition.instance_of?( Port ) then 5046 4794 check_call_port_init 5047 if @definition.get_port_type == :CALL then # :ENTRY ãªãã¨ã©ã¼ãç¡è¦ããªã4795 if @definition.get_port_type == :CALL then # :ENTRY ならエラー。無視しない 5048 4796 check_and_gen_through 5049 create_allocator_join # through ãã©ã°ã¤ã³çæããå¾ã§ãªãã¨ãæ¿å 5050 ¥åã®ã»ã«ã®ã¢ãã±ã¼ã¿ãçµåãã¦ãã¾ã 4797 create_allocator_join # through プラグイン生成した後でないと、挿入前のセルのアロケータを結合してしまう 5051 4798 end 5052 4799 elsif @definition == nil then … … 5057 4804 end 5058 4805 5059 #=== Join# å¤æ°ã®åæåãã§ãã¯4806 #=== Join# 変数の初期化チェック 5060 4807 def check_var_init 5061 # attribute, var ã®å ´å4808 # attribute, var の場合 5062 4809 if @definition.get_kind == :ATTRIBUTE then 5063 4810 # check_cell_cb_init( definition.get_type, @rhs ) 5064 # å³è¾ºã§åæåå¯è½ããã§ãã¯4811 # 右辺で初期化可能かチェック 5065 4812 @definition.get_type.check_init( @locale, @definition.get_identifier, @rhs, :ATTRIBUTE ) 5066 4813 elsif @definition.get_kind == :VAR then 5067 # var ã¯åæåã§ããªã4814 # var は初期化できない 5068 4815 cdl_error( "S1100 $1: cannot initialize var" , @name ) 5069 4816 else … … 5073 4820 end 5074 4821 5075 #=== Join# å¼ã³å£ã®åæåãã§ãã¯4822 #=== Join# 呼び口の初期化チェック 5076 4823 def check_call_port_init 5077 4824 ### Port 5078 4825 5079 # 左辺ã¯åãå£ãï¼åãå£ãåæåãããã¨ãã¦ããï¼ï¼4826 # 左辺は受け口か(受け口を初期化しようとしている)? 5080 4827 if @definition.get_port_type == :ENTRY then 5081 4828 cdl_error( "S1101 \'$1\' cannot initialize entry port" , @name ) … … 5083 4830 end 5084 4831 5085 # # é 5086 åæ·»æ°ã®æ´åæ§ãã§ã㯠5087 # # å¼ã³å£ã®å®ç¾©ã§ãéé 5088 åãªãæ·»æ°ãªããæ·»æ°ãªãé 5089 åãªãæ·»æ°ãªããæ·»æ°ããé 5090 åãªãæ·»æ°ãã 4832 # # 配列添数の整合性チェック 4833 # # 呼び口の定義で、非配列なら添数なし、添数なし配列なら添数なし、添数あり配列なら添数あり 5091 4834 as = @definition.get_array_size 5092 4835 if ( @subscript == nil && as != nil ) then … … 5111 4854 # end 5112 4855 5113 # mikan Expression ã® get_type ã§åå°åºãããæ¹ãã¹ãã¼ã 5114 # mikan '=' ã®å·¦è¾ºãé 5115 åãã©ããæªãã§ã㯠5116 #(1) '=' ã®å³è¾ºã¯ "Cell.ePort" ã®å½¢å¼ãï¼ 5117 # æ¼ç®å㯠"." ã㤠"." ã®å·¦è¾ºã :IDENTIFIER 5118 # "." ã®å³è¾ºã¯ãã§ãã¯ä¸è¦ (synatax çã« :IDENTIFIER) 5119 #(2) "Cell" ã¯åå¨ãããï¼ï¼ååãä¸è´ãããã®ã¯ãããï¼ 5120 #(3) "Cell" 㯠cell ãï¼ 5121 #(4) "Cell" ã® celltype ã¯æå¹ãï¼ (ç¡å¹ãªãæ¢ã«ã¨ã©ã¼ï¼ 5122 #(5) "ePort" 㯠"Cell" ã® celltype å 5123 ã«åå¨ãããï¼ 5124 #(6) "ePort" 㯠entry port ãï¼ 5125 #(7) signature ã¯ä¸è´ããã 5126 5127 # å³è¾ºããªãï¼ä»¥åã®æ®µéã§ã¨ã©ã¼ï¼ 4856 # mikan Expression の get_type で型導出させる方がスマート 4857 # mikan '=' の左辺が配列かどうか未チェック 4858 #(1) '=' の右辺は "Cell.ePort" の形式か? 4859 # 演算子は "." かつ "." の左辺が :IDENTIFIER 4860 # "." の右辺はチェック不要 (synatax 的に :IDENTIFIER) 4861 #(2) "Cell" は存在するか?(名前が一致するものはあるか) 4862 #(3) "Cell" は cell か? 4863 #(4) "Cell" の celltype は有効か? (無効なら既にエラー) 4864 #(5) "ePort" は "Cell" の celltype 内に存在するか? 4865 #(6) "ePort" は entry port か? 4866 #(7) signature は一致するか 4867 4868 # 右辺がない(以前の段階でエラー) 5128 4869 return unless @rhs 5129 4870 5130 # cCall = composite.cCall; ã®ãã§ãã¯ï¼ãã®å½¢å¼ã¯å±æ§ç¨5131 # å¼ã³å£ã export ããã«ã¯ cCall => composite.cCall; ã®å½¢å¼ãç¨ãã4871 # cCall = composite.cCall; のチェック.この形式は属性用 4872 # 呼び口を export するには cCall => composite.cCall; の形式を用いる 5132 4873 if @rhs.instance_of?( Array ) == true && @rhs[0] == :COMPOSITE then 5133 4874 cdl_error( "S1107 to export port, use \'cCall => composite.cCall\'" ) … … 5137 4878 end 5138 4879 5139 # å³è¾ºã® Expression ã®è¦ç´ ãåãåºã4880 # 右辺の Expression の要素を取り出す 5140 4881 ret = @rhs.analyze_cell_join_expression 5141 4882 if ret == nil then #1 … … 5145 4886 5146 4887 nsp, @rhs_subscript, @port_name = ret[0], ret[1], ret[2] 5147 @cell_name = nsp.get_name # mikan ns::cellname ã®å½¢å¼ã®èæ 5148 ® 5149 5150 # composite ã®å®ç¾©ã®ä¸ãªã object ã¯çµåå 5151 cell ããè¦ã¤ãããªããã° nil ãè¿ã 5152 # composite ã®å®ç¾©å¤ãªã false ãè¿ã 4888 @cell_name = nsp.get_name # mikan ns::cellname の形式の考慮 4889 4890 # composite の定義の中なら object は結合先 cell か、見つからなければ nil が返る 4891 # composite の定義外なら false が返る 5153 4892 object = CompositeCelltype.find( @cell_name ) 5154 4893 if object == false then 5155 # mikan 左辺ã namespace ã«å¯¾å¿ãã¦ããªãããã path ã«ãã¦find4894 # mikan 左辺が namespace に対応していないため。 path にして find 5156 4895 # p nsp.get_path_str, nsp.get_path 5157 4896 object = Namespace.find( nsp ) #1 … … 5172 4911 object.set_f_ref 5173 4912 5174 # å³è¾ºã®ã»ã«ã®ã»ã«ã¿ã¤ã4913 # 右辺のセルのセルタイプ 5175 4914 celltype = object.get_celltype 5176 4915 … … 5185 4924 cdl_error( "S1113 \'$1\' signature mismatch" , @port_name ) 5186 4925 elsif object2.get_array_size then 5187 # åãå£é 5188 å 4926 # 受け口配列 5189 4927 5190 4928 unless @rhs_subscript then 5191 # å³è¾ºã«æ·»æ°æå®ããªãã£ã4929 # 右辺に添数指定がなかった 5192 4930 cdl_error( "S1114 \'$1\' should be array" , @port_name ) 5193 4931 else … … 5195 4933 as = object2.get_array_size 5196 4934 if( as.kind_of?( Integer ) && as <= @rhs_subscript )then 5197 # åãå£é 5198 åã®å¤§ããã«å¯¾ããå³è¾ºã®æ·»æ°ãåãã大ãã 4935 # 受け口配列の大きさに対し、右辺の添数が同じか大きい 5199 4936 cdl_error( "S1115 $1[$2]: subscript out of range (< $3)" , @port_name, @rhs_subscript, as ) 5200 4937 else … … 5203 4940 @celltype = celltype 5204 4941 @port = object2 5205 # å³è¾ºã®ã»ã«ã®åãå£ object2 ãåç 5206 §æ¸ã¿ã«ãã 4942 # 右辺のセルの受け口 object2 を参照済みにする 5207 4943 # object2: Port, @definition: Port 5208 4944 @cell.set_entry_port_max_subscript( @port, @rhs_subscript ) … … 5214 4950 end 5215 4951 elsif @rhs_subscript then 5216 # åãå£é 5217 åã§ãªãã®ã«å³è¾ºã§æ·»æ°æå®ããã¦ãã 4952 # 受け口配列でないのに右辺で添数指定されている 5218 4953 cdl_error( "S1116 \'$1\' entry port is not array" , @port_name ) 5219 4954 else … … 5223 4958 @celltype = celltype 5224 4959 5225 # å³è¾ºã®ã»ã« object ã®åãå£ object2 ãåç 5226 §æ¸ã¿ã«ãã 4960 # 右辺のセル object の受け口 object2 を参照済みにする 5227 4961 # object2: Port, @definition: Port 5228 4962 5229 4963 # debug 5230 4964 # p "rhs: #{@cell} #{@cell.get_name}" 5231 end # end of port (object2) ãã§ãã¯4965 end # end of port (object2) チェック 5232 4966 5233 4967 #else 5234 # celltype == nil ( ãã§ã«ã¨ã©ã¼)5235 end # end of celltyep ãã§ãã¯4968 # celltype == nil (すでにエラー) 4969 end # end of celltyep チェック 5236 4970 5237 4971 5238 4972 check_region( object ) 5239 4973 5240 end # end of cell (object) ãã§ãã¯5241 5242 end 5243 5244 #=== Join# ã¢ãã±ã¼ã¿ã®çµåãçæ4974 end # end of cell (object) チェック 4975 4976 end 4977 4978 #=== Join# アロケータの結合を生成 5245 4979 # STAGE: S 5246 #cell:: å¼ã³å£ã®çµåå 5247 ã®ã»ã« 4980 #cell:: 呼び口の結合先のセル 5248 4981 # 5249 # ããã§ã¯å¼ã³å£å´ã«çæãããã¢ãã±ã¼ã¿å¼ã³å£ã®çµåãçæ 5250 # åãå£å´ã¯ Cell ã® set_specifier_list ã§çæ 5251 # a[*] ã®å 5252 容㯠Cell ã® set_specifier_list ãåç 5253 § 4982 # ここでは呼び口側に生成されるアロケータ呼び口の結合を生成 4983 # 受け口側は Cell の set_specifier_list で生成 4984 # a[*] の内容は Cell の set_specifier_list を参照 5254 4985 def create_allocator_join 5255 4986 5256 cell = get_rhs_cell2 # å³è¾ºã®ã»ã«ãå¾ã4987 cell = get_rhs_cell2 # 右辺のセルを得る 5257 4988 port = get_rhs_port2 5258 4989 5259 if( cell && cell.get_allocator_list ) then # cell == nil ãªãæ¢ã«ã¨ã©ã¼4990 if( cell && cell.get_allocator_list ) then # cell == nil なら既にエラー 5260 4991 5261 4992 dbgPrint "create_allocator_join: #{@owner.get_name}.#{@name}=>#{cell ? cell.get_name : "nil"}\n" … … 5264 4995 5265 4996 if( a[0+1] == port && a[1+1] == @rhs_subscript )then 5266 # ååã®ä¸è´ãããã®ã®çµåãçæãã5267 # éä¸è¶³ã¯ãå¥éãã§ãã¯ããã4997 # 名前の一致するものの結合を生成する 4998 # 過不足は、別途チェックされる 5268 4999 cp_name = :"#{@name}_#{a[2+1]}_#{a[3+1]}" 5269 5000 # p "creating allocator join #{cp_name} #{@subscript} #{a[1+1]}" … … 5280 5011 end 5281 5012 5282 #=== Join# ãªã¼ã¸ã§ã³éã®çµåããã§ã㯠5283 # ãªã¼ã¸ã§ã³éã® through ã«ãã @region_through_list ã®ä½æ 5284 # å®éã®çæ㯠check_and_gen_through ã§è¡ã 5285 # mikan Cell#distance ã¨Region ã¸ãã©ãçãã¾ã§ããã®å¦çã«å 5286 ±éé¨åãå¤ã 5013 #=== Join# リージョン間の結合をチェック 5014 # リージョン間の through による @region_through_list の作成 5015 # 実際の生成は check_and_gen_through で行う 5016 # mikan Cell#distance とRegion へたどり着くまでための処理に共通部分が多い 5287 5017 def check_region( object ) 5288 5018 … … 5291 5021 # print "DOMAIN: check_region #{@owner.get_name}.#{@name} => #{object.get_name}\n" 5292 5022 5293 # ãã©ã°ã¤ã³ã§çæããããªãã§ã¯çæããªã5294 # ãããªãã¨ãã©ã°ã¤ã³çæããããã®ã¨ã®éã§ãç¡éã«çæããã5023 # プラグインで生成されたなかでは生成しない 5024 # さもないとプラグイン生成されたものとの間で、無限に生成される 5295 5025 ## if Generator.get_nest >= 1 then 5296 ## if Generator.get_plugin then # mikan ããã¯å¿ 5297 è¦ï¼ (æå³è§£æ段éã§ã®å®è¡ã«ãªãã®ã§ä¸é©å) 5026 ## if Generator.get_plugin then # mikan これは必要? (意味解析段階での実行になるので不適切) 5298 5027 if @owner.get_plugin.kind_of?( ThroughPlugin ) then 5299 # ãã©ã°ã¤ã³çæãããã»ã«ã®å ´åãçµåãã§ãã¯ã®ã¿5028 # プラグイン生成されたセルの場合、結合チェックのみ 5300 5029 return 5301 5030 end 5302 5031 5303 # region ã®ãã§ãã¯5304 r1 = @owner.get_region # å¼ã³å£ã»ã«ã®region5305 r2 = object.get_region # åãå£ã»ã«ã®region5306 5307 if ! r1.equal? r2 then # åä¸ region ãªãå¼åºãå¯è½5032 # region のチェック 5033 r1 = @owner.get_region # 呼び口セルの region 5034 r2 = object.get_region # 受け口セルの region 5035 5036 if ! r1.equal? r2 then # 同一 region なら呼出し可能 5308 5037 5309 5038 f1 = r1.get_family_line … … 5312 5041 len2 = f2.length 5313 5042 5314 # ä¸ä¸è´ã«ãªãã¨ããï¼å 5315 å¼ï¼ãæ¢ã 5316 i = 1 # i = 0 㯠:RootRegion ãªã®ã§å¿ 5317 ãä¸è´ 5043 # 不一致になるところ(兄弟)を探す 5044 i = 1 # i = 0 は :RootRegion なので必ず一致 5318 5045 while( i < len1 && i < len2 ) 5319 5046 if( f1[i] != f2[i] )then … … 5323 5050 end 5324 5051 5325 sibling_level = i # å 5326 å¼ã¨ãªãã¬ãã«ããããã¯ã©ã¡ããä¸æ¹ãçµãã£ãã¬ãã« 5052 sibling_level = i # 兄弟となるレベル、もしくはどちらか一方が終わったレベル 5327 5053 5328 5054 dbgPrint "sibling_level: #{i}\n" … … 5337 5063 5338 5064 5339 # å¼ã³å´ã«ã¤ãã¦å¼ã³å 5340 ã®ã¬ãã«ããå 5341 å¼ã¬ãã«ã¾ã§ï¼out_through ããã§ãã¯ããã³æ¿å 5342 ¥ï¼ 5065 # 呼び側について呼び元のレベルから兄弟レベルまで(out_through をチェックおよび挿入) 5343 5066 i = len1 -1 5344 5067 if b_to_through then … … 5364 5087 5365 5088 out_through_list.each { |ol| 5366 if ol[0] then # plugin_name ãæå®ããã¦ããªããã°ç»é²ããªã5089 if ol[0] then # plugin_name が指定されていなければ登録しない 5367 5090 plugin_arg = CDLString.remove_dquote ol[1] 5368 5091 through = [ ol[0], :"Join_out_through_", plugin_arg, f1[i], f1[i-1], :OUT_THROUGH, region_count] … … 5377 5100 end 5378 5101 5379 # å 5380 å¼ã¬ãã«ã«ããã¦ï¼to_through ããã§ãã¯ããã³æ¿å 5381 ¥ï¼ 5102 # 兄弟レベルにおいて(to_through をチェックおよび挿入) 5382 5103 if f1[sibling_level] && f2[sibling_level] then 5383 5104 dbgPrint "going from #{f1[sibling_level].get_name} to #{f2[sibling_level].get_name}\n" 5384 5105 found = 0 5385 region_count = f1[i].next_to_through_count( f2[sibling_level].get_name ) # to_through ã® region ã«ã¦ã³ã5106 region_count = f1[i].next_to_through_count( f2[sibling_level].get_name ) # to_through の region カウント 5386 5107 f1[sibling_level].get_to_through_list.each { |t| 5387 if t[0][0] == f2[sibling_level].get_name then # region åãä¸è´ããã?5388 if t[1] then # plugin_name ãæå®ããã¦ããªããã°ç»é²ããªã5108 if t[0][0] == f2[sibling_level].get_name then # region 名が一致するか ? 5109 if t[1] then # plugin_name が指定されていなければ登録しない 5389 5110 plugin_arg = CDLString.remove_dquote t[2] 5390 5111 through = [ t[1], :"Join_to_through__", plugin_arg, f1[sibling_level], f2[sibling_level], :TO_THROUGH, region_count ] … … 5409 5130 end 5410 5131 5411 # åãå´ã«ã¤ãã¦å 5412 å¼ã¬ãã«ããåãå´ã®ã¬ãã«ã¾ã§ï¼in_through ããã§ãã¯ããã³æ¿å 5413 ¥ï¼ 5132 # 受け側について兄弟レベルから受け側のレベルまで(in_through をチェックおよび挿入) 5414 5133 if b_to_through then 5415 i = sibling_level + 1 # to_through ãçµãå ´åãæåã® in_through ã¯é©ç¨ããªã5134 i = sibling_level + 1 # to_through を経た場合、最初の in_through は適用しない 5416 5135 else 5417 5136 i = sibling_level … … 5436 5155 end 5437 5156 in_through_list.each { |il| 5438 if il[0] then # plugin_name ãæå®ããã¦ããªããã°ç»é²ããªã5157 if il[0] then # plugin_name が指定されていなければ登録しない 5439 5158 plugin_arg = CDLString.remove_dquote il[1] 5440 5159 through = [ il[0], :"Join_in_through_", plugin_arg, f2[i-1], f2[i],:IN_THROUGH, region_count ] … … 5449 5168 5450 5169 5451 #=== Join# çæããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯5452 # å³è¾ºã®ã»ã«ããçæãããªããªã¼ã¸ã§ã³ã«ããã°ã¨ã©ã¼5453 # å³è¾ºã¯ããã©ã°ã¤ã³çæãããã»ã«ãããã°ãããã対象ã¨ãã5170 #=== Join# 生成しないリージョンへの結合かチェック 5171 # 右辺のセルが、生成されないリージョンにあればエラー 5172 # 右辺は、プラグイン生成されたセルがあれば、それを対象とする 5454 5173 def check_region2 5455 5174 lhs_cell = @owner 5456 5175 5457 # çæããªããªã¼ã¸ã§ã³ã®ã»ã«ã¸ã®çµåãï¼5176 # 生成しないリージョンのセルへの結合か? 5458 5177 # if join.get_cell && ! join.get_cell.is_generate? then 5459 # if get_rhs_cell && ! get_rhs_cell.is_generate? then # composite ã»ã«ãããã¿ã¤ã宣è¨ã®å ´åä¾å¤5178 # if get_rhs_cell && ! get_rhs_cell.is_generate? then # composite セルがプロタイプ宣言の場合例外 5460 5179 # print "Link root: (caller #{@owner.get_name}) '#{@owner.get_region.get_link_root.get_name}'" 5461 5180 # print " #{@owner.get_region.get_link_root == get_rhs_region.get_link_root ? "==" : "!="} " … … 5470 5189 end 5471 5190 else 5472 # rhs ã®ã»ã«ãåå¨ããªãã£ã (æ¢ã«ã¨ã©ã¼)5191 # rhs のセルが存在しなかった (既にエラー) 5473 5192 end 5474 5193 end … … 5478 5197 end 5479 5198 5480 #=== Join# specifier ãè¨å®5199 #=== Join# specifier を設定 5481 5200 # STAGE: B 5482 # set_specifier_list ã¯ãjoin ã®è§£æã®æå¾ã§å¼ã³åºããã5483 # through æå®åãè¨å®5484 # check_and_gen_through ãå¼åºãã¦ãthrough çæ5201 # set_specifier_list は、join の解析の最後で呼び出される 5202 # through 指定子を設定 5203 # check_and_gen_through を呼出して、through 生成 5485 5204 def set_specifier_list( specifier_list ) 5486 5205 … … 5490 5209 # set plugin_name 5491 5210 plugin_name = s[1].to_s 5492 plugin_name[0] = "#{plugin_name[/^./].upcase}" # å 5493 é æåã大æåã« : ruby ã®ã¯ã©ã¹åã®å¶ç´ 5211 plugin_name[0] = "#{plugin_name[/^./].upcase}" # 先頭文字を大文字に : ruby のクラス名の制約 5494 5212 5495 5213 # set cell_name … … 5498 5216 # set plugin_arg 5499 5217 plugin_arg = CDLString.remove_dquote s[2].to_s 5500 # plugin_arg = s[2].to_s.gsub( /\A"(.*)/, '\1' ) # åå¾ã® "" ãåãé¤ã5218 # plugin_arg = s[2].to_s.gsub( /\A"(.*)/, '\1' ) # 前後の "" を取り除く 5501 5219 # plugin_arg.sub!( /(.*)"\z/, '\1' ) 5502 5220 … … 5507 5225 end 5508 5226 5509 #=== Join# through ã®ãã§ãã¯ã¨çæ5510 # new_join ã®ä¸ã® check_region 㧠region éã® through ã @region_through ã«è¨å®ããã5511 # set_specifier ã§å¼ã³å£ã®çµåã§æå®ããã through ã @cp_through è¨å®ããã5512 # ãã®å¾ããã®ã¡ã½ãããå¼ã°ãã5227 #=== Join# through のチェックと生成 5228 # new_join の中の check_region で region 間の through が @region_through に設定される 5229 # set_specifier で呼び口の結合で指定された through が @cp_through 設定される 5230 # その後、このメソッドが呼ばれる 5513 5231 def check_and_gen_through 5514 5232 … … 5531 5249 5532 5250 @through_list = @cp_through_list + @region_through_list 5533 # å¾ãã @cp_through_list 㨠@region_through_list ã«åããããããã®ãããªå®è£ 5534 ã«ãªã£ã 5251 # 後から @cp_through_list と @region_through_list に分けたため、このような実装になった 5535 5252 5536 5253 if @through_list then # nil when the join is not Port 5537 len = @through_list.length # through ãé£æ¥ãã¦ããæ°5254 len = @through_list.length # through が連接している数 5538 5255 else 5539 5256 len = 0 … … 5546 5263 end 5547 5264 5548 # é£ç¶ãã through ã«ã¤ãã¦ãåãå£å´ããé ã«ã»ã«ãçæã解éãã5265 # 連続した through について、受け口側から順にセルを生成し解釈する 5549 5266 i = len - 1 5550 5267 while i >= 0 … … 5575 5292 5576 5293 else 5577 # æå¾ã®ã»ã«ã®å ´åã次ã®ã»ã«ã®ååããã¼ãå5294 # 最後のセルの場合、次のセルの名前、ポート名 5578 5295 next_cell = @cell 5579 5296 next_port_name = @port_name 5580 5297 5581 5298 if next_cell == nil then 5582 # çµåå 5583 ããªã 5299 # 結合先がない 5584 5300 return 5585 5301 end … … 5587 5303 5588 5304 if i >= cp_len then 5589 # region_through_list é¨å5590 # region ãã @cell_name.@port_name ã¸ã® through ããªããæ¢ã5305 # region_through_list 部分 5306 # region から @cell_name.@port_name への through がないか探す 5591 5307 # rp = @through_list[i][3].find_cell_port_through_plugin( @cell_name, @port_name ) #762 5592 5308 rp = @through_list[i][3].find_cell_port_through_plugin( @cell.get_global_name, @port_name ) 5593 # @through_list[i] 㨠@region_through_list[i-cp_len] ã¯åã 5594 # å 5595 ±ç¨ããªãããã«ããã«ã¯ãè¦ã¤ãããªãã£ããã¨ã«ããã°ãã 5309 # @through_list[i] と @region_through_list[i-cp_len] は同じ 5310 # 共用しないようにするには、見つからなかったことにすればよい 5596 5311 # rp = nil 5597 5312 else 5598 # region 以å¤ã®ãã®ã¯å 5599 ±æããªã 5600 # å¼ã³å£å´ã«æå®ããã¦ããããplugin_arg ãç°ãªããããããªã 5313 # region 以外のものは共有しない 5314 # 呼び口側に指定されているし、plugin_arg が異なるかもしれない 5601 5315 rp = nil 5602 5316 end … … 5607 5321 end 5608 5322 else 5609 # è¦ã¤ãã£ããã®ãå 5610 ±ç¨ãã 5323 # 見つかったものを共用する 5611 5324 @through_generated_list[ i ] = rp 5612 5325 end 5613 5326 5614 5327 if i >= cp_len then 5615 # @through_generated_list ã®ãã¡ @region_through_listã«å¯¾å¿ããé¨å5328 # @through_generated_list のうち @region_through_listに対応する部分 5616 5329 @region_through_generated_list[ i - cp_len ] = @through_generated_list[ i ] 5617 5330 if rp == nil then 5618 # çæãããã®ã region(@through_list[i][3]) ã®ãªã¹ãã«è¿½å5331 # 生成したものを region(@through_list[i][3]) のリストに追加 5619 5332 # @through_list[i][3].add_cell_port_through_plugin( @cell_name, @port_name, @through_generated_list[i] ) #762 5620 5333 @through_list[i][3].add_cell_port_through_plugin( @cell.get_global_name, @port_name, @through_generated_list[i] ) … … 5623 5336 5624 5337 if i == 0 then 5625 # æãå¼ã³å£å´ã®ã»ã«ã¯ãCDL ä¸ã®çµåããªããããåç 5626 §ããããã¨ã«ãªããªã 5627 # mikan namespace å¯¾å¿ 5338 # 最も呼び口側のセルは、CDL 上の結合がないため、参照されたことにならない 5339 # mikan namespace 対応 5628 5340 # cell = Namespace.find( [ @through_generated_list[0].get_cell_name] ) #1 5629 5341 if @through_generated_list[0] == nil then 5630 return # plugin_object ã®çæã«å¤±æãã¦ãã5342 return # plugin_object の生成に失敗している 5631 5343 end 5632 5344 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 … … 5652 5364 end 5653 5365 5654 #=== Join# through ãã©ã°ã¤ã³ãå¼ã³åºã㦠CDL çæãããã¨ã¨ãã«ãimport ãã5366 #=== Join# through プラグインを呼び出して CDL 生成させるとともに、import する 5655 5367 def gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name ) 5656 5368 … … 5660 5372 plugin_arg = through[ 2 ] 5661 5373 if through[ 3 ] then 5662 # region éã® through ã®å ´å5374 # region 間の through の場合 5663 5375 @@start_region = through[ 3 ] 5664 5376 if next_cell.get_region.equal? @@start_region then … … 5670 5382 @@region_count = through[ 6 ] 5671 5383 else 5672 # å¼ã³å£ã® through ã®å ´å5673 @@start_region = @owner.get_region # å¼ã³å£å´ã»ã«ã®region5674 @@end_region = next_cell.get_region # 次ã®ã»ã«ã®region5675 @@through_type = :THROUGH # å¼ã³å£ã® through æå®5384 # 呼び口の through の場合 5385 @@start_region = @owner.get_region # 呼び口側セルの region 5386 @@end_region = next_cell.get_region # 次のセルの region 5387 @@through_type = :THROUGH # 呼び口の through 指定 5676 5388 @@region_count = 0 5677 5389 end … … 5687 5399 5688 5400 begin 5689 eval( eval_str ) # plugin ãçæ5401 eval( eval_str ) # plugin を生成 5690 5402 plugin_object.set_locale @locale 5691 5403 rescue Exception => evar … … 5702 5414 @through_generated_list[ i ] = plugin_object 5703 5415 5704 # Region ã«é¢ããæ 5705 å ±ãè¨å® 5706 # å¾ãã追å ããã®ã§ãnew ã®å¼æ°å¤ã§è¨å® 5416 # Region に関する情報を設定 5417 # 後から追加したので、new の引数外で設定 5707 5418 # plugin_object.set_through_info( start_region, end_region, through_type ) 5708 5419 … … 5710 5421 end 5711 5422 5712 # ãã©ã°ã¤ã³ã¸ã®å¼æ°ã§æ¸¡ããªããã®ããä¸æçã«è¨æ¶ãã¦ãã5713 # ãã©ã°ã¤ã³ã® initialize ã®ä¸ã§ã³ã¼ã«ããã¯ãã¦è¨å®ãã5423 #プラグインへの引数で渡さないものを、一時的に記憶しておく 5424 # プラグインの initialize の中でコールバックして設定する 5714 5425 @@plugin_creating_join = nil 5715 5426 @@start_region = nil … … 5718 5429 @@region_count = nil 5719 5430 5720 #=== Join# ThroughPlugin ã®è¿½å æ 5721 å ±ãè¨å®ãã 5722 # ãã®ã¡ã½ãã㯠ThroughPlugin#initialize ããå¼ã³åºããã 5723 # plugin_object ãçæããéã®å¼æ°ã§ã¯ä¸è¶³ããæ 5724 å ±ã追å ãã 5431 #=== Join# ThroughPlugin の追加情報を設定する 5432 # このメソッドは ThroughPlugin#initialize から呼び出される 5433 # plugin_object を生成する際の引数では不足する情報を追加する 5725 5434 def self.set_through_info plugin_object 5726 5435 plugin_object.set_through_info( @@start_region, @@end_region, @@through_type, … … 5734 5443 end 5735 5444 5736 #=== Join#é 5737 åæ·»æ°ãå¾ã 5738 # @subscript ã®èª¬æãåç 5739 §ã®ã㨠5445 #=== Join#配列添数を得る 5446 # @subscript の説明を参照のこと 5740 5447 def get_subscript 5741 5448 @subscript 5742 5449 end 5743 5450 5744 def get_cell_name # åãå£ã»ã«å5451 def get_cell_name # 受け口セル名 5745 5452 @cell_name 5746 5453 end … … 5754 5461 end 5755 5462 5756 #=== Join# å³è¾ºã®å®ã»ã«ãå¾ã 5757 # å®ã»ã«ã¨ã¯ through ã§æ¿å 5758 ¥ããããã®ãcomposite ã®å 5759 é¨ãªã©å®éã«çµåãããå 5760 5761 # ãã®ã¡ã½ããã¯ãget_rhs_port ã¨å¯¾ã«ãªã£ã¦ãã 5762 # ãã®ã¡ã½ããã¯ãæå³è§£æ段éã§ã¯å¼ã³åºãã¦ã¯ãªããªã (対象ã»ã«ã®æå³è§£æãæ¸ãåã«ã¯æ£ããçµæãè¿ããªã) 5463 #=== Join# 右辺の実セルを得る 5464 # 実セルとは through で挿入されたもの、composite の内部など実際に結合される先 5465 # このメソッドは get_rhs_port と対になっている 5466 # このメソッドは、意味解析段階では呼び出してはならない (対象セルの意味解析が済む前には正しい結果を返さない) 5763 5467 def get_rhs_cell 5764 # through æå®ããï¼5468 # through 指定あり? 5765 5469 if @through_list[0] then 5766 # mikan through ã§çæãããã®ã root namespace éå®5470 # mikan through で生成したものが root namespace 限定 5767 5471 if @through_generated_list[0] then 5768 5472 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] ) #1 5769 5473 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 5770 # cell ã nil ã«ãªãã®ã¯ãã©ã°ã¤ã³ã® get_cell_namespace_path ãæ£ãããªããã5771 # ãã©ã°ã¤ã³çæã³ã¼ããã¨ã©ã¼ã«ãªã£ã¦ããã5772 # ã§ãã®æªããã©ã°ã¤ã³ãå¤ããã°ãcell == nil ãã¯ãããæ¹ãããã5474 # cell が nil になるのはプラグインの get_cell_namespace_path が正しくないか、 5475 # プラグイン生成コードがエラーになっている。 5476 # できの悪いプラグインが多ければ、cell == nil をはじいた方がよい。 5773 5477 return cell.get_real_cell( @through_generated_list[0].get_through_entry_port_name ) 5774 5478 else 5775 return nil # generate ã«å¤±æãã¦ãã5479 return nil # generate に失敗している 5776 5480 end 5777 5481 elsif @cell then 5778 5482 return @cell.get_real_cell( @port_name ) 5779 5483 else 5780 # å³è¾ºãæªå®ç¾©ã®å ´å @cell 㯠nil (æ¢ã«ã¨ã©ã¼)5484 # 右辺が未定義の場合 @cell は nil (既にエラー) 5781 5485 return nil 5782 5486 end 5783 5487 end 5784 5488 5785 #=== Join# å³è¾ºã®ã»ã«ãå¾ã5786 # å³è¾ºã®ã»ã«ãå¾ãããã ããcomposite å±éããã¦ããªã5787 # composite å±éããããã®ãå¾ãã«ã¯ get_rhs_cell ã使ã5788 # ãããã¿ã¤ã宣è¨ããããã¦ããªãå ´åã«ã¯ããã¡ããã使ããªã5789 # ãã®ã¡ã½ãã㯠get_rhs_port2 ã¨å¯¾ã«ãªã£ã¦ãã5489 #=== Join# 右辺のセルを得る 5490 # 右辺のセルを得る。ただし、composite 展開されていない 5491 # composite 展開されたものを得るには get_rhs_cell を使う 5492 # プロトタイプ宣言しかされていない場合には、こちらしか使えない 5493 # このメソッドは get_rhs_port2 と対になっている 5790 5494 def get_rhs_cell2 5791 # through æå®ããï¼5495 # through 指定あり? 5792 5496 if @through_list[0] then 5793 # mikan through ã§çæãããã®ã root namespace éå®5497 # mikan through で生成したものが root namespace 限定 5794 5498 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name ] ) 5795 5499 if @through_generated_list[0] then … … 5797 5501 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 5798 5502 else 5799 cell = @cell # generate ã«å¤±æãã¦ãã5503 cell = @cell # generate に失敗している 5800 5504 end 5801 5505 else … … 5806 5510 end 5807 5511 5808 #=== Join# å³è¾ºã®ã»ã«ãå¾ã5809 # through ã¯é©ç¨ããªãããcomposite ã¯å±éããå¾ã®ã»ã«5810 # ( æå³è§£æãçµãã£ã¦ããªãã¨ãcomposite å±éãçµãã£ã¦ããªã)5811 # ãã®ã¡ã½ãã㯠get_rhs_port3 ã¨å¯¾ã«ãªã£ã¦ãã5512 #=== Join# 右辺のセルを得る 5513 # through は適用しないが、composite は展開した後のセル 5514 # (意味解析が終わっていないと、composite 展開が終わっていない) 5515 # このメソッドは get_rhs_port3 と対になっている 5812 5516 def get_rhs_cell3 5813 5517 if @cell then … … 5816 5520 end 5817 5521 5818 #=== Join# å³è¾ºã®ã»ã«ã®ãªã¼ã¸ã§ã³ãå¾ã5819 # å³è¾ºãæªå®ç¾©ã®å ´åãnil ãè¿ã5820 # composite ã®å ´åãå®ã»ã«ã§ã¯ãªã composite cell ã® region ãè¿ã(composite ã¯ãã¹ã¦åã region ã«å±ãã)5821 # composite ã® cell ããããã¿ã¤ã宣è¨ããã¦ããã¨ã get_rhs_cell/get_real_cell 㯠ruby ã®ä¾å¤ã¨ãªã5522 #=== Join# 右辺のセルのリージョンを得る 5523 # 右辺が未定義の場合、nil を返す 5524 # composite の場合、実セルではなく composite cell の region を返す(composite はすべて同じ region に属する) 5525 # composite の cell がプロトタイプ宣言されているとき get_rhs_cell/get_real_cell は ruby の例外となる 5822 5526 def get_rhs_region 5823 # through æå®ããï¼5527 # through 指定あり? 5824 5528 if @through_list[0] then 5825 5529 if @through_generated_list[0] then 5826 # mikan through ã§çæãããã®ã root namespace éå®5530 # mikan through で生成したものが root namespace 限定 5827 5531 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] ) #1 5828 5532 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 … … 5831 5535 end 5832 5536 else 5833 return nil # generate ã«å¤±æãã¦ãã5537 return nil # generate に失敗している 5834 5538 end 5835 5539 elsif @cell then 5836 5540 return @cell.get_region 5837 5541 end 5838 # å³è¾ºãæªå®ç¾©ã®å ´å @cell 㯠nil (æ¢ã«ã¨ã©ã¼)5542 # 右辺が未定義の場合 @cell は nil (既にエラー) 5839 5543 return nil 5840 5544 end 5841 5545 5842 def get_cell_global_name # åãå£ã»ã«åï¼ã³ã³ãã¸ãããªãå±éããå 5843 å´ã®ã»ã«ï¼ 5546 def get_cell_global_name # 受け口セル名(コンポジットなら展開した内側のセル) 5844 5547 5845 5548 # debug … … 5855 5558 end 5856 5559 5857 #=== Join# çµåã®å³è¾ºã®åãå£ã®åå 5858 # namespace å + '_' + ã»ã«å + '_' + åãå£å ï¼ãã®ã»ã«ã composite ãªãã°å±éå¾ã®ã»ã«åãåãå£åï¼ 5859 #subscript:: Integer å¼ã³å£é 5860 åã®ææ·»æ° ã¾ã㯠nil å¼ã³å£é 5861 åã§ãªãæ 5862 def get_port_global_name( subscript = nil ) # åãå£åï¼ã³ã³ãã¸ãããªãå±éããå 5863 å´ã®ã»ã«ï¼ 5560 #=== Join# 結合の右辺の受け口の名前 5561 # namespace 名 + '_' + セル名 + '_' + 受け口名 (このセルが composite ならば展開後のセル名、受け口名) 5562 #subscript:: Integer 呼び口配列の時添数 または nil 呼び口配列でない時 5563 def get_port_global_name( subscript = nil ) # 受け口名(コンポジットなら展開した内側のセル) 5864 5564 5865 5565 # debug 5866 5566 dbgPrint "Cell get_port_global_name: #{@cell_name}\n" 5867 5567 5868 # through æå®ããï¼5568 # through 指定あり? 5869 5569 if @through_list[0] then 5870 5570 5871 # mikan through ã§çæãããã®ã root namespace éå®5571 # mikan through で生成したものが root namespace 限定 5872 5572 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] ) #1 5873 5573 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 5874 5574 5875 # through ã§æ¿å 5876 ¥ãããã»ã«ã§ãå®éã«æ¥ç¶ãããã»ã«ï¼compositeã®å ´åå 5877 é¨ã®)ã®åãå£ã® C è¨èªåå 5575 # through で挿入されたセルで、実際に接続されるセル(compositeの場合内部の)の受け口の C 言語名前 5878 5576 return cell.get_real_global_port_name( @through_generated_list[0].get_through_entry_port_name ) 5879 5577 else 5880 5578 5881 # å®éã«æ¥ç¶ãããã»ã«ã®åãå£ã® C è¨èªåå5579 # 実際に接続されるセルの受け口の C 言語名前 5882 5580 if @cell then 5883 5581 return @cell.get_real_global_port_name( @port_name ) … … 5902 5600 end 5903 5601 5904 #=== Join# å³è¾ºã®ãã¼ããå¾ã 5905 # å³è¾ºã composite ã®å ´åã¯ãå 5906 é¨ã®ç¹ããã»ã«ã®ãã¼ã, through ã®å ´åã¯æ¿å 5907 ¥ãããã»ã«ã®ãã¼ã 5908 # ãã®ã¡ã½ãã㯠get_rhs_cell ã¨å¯¾ã«ãªã£ã¦ãã 5602 #=== Join# 右辺のポートを得る 5603 # 右辺が composite の場合は、内部の繋がるセルのポート, through の場合は挿入されたセルのポート 5604 # このメソッドは get_rhs_cell と対になっている 5909 5605 def get_rhs_port 5910 # through æå®ããï¼5606 # through 指定あり? 5911 5607 if @through_list[0] then 5912 # mikan through ã§çæãããã®ã root namespace éå®5913 # through ã§çæãããã»ã«ãæ¢ã5608 # mikan through で生成したものが root namespace 限定 5609 # through で生成されたセルを探す 5914 5610 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] ) #1 5915 5611 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 5916 # cell ã®ãã©ã°ã¤ã³ã§çæããããã¼ãåã®ãã¼ããæ¢ã (composite ãªãå 5917 é¨ã®ç¹ãããã¼ã) 5612 # cell のプラグインで生成されたポート名のポートを探す (composite なら内部の繋がるポート) 5918 5613 return cell.get_real_port( @through_generated_list[0].get_through_entry_port_name ) 5919 5614 else 5920 # ãã¼ããè¿ã(composite ãªãå 5921 é¨ã®ç¹ãããã¼ããè¿ã) 5615 # ポートを返す(composite なら内部の繋がるポートを返す) 5922 5616 return @cell.get_real_port( @port_name ) 5923 5617 end 5924 5618 end 5925 5619 5926 #=== Join# å³è¾ºã®ãã¼ããå¾ã5927 # å³è¾ºã®ãã¼ããå¾ãã5928 # ããã¯ãããã¿ã¤ã宣è¨ããããã¦ããªãå ´åã«ã¯ããã¡ããã使ããªã5620 #=== Join# 右辺のポートを得る 5621 # 右辺のポートを得る。 5622 # これはプロトタイプ宣言しかされていない場合には、こちらしか使えない 5929 5623 def get_rhs_port2 5930 # through æå®ããï¼5624 # through 指定あり? 5931 5625 if @through_list[0] then 5932 5626 if @through_generated_list[0] then 5933 5627 port = @through_generated_list[0].get_through_entry_port_name.to_sym 5934 5628 else 5935 port = @port_name # generate ã«å¤±æãã¦ãã5629 port = @port_name # generate に失敗している 5936 5630 end 5937 5631 else … … 5942 5636 end 5943 5637 5944 #=== Join# å³è¾ºã®ãã¼ããå¾ã5945 # through ã¯é©ç¨ããªãããcomposite ã¯å±éããå¾ã®ã»ã«ã®å¯¾å¿ãããã¼ã5638 #=== Join# 右辺のポートを得る 5639 # through は適用しないが、composite は展開した後のセルの対応するポート 5946 5640 def get_rhs_port3 5947 5641 if @cell then … … 5950 5644 end 5951 5645 5952 #=== Join# å¼ã³å£é 5953 åã®2çªç®ä»¥éã®è¦ç´ ã追å ãã 5954 # ä¸çªæåã«å®ç¾©ãããé 5955 åè¦ç´ ãå 5956 ¨è¦ç´ ã®åæå¤ã®é 5957 åãæ㤠5958 # ãã®ã¡ã½ããã¯éé 5959 åã®å ´åãå¼åºãããï¼join éè¤ã¨ã©ã¼ã®å ´åï¼ 5960 #join2:: Join å¼ã³å£é 5961 åè¦ç´ ã® Join 5646 #=== Join# 呼び口配列の2番目以降の要素を追加する 5647 # 一番最初に定義された配列要素が全要素の初期値の配列を持つ 5648 # このメソッドは非配列の場合も呼出される(join 重複エラーの場合) 5649 #join2:: Join 呼び口配列要素の Join 5962 5650 def add_array_member join2 5963 5651 5964 # subscript2: join2 ã®å·¦è¾ºæ·»æ°5652 # subscript2: join2 の左辺添数 5965 5653 subscript2 = join2.get_subscript 5966 5654 5967 5655 if @subscript == nil then # not array : initialize duplicate 5968 # éé 5969 åã®å ´åãjoin ãéè¤ãã¦ãã 5656 # 非配列の場合、join が重複している 5970 5657 cdl_error( "S1127 \'$1\' duplicate", @name ) 5971 5658 # print "add_array_member2: #{@owner.get_name}\n" 5972 5659 5973 5660 elsif @subscript >= 0 then 5974 # æ·»æ°æå®ããã®å ´å5661 # 添数指定ありの場合 5975 5662 if( subscript2 == nil || subscript2 < 0 ) then 5976 # join2 左辺ã¯éé 5977 åã¾ãã¯æ·»æ°ãªã 5978 # é 5979 åãä¸ä¸è´ 5663 # join2 左辺は非配列または添数なし 5664 # 配列が不一致 5980 5665 cdl_error( "S1128 \'$1\' inconsistent array definition", @name ) 5981 5666 elsif @array_member[subscript2] != nil then 5982 # åãæ·»æ°ãæ¢ã«å®ç¾©æ¸ã¿5667 # 同じ添数が既に定義済み 5983 5668 cdl_error( "S1129 \'$1\' redefinition of subscript $2" ,@name, subscript2 ) 5984 5669 else 5985 # æ·»æ°ã®ä½ç½®ã«è¦ç´ ã追å5670 # 添数の位置に要素を追加 5986 5671 @array_member[subscript2] = join2.get_rhs 5987 5672 @array_member2[subscript2] = join2 … … 5990 5675 5991 5676 else 5992 # æ·»æ°æå®ãªãã®å ´å5677 # 添数指定なしの場合 5993 5678 if( subscript2 == nil || subscript2 >= 0 ) then 5994 # join2 左辺ã¯éé 5995 åã¾ãã¯æ·»æ°æ 5996 # é 5997 åãä¸ä¸è´ 5679 # join2 左辺は非配列または添数有 5680 # 配列が不一致 5998 5681 cdl_error( "S1130 \'R1\' inconsistent array definition", @name ) 5999 5682 end 6000 5683 6001 # æ·»æ°ãªãé 6002 åã®å ´åãé 6003 åè¦ç´ ã追å 5684 # 添数なし配列の場合、配列要素を追加 6004 5685 @array_member << join2.get_rhs 6005 5686 @array_member2 << join2 … … 6025 5706 while i < @array_member2.length 6026 5707 if @array_member2[i] != self && @array_member[i] != nil then 6027 # @array_member2[i] ã nil ã«ãªãã®ã¯ optional ã®æã¨ã 6028 # Join ã® initialize ã§ç¡é§ã« @array_member2 ãè¨å®ããã¦ããå ´å 6029 # ç¡é§ã«è¨å®ããã¦ãããã®ã«ã¤ãã¦ã¯ãå帰çã«å¼ã³åºãå¿ 6030 è¦ã¯ãªãï¼clone_for_composite ã§ã¯å¯¾çãã¦ããï¼ 5708 # @array_member2[i] が nil になるのは optional の時と、 5709 # Join の initialize で無駄に @array_member2 が設定されている場合 5710 # 無駄に設定されているものについては、再帰的に呼び出す必要はない(clone_for_composite では対策している) 6031 5711 @array_member2[i].change_name( name ) 6032 5712 end … … 6036 5716 end 6037 5717 6038 # composite cell ãå±éããã»ã«ã®çµåã clone ããã»ã«ã®ååã«å¤æ´5718 # composite cell を展開したセルの結合を clone したセルの名前に変更 6039 5719 def change_rhs_port( clone_cell_list, celltype ) 6040 5720 … … 6054 5734 dbgPrint " cell_name: #{@cell_name} => #{c.get_global_name}, #{c.get_name}\n" 6055 5735 6056 # @rhs ã®å 6057 容ã調æ´ãã¦ããï¼ãã®å 6058 容ã¯ãsubscript ãé¤ãã¦ãå¾ãã使ããã¦ããªãï¼ 5736 # @rhs の内容を調整しておく(この内容は、subscript を除いて、後から使われていない) 6059 5737 elements = @rhs.get_elements 6060 if elements[0] == :OP_SUBSC then # å³è¾ºï¼åãå£é 6061 åï¼ 5738 if elements[0] == :OP_SUBSC then # 右辺:受け口配列? 6062 5739 elements = elements[1] 6063 5740 end 6064 5741 6065 # å³è¾ºããcell.ePort ã®å½¢å¼ã§ãªã5742 # 右辺が cell.ePort の形式でない 6066 5743 if elements[0] != :OP_DOT || elements[1][0] != :IDENTIFIER then #1 6067 5744 return 6068 5745 else 6069 # ã»ã«åã composite å 6070 é¨ã®ååãããå¤é¨ã®ååã«å 6071 ¥ãæ¿ãã 5746 # セル名を composite 内部の名前から、外部の名前に入れ替える 6072 5747 # elements[1][1] = Token.new( c.get_name, nil, nil, nil ) 6073 5748 elements[1][1] = NamespacePath.new( c.get_name, false, c.get_namespace ) … … 6076 5751 @cell_name = c.get_name 6077 5752 @cell = c 6078 # @definition = nil # @definition ãæå¹ï¼ ãã§ãã¯æ¸ã¿ï¼ã¨ã¯ãããªãï¼5753 # @definition = nil # @definition が有効: チェック済み(とは、しない) 6079 5754 6080 5755 if @array_member2 then … … 6085 5760 i = 0 6086 5761 while i < @array_member2.length 6087 # @array_member2[i] ã nil ã«ãªãã®ã¯ optional ã®æã¨ã 6088 # Join ã® initialize ã§ç¡é§ã« @array_member2 ãè¨å®ããã¦ããå ´å 6089 # ç¡é§ã«è¨å®ããã¦ãããã®ã«ã¤ãã¦ã¯ãå帰çã«å¼ã³åºãå¿ 6090 è¦ã¯ãªãï¼clone_for_composite ã§ã¯å¯¾çãã¦ããï¼ 5762 # @array_member2[i] が nil になるのは optional の時と、 5763 # Join の initialize で無駄に @array_member2 が設定されている場合 5764 # 無駄に設定されているものについては、再帰的に呼び出す必要はない(clone_for_composite では対策している) 6091 5765 if @array_member2[i] != self && @array_member[i] != nil then 6092 5766 @array_member2[i].change_rhs_port( clone_cell_list, celltype ) … … 6098 5772 end 6099 5773 6100 #=== Join# composite ã»ã«ç¨ã«ã¯ãã¼ã³ 6101 #cell_global_name:: string : 親ã»ã«ã®ã°ãã¼ãã«å 6102 # å³è¾ºã® C_EXP ã«å«ã¾ãã $id$, $cell$, $ct$ ãç½®æ 6103 # ããã§ç½®æããã®ã¯ composite ã® attribute ã® C_EXP ã composite ã»ã«ã¿ã¤ãããã³ã»ã«åã«ç½®æãããã 6104 # ï¼å 6105 é¨ã»ã«ã® C_EXP ãããã§ç½®æãããï¼ 6106 # @through_list ãªã©ãã³ãã¼ãããã®ã§ããããå¼ã³åºãããåã«ç¢ºå®ããå¿ 6107 è¦ããã 5774 #=== Join# composite セル用にクローン 5775 #cell_global_name:: string : 親セルのグローバル名 5776 # 右辺の C_EXP に含まれる $id$, $cell$, $ct$ を置換 5777 # ここで置換するのは composite の attribute の C_EXP を composite セルタイプおよびセル名に置換するため 5778 # (内部セルの C_EXP もここで置換される) 5779 # @through_list などもコピーされるので、これが呼び出される前に確定する必要がある 6108 5780 def clone_for_composite( ct_name, cell_name, locale, b_need_recursive = true ) 6109 5781 … … 6125 5797 6126 5798 def clone_array_member( array_member, array_member2, ct_name, cell_name, prev, locale ) 6127 # é 6128 åã®ã³ãã¼ãä½ã 5799 # 配列のコピーを作る 6129 5800 am = array_member.clone 6130 5801 am2 = array_member2.clone 6131 5802 6132 # é 6133 åè¦ç´ ã®ã³ãã¼ãä½ã 5803 # 配列要素のコピーを作る 6134 5804 i = 0 6135 5805 while i < am2.length 6136 5806 if array_member2[i] == prev then 6137 # èªåèªèº«ã§ããï¼ã®ã§ãå¼åºãã¨ç¡éå帰å¼åºãã¨ãªãï¼5807 # 自分自身である(ので、呼出すと無限再帰呼出しとなる) 6138 5808 am2[i] = self 6139 5809 elsif array_member2[i] then 6140 5810 am2[i] = array_member2[i].clone_for_composite( ct_name, cell_name, locale, false ) 6141 5811 else 6142 # 以åã®ã¨ã©ã¼ã§ array_member2[i] 㯠nil ã«ãªã£ã¦ãã5812 # 以前のエラーで array_member2[i] は nil になっている 6143 5813 end 6144 5814 … … 6149 5819 end 6150 5820 6151 # i = 0 ã¯ãããã§èªåèªèº«ãè¨å®5821 # i = 0 は、ここで自分自身を設定 6152 5822 # am2[0] = self 6153 5823 … … 6157 5827 end 6158 5828 6159 #=== Join# rhs ãå 6160 ¥ãæãã 5829 #=== Join# rhs を入れ換える 6161 5830 #rhs:: Expression | initializer 6162 # å³è¾ºãå 6163 ¥ãæããï¼ 6164 # ãã®ã¡ã½ããã¯ãcomposite 㧠cell ã®å±æ§ã®åæå¤ã attribute ã®å¤ã§ç½®ãæããã®ã«ä½¿ããã 6165 # ãã®ã¡ã½ãã㯠composite å 6166 ã® cell ã®å±æ§ã®åæå¤ãå®æ°ã§ã¯ãªãå¼ã«ãªã£ãå ´åãä¸è¦ã«ãªã 5831 # 右辺を入れ換える. 5832 # このメソッドは、composite で cell の属性の初期値を attribute の値で置き換えるのに使われる 5833 # このメソッドは composite 内の cell の属性の初期値が定数ではなく式になった場合、不要になる 6167 5834 def change_rhs rhs 6168 5835 @rhs = rhs 6169 5836 end 6170 5837 6171 #=== Join# clone ããã join ã® owner ãå¤æ´5838 #=== Join# clone された join の owner を変更 6172 5839 def set_cloned( owner ) 6173 5840 dbgPrint "Join#set_cloned: #{@name} prev owner: #{@owner.get_name} new owner: #{owner.get_name}\n" … … 6255 5922 end 6256 5923 6257 #== éçµå5924 #== 逆結合 6258 5925 class ReverseJoin < BDNode 6259 5926 #@ep_name:: Symbol … … 6280 5947 end 6281 5948 6282 # CLASS: CompositeCelltype ç¨ã®Join6283 # REM: CompositeCelltype ã export ãããã®5949 # CLASS: CompositeCelltype 用の Join 5950 # REM: CompositeCelltype が export するもの 6284 5951 class CompositeCelltypeJoin < BDNode 6285 # @export_name:: string : CompositeCelltype ã export ããååï¼å¼ã³å£ãåãå£ãå±æ§ï¼ 6286 # @internal_cell_name:: string : CompositeCelltype å 6287 é¨ã®ã»ã«ã®åå 6288 # @internal_cell_elem_name:: string : CompositeCelltype å 6289 é¨ã®ã»ã«ã®å¼ã³å£ãåãå£ãå±æ§ã®åå 6290 # @cell : Cell : Cell:: internal cell : CompositeCelltyep å 6291 é¨ã®ã»ã«ï¼in_compositeã»ã«ï¼ 5952 # @export_name:: string : CompositeCelltype が export する名前(呼び口、受け口、属性) 5953 # @internal_cell_name:: string : CompositeCelltype 内部のセルの名前 5954 # @internal_cell_elem_name:: string : CompositeCelltype 内部のセルの呼び口、受け口、属性の名前 5955 # @cell : Cell : Cell:: internal cell : CompositeCelltyep 内部のセル(in_compositeセル) 6292 5956 # @port_decl:: Port | Decl 6293 5957 # @b_pseudo: bool : … … 6304 5968 end 6305 5969 6306 #=== CompositeCelltypeJoin# CompositeCelltypeJoin ã®å¯¾è±¡ã»ã«ãï¼6307 #cell:: Cell 対象ãã©ãããã§ãã¯ããã»ã«5970 #=== CompositeCelltypeJoin# CompositeCelltypeJoin の対象セルか? 5971 #cell:: Cell 対象かどうかチェックするセル 6308 5972 # 6309 # CompositeCelltypeJoin 㨠cell ã®ååãä¸è´ããããã§ãã¯ãã6310 # port_decl ãæå®ãããå ´åã¯ãç¾ç¶ä½¿ããã¦ããªã5973 # CompositeCelltypeJoin と cell の名前が一致するかチェックする 5974 # port_decl が指定された場合は、現状使われていない 6311 5975 def match?( cell, port_decl = nil ) 6312 5976 … … 6324 5988 6325 5989 # if @cell.equal?( cell ) && ( port_decl == nil || @port_decl.equal?( port_decl ) ) then 6326 # ãªã port_decl ãä¸è´ããªããã°ãªããªãã£ããå¿ããã6327 # recursive_composite ã§ååã®ä¸è´ã«å¤æ´0609175990 # なぜ port_decl が一致しなければならなかったか忘れた。 5991 # recursive_composite で名前の一致に変更 060917 6328 5992 if((@cell.get_name == cell.get_name) && (port_decl == nil || @port_decl.get_name == port_decl.get_name))then 6329 5993 true … … 6357 6021 end 6358 6022 6359 # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã6023 # @port_decl が Port の場合のみ呼び出してよい 6360 6024 def get_port_type 6361 6025 if @port_decl then … … 6379 6043 end 6380 6044 6381 # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã6045 # @port_decl が Port の場合のみ呼び出してよい 6382 6046 def is_require? 6383 6047 if @port_decl then … … 6386 6050 end 6387 6051 6388 # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã6052 # @port_decl が Port の場合のみ呼び出してよい 6389 6053 def is_allocator_port? 6390 6054 if @port_decl then … … 6393 6057 end 6394 6058 6395 # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã6059 # @port_decl が Port の場合のみ呼び出してよい 6396 6060 def is_optional? 6397 6061 if @port_decl then … … 6400 6064 end 6401 6065 6402 #=== CompositeCelltypeJoin# å³è¾ºã Decl ãªãã°åæååï¼å¼ï¼ãè¿ã6403 # ãã®ã¡ã½ãã㯠Cell ã® check_join ããåæå¤ãã§ãã¯ã®ããã«å¼ã³åºããã6066 #=== CompositeCelltypeJoin# 右辺が Decl ならば初期化子(式)を返す 6067 # このメソッドは Cell の check_join から初期値チェックのために呼び出される 6404 6068 def get_initializer 6405 6069 if @port_decl.instance_of? Decl then … … 6414 6078 end 6415 6079 6416 #=== CompositeCelltypeJoin# é 6417 åãµã¤ãºãå¾ã 6418 #RETURN:: nil: not array, "[]": 大ããæå®ãªã, Integer: 大ããæå®ãã 6080 #=== CompositeCelltypeJoin# 配列サイズを得る 6081 #RETURN:: nil: not array, "[]": 大きさ指定なし, Integer: 大きさ指定あり 6419 6082 def get_array_size 6420 6083 @port_decl.get_array_size 6421 6084 end 6422 6085 6423 #=== CompositeCelltypeJoin# signature ãå¾ã6424 # @port_decl ã Port ã®æã®ã¿å¼ã³åºãã¦ããã6086 #=== CompositeCelltypeJoin# signature を得る 6087 # @port_decl が Port の時のみ呼び出してもよい 6425 6088 def get_signature 6426 6089 @port_decl.get_signature … … 6465 6128 # @file_name:: string 6466 6129 # @format:: string 6467 # @arg_list:: Expression ã® elements ã¨åãå½¢å¼[ [:IDENTIFIER, String], ... ]6130 # @arg_list:: Expression の elements と同じ形式 [ [:IDENTIFIER, String], ... ] 6468 6131 # @f_celltype:: bool : true: celltype factory, false: cell factory 6469 6132 … … 6476 6139 case name 6477 6140 when :write 6478 # write é¢æ°6141 # write 関数 6479 6142 @name = name 6480 6143 6481 # write é¢æ°ã®ç¬¬ä¸å¼æ°ï¼åºåå 6482 ãã¡ã¤ã«å 6483 # å¼ãè©ä¾¡ããï¼é常åä¸ã®æååã§ãããããåä¸ã®æååãè¿ãããï¼ 6144 # write 関数の第一引数:出力先ファイル名 6145 # 式を評価する(通常単一の文字列であるから、単一の文字列が返される) 6484 6146 @file_name = file_name.eval_const(nil).val # file_name : Expression 6485 6147 if ! @file_name.instance_of?( String ) then 6486 # æååå®æ°ã§ã¯ãªãã£ã6148 # 文字列定数ではなかった 6487 6149 cdl_error( "S1132 $1: 1st parameter is not string(file name)" , @name ) 6488 6150 @file_name = nil 6489 6151 end 6490 6152 6491 # write é¢æ°ã®ç¬¬äºå¼æ°ï¼ãã©ã¼ãããæåå6153 # write 関数の第二引数:フォーマット文字列 6492 6154 @format = format.eval_const(nil).val # format : Expression 6493 # å¼ãè©ä¾¡ããï¼é常åä¸ã®æååã§ãããããåä¸ã®æååãè¿ãããï¼6155 # 式を評価する(通常単一の文字列であるから、単一の文字列が返される) 6494 6156 if ! @format.instance_of?( String ) then 6495 # æååå®æ°ã§ã¯ãªãã£ã6157 # 文字列定数ではなかった 6496 6158 cdl_error( "S1133 $1: 2nd parameter is not string(fromat)" , @name ) 6497 6159 @format = nil 6498 6160 end 6499 6161 6500 # 第ä¸å¼æ°ä»¥éãå¼æ°ãªã¹ãã¨ãã mikan å¼æ°ã®ãã§ãã¯6162 # 第三引数以降を引数リストとする mikan 引数のチェック 6501 6163 @arg_list = arg_list 6502 6164 … … 6575 6237 #== Domain 6576 6238 # 6577 # region ã® domain ãè¨æ¶ããã¯ã©ã¹6239 # region の domain を記憶するクラス 6578 6240 class DomainType < Node 6579 #@name::Symbol : ãã¡ã¤ã³ã¿ã¤ãã®ååex) HRP26241 #@name::Symbol : ドメインタイプの名前 ex) HRP2 6580 6242 #@region::Region 6581 6243 #@plugin_name::Symbol : ex) HRP2Plugin 6582 6244 #@option::String : ex) "trusted", "nontrusted" 6583 #@plugin::DomainPlugin ã®åã¯ã©ã¹6245 #@plugin::DomainPlugin の子クラス 6584 6246 6585 6247 include PluginModule 6586 6248 6587 # ãã¡ã¤ã³ã«å±ãã region ã®Hash6588 # domain æå®ãä¸åº¦ãè¡ãããªãå ´åããã®ãªã¹ãã¯ç©ºã§ãã6589 # ã«ã¼ããªã¼ã¸ã§ã³ã¯ option = "OutOfDomain" ã§ç»é²ããã (domain æå®ãç¡ããã°ç»é²ãããªã)6249 # ドメインに属する region の Hash 6250 # domain 指定が一度も行われない場合、このリストは空である 6251 # ルートリージョンは option = "OutOfDomain" で登録される (domain 指定が無ければ登録されない) 6590 6252 @@domain_regions = { } # { :domain_type => [ region, ... ] } 6591 6253 … … 6628 6290 end 6629 6291 6630 #== Domain ãªã¼ã¸ã§ã³ã® Hash ãå¾ã 6631 # @@domain_regions ã®èª¬æåç 6632 § 6292 #== Domain リージョンの Hash を得る 6293 # @@domain_regions の説明参照 6633 6294 def self.get_domain_regions 6634 6295 return @@domain_regions … … 6649 6310 end 6650 6311 6651 #== Region ã¯ã©ã¹6312 #== Region クラス 6652 6313 # 6653 # Region 㯠Namespace ãç¶æ¿ãã¦ãã6654 # root region ã¯ç¹æ®ã§ãroot namespace ã¨åãã§ãã6314 # Region は Namespace を継承している 6315 # root region は特殊で、root namespace と同じである 6655 6316 # 6656 # cell 㯠region ã«å±ãã6657 # region ã«å±ãã cell ã®ãªã¹ã㯠Namespace ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¨ãã¦è¨æ¶ããã6317 # cell は region に属する 6318 # region に属する cell のリストは Namespace クラスのインスタンス変数として記憶される 6658 6319 # 6659 6320 class Region < Namespace 6660 6321 # @name:: string 6661 # @in_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil ã®æ in ç¦æ¢6662 # @out_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil ã®æ out ç¦æ¢6322 # @in_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil の時 in 禁止 6323 # @out_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil の時 out 禁止 6663 6324 # @to_through_list:: [ [ dst_region, plugin_name, plugin_arg ], ... ] 6664 # @cell_port_throug_plugin_list:: { "#{cell_name}.#{port_name}" => through_generated_list ã®è¦ç´}6665 # ãã® region ãã cell_name.port_name ã¸ã® through ãã©ã°ã¤ã³ã§çæããããªãã¸ã§ã¯ã6325 # @cell_port_throug_plugin_list:: { "#{cell_name}.#{port_name}" => through_generated_list の要素 } 6326 # この region から cell_name.port_name への through プラグインで生成されたオブジェクト 6666 6327 # @region_type::Symbol : :NODE, :LINKUNIT, :DOMAIN, :CLASS 6667 # @region_type_param::Symbol : domain, class ã®åå. node, linkunit ã§ã¯nil6668 # @link_root:: Region : linkUnit ã®æ ¹ã£ãã¨ãªã region (node, linkunit ãæå®ãããregion)6669 # @family_line:: [ @region_root, ...,@region_me ] 家系6670 # @in_through_count:: Integer : n çªç®ã® in_through çµå(n>=0)6671 # @out_through_count:: Integer : n çªç®ã® out_through çµå(n>=0)6672 # @to_through_count:: { :RegionName => Integer }: RegionName ã¸ã® n çªç®ã® to_through çµå(n>=0)6673 # @domain_type::DomainType : domain æå®ããã¦ããªãå ´åãnil6674 # @domain_root::Region : domain æå®ããã¦ããªã Region (root ã®å ´ånil)6328 # @region_type_param::Symbol : domain, class の名前. node, linkunit では nil 6329 # @link_root:: Region : linkUnit の根っことなる region (node, linkunit が指定された region) 6330 # @family_line:: [ @region_root, ...,@region_me ] 家系 6331 # @in_through_count:: Integer : n 番目の in_through 結合 (n>=0) 6332 # @out_through_count:: Integer : n 番目の out_through 結合 (n>=0) 6333 # @to_through_count:: { :RegionName => Integer }: RegionName への n 番目の to_through 結合 (n>=0) 6334 # @domain_type::DomainType : domain 指定されていない場合、nil 6335 # @domain_root::Region : domain 指定されていなる Region (root の場合 nil) 6675 6336 6676 6337 @@in_through_list = [] … … 6680 6341 @@region_type_param = nil 6681 6342 @@domain_name = nil 6682 @@domain_option = nil # Token ãå 6683 ¥ã 6343 @@domain_option = nil # Token が入る 6684 6344 6685 6345 @@link_roots = [] 6686 6346 6687 6347 def initialize( name ) 6688 # mikan name ã® Namespace 修飾6689 # object = Namespace.find( [ name ] ) # 親ã¾ã§æãã«ãã6348 # mikan name の Namespace 修飾 6349 # object = Namespace.find( [ name ] ) # 親まで捜しにいく 6690 6350 if name != "::" then 6691 6351 object = Namespace.get_current.find( name ) #1 6692 6352 else 6693 # root ãªã¼ã¸ã§ã³6353 # root リージョン 6694 6354 object = nil 6695 6355 @@region_type = :NODE … … 6727 6387 dbgPrint "Region.new: re-appear #{@name}\n" 6728 6388 6729 # # Region path ãåååºç¾ã¨ä¸è´ãããï¼6389 # # Region path が前回出現と一致するか? 6730 6390 # if @@region_stack[ @@region_stack_sp - 1 ] then 6731 6391 # my_path = @@region_stack[ @@region_stack_sp - 1 ].get_path_string.to_s + "." + @name.to_s … … 6737 6397 # end 6738 6398 6739 # ååºç¾6399 # 再出現 6740 6400 # @@region_stack[@@region_stack_sp] = object 6741 6401 6742 # ååºç¾æã« specifier ãæå®ããã¦ãããï¼6402 # 再出現時に specifier が指定されているか? 6743 6403 if( @in_through_list.length != 0 || @out_through_list.length != 0 || @to_through_list.length != 0 || @region_type != nil )then 6744 6404 cdl_error( "S1140 $1: region specifier must place at first appearence" , name ) … … 6747 6407 6748 6408 else 6749 # ã¨ã©ã¼ç¨ããã¼å®ç¾©6750 6751 # ç°ãªãååã®ãªãã¸ã§ã¯ããå®ç¾©æ¸ã¿6409 # エラー用ダミー定義 6410 6411 # 異なる同名のオブジェクトが定義済み 6752 6412 cdl_error( "S1141 $1 duplication, previous one : $2" , name, object.class ) 6753 # @@region_stack[@@region_stack_sp] = self # ã¨ã©ã¼ææ«å®region6754 end 6755 else 6756 # ååºç¾6413 # @@region_stack[@@region_stack_sp] = self # エラー時暫定 region 6414 end 6415 else 6416 # 初出現 6757 6417 dbgPrint "Region.new: #{@name}\n" 6758 6418 set_region_family_line … … 6807 6467 end 6808 6468 6809 #== Region ã«ã¼ããªã¼ã¸ã§ã³ãå¾ã6810 # ã«ã¼ããªã¼ã¸ã§ã³ã¯ãã«ã¼ããã¼ã ã¹ãã¼ã¹ã¨åãã§ãã6469 #== Region ルートリージョンを得る 6470 # ルートリージョンは、ルートネームスペースと同じである 6811 6471 def self.get_root 6812 6472 Namespace.get_root … … 6816 6476 6817 6477 dbgPrint "set_region_family_line: Region: #{@name} \n" 6818 # root namespace (root region) ã® region type ã¯:NODE6478 # root namespace (root region) の region type は :NODE 6819 6479 if @name == "::" then 6820 6480 @region_type = :NODE … … 6834 6494 6835 6495 if @domain_type then 6836 # ã«ã¼ããªã¼ã¸ã§ã³ãæåãã @domain_type è¨å®ããããã¨ã¯ãªãã® 6837 # 㧠@owner == nil ã調ã¹ãå¿ 6838 è¦ã¯ãªã 6496 # ルートリージョンが最初から @domain_type 設定されることはないの 6497 # で @owner == nil を調べる必要はない 6839 6498 @owner.set_domain_type @domain_type 6840 6499 end … … 6850 6509 @link_root = nil 6851 6510 6852 # @family_line ãä½æãã 6853 # @link_root ãã¿ã¤ãã 6854 # (ä¸ä½ã«ãã©ã£ã¦ãã£ã¦ Region 㧠node ã¾ã㯠linkunit ã®ããããå 6855 ã«è¦ã¤ãã£ããã®ã @link_root ã¨ãªã) 6856 # root namespace 㯠Region ã㤠node ãªã®ã§å¿ 6857 ã @link_root ã¯è¦ã¤ãã 6858 # mikan: self ã node, linkUnit ã®å ´åãããã§æå¾ 6859 ããã¨ããã«è¨å®ãããªããããRegion#initialize ã§åè¨å® 6511 # @family_line を作成する 6512 # @link_root もみつける 6513 # (上位にたどっていって Region で node または linkunit のいずれか先に見つかったものが @link_root となる) 6514 # root namespace は Region かつ node なので必ず @link_root は見つかる 6515 # mikan: self が node, linkUnit の場合、ここで期待したとおりに設定されないため、Region#initialize で再設定 6860 6516 obj = self 6861 6517 while 1 … … 6868 6524 end 6869 6525 else 6870 # ãããªããã°Namespace6871 # namespace ã®ä¸ã« region ãããå ´å6872 end 6873 6874 # root namespace ã«ãã©ãçãã°çµã6526 # さもなければ Namespace 6527 # namespace の下に region がある場合 6528 end 6529 6530 # root namespace にたどり着けば終り 6875 6531 break if obj.get_name == "::" 6876 6532 … … 6883 6539 end 6884 6540 6885 #== Region# ãã¡ã¤ã³ãè¨å®ãã6541 #== Region#ドメインを設定する 6886 6542 def set_domain_type domain_type 6887 6543 if @region_type == :NODE then … … 6927 6583 end 6928 6584 6929 #== Region# domain ã®æ ¹ã£ãã¨ãªã region ãå¾ã6930 # Region ã®ã¤ã³ã¹ã¿ã³ã¹ãè¿ã6931 # domain æå®åãããã°ããã®ãªã¼ã¸ã§ã³ããã¡ã¤ã³ã«ã¼ãã§ãã6932 # ãªããã°ã親ãªã¼ã¸ã§ã³ã®ãã¡ã¤ã³ã«ã¼ãã¨ãã6585 #== Region# domain の根っことなる region を得る 6586 # Region のインスタンスを返す 6587 # domain 指定子があれば、そのリージョンがドメインルートである 6588 # なければ、親リージョンのドメインルートとする 6933 6589 def get_domain_root 6934 6590 @domain_root … … 6970 6626 end 6971 6627 6972 #=== Region# æ§æ解æä¸ã® region ãå¾ã 6973 # æ§æ解æä¸ Namespace (ãããã¯åã¯ã©ã¹ã® Region) ã®ä¸ä½ããã©ã£ã¦ Region ãè¦ã¤ãã 6974 # cell ã namespace ä¸ã«ãããã¨ãã§ããªããã°ãã«ã¼ããã¾ããå¿ 6975 è¦ã¯ãªã 6628 #=== Region# 構文解析中の region を得る 6629 # 構文解析中 Namespace (あるいは子クラスの Region) の上位をたどって Region を見つける 6630 # cell が namespace 下におくことができなければ、ループをまわす必要はない 6976 6631 def self.get_current 6977 6632 # @@region_stack[@@region_stack_sp] … … 6986 6641 end 6987 6642 6988 #=== Region# through ãã©ã°ã¤ã³ã§ããã® region ãã cell_name.port_name ã¸ã®ãã©ã°ã¤ã³ãªãã¸ã§ã¯ããç»é²6989 # mikan namesppace 対å¿(cell_name)6643 #=== Region# through プラグインで、この region から cell_name.port_name へのプラグインオブジェクトを登録 6644 # mikan namesppace 対応 (cell_name) 6990 6645 def add_cell_port_through_plugin( cell_name, port_name, through_plugin_object ) 6991 6646 @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}" ] = through_plugin_object … … 7002 6657 end 7003 6658 7004 #=== Region# to_region ã¸ã®è·é¢ï¼unreachable ãªå ´å nil) 7005 # mikan Cell#check_region ã¨Region ã¸ãã©ãçãã¾ã§ããã®å¦çã«å 7006 ±éæ§ãé«ã 7007 # region#distance 㯠require ã§ç¨ãããã 6659 #=== Region# to_region への距離(unreachable な場合 nil) 6660 # mikan Cell#check_region とRegion へたどり着くまでための処理に共通性が高い 6661 # region#distance は require で用いられる 7008 6662 def distance( to_region ) 7009 6663 7010 r1 = self # åºçºregion7011 r2 = to_region # ç®çregion6664 r1 = self # 出発 region 6665 r2 = to_region # 目的 region 7012 6666 dist = 0 7013 6667 7014 if ! r1.equal? r2 then # åä¸ region ãªãå¼åºãå¯è½7015 7016 # mikan namespace 対å¿6668 if ! r1.equal? r2 then # 同一 region なら呼出し可能 6669 6670 # mikan namespace 対応 7017 6671 f1 = r1.get_family_line 7018 6672 len1 = f1.length … … 7020 6674 len2 = f2.length 7021 6675 7022 # ä¸ä¸è´ã«ãªãã¨ããï¼å 7023 å¼ï¼ãæ¢ã 7024 i = 1 # i = 0 㯠:RootRegion ãªã®ã§å¿ 7025 ãä¸è´ 6676 # 不一致になるところ(兄弟)を探す 6677 i = 1 # i = 0 は :RootRegion なので必ず一致 7026 6678 while( i < len1 && i < len2 ) 7027 6679 if( f1[i] != f2[i] )then … … 7031 6683 end 7032 6684 7033 sibling_level = i # å 7034 å¼ã¨ãªãã¬ãã«ããããã¯ã©ã¡ããä¸æ¹ãçµãã£ãã¬ãã« 6685 sibling_level = i # 兄弟となるレベル、もしくはどちらか一方が終わったレベル 7035 6686 7036 6687 # p "sibling_level: #{i}" … … 7038 6689 # p "to: #{f2[i].get_name}" if f2[i] 7039 6690 7040 # å¼ã³å´ã«ã¤ãã¦å¼ã³å 7041 ã®ã¬ãã«ããå 7042 å¼ã¬ãã«ã¾ã§ï¼out_through ããã§ãã¯ããã³æ¿å 7043 ¥ï¼ 6691 # 呼び側について呼び元のレベルから兄弟レベルまで(out_through をチェックおよび挿入) 7044 6692 i = len1 -1 7045 6693 while i >= sibling_level … … 7064 6712 end 7065 6713 7066 # å 7067 å¼ã¬ãã«ã«ããã¦ï¼to_through ããã§ãã¯ããã³æ¿å 7068 ¥ï¼ 6714 # 兄弟レベルにおいて(to_through をチェックおよび挿入) 7069 6715 if f1[sibling_level] && f2[sibling_level] then 7070 6716 dbgPrint "going from #{f1[sibling_level].get_name} to #{f2[sibling_level].get_name}\n" … … 7081 6727 found = 0 7082 6728 f1[sibling_level].get_to_through_list.each { |t| 7083 if t[0][0] == f2[sibling_level].get_name then # region åãä¸è´ããã?6729 if t[0][0] == f2[sibling_level].get_name then # region 名が一致するか ? 7084 6730 found = 1 7085 6731 end … … 7092 6738 end 7093 6739 7094 # åãå´ã«ã¤ãã¦å 7095 å¼ã¬ãã«ããåãå´ã®ã¬ãã«ã¾ã§ï¼in_through ããã§ãã¯ããã³æ¿å 7096 ¥ï¼ 6740 # 受け側について兄弟レベルから受け側のレベルまで(in_through をチェックおよび挿入) 7097 6741 i = sibling_level 7098 6742 while i < len2 … … 7137 6781 class Import_C < Node 7138 6782 7139 # ãããã®ååæååã®ãªã¹ã6783 # ヘッダの名前文字列のリスト 7140 6784 @@header_list = {} 7141 6785 @@header_list2 = [] 7142 6786 @@define_list = {} 7143 6787 7144 #=== Import_C# import_C ã®çæï¼ããããã¡ã¤ã«ãåè¾¼ãï¼7145 #header:: Token : import_C ã®ç¬¬ä¸å¼æ°æååãªãã©ã«ãã¼ã¯ã³7146 #define:: Token : import_C ã®ç¬¬äºå¼æ°æååãªãã©ã«ãã¼ã¯ã³6788 #=== Import_C# import_C の生成(ヘッダファイルを取込む) 6789 #header:: Token : import_C の第一引数文字列リテラルトークン 6790 #define:: Token : import_C の第二引数文字列リテラルトークン 7147 6791 def initialize( header, define = nil ) 7148 6792 super() 7149 # ããããã¡ã¤ã«åæååããåå¾ã® "" ãåãé¤ã6793 # ヘッダファイル名文字列から前後の "" を取り除く 7150 6794 # header = header.to_s.gsub( /\A"(.*)"\z/, '\1' ) 7151 6795 header = CDLString.remove_dquote header.to_s 7152 6796 7153 6797 if define then 7154 # åå¾ã® "" ãåãé¤ã6798 # 前後の "" を取り除く 7155 6799 # def_opt = define.to_s.gsub( /\A"(.*)/, '\1' ) 7156 6800 # def_opt.sub!( /(.*)"\z/, '\1' ) 7157 6801 def_opt = CDLString.remove_dquote define.to_s 7158 6802 7159 # "," ã -D ã«ç½®ãæã6803 # "," を -D に置き換え 7160 6804 def_opt = def_opt.gsub( /,/, " -D " ) 7161 6805 7162 # å 7163 é ã« -D ãæ¿å 7164 ¥ # mikan ä¸é©å㪠define å 7165 ¥åããã£ãå ´åãCPP æã«ã¨ã©ã¼ 6806 # 先頭に -D を挿入 # mikan 不適切な define 入力があった場合、CPP 時にエラー 7166 6807 def_opt = def_opt.gsub( /^/, "-D " ) 7167 6808 7168 6809 end 7169 6810 7170 # ã³ãã³ãã©ã¤ã³æå®ãããDEFINE6811 # コマンドライン指定された DEFINE 7171 6812 $define.each{ |define| 7172 6813 if $IN_EXERB then … … 7189 6830 if found == false then 7190 6831 begin 7191 # ãã¡ã¤ã«ã® stat ãåã£ã¦ã¿ã(ãªããã°ä¾å¤çºç)6832 # ファイルの stat を取ってみる(なければ例外発生) 7192 6833 File.stat( "#{path}/#{header}" ) 7193 6834 7194 # cdl ãè¦ã¤ãã£ããã¡ã¤ã«ãã¹ã«åè¨å®6835 # cdl を見つかったファイルパスに再設定 7195 6836 header_path = "#{path}/#{header}" 7196 6837 found = true … … 7207 6848 end 7208 6849 7209 # èªè¾¼ã¿æ¸ã¿ï¼6850 # 読込み済み? 7210 6851 if( @@header_list[ header ] ) then 7211 # 第äºå¼æ° define ã以åã¨ç°ãªã6852 # 第二引数 define が以前と異なる 7212 6853 if @@define_list[ header ].to_s != define.to_s then 7213 6854 cdl_error( "S1143 import_C: arg2: mismatch with previous one" ) 7214 6855 end 7215 # ãããã«ããèªã¿è¾¼ã¾ãªã6856 # いずれにせよ読み込まない 7216 6857 return 7217 6858 end 7218 6859 7219 # ãããã®ãªã¹ããè¨é²6860 # ヘッダのリストを記録 7220 6861 @@header_list[ header ] = header_path 7221 6862 @@header_list2 << header … … 7241 6882 end 7242 6883 7243 # CPP åºåç¨ tmp ãã¡ã¤ã«å6884 # CPP 出力用 tmp ファイル名 7244 6885 tmp_header = header.gsub( /\//, "_" ) 7245 6886 tmp_header = "#{$gen}/tmp_#{tmp_header}" 7246 6887 7247 # CPP ã³ãã³ãã©ã¤ã³ãä½æ6888 # CPP コマンドラインを作成 7248 6889 cmd = "#{$cpp} #{def_opt} #{include_opt} #{tmp_C}" 7249 6890 … … 7253 6894 end 7254 6895 7255 # ããªããã»ããµã³ãã³ãã pipe ã¨ãã¦éã7256 # cmd 㯠cygwin/Linux ã§ã¯ bash(sh) çµç±ã§å®è¡ããã7257 # Exerb çã§ã¯ cmd.exe çµç±ã§å®è¡ããã7258 # ãã®å·®ã¯å¼ãæ°ã® (), $, % ãªã©ã·ã§ã«ã®ç¹å¥ãªæåã®è©ä¾¡ã«ç¾ããã®ã§æ³¨æ6896 # プリプロセッサコマンドを pipe として開く 6897 # cmd は cygwin/Linux では bash(sh) 経由で実行される 6898 # Exerb 版では cmd.exe 経由で実行される 6899 # この差は引き数の (), $, % などシェルの特別な文字の評価に現れるので注意 7259 6900 cpp = IO.popen( cmd, "r:ASCII-8BIT" ) 7260 6901 begin … … 7269 6910 print_exception( evar ) 7270 6911 ensure 7271 tmp_file.close if tmp_file # mikan File.open ã«å¤±æããæ tmp_file == nil ã¯ä¿è¨¼ããã¦ãã?6912 tmp_file.close if tmp_file # mikan File.open に失敗した時 tmp_file == nil は保証されている ? 7272 6913 cpp.close 7273 6914 end … … 7277 6918 end 7278 6919 7279 # C è¨èªã®ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ6920 # C 言語のパーサインスタンスを生成 7280 6921 c_parser = C_parser.new 7281 6922 7282 # tmp_header ããã¼ã¹6923 # tmp_header をパース 7283 6924 c_parser.parse( [tmp_header] ) 7284 6925 7285 # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã6926 # 終期化 パーサスタックを戻す 7286 6927 c_parser.finalize 7287 6928 … … 7337 6978 7338 6979 class Import < Node 7339 # @b_reuse::bool: åå©ç¨ï¼ã»ã«ã¿ã¤ãã® template çæä¸è¦7340 # @b_reuse_real::bool: å®éã«åå©ç¨7341 # @cdl:: string: import ããCDL7342 # @cdl_path:: string: CDL ã®ãã¹7343 # @b_imported:: bool: import ããã(ã³ãã³ãã©ã¤ã³æå®ããã¦ããªã)7344 7345 # ãããã®ååæååã®ãªã¹ã æ·»åï¼expand ãããã¹ãå¤ï¼Import6980 # @b_reuse::bool: 再利用.セルタイプの template 生成不要 6981 # @b_reuse_real::bool: 実際に再利用 6982 # @cdl:: string: import する CDL 6983 # @cdl_path:: string: CDL のパス 6984 # @b_imported:: bool: import された(コマンドライン指定されていない) 6985 6986 # ヘッダの名前文字列のリスト 添字:expand したパス、値:Import 7346 6987 @@import_list = {} 7347 6988 … … 7364 7005 end 7365 7006 7366 #=== Import# import ãè¡ã7367 #cdl:: string cdl ã¸ã®ãã¹ï¼"" ã§å²ã¾ãã¦ãããã¨ãä»®å®7368 #b_reuse:: bool true: template ãçæããªã7007 #=== Import# import を行う 7008 #cdl:: string cdl へのパス."" で囲まれていることを仮定 7009 #b_reuse:: bool true: template を生成しない 7369 7010 def initialize( cdl, b_reuse = false, b_imported = true ) 7370 7011 Import.push self … … 7372 7013 super() 7373 7014 @@current_import = self 7374 # ããããã¡ã¤ã«åæååããåå¾ã® "", <> ãåãé¤ãn7015 # ヘッダファイル名文字列から前後の "", <> を取り除くn 7375 7016 @cdl = cdl.to_s.gsub( /\A["<](.*)[">]\z/, '\1' ) 7376 7017 7377 # ãµã¼ããã¹ããæ¢ã7018 # サーチパスから探す 7378 7019 found = false 7379 7020 @cdl_path = "" … … 7383 7024 7384 7025 if Generator.get_plugin then 7385 # plugin ãã import ããã¦ããå ´å gen ããµã¼ããã¹ã®å 7386 é ã«å ãã 7026 # plugin から import されている場合 gen をサーチパスの先頭に加える 7387 7027 search_path = [ $gen ] + $import_path 7388 7028 else … … 7399 7039 end 7400 7040 7401 # ãã¡ã¤ã«ã® stat ãåã£ã¦ã¿ã(ãªããã°ä¾å¤çºç)7041 # ファイルの stat を取ってみる(なければ例外発生) 7402 7042 File.stat( cdl_path ) 7403 7043 7404 # cdl ãè¦ã¤ãã£ããã¡ã¤ã«ãã¹ã«åè¨å®7044 # cdl を見つかったファイルパスに再設定 7405 7045 @cdl_path = cdl_path 7406 7046 found = true … … 7419 7059 end 7420 7060 7421 # èªè¾¼ã¿æ¸ã¿ãªããèªè¾¼ã¾ãªã7061 # 読込み済みなら、読込まない 7422 7062 prev = @@import_list[ File.expand_path( @cdl_path ) ] 7423 7063 if( prev ) then … … 7428 7068 end 7429 7069 7430 # import ãªã¹ããè¨é²7070 # import リストを記録 7431 7071 @@import_list[ File.expand_path( @cdl_path ) ] = self 7432 7072 7433 # plugin ãã import ããã¦ããå ´å7073 # plugin から import されている場合 7434 7074 plugin = Generator.get_plugin 7435 7075 7436 # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èªã¿è¾¼ã)7076 # パーサインスタンスを生成(別パーサで読み込む) 7437 7077 parser = Generator.new 7438 7078 7439 # plugin ãã import ããã¦ããå ´åã® plugin è¨å®7079 # plugin から import されている場合の plugin 設定 7440 7080 parser.set_plugin plugin 7441 7081 7442 # reuse ãã©ã°ãè¨å®7082 # reuse フラグを設定 7443 7083 parser.set_reuse @b_reuse_real 7444 7084 7445 # cdl ããã¼ã¹7085 # cdl をパース 7446 7086 parser.parse( [@cdl_path] ) 7447 7087 7448 # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã7088 # 終期化 パーサスタックを戻す 7449 7089 parser.finalize 7450 7090 Import.pop … … 7471 7111 end 7472 7112 7473 #=== cdl ã®ååãè¿ã7474 # å¼æ°ã§æå®ããã¦ãã cdl åãä¸é¨ãã¹ãå«ãå¯è½æ§ããã7113 #=== cdl の名前を返す 7114 # 引数で指定されている cdl 名。一部パスを含む可能性がある 7475 7115 def get_cdl_name 7476 7116 @cdl … … 7478 7118 end 7479 7119 7480 #== generate: signature ãã©ã°ã¤ã³ã®ãã¼ãã¨å®è¡7120 #== generate: signature プラグインのロードと実行 7481 7121 class Generate < Node 7482 7122 #@plugin_name:: Symbol 7483 7123 #@signature_nsp:: NamespacePath 7484 #@option:: String '"', '"' ã§å²ã¾ãã¦ãã7124 #@option:: String '"', '"' で囲まれている 7485 7125 7486 7126 include PluginModule … … 7490 7130 @plugin_name = plugin_name 7491 7131 @signature_nsp = signature_nsp 7492 option = option.to_s # option ã¯Token7132 option = option.to_s # option は Token 7493 7133 @option = option 7494 7134 … … 7511 7151 7512 7152 begin 7513 eval( eval_str ) # plugin ãçæ7153 eval( eval_str ) # plugin を生成 7514 7154 plugin_object.set_locale @locale 7515 7155 rescue Exception => evar … … 7523 7163 end 7524 7164 7525 #== åå空éãã¹7165 #== 名前空間パス 7526 7166 class NamespacePath < Node 7527 7167 #@b_absolute::Bool 7528 7168 #@path::[ Symbol,... ] 7529 #@namespace::Namespace: @b_absolute == false ã®ã¨ããåºç¹ã¨ãªãnamespace7169 #@namespace::Namespace: @b_absolute == false のとき、基点となる namespace 7530 7170 7531 7171 #=== NamespacePath# initialize 7532 #ident::Symbol æåã®åå, ãã ã "::" ã®ã¿ã®å ´å㯠String 7533 #b_absolute:Bool "::" ã§å§ã¾ã£ã¦ããå ´å true 7534 #namespace::Namespace b_absolute = false ãã¤ãæ§æ解é段é以å¤ã§å¼ã³åºãå ´åã¯ãå¿ 7535 ãæå®ããã㨠7172 #ident::Symbol 最初の名前, ただし "::" のみの場合は String 7173 #b_absolute:Bool "::" で始まっている場合 true 7174 #namespace::Namespace b_absolute = false かつ、構文解釈段階以外で呼び出す場合は、必ず指定すること 7536 7175 def initialize( ident, b_absolute, namespace = nil ) 7537 7176 super() … … 7559 7198 end 7560 7199 7561 #=== NamespacePath# append ãã7200 #=== NamespacePath# append する 7562 7201 #RETURN self 7563 # ãã®ã¡ã½ããã¯ãå 7564 ã® NamespacePath ãªãã¸ã§ã¯ããå¤å½¢ãã¦è¿ã 7202 # このメソッドは、元の NamespacePath オブジェクトを変形して返す 7565 7203 def append!( ident ) 7566 7204 @path << ident 7567 7205 return self 7568 7206 end 7569 #=== NamespacePath# append ãã 7570 # ãã®ã¡ã½ããã¯ãå 7571 ã® NamespacePath ãªãã¸ã§ã¯ããå¤å½¢ããªã 7572 #RETURN:: è¤è£½ãã NamespacePath 7207 #=== NamespacePath# append する 7208 # このメソッドは、元の NamespacePath オブジェクトを変形しない 7209 #RETURN:: 複製した NamespacePath 7573 7210 def append( ident ) 7574 7211 cl = self.clone … … 7586 7223 end 7587 7224 7588 #=== NamespacePath# ã¯ãã¼ã³ãä½æãã¦ååãå¤æ´ãã7225 #=== NamespacePath#クローンを作成して名前を変更する 7589 7226 def change_name name 7590 7227 cl = self.clone … … 7595 7232 alias :change_name_clone :change_name 7596 7233 7597 #=== NamespacePath#ååãå¤æ´ãã 7598 # ãã®ã¤ã³ã¹ã¿ã³ã¹ãåç 7599 §ãããã¹ã¦ã«å½±é¿ãä¸ãããã¨ã«æ³¨æ 7234 #=== NamespacePath#名前を変更する 7235 # このインスタンスを参照するすべてに影響を与えることに注意 7600 7236 def change_name_no_clone name 7601 7237 @path[ @path.length - 1 ] = name … … 7603 7239 end 7604 7240 7605 #=== NamespacePath:: path æååãå¾ã7606 # CDL ç¨ã® path æååãçæ7241 #=== NamespacePath:: path 文字列を得る 7242 # CDL 用の path 文字列を生成 7607 7243 def to_s 7608 7244 get_path_str … … 7633 7269 end 7634 7270 7635 #=== NamespacePath:: ãã¹ã®é 7636 åãè¿ã 7637 # is_absolute? true ã®å ´åãã«ã¼ãããã®ãã¹ 7638 # false ã®å ´åãbase_namespace ããã®ç¸å¯¾ 7639 # ã«ã¼ã namespace ã®å ´åãé·ãï¼ã®é 7640 åãè¿ã 7271 #=== NamespacePath:: パスの配列を返す 7272 # is_absolute? true の場合、ルートからのパス 7273 # false の場合、base_namespace からの相対 7274 # ルート namespace の場合、長さ0の配列を返す 7641 7275 # 7642 7276 def get_path … … 7644 7278 end 7645 7279 7646 #=== NamespacePath#ãã«ãã¹ã®é 7647 åãè¿ã 7648 # è¿ãããé 7649 åãæ¸ãæãã¦ã¯ãªããªã 7280 #=== NamespacePath#フルパスの配列を返す 7281 # 返された配列を書き換えてはならない 7650 7282 def get_full_path 7651 7283 if @b_absolute then … … 7656 7288 end 7657 7289 7658 #=== NamespacePath:: ç¸å¯¾ãã¹ã®ãã¼ã¹ã¨ãªãnamespace7659 # is_absolute? == false ã®æã®ã¿æå¹ãªå¤ãè¿ã (true ãªãnil)7290 #=== NamespacePath:: 相対パスのベースとなる namespace 7291 # is_absolute? == false の時のみ有効な値を返す (true なら nil) 7660 7292 def get_base_namespace 7661 7293 @namespace 7662 7294 end 7663 7295 7664 #=== NamespacePath:: C è¨èªã°ãã¼ãã«åãå¾ã7296 #=== NamespacePath:: C 言語グローバル名を得る 7665 7297 def get_global_name 7666 7298 if @b_absolute then … … 7680 7312 end 7681 7313 7682 #=== NamespacePath:: å解ã㦠NamespacePath ã¤ã³ã¹ã¿ã³ã¹ãçæãã7683 #path_str:: String : namespace ã¾ã㯠region ã®ãã¹ex) "::path::A" , "::", "ident"7684 #b_force_absolute:: Bool : "::" ã§å§ã¾ã£ã¦ããªãå ´åã§ã絶対ãã¹ã«æ±ã7314 #=== NamespacePath:: 分解して NamespacePath インスタンスを生成する 7315 #path_str:: String : namespace または region のパス ex) "::path::A" , "::", "ident" 7316 #b_force_absolute:: Bool : "::" で始まっていない場合でも絶対パスに扱う 7685 7317 # 7686 # NamespacePath ã¯é常æ§æ解æããã¦ä½æããã7687 # ãã®ã¡ã½ããã¯ããªãã·ã§ã³ãªã©ã§æå®ãããæååãå解ã㦠NamespacePath ãçæããã®ã«ç¨ãã7688 # ãã§ãã¯ã¯ããããä¸é©åãªãã¹æå®ã¯ãä¸é©å㪠NamespacePath ãçæããã7318 # NamespacePath は通常構文解析されて作成される 7319 # このメソッドは、オプションなどで指定される文字列を分解して NamespacePath を生成するのに用いる 7320 # チェックはゆるい。不適切なパス指定は、不適切な NamespacePath が生成される 7689 7321 def self.analyze( path_str, b_force_absolute = false ) 7690 7322 … … 7725 7357 end 7726 7358 7727 # 以ä¸åä½ãã¹ãã³ã¼ã7359 # 以下単体テストコード 7728 7360 if $unit_test then 7729 7361 root_namespace = Namespace.new("::") -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/ctypes.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : ctypes.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 # CType 㯠C_parser ã§å®ç¾©ãããåãæ±ã CIntType, CFloatType ãªã©ã« include ãããã®56 # CIntType 㯠IntType ãç¶æ¿ãããªã©ãC ã®åã§ã¯ TECS ã®åãç¶æ¿ãã40 # CType は C_parser で定義される型を扱う CIntType, CFloatType などに include するもの 41 # CIntType は IntType を継承するなど、C の型では TECS の型を継承する 57 42 module CType 58 43 59 #=== æ§æè¦ç´ type_specifier ãè¤æ°æå®ããã¦ããå ´åã« merge ãã60 # merge 㯠const(CIntType) unsigned(CIntTtype), long(CIntType), ãªã©ã¨ä»ã®åããã¼ã¸ãã61 # const, unsigned, long ãªã©ã¯ãåä½ã§ int (CIntType) åã«ãªããã44 #=== 構文要素 type_specifier が複数指定されている場合に merge する 45 # merge は const(CIntType) unsigned(CIntTtype), long(CIntType), などと他の型をマージする 46 # const, unsigned, long などは、単体で int (CIntType) 型になりうる 62 47 # 63 # mikan C ã®ææ³ãå³å¯ã«ã¯ãã§ãã¯ãã¦ããªã long struct çãã§ãã¦ãã¾ã48 # mikan C の文法を厳密にはチェックしていない long struct 等もできてしまう 64 49 def merge another 65 50 66 51 # p "self: #{self.class} kind_of( IntType ): #{self.kind_of?( IntType )} another: #{another.class}" 67 52 68 # signed, unsigned ã Symbol ã¨ãã¦æ¥ãäºã¯ç¡ããªã£ã53 # signed, unsigned が Symbol として来る事は無くなった 69 54 # if another.instance_of? Symbol then 70 # # ãã㧠Symbol 㯠:SIGNED, :UNSIGNED ã®ãããã55 # # ここで Symbol は :SIGNED, :UNSIGNED のいずれか 71 56 # 72 # # CIntType ãï¼57 # # CIntType か? 73 58 # if self.instance_of? CIntType then 74 59 # self.set_sign another … … 84 69 @bit_size = -5 # long long 85 70 else 86 # self 㯠int åãanother ã® bit_size ã (int 以å¤ã§ããã°)ãã¡ãã«ãã87 # mikan ä¸è¨ä»¥å¤ã§ ä¸¡æ¹ -3 ã§ãªããã°ãæ¬æ¥ã¨ã©ã¼71 # self は int 型、another の bit_size が (int 以外であれば)そちらにする 72 # mikan 上記以外で 両方 -3 でなければ、本来エラー 88 73 @bit_size = another.get_bit_size 89 74 end … … 91 76 92 77 if another.get_sign then 93 # another 㧠sign ãæå®ããã¦ããã°ããã¡ãã®ãã®ãæ¡ç¨ãã mikan çç¾ã®ãã§ãã¯78 # another で sign が指定されていれば、そちらのものを採用する mikan 矛盾のチェック 94 79 @sign = another.get_sign 95 80 end 96 81 97 82 # if another.get_qualifier then 98 # # another 㧠qualifier ãæå®ããã¦ããã°ããã¡ãã®ãã®ãæ¡ç¨ãã mikan çç¾ã®ãã§ãã¯83 # # another で qualifier が指定されていれば、そちらのものを採用する mikan 矛盾のチェック 99 84 # @qualifier = another.get_qualifier 100 85 # end … … 110 95 return another.merge self 111 96 elsif self.instance_of?( CDefinedType ) then 112 # mikan unsigned ãªã©ã¨ã® merge ã®ä¸æ£æ¤åº97 # mikan unsigned などとの merge の不正検出 113 98 if another.is_const? then 114 99 @b_const = true … … 135 120 else 136 121 # mikan long double 137 # TECS ã«ã¯ long double ã表ç¾ããæ段ããªã (double80_t ãå®ç¾©ããã°ããã?)122 # TECS には long double を表現する手段がない (double80_t を定義すればよいか?) 138 123 # cdl_warning( "C1003 $1 & $2 incompatible (\'long double\' is not supported.). Treated as $3." , self.class, another.class, self.class ) 139 124 cdl_warning( "W9999 $1 & $2 incompatible (\'long double\' is not supported.). Treated as $3." , self.get_type_str, another.get_type_str, self.get_type_str ) … … 142 127 end 143 128 144 #=== qualifier ãè¨å®ãã 145 # å 146 ã® Type ã¯ã©ã¹ã§ã¯çç¾ãã§ãã¯ããªãï¼TECSã®æ¬æ¥ã®ææ³ã§ã¯éè¤æå®ã§ããªãããï¼ 129 #=== qualifier を設定する 130 # 元の Type クラスでは矛盾チェックしない(TECSの本来の文法では重複指定できないため) 147 131 def set_qualifier( qual ) 148 132 … … 181 165 182 166 def initialize( bit_size ) 183 #p super.class mikan super.class ã Symbol ã ããªãï¼167 #p super.class mikan super.class が Symbol だ、なぜ? 184 168 super( bit_size ) 185 169 end -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/expression.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : expression.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 … … 71 56 72 57 #=== Expression# to_s 73 # C è¨èªã½ã¼ã¹åãã®æååãçæ(globa_name)58 # C 言語ソース向きの文字列を生成 (globa_name) 74 59 def to_s 75 60 elements_to_s( @elements ) … … 77 62 78 63 #=== Expression# to_str 79 # C è¨èªã½ã¼ã¹åãã®æååãçæ(globa_name)64 # C 言語ソース向きの文字列を生成 (globa_name) 80 65 def to_str( name_list, pre, post ) 81 66 elements_to_s( @elements, name_list, pre, post ) … … 83 68 84 69 #=== Expression#to_CDL_str 85 # CDL 表ç¾ã®æååãçæ70 # CDL 表現の文字列を生成 86 71 def to_CDL_str 87 72 return to_s 88 73 end 89 74 90 #=== å®æ°å¼ã¨ãã¦è©ä¾¡ãã(ãã©ã¤ãã¦ã¿ã)75 #=== 定数式として評価する(トライしてみる) 91 76 # 92 # ãã®ã¡ã½ããã¯ãå®æ°å¼ãè©ä¾¡ãã 93 # ã»attribute, var ã®åæåå 94 # ã»size_is, count_is å¼æ° 95 # ã»é 96 åã®æ·»æ° 77 # このメソッドは、定数式を評価する 78 # ・attribute, var の初期化子 79 # ・size_is, count_is 引数 80 # ・配列の添数 97 81 # 98 # name_list(NamedList|Nil): å¼ããåç 99 §å¯è½ãªãªã¹ãï¼ 100 # NamedList ã®è¦ç´ 㯠size_is, count_is ã®å¼æ°è©ä¾¡ã®å ´å ParamDecl (é¢æ°ä»®å¼æ°) 82 # name_list(NamedList|Nil): 式から参照可能なリスト. 83 # NamedList の要素は size_is, count_is の引数評価の場合 ParamDecl (関数仮引数) 101 84 # 102 # name_list2(NamedList|Nil) : NamedList ã®è¦ç´ 㯠Decl (attribute, var) ã§ããï¼çç¥ænil85 # name_list2(NamedList|Nil) : NamedList の要素は Decl (attribute, var) である.省略時 nil 103 86 # 104 # RETURN: è©ä¾¡ããå®æ°ï¼è©ä¾¡ã§ããªãã£ãå ´å㯠nil ãè¿ã87 # RETURN: 評価した定数.評価できなかった場合は nil を返す 105 88 # 106 # å㯠get_type ã§ãè©ä¾¡ããï¼å®æ°ã¨ãã¦æ±ããããªãã¨ãã«ä½¿ç¨ã§ããï¼107 # Array ãè¿ãã®ã¯ attr{ int *a = {1, 2, 3}; int *b = a; }; ã® b ã®å³è¾ºãè©ä¾¡ããå ´å89 # 型は get_type で、評価する(定数として求められないときに使用できる) 90 # Array を返すのは attr{ int *a = {1, 2, 3}; int *b = a; }; の b の右辺を評価した場合 108 91 109 92 def eval_const( name_list, name_list2 = nil ) … … 116 99 return val.to_i 117 100 elsif val.kind_of? PointerVal then 118 return val.to_i # mikan ã¨ã©ã¼ V1008 ãçºçãã¦ãã¾ã101 return val.to_i # mikan エラー V1008 が発生してしまう 119 102 # elsif val.kind_of? EnumVal then 120 103 # enum mikan 121 104 else 122 # C_EXP, Array ã¾ã㯠nil ï¼ãã®ã¾ã¾è¿ã105 # C_EXP, Array または nil :そのまま返す 123 106 return val 124 107 end 125 108 end 126 109 127 #=== å®æ°å¼ã¨ãã¦è©ä¾¡ãã2(ãã©ã¤ãã¦ã¿ã)110 #=== 定数式として評価する2(トライしてみる) 128 111 # 129 # IntegerVal, FloatVal ããã®ã¾ã¾è¿ãï¼eval_const ã§ã¯ Integer, Float ã«å¤æï¼112 # IntegerVal, FloatVal をそのまま返す(eval_const では Integer, Float に変換) 130 113 def eval_const2( name_list, name_list2 = nil, nest = 0 ) 131 114 val = elements_eval_const( @elements, name_list, name_list2, nest ) 132 115 end 133 116 134 #=== å¼ã®åãè©ä¾¡ãã117 #=== 式の型を評価する 135 118 # 136 # eval_const ã§å¤ãå¾ãããªãå ´åãåãå°åºå¯è½ã§ããã°åãå¾ã137 # param ãå«ãã å¼ã¯å®æ°å¤ãæ±ããããªãããåãå¾ããã¨ã¯ã§ãã138 # æªå®ç¾©å¤æ°ãå«ãã åã¯ãå¾ããã¨ãã§ããªã (ããã¼åå®ç¾©ãè¿ã)139 def get_type( namedList ) # åå空éã® NamedList ãæå®119 # eval_const で値が得られない場合、型を導出可能であれば型を得る 120 # param を含んだ式は定数値を求められないが、型を得ることはできる 121 # 未定義変数を含んだ型は、得ることができない (ダミー型定義が返る) 122 def get_type( namedList ) # 名前空間の NamedList を指定 140 123 elements_get_type( @elements, namedList ) 141 124 end … … 150 133 151 134 def show_tree( indent ) 152 # mikan override ãã¦ãã¾ã£ã print ãå¼åºãæ¹æ³ãããããªãã®ã§ãããã135 # mikan override してしまった print を呼出す方法がわからないのでこうした 153 136 str = "" 154 137 indent.times { str += " " } … … 158 141 ## private 159 142 160 #=== å¼ãæååã«å¤æ161 #name_list:: attribute (Celltype::@attribute_list), struct ã® @member_list ãä»®å®ãã¦ãã143 #=== 式を文字列に変換 144 #name_list:: attribute (Celltype::@attribute_list), struct の @member_list を仮定している 162 145 def elements_to_s( elements, name_list = nil, pre = nil, post = nil ) 163 146 if elements.instance_of? Token then 164 return elements.to_s # OP_DOT, OP_REF ã®å³è¾º147 return elements.to_s # OP_DOT, OP_REF の右辺 165 148 end 166 149 … … 246 229 end 247 230 248 # å®æ°å¼(elements)ãè©ä¾¡ãã231 # 定数式(elements)を評価する 249 232 # 250 # ãã®ã¡ã½ãã㯠Expression ã¯ã©ã¹ã®ã¡ã½ããã§ããå¿ 251 è¦ã¯ãªãï¼é¢æ°åã§ããï¼ 233 # このメソッドは Expression クラスのメソッドである必要はない(関数化できる) 252 234 # 253 # elements ã¯å¼ã®è¦ç´235 # elements は式の要素 254 236 # 255 # name_list, name_list2 㯠eval_const ãåç 256 § 237 # name_list, name_list2 は eval_const を参照 257 238 # 258 # RETURN: è©ä¾¡ããå®æ°ãè©ä¾¡ã§ããªãã£ãå ´å㯠nil ãè¿ã 259 260 MAX_NEST_LEVEL = 64 # ç°¡æã®ã«ã¼ãæ¤åºï¼åç 261 §ã®ãã¹ãã 64 ã¾ã§è¨±å¯ããï¼ 239 # RETURN: 評価した定数、評価できなかった場合は nil を返す 240 241 MAX_NEST_LEVEL = 64 # 簡易のループ検出(参照のネストを 64 まで許可する) 262 242 def elements_eval_const( elements, name_list, name_list2 = nil, nest = nil ) 263 243 … … 266 246 nsp = elements[1] 267 247 268 # #809 ã®ä¿®æ£ããã (å¥ã®åé¡ã解決ãããã¦ããªã) 269 # nest += 1 # åç 270 §ãã«ã¼ãã«ãªã£ã¦ããªããã®ãã§ã㯠271 # # mikan æ¬å½ã«ã«ã¼ããã¦ãããã©ããã§ã¯ãªããåç´ã«å¤æ°ã®åç 272 §ãç¹°ãè¿ãã¦ãããã¨ã§å¤å®ãã¦ãã 248 # #809 の修正しかけ (別の問題が解決しきれていない) 249 # nest += 1 # 参照がループになっていないかのチェック 250 # # mikan 本当にループしているかどうかではなく、単純に多数の参照を繰り返していることで判定している 273 251 # if nest > MAX_NEST_LEVEL then 274 252 # cdl_error( "E9999: '$1' too many reference (maybe loop) max=$1" , nsp.to_s, MAX_NEST_LEVEL ) … … 285 263 end 286 264 287 # è¦ã¤ãããªããã°å®æ°å®ç¾©ããæ¢ã265 # 見つからなければ定数定義から探す 288 266 if object == nil then 289 object = Namespace.find( nsp )# mikan namespace ã®å¯¾å¿ #1 290 end 291 292 # ãã®å®è£ 293 ã¯ãããå°ãæ´çãããã¹ã 294 # ãããå¼åºãããã®ã¯ã以ä¸ã®å ´å 295 # ã»attribute, var ã®å³è¾ºå¼ã®è©ä¾¡ 296 # ã»size_is å¼æ°ã®è©ä¾¡ï¼é¢æ°ãã©ã¡ã¼ã¿ã®å ´åã¨attribute, var ã®å ´åããã 297 # 以ä¸ã®ã¨ã©ã¼ãã§ãã¯ã§ã¯ããããããã£ã¡ãã«ãªã£ã¦èª¤ããæ¤åºãããã¨ãã¦ãã 298 299 # IDENTIFIER ã¯è¦ã¤ãããªãã£ãï¼ 267 object = Namespace.find( nsp )# mikan namespace の対応 #1 268 end 269 270 # この実装は、もう少し整理されるべき 271 # これが呼出されるのは、以下の場合 272 # ・attribute, var の右辺式の評価 273 # ・size_is 引数の評価:関数パラメータの場合とattribute, var の場合がある 274 # 以下のエラーチェックでは、これらがごっちゃになって誤りを検出しようとしている 275 276 # IDENTIFIER は見つからなかった? 300 277 if object == nil then 301 278 cdl_error( "E1001 $1: not found" , nsp.get_path_str ) … … 303 280 return nil 304 281 elsif object.instance_of?( Join ) then 305 # Join ã®å ´åï¼ cell ã®ä¸ã® attribute, var, call ã®ã©ãããè¦ã¤ãã£ã306 # Decl (attribute, var) ã§ãªãï¼282 # Join の場合: cell の中の attribute, var, call のどれかが見つかった 283 # Decl (attribute, var) でない? 307 284 if ! object.get_definition.instance_of?( Decl ) then 308 285 cdl_error( "E1002 $1: not constant (port)" , nsp.get_path_str ) … … 311 288 return object.get_rhs.eval_const2( name_list, name_list2, nest ) 312 289 elsif ! object.instance_of?( Decl ) then 313 # Decl ã§ãªãå ´åï¼ å®æ°ã§ããªã290 # Decl でない場合: 定数でもない 314 291 if ( ! object.instance_of?( ParamDecl ) ) then 315 # mikan paramdecl ã¯ç¡è¦ãã316 # ParamList ããå¼ã°ããã¨ã292 # mikan paramdecl は無視する 293 # ParamList から呼ばれたとき 317 294 cdl_error( "E1003 $1: not constant" , nsp.get_path_str ) 318 295 else … … 324 301 object.referenced 325 302 if object.get_initializer == nil then 326 # åæååã®åå¨ããªãå¤æ° # mikan ããã¸ããã®ã¯ãé常ããããªãã¯ãï¼æªæ¤è¨¼ï¼303 # 初期化子の存在しない変数 # mikan ここへくるのは、通常ありえないはず(未検証) 327 304 return IntegerVal.new( 0 ) 328 305 else 329 # Decl ã®å³è¾ºã®è©ä¾¡330 # mikan size_is å¼æ°ã«ç¾ããå¤æ°ã®åãé©åãã®ãã§ãã¯ãã306 # Decl の右辺の評価 307 # mikan size_is 引数に現れる変数の型が適切かのチェックする 331 308 if object.get_initializer.instance_of?( Expression ) || object.get_initializer.instance_of?( C_EXP ) then 332 309 return object.get_initializer.eval_const2( name_list, name_list2, nest ) 333 310 else 334 # Array ã®å ´å311 # Array の場合 335 312 return object.get_initializer 336 313 end … … 440 417 # p "val.respond_to?( \"-@\" )=#{val.respond_to?( "-@" )} #{val.class}" 441 418 # p "val.respond_to?( \"~@\" )=#{val.respond_to?( "~@" )}" 442 #2.0 if val.respond_to?( "~@" ) then # Ruby 1.9, 2.0 preview çã§ã¯ä¾å¤ãçºçãã¦ãã¾ã419 #2.0 if val.respond_to?( "~@" ) then # Ruby 1.9, 2.0 preview 版では例外が発生してしまう 443 420 if val.kind_of? IntegerVal then 444 421 return ~ val … … 586 563 def elements_get_type( elements, namedList ) 587 564 type = elements_get_type_sub( elements, namedList ) 588 # è¿ãããæ¹ã DefinedType ã®å ´å å 589 ã®åãè¿ã 565 # 返された方が DefinedType の場合 元の型を返す 590 566 if type.kind_of?( DefinedType ) then 591 567 type = type.get_type … … 626 602 unless type.kind_of?( PtrType ) then 627 603 cdl_error( "E1013 \'*\': operand is not pointer value" ) 628 return IntType.new( 8 ) # IntType ãè¿ãã¦ãã604 return IntType.new( 8 ) # IntType を返しておく 629 605 end 630 606 return type.get_referto 631 607 632 608 when :OP_U_PLUS, :OP_U_MINUS 633 # mikan operand ãé©åãªåããã§ãã¯ãã¦ããªã609 # mikan operand が適切な型かチェックしていない 634 610 return elements_get_type( elements[1], namedList ) 635 611 636 612 when :OP_ADD, :OP_SUB, :OP_MULT, :OP_DIV, :OP_REMAIN 637 # mikan operand ãé©åãªåããã§ãã¯ãã¦ããªãï¼å·¦è¾ºã®åãæ¡ç¨ãã¦ãã613 # mikan operand が適切な型かチェックしていない&左辺の型を採用している 638 614 return elements_get_type( elements[1], namedList ) 639 615 640 616 when :OP_U_TILDE 641 # mikan operand ãæ´æ°ããã§ãã¯ãã¦ããªã617 # mikan operand が整数かチェックしていない 642 618 return elements_get_type( elements[1], namedList ) 643 619 when :OP_AND, :OP_EOR, :OP_OR, :OP_LSFT, :OP_RSFT 644 # mikan operand ãæ´æ°ããã§ãã¯ãã¦ããªã620 # mikan operand が整数かチェックしていない 645 621 return BoolType.new 646 622 when :OP_U_EXCLAM 647 # mikan operand ãæ´æ°ããã§ãã¯ãã¦ããªã623 # mikan operand が整数かチェックしていない 648 624 return BoolType.new 649 625 … … 655 631 end 656 632 657 # å¼ã size_is, count_is, string ã®å¼æ°ã§ããå ´åã®æ¹åã®ãã§ãã¯633 # 式が size_is, count_is, string の引数である場合の方向のチェック 658 634 def elements_check_dir_for_param( elements, namedList, dir, spec ) 659 # dir ï¼ å 660 ã®å¼æ°ã®æ¹å 661 # direct: size_is ãªã©ã®å¼æ°ã®å¤æ°ã®æ¹å 635 # dir : 元の引数の方向 636 # direct: size_is などの引数の変数の方向 662 637 663 638 case elements[0] … … 690 665 judge = true if ( direct == :IN || direct == :INOUT ) 691 666 req_direct = "in or inout" 692 when :OUT, :RECEIVE # mikan out 㧠count_is ã®ã¿æå®ããã¦ããå ´å in ã§ãªãã¦ã¯ãªããªã667 when :OUT, :RECEIVE # mikan out で count_is のみ指定されている場合 in でなくてはならない 693 668 judge = true if ( direct == :OUT || direct == :INOUT ) 694 669 req_direct = "out or inout" … … 706 681 return true 707 682 708 # åé 709 æ¼ç®å 683 # 単項演算子 710 684 when :OP_U_ASTER, :OP_SIZEOF_EXPR, :OP_SIZEOF_TYPE, :OP_U_PLUS, :OP_U_MINUS, :OP_U_TILDE, :OP_U_EXCLAM, :CAST, :OP_U_AMP, :PARENTHESES, 711 685 elements_check_dir_for_param( elements[1], namedList, dir, spec ) 712 686 713 # 2é 714 æ¼ç®å 687 # 2項演算子 715 688 when :OP_SUBSC, :OP_DOT, :OP_REF, :OP_MULT, :OP_DIV, :OP_REMAIN, :OP_ADD, :OP_SUB, :OP_LSFT, :OP_RSFT, :OP_LT, :OP_GT, :OP_LE, :OP_GE, :OP_EQ, :OP_NE, :OP_AND, :OP_EOR, :OP_OR, :OP_LAND, :OP_LOR 716 689 return elements_check_dir_for_param( elements[1], namedList, dir, spec ) && elements_check_dir_for_param( elements[2], namedList, dir, spec ) 717 690 718 # 3é 719 æ¼ç®å 691 # 3項演算子 720 692 when :OP_CEX 721 693 return elements_check_dir_for_param( elements[1], namedList, dir, spec ) && elements_check_dir_for_param( elements[2], namedList, dir, spec ) && elements_check_dir_for_param( elements[3], namedList, dir, spec ) … … 729 701 #Express# get_allocator_rhs_elem 730 702 #alloc_type::Symbol :NORMAL_ALLOC|:INTERNAL_ALLOC|:RELAY_ALLOC 731 # å¼ãã¢ãã±ã¼ã¿æå®åã®å³è¾ºã¨ãã¦å¦¥å½ããã§ãã¯ããæ£ãããã°å解ããå¤ãè¿ã703 #式がアロケータ指定子の右辺として妥当かチェックし、正しければ分解した値を返す 732 704 #return: 733 705 # :NORMAL_ALLOC [ cell_nsp, ep_name ] # rhs = cell_nsp.ep_name ex) Alloc.eAlloc … … 767 739 end 768 740 769 #Expression#Expression ã®ã¯ãã¼ã³ãä½æãã741 #Expression#Expression のクローンを作成する 770 742 def clone_for_composite 771 743 cl = self.clone … … 775 747 end 776 748 777 #Expression#elements ã®ã¯ãã¼ã³ãä½æ749 #Expression#elements のクローンを作成 778 750 #elements::Array 779 # ãã®ã¡ã½ããã¯ãArray ã®ãã£ã¼ãã³ãã¼ãè¡ã751 # このメソッドは、Array のディープコピーを行う 780 752 def clone_elements elements 781 753 elements = elements.clone … … 794 766 end 795 767 796 #=== Expression# ã»ã«çµåã®å¼ã解æãã768 #=== Expression#セル結合の式を解析する 797 769 # Cell.eEntry => [ :OP_DOT, [ :IDENTIFIER, token ], token ] 798 770 # Cell.eEntry[expression] => [ :OP_SUBSC, [ :OP_DOT, [ :IDENTIFIER, token ], token ], expression ] 799 771 # Return: [ NamespacePath(cell_name), Integer(subscript) or nil, Token(port_name)] 800 772 def analyze_cell_join_expression 801 # å³è¾ºã® Expression ã®è¦ç´ ãåãåºã773 # 右辺の Expression の要素を取り出す 802 774 elements = @elements 803 if elements[0] == :OP_SUBSC then # å³è¾ºï¼åãå£é 804 åï¼ 775 if elements[0] == :OP_SUBSC then # 右辺:受け口配列? 805 776 # elements = [ :OP_SUBSC, [ :OP_DOT, [ :IDENTIFIER, token ], token ], expression ] 806 subscript = elements[2].eval_const(nil) # åãå£é 807 åã®æ·»æ° 808 elements = elements[1] # mikan é 809 åã ã£ãå ´å 777 subscript = elements[2].eval_const(nil) # 受け口配列の添数 778 elements = elements[1] # mikan 配列だった場合 810 779 else 811 780 subscript = nil … … 823 792 end 824 793 825 #=== Expression# ã»ã«ã¸ã®çµåã®å¼ãçæãã794 #=== Expression# セルへの結合の式を生成する 826 795 #nsp:: NamespacePath 827 796 #subscript:: Integer 828 797 #port_name:: Symbol 829 # analyze_cell_join_expression ã¨å¯¾ã«ãªã£ã¦ãã798 # analyze_cell_join_expression と対になっている 830 799 def self.create_cell_join_expression( nsp, subscript, port_name, locale = nil ) 831 800 if ! port_name.instance_of?( Symbol ) then … … 843 812 end 844 813 845 #=== Expression# æ´æ°å®æ°ã®å¼ãçæãã846 #val:: Integer : å¤ï¼ æ´æ°814 #=== Expression#整数定数の式を生成する 815 #val:: Integer : 値: 整数 847 816 def self.create_integer_constant( val, locale = nil ) 848 817 if val != Integer( val ) || val < 0 then … … 852 821 end 853 822 854 #=== Expression# åä¸ã®èå¥åã®å¼ã解æãã823 #=== Expression#単一の識別子の式を解析する 855 824 # Identifier => [ :IDENTIFIER, token ] 856 825 # Return: NamespacePath(Identifier) 857 826 def analyze_single_identifier 858 # å³è¾ºã® Expression ã®è¦ç´ ãåãåºã827 # 右辺の Expression の要素を取り出す 859 828 elements = @elements 860 829 if elements[0] == :IDENTIFIER … … 866 835 867 836 #=== Expression# 868 #nsp:: NamespacePath : åç 869 §ãããã®èå¥å 837 #nsp:: NamespacePath : 参照するもの識別子 870 838 def self.create_single_identifier( nsp, locale ) 871 839 if ! nsp.instance_of?( NamespacePath ) then … … 875 843 end 876 844 877 #=== è©ä¾¡å¯è½ããã§ãã¯ãã878 #*v:: å¯å¤åå¼æ°ï¼ä»»æã®åï¼879 # ãã¹ã¦ã BaseVal ã®åã¯ã©ã¹ï¼å¤ï¼ã§ããã°ãè©ä¾¡å¯è½ã¨å¤æãã845 #=== 評価可能かチェックする 846 #*v:: 可変個引数(任意の型) 847 # すべてが BaseVal の子クラス(値)であれば、評価可能と判断する 880 848 def evaluable?( *v ) 881 849 v.each{ |val| … … 896 864 897 865 #c_exp_string::String 898 #b_renew::Bool : true ãªã C_EXP ã® clone ä½æï¼ã¨ã¹ã±ã¼ãå¦ççãããªãï¼866 #b_renew::Bool : true なら C_EXP の clone 作成(エスケープ処理等をしない) 899 867 def initialize( c_exp_string, b_renew = false ) 900 868 if b_renew then 901 869 @c_exp_string = c_exp_string 902 870 else 903 # åå¾ã® " ãåãé¤ã871 # 前後の " を取り除く 904 872 # str = c_exp_string.to_s.sub( /^\"(.*)\"$/, "\\1" ) 905 873 str = CDLString.remove_dquote c_exp_string.to_s … … 908 876 end 909 877 910 #=== composite ç¨ã« C_EXP ã clone ãã878 #=== composite 用に C_EXP を clone する 911 879 #ct_name:: 912 880 #cell_name:: 913 # composite ã® attribute ã«ç¾ãã C_EXP ãæååç½®æãã¦çæããªããï¼914 # ãã®æååç½®æã¯ãæå³è§£é段éã§è¡ãï¼915 # ä»ã® C_EXP ã®æååç½®æã¯ãã³ã¼ãçæ段éã§è¡ãï¼881 # composite の attribute に現れる C_EXP を文字列置換して生成しなおす. 882 # この文字列置換は、意味解釈段階で行う. 883 # 他の C_EXP の文字列置換は、コード生成段階で行う. 916 884 def clone_for_composite( ct_name, cell_name, locale ) 917 885 dbgPrint "C_EXP: #{ct_name} #{cell_name} #{@c_exp_string}\n" … … 928 896 end 929 897 930 #=== C_EXP ãè©ä¾¡ãã931 # C_EXP ã®å¼ãæ°æååãè¿ã932 # æ¬æ¥ C_EXP 㯠eval_const ãã対象ã§ã¯ãªããã便å®ä¸ eval_const ã§å¯¾å¿898 #=== C_EXP を評価する 899 # C_EXP の引き数文字列を返す 900 # 本来 C_EXP は eval_const する対象ではないが、便宜上 eval_const で対応 933 901 def eval_const( name_list, name_list2 = nil ) 934 902 return self -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/gen_xml.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : gen_xml.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 … … 80 65 81 66 def gen_XML( file, nest ) 82 # signature ã®ã³ã¼ããçæ67 # signature のコードを生成 83 68 @signature_list.each { |s| 84 69 s.gen_XML file, nest 85 70 } 86 71 87 # celltype ã®ã³ã¼ããçæ72 # celltype のコードを生成 88 73 @celltype_list.each { |t| 89 74 t.gen_XML( file, nest ) 90 75 } 91 76 92 # composite ã®ã³ã¼ããçæ77 # composite のコードを生成 93 78 @compositecelltype_list.each { |t| 94 79 t.gen_XML( file, nest ) 95 80 } 96 81 97 # cell ã®ã³ã¼ããçæ82 # cell のコードを生成 98 83 @cell_list.each { |t| 99 84 t.gen_XML( file, nest ) 100 85 } 101 86 102 # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ87 # サブネームスペースのコードを生成 103 88 @namespace_list.each { |n| 104 89 kind = n.instance_of?( Namespace ) ? "namespace" : "region" … … 250 235 251 236 # 252 # Celltype ã¨å 253 ±ç¨å¯è½ãªã¯ãã ãã以ä¸ã®ç¹ã®å¤æ´ãå¿ 254 è¦ 255 # @active â @b_active 256 # @singleton â @b_singleton 257 # @attribute â @name_list (Decl) 258 # @port â @name_list (Port) 237 # Celltype と共用可能なはずだが、以下の点の変更が必要 238 # @active ⇒ @b_active 239 # @singleton ⇒ @b_singleton 240 # @attribute ⇒ @name_list (Decl) 241 # @port ⇒ @name_list (Port) 259 242 class CompositeCelltype 260 243 def gen_XML file, nest -
Property svn:mime-type
changed from
-
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
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/location.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : location.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 … … 77 62 78 63 #== Cell_location 79 # tecscde ã®ä½ç½®æ 80 å ± 64 # tecscde の位置情報 81 65 class Cell_location 82 66 … … 105 89 106 90 #== Join_location 107 # tecscde ã®ä½ç½®æ 108 å ± 91 # tecscde の位置情報 109 92 class Join_location 110 93 @@join_location_list = [] -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/messages.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : messages.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 #== TECS ã®çæããåå½èªåå¿ 56 è¦ãªæåå 57 # ç¾ç¶ãã¨ã©ã¼ã¡ãã»ã¼ã¸ã¯è±èªã®ã¿ 58 # çæãã¡ã¤ã«ã®ã³ã¡ã³ãã¨ãã¦åºåãããæåå 40 #== TECS の生成する各国語化必要な文字列 41 # 現状、エラーメッセージは英語のみ 42 # 生成ファイルのコメントとして出力される文字列 59 43 class TECSMsg 60 44 61 #=== TECSMsg# çæãããããããã³ãã¬ã¼ããªã©ã«å«ããã³ã¡ã³ãã®åå¾62 # CDL ã®æåã³ã¼ãã«åããã¦ãæåã³ã¼ãå¤æãè¡ã45 #=== TECSMsg#生成するヘッダやテンプレートなどに含めるコメントの取得 46 # CDL の文字コードに合わせて、文字コード変換を行う 63 47 def self.get( msg ) 64 48 str = @@comment[ msg ] … … 71 55 end 72 56 73 #=== TECSMsg# ãã¼ã«ã©ã¤ãºãããã¨ã©ã¼ã¡ãã»ã¼ã¸ãå¾ã74 #body::String : "S0001 error message body" ã®å½¢å¼75 # S0001 ã®é¨åã使ç¨ããã76 # Generator.error2 ããå¼ã³åºããã57 #=== TECSMsg#ローカライズされたエラーメッセージを得る 58 #body::String : "S0001 error message body" の形式 59 # S0001 の部分が使用される 60 # Generator.error2 から呼び出される 77 61 def self.get_error_message( body ) 78 body =~ /^[A-Z0-9]+/ # ã¨ã©ã¼çªå·ãåãåºã62 body =~ /^[A-Z0-9]+/ # エラー番号を取り出す 79 63 num = $& 80 64 if num then … … 91 75 end 92 76 93 #=== TECSMsg# ãã¼ã«ã©ã¤ãºãããã¦ã©ã¼ãã³ã°ã¡ãã»ã¼ã¸ãå¾ã94 # Generator.warning2 ããå¼ã³åºããã77 #=== TECSMsg#ローカライズされたウォーニングメッセージを得る 78 # Generator.warning2 から呼び出される 95 79 def self.get_warning_message( body ) 96 body =~ /^[A-Z0-9]+/ # ã¦ã©ã¼ãã³ã°çªå·ãåãåºã80 body =~ /^[A-Z0-9]+/ # ウォーニング番号を取り出す 97 81 num = $& 98 82 msg = @@warning_message[ num.to_sym ] -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/optimize.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : optimize.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 … … 58 43 Other processes are setting ID for each cell and setting domain information 59 44 60 ãã®ãã¡ã¤ã«ã«ã¯ãæå³è§£æããã³ã¼ãçæã®éã§è¡ãã¹ãå¦çãå«ã¾ããï¼ 61 æé©åããã®ä¸ã¤ã§ããï¼ 62 ãã®ä»ã«ãã»ã«æ¯ã® ID ä»ãããã¡ã¤ã³ãããè¡ãï¼ 63 ã³ã¼ãçæ対象ã¨ãªãã»ã«ã対象ã«å¦çãè¡ããã®ãå«ã¾ããï¼ 45 このファイルには、意味解析からコード生成の間で行うべき処理が含まれる. 46 最適化もその一つである. 47 その他に、セル毎の ID 付け、ドメインわけを行う. 48 コード生成対象となるセルを対象に処理を行うものが含まれる. 64 49 =end 65 50 66 51 class Namespace 67 52 68 #=== åã»ã«ã« ID ï¼æ´æ°å¤ï¼ãå²ä»ãã53 #=== 各セルに ID (整数値)を割付ける 69 54 def set_cell_id_and_domain 70 # celltype ã®åã»ã«ã« ID ãå²ä»ãã55 # celltype の各セルに ID を割付ける 71 56 @celltype_list.each { |t| 72 57 t.set_cell_id_and_domain 73 58 } 74 59 75 # ãµããã¼ã ã¹ãã¼ã¹ã®åã»ã«ã« ID ãå²ä»ãã60 # サブネームスペースの各セルに ID を割付ける 76 61 @namespace_list.each { |n| 77 62 n.set_cell_id_and_domain … … 80 65 81 66 def optimize 82 # celltype ã®æé©å67 # celltype の最適化 83 68 @celltype_list.each { |t| 84 69 t.optimize 85 70 } 86 71 87 # ãµããã¼ã ã¹ãã¼ã¹ã®æé©å72 # サブネームスペースの最適化 88 73 @namespace_list.each { |n| 89 74 n.optimize … … 92 77 93 78 def reset_optimize 94 # celltype ã®æé©å79 # celltype の最適化 95 80 @celltype_list.each { |t| 96 81 t.reset_optimize 97 82 } 98 83 99 # ãµããã¼ã ã¹ãã¼ã¹ã®æé©å84 # サブネームスペースの最適化 100 85 @namespace_list.each { |n| 101 86 n.reset_optimize … … 106 91 class Celltype 107 92 108 ID_BASE = 1 # reset_optimize ã§ãªã»ãããã93 ID_BASE = 1 # reset_optimize でリセットする 109 94 @@ID_BASE = ID_BASE 110 95 … … 114 99 end 115 100 116 #=== åã»ã«ã« ID ï¼æ´æ°å¤ï¼ãå²ä»ãã101 #=== 各セルに ID (整数値)を割付ける 117 102 def set_cell_id 118 103 … … 122 107 123 108 if $unique_id then 124 @id_base = @@ID_BASE # id ãã·ã¹ãã å 125 ¨ä½ã§é£çªã«ãã 109 @id_base = @@ID_BASE # id をシステム全体で連番にする 126 110 else 127 @id_base = 1 # base ã常㫠1 ããå§ãã111 @id_base = 1 # base を常に 1 から始める 128 112 end 129 113 … … 131 115 no_id_specified_cells = [] 132 116 133 # ãããã¿ã¤ããé¤ããæ°ãæ±ãã117 # プロトタイプを除いた数を求める 134 118 @cell_list.each{ |c| 135 119 if c.is_generate? then … … 148 132 } 149 133 150 @ordered_cell_list = [] # id = 1 ãæ·»æ° 0 ã«æ ¼ç´ããã151 # ID æå®ããã¦ããã»ã«ã« id çªå·ãä¸ãã134 @ordered_cell_list = [] # id = 1 が添数 0 に格納される 135 # ID 指定されているセルに id 番号を与える 152 136 id_specified_cells.each{ |c| 153 137 id = c.get_specified_id … … 169 153 end 170 154 @ordered_cell_list[ id - 1 ] = c 171 # éãçªå·ã¨ããå ´åã®ãã @id_base ãå ãã155 # 通し番号とする場合のため @id_base を加える 172 156 c.set_id( @id_base - 1 + id ) 173 157 if $verbose then … … 176 160 } 177 161 178 # ID æå®ããã¦ããªãã»ã«ã« id çªå·ãä¸ãã162 # ID 指定されていないセルに id 番号を与える 179 163 i = 0 180 164 no_id_specified_cells.each{ |c| … … 226 210 227 211 @domain_roots.each{ |dn, regions| 228 # domain_type ã¯ä¸ã¤ã®ãã¼ãã«ä¸ã¤ãããªãã®ã§ãä¸ã¤ã®è¦ç´ ãç¡æ¡ä»¶ã§åãåºã212 # domain_type は一つのノードに一つしかないので、一つの要素を無条件で取り出す 229 213 if regions.length > 1 then 230 214 cdl_info( "celltype:#{@name} has cells in multi domain.\n" ) … … 239 223 def optimize 240 224 241 # port ã®åç 242 §ããã»ã«ã¿ã¤ãã®æ°ãã»ã«ã®æ°ãæ±ãã 225 # port の参照するセルタイプの数、セルの数を求める 243 226 if $verbose then 244 227 print "=== optimizing celltype #{get_namespace_path.to_s} ===\n" … … 248 231 next if port.get_port_type != :CALL 249 232 if port.is_omit? then 250 # å¼ã³å£æé©åå®æ½233 # 呼び口最適化実施 251 234 @b_cp_optimized = true 252 @n_call_port_omitted_in_CB += 1 # CB ã§çç¥ããå¼ã³å£253 port.set_skelton_useless # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©å254 port.set_VMT_useless # VMT ä¸è¦æé©å (ç´æ¥åãå£é¢æ°ãå¼åºã)235 @n_call_port_omitted_in_CB += 1 # CB で省略する呼び口 236 port.set_skelton_useless # スケルトン関数不要最適化 237 port.set_VMT_useless # VMT 不要最適化 (直接受け口関数を呼出す) 255 238 if $verbose then 256 239 print "optimized by omit: port: #{port.get_name} : o\n" … … 263 246 end 264 247 265 port_cells = [] # å¼ã³å 266 ã»ã« 267 port_ports = [] # å¼ã³å 268 ã®ãã¼ã 269 270 # ã»ã«ã®åç 271 §ããã»ã«ãéããï¼ãã¼ããä¸ç·ã«éããï¼ 248 port_cells = [] # 呼び先セル 249 port_ports = [] # 呼び先のポート 250 251 # セルの参照するセルを集める(ポートも一緒に集める) 272 252 @cell_list.each{ |cell| 273 253 … … 281 261 if j then 282 262 if j.get_array_member2 then 283 # å¼ã³å£é 284 åã®å ´åãå 285 ¨é¨ã®çµåå 286 ãéãã 263 # 呼び口配列の場合、全部の結合先を集める 287 264 j.get_array_member2.each { |j2| 288 265 if j2 then 289 266 port_cells << j2.get_rhs_cell 290 port_ports << j2.get_rhs_port # å³è¾ºã®ãã¼ã267 port_ports << j2.get_rhs_port # 右辺のポート 291 268 else 292 # optional ã§ãããæ·»æ°ã®ã¿åæåããã¦ããªãï¼ãã¹ã¦åæåãããªãå ´åã¯ãä¸ï¼269 # optional で、ある添数のみ初期化されていない(すべて初期化されない場合は、下) 293 270 port_cells << nil 294 271 port_ports << nil … … 296 273 } 297 274 else 298 # å 299 ¨ã¦ã®çµåå 300 ãéãã 275 # 全ての結合先を集める 301 276 port_cells << j.get_rhs_cell 302 port_ports << j.get_rhs_port # å³è¾ºã®ãã¼ã277 port_ports << j.get_rhs_port # 右辺のポート 303 278 end 304 279 else 305 # optional ã§åæåããã¦ããªãï¼nil ãè¦ç´ ã«å ãã¦ããï¼280 # optional で初期化されていない(nil を要素に加えておく) 306 281 port_cells << nil 307 port_ports << nil # å³è¾ºã®ãã¼ã282 port_ports << nil # 右辺のポート 308 283 end 309 284 } 310 285 311 # éè¤è¦ç´ ãåãé¤ã286 # 重複要素を取り除く 312 287 port_cells.uniq! 313 288 port_ports.uniq! 314 289 315 # å¼ã³å£ã®å¼ã³å 316 ãä¸ã¤ã®ãã¼ãã ããï¼ 290 # 呼び口の呼び先が一つのポートだけか? 317 291 if port_ports.length == 1 then 318 292 319 # å¼ã³å£é 320 åãå¯å¤é·ã®å ´åãæé©åããªã 321 # mikan å¼ã³å£é 322 åè¦ç´ æ°ãã¯ãä¸å 323 ·åæ«å®å¯¾ç 324 # ããæã¾ããä¿®æ£ã¯ãåãå£ã¸ã®ãã¤ã³ã¿ã¯çç¥ããããé 325 ååæ°ã¯åºåãã(#_CP_#, #_TCP_#) 326 # ããã«é 327 ååæ°ãå®æ°åã§ããã®ã§ããã°ãå®æ°ãã¯ããåºå (#_NCPA_#) 293 # 呼び口配列が可変長の場合、最適化しない 294 # mikan 呼び口配列要素数マクロ不具合暫定対策 295 # より望ましい修正は、受け口へのポインタは省略するが、配列個数は出力する(#_CP_#, #_TCP_#) 296 # さらに配列個数が定数化できるのであれば、定数マクロを出力 (#_NCPA_#) 328 297 next if port.get_array_size == "[]" 329 298 330 # å¼ã³å£æé©åå®æ½299 # 呼び口最適化実施 331 300 @b_cp_optimized = true 332 301 333 # å¼ã³å 334 ãä¸ã¤ã®ã»ã«ã ããï¼ 302 # 呼び先が一つのセルだけか? 335 303 if port_cells.length == 1 then 336 304 337 # å¼ã³å£ã¯ optional ã§åæåããã¦ããªããã¾ãã¯åãå£ã¯é 338 åã§ã¯ãªããï¼ 305 # 呼び口は optional で初期化されていない、または受け口は配列ではないか? 339 306 if port_ports[0] == nil || port_ports[0].get_array_size == nil then 340 307 341 @n_call_port_omitted_in_CB += 1 # CB ã§çç¥ããå¼ã³å£342 port.set_cell_unique # ã»ã«ä¸ã¤ã ãæé©å343 port.set_skelton_useless # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©å344 port.set_VMT_useless # VMT ä¸è¦æé©å (ç´æ¥åãå£é¢æ°ãå¼åºã)308 @n_call_port_omitted_in_CB += 1 # CB で省略する呼び口 309 port.set_cell_unique # セル一つだけ最適化 310 port.set_skelton_useless # スケルトン関数不要最適化 311 port.set_VMT_useless # VMT 不要最適化 (直接受け口関数を呼出す) 345 312 346 313 if $verbose then … … 348 315 end 349 316 else 350 port.set_VMT_useless # VMT ä¸è¦æé©å (ã¹ã±ã«ãã³é¢æ°ãå¼åºã)317 port.set_VMT_useless # VMT 不要最適化 (スケルトン関数を呼出す) 351 318 352 319 if $verbose then … … 355 322 end 356 323 357 else # å¼ã³å 358 ãè¤æ°ã®ã»ã«ï¼åä¸ã®ãã¼ãï¼ 359 360 # å¼ã³å£ã¯ optional ã§åæåããã¦ããªããã¾ãã¯åãå£ã¯é 361 åã§ã¯ãªããï¼ 324 else # 呼び先が複数のセル(単一のポート) 325 326 # 呼び口は optional で初期化されていない、または受け口は配列ではないか? 362 327 if port_ports[0] == nil || port_ports[0].get_array_size == nil then 363 328 if ! @singleton then 364 port.set_skelton_useless # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©å365 port.set_VMT_useless # VMT ä¸è¦æé©å (ã¹ã±ã«ãã³é¢æ° or åãå£é¢æ°ãå¼åºã)329 port.set_skelton_useless # スケルトン関数不要最適化 330 port.set_VMT_useless # VMT 不要最適化 (スケルトン関数 or 受け口関数を呼出す) 366 331 367 332 if $verbose then … … 369 334 end 370 335 else 371 port.set_VMT_useless # VMT ä¸è¦æé©å (ã¹ã±ã«ãã³é¢æ° or åãå£é¢æ°ãå¼åºã)336 port.set_VMT_useless # VMT 不要最適化 (スケルトン関数 or 受け口関数を呼出す) 372 337 373 338 if $verbose then … … 379 344 380 345 port.set_only_callee( port_ports[0], port_cells[0] ) 381 # set_cell_unique ã§ãªãå ´å cell ã¯æå³ããªã346 # set_cell_unique でない場合 cell は意味がない 382 347 383 348 end … … 387 352 } 388 353 389 # åãå£æé©åã®è¨å®354 # 受け口最適化の設定 390 355 @port.each{ |port| 391 356 next if port.get_port_type != :CALL 392 357 393 # å¼ã³å£å´ã®æé©åç¶æ 394 358 # 呼び口側の最適化状態 395 359 b_VMT_useless = port.is_VMT_useless? 396 360 b_skelton_useless = port.is_skelton_useless? 397 361 398 # ã»ã«ã®åç 399 §ããã»ã«ãéããï¼ãã¼ããä¸ç·ã«éããï¼ 362 # セルの参照するセルを集める(ポートも一緒に集める) 400 363 @cell_list.each{ |cell| 401 364 … … 407 370 j = jl.get_item( port.get_name ) 408 371 409 if j then # optional ã§çµåããã¦ããªãå ´ånil372 if j then # optional で結合されていない場合 nil 410 373 if j.get_array_member2 then 411 # å¼ã³å£é 412 å 374 # 呼び口配列 413 375 j.get_array_member2.each { |j2| 414 376 if j2 then 415 port2 = j2.get_rhs_port # å³è¾ºã®ãã¼ã416 # åãå£å´ã®æé©åå¯è½æ§ãè¨å®377 port2 = j2.get_rhs_port # 右辺のポート 378 # 受け口側の最適化可能性を設定 417 379 port2.set_entry_VMT_skelton_useless( b_VMT_useless, b_skelton_useless ) 418 380 #else 419 # optional ã§å¼ã³å£é 420 åè¦ç´ ãåæåããã¦ããªã 381 # optional で呼び口配列要素が初期化されていない 421 382 end 422 383 } 423 384 else 424 port2 = j.get_rhs_port # å³è¾ºã®ãã¼ã425 # åãå£å´ã®æé©åå¯è½æ§ãè¨å®385 port2 = j.get_rhs_port # 右辺のポート 386 # 受け口側の最適化可能性を設定 426 387 port2.set_entry_VMT_skelton_useless( b_VMT_useless, b_skelton_useless ) 427 388 end … … 431 392 end 432 393 433 #Celltype# ãªã»ãããã394 #Celltype# リセットする 434 395 def reset_optimize 435 @@ID_BASE = ID_BASE # æ¬å½ã¯ä¸åã ãã§ãã436 @id_base = 1 # set_cell_id ã§ãªã»ãããããã®ã§ä¸è¦437 438 @b_cp_optimized = false # å¼ã³å£æé©å439 @n_call_port_omitted_in_CB = 0 # å¼ã³å£æé©åã«ããä¸çæã¨ãªã£ããã¼ãã®æ°440 @n_cell_gen = 0 # çæã»ã«åæ°396 @@ID_BASE = ID_BASE # 本当は一回だけでよい 397 @id_base = 1 # set_cell_id でリセットされるので不要 398 399 @b_cp_optimized = false # 呼び口最適化 400 @n_call_port_omitted_in_CB = 0 # 呼び口最適化により不生成となったポートの数 401 @n_cell_gen = 0 # 生成セル個数 441 402 @port.each{ |p| 442 403 p.reset_optimize … … 446 407 end 447 408 448 #Celltype# ããã㯠include ããã¦ããã449 #hname::Symbol : ãããå450 #RETURN:: bool_t: false ã¤ã³ã¯ã«ã¼ãããã¦ããªããtrue ã¤ã³ã¯ã«ã¼ãããã¦ãã451 # #_ISH_#, #_ICT_# ã§ããããåãè¾¼ã¾ãã¦ããããã§ãã¯ãã452 # false ãè¿ã£ãå ´åãhname ã¯ç»é²ããã¦ã次åã®å¼ã³åºãã§ã¯ true ãè¿ã409 #Celltype# ヘッダは include されているか 410 #hname::Symbol : ヘッダ名 411 #RETURN:: bool_t: false インクルードされていない、true インクルードされている 412 # #_ISH_#, #_ICT_# でヘッダが取り込まれているかチェックする 413 # false が返った場合、hname は登録されて、次回の呼び出しでは true が返る 453 414 def header_included?( hname ) 454 415 if @included_header[ hname ] == nil then -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/plugin.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : plugin.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 #== class ã¢ã¸ã¥ã¼ã«56 # ThroughPlugin, SignaturePlugin, CelltypePlugin ã« include ãã40 #== class モジュール 41 # ThroughPlugin, SignaturePlugin, CelltypePlugin に include する 57 42 class Plugin < Node 58 #@error_backlog:: [msg1, msg2, ... ] @locale ãè¨å®ãããåã«çºçããã¨ã©ã¼43 #@error_backlog:: [msg1, msg2, ... ] @locale が設定される前に発生したエラー 59 44 60 45 PluginArgProc = { … … 65 50 super 66 51 @b_silent = false 67 @locale = nil # set_locale ãå¼ã³åºãããã¾ã§ nil ã¨ãªã52 @locale = nil # set_locale が呼び出されるまで nil となる 68 53 @error_backlog = [] 69 54 end 70 55 71 56 #=== Plugin#cdl_error 72 # set_locale ãå¼ã³åºãããã¾ã§ @error_backlog ã«ä¿åãä¿çãã57 # set_locale が呼び出されるまで @error_backlog に保存し保留する 73 58 def cdl_error *arg 74 59 if @locale then … … 79 64 end 80 65 81 #=== locale ãè¨å®ãã82 # Node 㯠initialize 㧠locale ãè¨å®ããããplugin 㯠parse ã¨ã¯83 # ç°ãªãã¿ã¤ãã³ã° new ããããããlocale ãåè¨å®ãã84 # ãã®ã¡ã½ããã2度å¼ã³åºã㨠@error_backlog ã®ã¨ã©ã¼ã2度åºåããã¦ãã¾ã66 #=== locale を設定する 67 # Node は initialize で locale を設定するが、plugin は parse とは 68 # 異なるタイミング new されるため、locale を再設定する 69 # このメソッドを2度呼び出すと @error_backlog のエラーが2度出力されてしまう 85 70 def set_locale locale 86 71 @locale = locale … … 90 75 end 91 76 92 ### æå³è§£æ段éã§å¼ã³åºãããã¡ã½ãã###93 #=== CDL ãã¡ã¤ã«ã®çæ94 # typedef, signature, celltype, cell ã®ã³ã¼ããçæ95 # éè¤ãã¦çæãã¦ã¯ãªããªã96 # ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã97 # ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã98 #file:: FILE çæãããã¡ã¤ã«77 ### 意味解析段階で呼び出されるメソッド ### 78 #=== CDL ファイルの生成 79 # typedef, signature, celltype, cell のコードを生成 80 # 重複して生成してはならない 81 # すでに生成されている場合は出力しないこと。 82 # もしくは同名の import により、重複を避けること。 83 #file:: FILE 生成するファイル 99 84 def gen_cdl_file file 100 85 end 101 86 102 87 103 ### ã³ã¼ãç段éã§å¼ã³åºãããã¡ã½ãã###104 #=== ãã©ã°ã¤ã³ã¯ gen_ep_func ãæä¾ããã105 # gen_ep_func å®ç¾© â ãã³ãã¬ã¼ãã§ã¯ãªããã»ã«ã¿ã¤ãã³ã¼ã(tCelltype.c)ãçæ106 # gen_ep_func æªå®ç¾© â ãã³ãã¬ã¼ã(tCelltype_templ.c)ãçæ88 ### コード生段階で呼び出されるメソッド ### 89 #=== プラグインは gen_ep_func を提供するか 90 # gen_ep_func 定義 ⇒ テンプレートではない、セルタイプコード(tCelltype.c)を生成 91 # gen_ep_func 未定義 ⇒ テンプレート(tCelltype_templ.c)を生成 107 92 def gen_ep_func? 108 93 self.class.method_defined?( :gen_ep_func_body ) 109 94 end 110 95 111 #=== åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã 112 # ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿ 113 è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã 114 # ãã®ã¡ã½ãããæªå®ç¾©ã§ããã°ããã©ã°ã¤ã³ã¯ã»ã«ã¿ã¤ãã³ã¼ããçæããªã (é常éããã³ãã¬ã¼ããçæãã) 115 # gen_cdl_file ã®ä¸ã§çæãããã»ã«ã¿ã¤ãã«å¯¾ãã¦å¼ã³åºããã 116 #file:: FILE åºåå 117 ãã¡ã¤ã« (tCelltype.c) 96 #=== 受け口関数の本体(C言語)を生成する 97 # プラグインの場合、変更する必要のないセルタイプコードを生成する 98 # このメソッドが未定義であれば、プラグインはセルタイプコードを生成しない (通常通りテンプレートを生成する) 99 # gen_cdl_file の中で生成されたセルタイプに対して呼び出される 100 #file:: FILE 出力先ファイル (tCelltype.c) 118 101 #b_singleton:: bool true if singleton 119 102 #ct_name:: Symbol … … 127 110 # end 128 111 129 #=== åãå£é¢æ°ã® preamble (Cè¨èª)ãçæãã 130 # å¿ 131 è¦ãªã preamble é¨ã«åºåãã 132 # gen_cdl_file ã®ä¸ã§ã§çæãããã»ã«ã¿ã¤ãã«å¯¾ãã¦å¼ã³åºããã 133 #file:: FILE åºåå 134 ãã¡ã¤ã« 112 #=== 受け口関数の preamble (C言語)を生成する 113 # 必要なら preamble 部に出力する 114 # gen_cdl_file の中でで生成されたセルタイプに対して呼び出される 115 #file:: FILE 出力先ファイル 135 116 #b_singleton:: bool true if singleton 136 117 #ct_name:: Symbol 137 118 #global_ct_name:: string 138 119 def gen_preamble( file, b_singleton, ct_name, global_ct_name ) 139 # ããã©ã«ãã§ã¯ä½ãåºåããªã 140 end 141 142 #=== åãå£é¢æ°ã® postamble (Cè¨èª)ãçæãã 143 # å¿ 144 è¦ãªã postamble é¨ã«åºåãã 145 # gen_cdl_file ã®ä¸ã§çæãããã»ã«ã¿ã¤ãã«å¯¾ãã¦å¼ã³åºããã 146 #file:: FILE åºåå 147 ãã¡ã¤ã« 120 # デフォルトでは何も出力しない 121 end 122 123 #=== 受け口関数の postamble (C言語)を生成する 124 # 必要なら postamble 部に出力する 125 # gen_cdl_file の中で生成されたセルタイプに対して呼び出される 126 #file:: FILE 出力先ファイル 148 127 #b_singleton:: bool true if singleton 149 128 #ct_name:: Symbol 150 129 #global_ct_name:: string 151 130 def gen_postamble( file, b_singleton, ct_name, global_ct_name ) 152 # ããã©ã«ãã§ã¯ä½ãåºåããªã153 end 154 155 #=== gen_cdl_file ã®ä¸ã§çæãããã»ã«ã¿ã¤ãã«æ°ããã»ã«ãçæããã156 # ã©ã®ã»ã«ã¿ã¤ãã㯠cell.get_celltype ã§åãã131 # デフォルトでは何も出力しない 132 end 133 134 #=== gen_cdl_file の中で生成されたセルタイプに新しいセルが生成された 135 # どのセルタイプかは cell.get_celltype で分かる 157 136 # 158 #file:: FILE åºåå 159 ãã¡ã¤ã« 137 #file:: FILE 出力先ファイル 160 138 #b_singleton:: bool true if singleton 161 139 #ct_name:: Symbol 162 140 #global_ct_name:: string 163 141 def new_cell cell 164 # ããã©ã«ãã§ã¯ä½ãããªã165 end 166 167 ### ãã©ã°ã¤ã³å¼æ°ã®è§£é###142 # デフォルトでは何もしない 143 end 144 145 ### プラグイン引数の解釈 ### 168 146 def parse_plugin_arg 169 147 arg = @plugin_arg_str.dup 170 148 171 # æ¹è¡ãæ¶ã149 # 改行を消す 172 150 arg.gsub!( /\\\n/, "" ) 173 151 174 152 while arg != "" 175 153 176 # åã®ç©ºç½èªã¿é£ã°ã154 # 前の空白読み飛ばす 177 155 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') 178 156 179 # èå¥ååå¾157 # 識別子取得 180 158 if arg =~ /\A[a-zA-Z_]\w*/ then 181 159 ident = $~ … … 186 164 end 187 165 188 # åã®ç©ºç½èªã¿é£ã°ã166 # 前の空白読み飛ばす 189 167 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') 190 168 … … 196 174 end 197 175 198 # åã®ç©ºç½èªã¿é£ã°ã176 # 前の空白読み飛ばす 199 177 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') 200 178 201 # å³è¾ºæåå202 if arg =~ /\A\\"(.*?)\\"\s*,/ then # \" \" ã§å²ã¾ãã¦ããå ´å203 rhs = $1 204 remain = $' 205 elsif arg =~ /\A%(.*?)%\s*,/ then # % % ã§å²ã¾ãã¦ããå ´å206 rhs = $1 207 remain = $' 208 elsif arg =~ /\A!(.*?)!\s*,/ then # $ $ ã§å²ã¾ãã¦ããå ´å209 rhs = $1 210 remain = $' 211 elsif arg =~ /\A'(.*?)'\s*,/ then # $ $ ã§å²ã¾ãã¦ããå ´å212 rhs = $1 213 remain = $' 214 elsif arg =~ /\A\\"(.*?)\\"\s*,/ then # || ã«ã [,$] ã«ãã§ããªãã£ã179 # 右辺文字列 180 if arg =~ /\A\\"(.*?)\\"\s*,/ then # \" \" で囲まれている場合 181 rhs = $1 182 remain = $' 183 elsif arg =~ /\A%(.*?)%\s*,/ then # % % で囲まれている場合 184 rhs = $1 185 remain = $' 186 elsif arg =~ /\A!(.*?)!\s*,/ then # $ $ で囲まれている場合 187 rhs = $1 188 remain = $' 189 elsif arg =~ /\A'(.*?)'\s*,/ then # $ $ で囲まれている場合 190 rhs = $1 191 remain = $' 192 elsif arg =~ /\A\\"(.*?)\\"\s*,/ then # || にも [,$] にもできなかった 215 193 rhs = $1 216 194 remain = $' 217 195 # elsif arg =~ /\A(.*?)\s*$/ then 218 elsif arg =~ /\A\\"(.*?)\\"\s*\z/ then # \" \" ã§å²ã¾ãã¦ããå ´å219 rhs = $1 220 remain = $' 221 elsif arg =~ /\A%(.*?)%\s*\z/ then # % % ã§å²ã¾ãã¦ããå ´å222 rhs = $1 223 remain = $' 224 elsif arg =~ /\A!(.*?)!\s*\z/ then # $ $ ã§å²ã¾ãã¦ããå ´å225 rhs = $1 226 remain = $' 227 elsif arg =~ /\A'(.*?)'\s*\z/ then # $ $ ã§å²ã¾ãã¦ããå ´å228 rhs = $1 229 remain = $' 230 elsif arg =~ /\A\\"(.*?)\\"\s*\z/ then # || ã«ã [,$] ã«ãã§ããªãã£ã196 elsif arg =~ /\A\\"(.*?)\\"\s*\z/ then # \" \" で囲まれている場合 197 rhs = $1 198 remain = $' 199 elsif arg =~ /\A%(.*?)%\s*\z/ then # % % で囲まれている場合 200 rhs = $1 201 remain = $' 202 elsif arg =~ /\A!(.*?)!\s*\z/ then # $ $ で囲まれている場合 203 rhs = $1 204 remain = $' 205 elsif arg =~ /\A'(.*?)'\s*\z/ then # $ $ で囲まれている場合 206 rhs = $1 207 remain = $' 208 elsif arg =~ /\A\\"(.*?)\\"\s*\z/ then # || にも [,$] にもできなかった 231 209 rhs = $1 232 210 remain = $' … … 234 212 rhs = $1 235 213 remain = $' 236 # åã®ç©ºç½èªã¿é£ã°ã214 # 前の空白読み飛ばす 237 215 rhs.sub!( /\A\s*(.*)\s*\z/, '\1') 238 216 elsif arg =~ /\A(.*?)\s*\z/ then … … 244 222 end 245 223 246 # 0 æåã®æååã to_sym ããã¨ä¾å¤çºçããã®ã§ç©ºç½æåã¨ãã224 # 0文字の文字列を to_sym すると例外発生するので空白文字とする 247 225 if rhs == "" then 248 226 rhs = " " 249 227 end 250 228 251 arg = remain # arg ã®æ®ãã®é¨å252 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') # åã®ç©ºç½èªã¿é£ã°ã253 254 # \ ãå¤ã255 rhs = rhs.gsub( /\\(.)/, "\\1" ) # ãã㧠$' ãå¤ãããã¨ã«æ³¨æï¼229 arg = remain # arg の残りの部分 230 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') # 前の空白読み飛ばす 231 232 # \ を外す 233 rhs = rhs.gsub( /\\(.)/, "\\1" ) # ここで $' が変わることに注意! 256 234 # print "parse_plugin_arg: #{ident} #{rhs}\n" 257 235 @plugin_arg_list[ ident ] = rhs … … 262 240 end 263 241 264 #=== ãã©ã°ã¤ã³å¼æ°ããã§ãã¯ãã265 # @plugin_arg_check_proc_tab ã«å¾ã£ã¦ãã©ã°ã¤ã³å¼æ°ããã§ãã¯ããã266 # å¤ãç¨æ³ï¼åã¯ã©ã¹ã§ãªã¼ãã¼ã©ã¤ãããå¼æ°èå¥åãæ£ããããã§ãã¯ãã267 #ident:: string: å¼æ°èå¥å268 #rhs:: string: å³è¾ºæåå242 #=== プラグイン引数をチェックする 243 # @plugin_arg_check_proc_tab に従ってプラグイン引数をチェックすする 244 # 古い用法:子クラスでオーバーライドし、引数識別子が正しいかチェックする 245 #ident:: string: 引数識別子 246 #rhs:: string: 右辺文字列 269 247 def check_plugin_arg( ident, rhs ) 270 248 … … 291 269 end 292 270 293 #=== ãã©ã°ã¤ã³ã®ã¡ãã»ã¼ã¸åºå271 #=== プラグインのメッセージ出力 294 272 def print_msg( msg ) 295 273 if @b_silent == true then … … 299 277 end 300 278 301 #=== ãã©ã°ã¤ã³å¼æ°silent279 #=== プラグイン引数 silent 302 280 def set_silent rhs 303 281 if rhs == "true" || rhs == nil then … … 307 285 end 308 286 309 #== åºåæååã EUC ããåºåãã¡ã¤ã«ã« convert ãã310 # tecsgen ã®ã½ã¼ã¹ã³ã¼ã㯠EUC ã§è¨è¿°ããã¦ãã311 # ããããåºåãã¡ã¤ã«ã®æåã³ã¼ãã«å¤æãã¦åºåãã287 #== 出力文字列を EUC から出力ファイルに convert する 288 # tecsgen のソースコードは EUC で記述されている 289 # これを、出力ファイルの文字コードに変換して出力する 312 290 # 313 # generate.rb ã§åºåãããã®ã¯ message.rb ã§å¤æãã¦ãã314 # generate.rb ã§åºåãããã®ã¯ APPFile ã¯ã©ã¹ã使ç¨ãã¦ãã315 # mikan: CFile ã§åºåãããã®ã« factory ã§è¿½è¨ã§ããªã (cdl ãã¡ã¤ã«ã®å ´åã追è¨ã§ãã¦ãæå³ããªã)291 # generate.rb で出力するものは message.rb で変換している 292 # generate.rb で出力するものは APPFile クラスを使用している 293 # mikan: CFile で出力したものに factory で追記できない (cdl ファイルの場合、追記できても意味がない) 316 294 class CFile 317 295 def self.open( path, mode ) -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/pluginModule.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : pluginModule.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 #== ãã©ã°ã¤ã³ããã¼ãããå´ã®ã¢ã¸ã¥ã¼ã«40 #== プラグインをロードする側のモジュール 56 41 # @@loaded_plugin_list:: {Symbol=>Integer} 57 42 module PluginModule … … 59 44 @@loaded_plugin_list = {} 60 45 61 #=== ãã©ã°ã¤ã³ããã¼ããã62 #return:: true : æåã false : 失æ46 #=== プラグインをロードする 47 #return:: true : 成功、 false : 失敗 63 48 # 64 # ãã§ã«ãã¼ãããã¦ãããã®ã¯ãéè¤ãã¦ãã¼ãããªã65 # load æã®ä¾å¤ã¯ãã®ã¡ã½ããã®ä¸ã§ãã£ãããã㦠false ãè¿ããã49 # すでにロードされているものは、重複してロードしない 50 # load 時の例外はこのメソッドの中でキャッチされて false が返される 66 51 def load_plugin( plugin_name, superClass ) 67 52 … … 73 58 print( "load '#{plugin_name}.rb'\n" ) 74 59 end 75 # "#{plugin_name}.rb" ããã¼ãï¼ã·ã¹ãã ç¨ã§ã¯ãªãã®ã§ãfatal ã¨ã©ã¼ã«ããªãï¼60 # "#{plugin_name}.rb" をロード(システム用ではないので、fatal エラーにしない) 76 61 if require_tecsgen_lib( "#{plugin_name}.rb", false ) == false 77 62 cdl_error( "P2001 $1.rb : fail to load plugin" , plugin_name ) … … 101 86 end 102 87 103 #=== ãã©ã°ã¤ã³ã® gen_cdl_file ãå¼ã³ã㦠cdl ãã¡ã¤ã«ãçæããã解éãè¡ã88 #=== プラグインの gen_cdl_file を呼びして cdl ファイルを生成させ、解釈を行う 104 89 def generate_and_parse plugin_object 105 if plugin_object == nil # ãã©ã°ã¤ã³ã®ãã¼ãã«å¤±æãã¦ããï¼æ¢ã«ã¨ã©ã¼ï¼90 if plugin_object == nil # プラグインのロードに失敗している(既にエラー) 106 91 return 107 92 end … … 109 94 if @@loaded_plugin_list[ plugin_name ] == nil 110 95 raise "#{plugin_name} might have different name " 111 # ãã©ã°ã¤ã³ã®ãã¡ã¤ã«åã¨ããã©ã°ã¤ã³ã®ã¯ã©ã¹åãç¸éããå ´å96 # プラグインのファイル名と、プラグインのクラス名が相違する場合 112 97 end 113 98 count = @@loaded_plugin_list[ plugin_name ] … … 141 126 end 142 127 143 #=== ãã©ã°ã¤ã³ã CDL ã® POST ã³ã¼ããçæ144 # tmp_plugin_post_code.cdl ã¸ã®åºå128 #=== プラグインが CDL の POST コードを生成 129 # tmp_plugin_post_code.cdl への出力 145 130 def self.gen_plugin_post_code file 146 131 dbgPrint "PluginModule #{@@loaded_plugin_list}\n" -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/syntaxobj.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 : syntaxobj.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 # mikan ruby ã® symbol ã¨æååã®ä½¿ãåããã©ããã¦ããã¾ããããªããã¨ãæã 56 ããã®ã§ name.to_sym ãå 57 ¥ãããã¨ã«ãã 40 # mikan ruby の symbol と文字列の使い分けがどうしてもうまくいかないことが時々あるので name.to_sym を入れることにした 58 41 59 42 #== Node 60 43 # 61 # Node ã®ç´æ¥ã®åã¯ã©ã¹ï¼ C_EXP, Type, BaseVal, BDNode(ã»ã¨ãã©ã®ãã®ã¯ BDNode ã®åã¯ã©ã¹) 62 # Node ã« (BDNodeã«ã) å 63 ¥ããªããã®: Token, Import, Import_C, Generate 44 # Node の直接の子クラス: C_EXP, Type, BaseVal, BDNode(ほとんどのものは BDNode の子クラス) 45 # Node に (BDNodeにも) 入らないもの: Token, Import, Import_C, Generate 64 46 # 65 # owner ãæããªããã®ã Node ã¨ãªã66 # ã¨ã©ã¼ã¯ãcdl_error ãéãã¦å ±åãã (æå³è§£æãæ§æ解æå¾ã«è¡ãããå ´åã«ã¯ãè¡çªå·ãæ£ããåºåã§ãã47 # owner を持たないものが Node となる 48 # エラーは、cdl_error を通じて報告する (意味解析が構文解析後に行われる場合には、行番号が正しく出力できる 67 49 # 68 50 … … 74 56 end 75 57 76 #=== ã¨ã©ã¼ãåºåãã58 #=== エラーを出力する 77 59 def cdl_error( message, *arg ) 78 60 Generator.error2( @locale, message, *arg ) 79 61 end 80 62 81 #=== ã¨ã©ã¼ãåºåãã82 #locale:: Array(locale info) : æ§æ解æä¸ã¯ç¡è¦ããã63 #=== エラーを出力する 64 #locale:: Array(locale info) : 構文解析中は無視される 83 65 def cdl_error2( locale, message, *arg ) 84 66 Generator.error2( locale, message, *arg ) 85 67 end 86 68 87 #=== ã¨ã©ã¼ãåºåãã69 #=== エラーを出力する 88 70 #locale:: Array(locale info) 89 # æ§æ解æä¸ cdl_error2 ã§ã¯ locale ãç¡è¦ããããããå¥ã« locale ãåºåãã71 # 構文解析中 cdl_error2 では locale が無視されるため、別に locale を出力する 90 72 def cdl_error3( locale, message, *arg ) 91 73 Generator.error( message, *arg ) … … 93 75 end 94 76 95 #=== ã¦ã©ã¼ãã³ã°åºåãã77 #=== ウォーニング出力する 96 78 def cdl_warning( message, *arg ) 97 79 Generator.warning2( @locale, message, *arg ) 98 80 end 99 81 100 #=== ã¦ã©ã¼ãã³ã°åºåãã82 #=== ウォーニング出力する 101 83 def cdl_warning2( locale, message, *arg ) 102 84 Generator.warning2( locale, message, *arg ) 103 85 end 104 86 105 #=== æ 106 å ±ã表示ãã 87 #=== 情報を表示する 107 88 def cdl_info( message ) 108 89 Console.puts "info: #{message}" … … 122 103 end 123 104 124 #== åæ¹åNode (Bi Direction Node)105 #== 双方向 Node (Bi Direction Node) 125 106 # 126 # Node ã®åã¯ã©ã¹ 127 # owner Node ããåç 128 §ããã¦ãããã® (owner ã¸ã®ãªã³ã¯ãåãåºãã) 107 # Node の子クラス 108 # owner Node から参照されているもの (owner へのリンクも取り出せる) 129 109 # 130 # get_owner ã§å¾ããããã®110 # get_owner で得られるもの 131 111 # FuncHead => Signature 132 112 # Decl => Namespace(const), Typedef(typedef), … … 134 114 # Struct(member), ParamDecl(parameter), FuncHead(funchead) 135 115 # Signature, Celltype, CompositeCelltype, Typedef => Namespace 136 #, Namespace => Namespace, Generator.class (root Namespace ã®å ´å)116 #, Namespace => Namespace, Generator.class (root Namespace の場合) 137 117 # Cell => Region, CompositeCelltype(in_composite) 138 118 # Port => Celltype, Composite … … 144 124 # ParamList => FuncHead 145 125 # Expression => Namespace 146 # 大åã®ãã®ã¯ new_* ã¡ã½ãã㧠owner Node ã«ä¼éããã147 # ãã®ã¡ã½ãããå¼ã³åºãããã¨ãã« owner Node ãè¨é²ããã148 # new_* ããªããã®ï¼126 # 大半のものは new_* メソッドで owner Node に伝達される 127 # そのメソッドが呼び出されたときに owner Node が記録される 128 # new_* がないもの: 149 129 # Decl(parameter), ParamDecl, ParamList, FuncHead, Expression 150 130 # 151 # Expression ã¯ãowner Node ã¨ãªããã®ãå¤ãããããæ¹é ãå°é£ã§ãããã152 # Expression ãå®ç¾©ãããã¨ãã® Namespace ã owner Node ã¨ãã153 # StructType 㯠Type ã®ä¸ç¨®ãªã®ã§ owner ãæããªã131 # Expression は、owner Node となるものが多くあるが、改造が困難であるため 132 # Expression が定義されたときの Namespace を owner Node とする 133 # StructType は Type の一種なので owner を持たない 154 134 # 155 135 class BDNode < Node … … 167 147 end 168 148 169 #=== owner ãè¨å®ãã149 #=== owner を設定する 170 150 def set_owner owner 171 151 dbgPrint "set_owner: #{owner.class.name}\n" … … 173 153 end 174 154 175 #=== owner ãå¾ã 176 # class ã®èª¬æãåç 177 § 155 #=== owner を得る 156 # class の説明を参照 178 157 def get_owner 179 158 if @owner == nil … … 184 163 end 185 164 186 #== Namespace åãæã¤BDNode165 #== Namespace 名を持つ BDNode 187 166 # Namespace(Region), Signature, Celltype, CompositeCelltype, Cell 188 167 class NSBDNode < BDNode … … 192 171 end 193 172 194 #=== å±ãã namespace ãå¾ã195 # owner ã namespace ã«ãã©ãçãã¾ã§ä¸ã«ãã©ã173 #=== 属する namespace を得る 174 # owner を namespace にたどり着くまで上にたどる 196 175 def get_namespace 197 176 if @owner.kind_of? Namespace … … 200 179 return @owner.get_namespace 201 180 else 202 # @owner == nil ãªã"::"181 # @owner == nil なら "::" 203 182 if @name != "::" then 204 183 raise "non-root namespace has no owner #{self.class.name}##{@name} #{self}" … … 217 196 end 218 197 219 #=== NamespacePath ãå¾ã198 #=== NamespacePath を得る 220 199 def get_namespace_path 221 200 return @NamespacePath … … 226 205 return @import.is_imported? 227 206 else 228 return false # mikan: ä»® @import ã nil ã«ãªãã±ã¼ã¹ã追æ±ã§ãã¦ããªã207 return false # mikan: 仮 @import が nil になるケースが追求できていない 229 208 end 230 209 end … … 233 212 class NamedList 234 213 # @names:: {} of items 235 # @items:: [] of items : item ã® CLASS 㯠get_name ã¡ã½ãããæã¤ã㨠get_name ã®æ»ãå¤ã¯ Symbol ã§ãªãã¦ã¯ãªããªã 236 # NamedList ã clone_for_composite ããå ´åã¯ãitem ã«ãã¡ã½ãããå¿ 237 è¦ 238 # @type:: string ã¨ã©ã¼ã¡ãã»ã¼ã¸ 214 # @items:: [] of items : item の CLASS は get_name メソッドを持つこと get_name の戻り値は Symbol でなくてはならない 215 # NamedList を clone_for_composite する場合は、item にもメソッドが必要 216 # @type:: string エラーメッセージ 239 217 240 218 def initialize( item, type ) … … 245 223 end 246 224 247 #=== è¦ç´ ãå ãã248 # parse ããæç¹ã§å ãããã¨(å ´æãè¨æ¶ãã)225 #=== 要素を加える 226 # parse した時点で加えること(場所を記憶する) 249 227 def add_item( item ) 250 228 … … 305 283 end 306 284 307 #=== composite cell ã clone ããæã«è¦ç´ (JOIN) ã® clone ãã285 #=== composite cell を clone した時に要素(JOIN) の clone する 308 286 # 309 # mikan ãã®ã¡ã½ãã㯠Join ã«ç¹åããã¦ããã®ã§ NamedList ããåé¢ãã¹ã287 # mikan このメソッドは Join に特化されているので NamedList から分離すべき 310 288 def clone_for_composite( ct_name, cell_name, locale ) 311 289 cl = self.clone … … 314 292 end 315 293 316 #=== clone ããã NamedList ã¤ã³ã¹ã¿ã³ã¹ã®åç 317 §ãããã®(item)ã clone 294 #=== clone された NamedList インスタンスの参照するもの(item)を clone 318 295 # 319 # mikan ãã®ã¡ã½ãã㯠Join ã«ç¹åããã¦ããã®ã§ NamedList ããåé¢ãã¹ã296 # mikan このメソッドは Join に特化されているので NamedList から分離すべき 320 297 def set_cloned( ct_name, cell_name, locale ) 321 298 items = [] … … 379 356 end 380 357 381 #== é¢æ°é é¨382 # signature ã«ç»é²ãããé¢æ°358 #== 関数頭部 359 # signature に登録される関数 383 360 class FuncHead <BDNode 384 361 # @declarator:: Decl … … 425 402 end 426 403 427 #=== FuncHead# é¢æ°ã®ååãè¿ã404 #=== FuncHead# 関数の名前を返す 428 405 def get_name 429 406 return @declarator.get_name 430 407 end 431 408 432 #=== FuncHead# é¢æ°ã®æ»ãå¤ã®åãè¿ã 433 # types.rb ã«å®ç¾©ããã¦ããå 434 # é¢æ°ãããã®å®ç¾©ã¨ãã¦ä¸å®å 435 ¨ãªå ´å nil ãè¿ã 409 #=== FuncHead# 関数の戻り値の型を返す 410 # types.rb に定義されている型 411 # 関数ヘッダの定義として不完全な場合 nil を返す 436 412 def get_return_type 437 413 if is_function? then … … 440 416 end 441 417 442 #=== FuncHead# é¢æ°ã®å¼æ°ã®ãªã¹ããè¿ã 443 # ParamList ãè¿ã 444 # é¢æ°ãããã®å®ç¾©ã¨ãã¦ä¸å®å 445 ¨ãªå ´å nil ãè¿ã 418 #=== FuncHead# 関数の引数のリストを返す 419 # ParamList を返す 420 # 関数ヘッダの定義として不完全な場合 nil を返す 446 421 def get_paramlist 447 422 if is_function? then … … 457 432 end 458 433 459 #=== 宣è¨460 # @kind ã§ç¤ºãããå種ã®å®£è¨434 #=== 宣言 435 # @kind で示される各種の宣言 461 436 class Decl < BDNode 462 437 463 438 # @identifer:: String 464 # @global_name:: String | nil : String(@kind=TYPEDEF||:CONSTANT), nil(@kind= ãã®ä»)465 # set_kind ã«ã¦è¨å®ããã439 # @global_name:: String | nil : String(@kind=TYPEDEF||:CONSTANT), nil(@kind=その他) 440 # set_kind にて設定される 466 441 # @type:: ArrayType, FuncType, PtrType, IntType, StructType 467 442 # VoidType, FloatType, DefinedType, BoolType 468 443 # @initializer:: constant_expression, mikan { initlist } 469 # @kind:: :VAR, :ATTRIBUTE, :PARAMETER, :TYPEDEF, :CONSTANT, :MEMBER, :FUNCHEAD(signature ã®é¢æ°å®ç¾©)444 # @kind:: :VAR, :ATTRIBUTE, :PARAMETER, :TYPEDEF, :CONSTANT, :MEMBER, :FUNCHEAD(signatureの関数定義) 470 445 # @b_referenced:: bool 471 446 # 472 # 以ä¸ã¯ã@kind ã :VAR, :ATTRIBUTE ã®ã¨ãã«æå¹ 473 # @rw:: bool # å¤ãææ³ã§ã¯ attr ã«æå®å¯è½ã ã£ãï¼æ¶ãã«ã¯ generate ã®ä¿®æ£ãå¿ 474 è¦ï¼ 447 # 以下は、@kind が :VAR, :ATTRIBUTE のときに有効 448 # @rw:: bool # 古い文法では attr に指定可能だった(消すには generate の修正も必要) 475 449 # @omit:: bool 476 # @choice_list:: [String] attr åæå¤ã®é¸æè¢477 # 以ä¸ã¯ã@kind ã :VAR, :ATTRIBUTE, :MEMBER ã®ã¨ãã«æå¹450 # @choice_list:: [String] attr 初期値の選択肢 451 # 以下は、@kind が :VAR, :ATTRIBUTE, :MEMBER のときに有効 478 452 # @size_is:: Expression or nil unless specified 479 # 以ä¸ã¯ã@kind ã :MEMBER ã®ã¨ãã«æå¹453 # 以下は、@kind が :MEMBER のときに有効 480 454 # @count_is:: Expression or nil unless specified 481 # attr, var ã®å ´åãcount_is ã¯æå®ã§ããªã455 # attr, var の場合、count_is は指定できない 482 456 # @string:: Expression, -1 (length not specified) or nil (not specified) 483 457 # 484 # mikan ParamDecl ã ãå¥ã«è¨ããããMemberDecl, AttrDecl ãªã©ãåããã¹ãã(ï¼)458 # mikan ParamDecl だけ別に設けたが、MemberDecl, AttrDecl なども分けるべきか(?) 485 459 486 460 def initialize( identifier ) … … 512 486 end 513 487 514 #== Decl ã®æå³ç誤ãããã§ãã¯ãã488 #== Decl の意味的誤りをチェックする 515 489 def check 516 490 # return nil if @type == nil 517 491 518 # æ§é ä½ã¿ã°ãã§ãã¯ï¼ãã¤ã³ã¿åããæ§é ä½ãåç 519 §ããã¦ããå ´åã¯ãã¿ã°ã®åå¨ããã§ãã¯ããªãï¼ 492 # 構造体タグチェック(ポインタ型から構造体が参照されている場合は、タグの存在をチェックしない) 520 493 @type.check_struct_tag @kind 521 494 522 # åã®ãã§ãã¯ãè¡ã495 # 型のチェックを行う 523 496 res = @type.check 524 497 if res then … … 526 499 end 527 500 528 # ä¸è¦ã®åæååããã§ãã¯ãã501 # 不要の初期化子をチェックする 529 502 if @initializer then 530 503 case @kind … … 532 505 cdl_error( "S2003 $1: $2 cannot have initializer" , @identifier, @kind.to_s.downcase ) 533 506 when :VAR, :ATTRIBUTE, :CONSTANT 534 # p @initializer ããã§ã¯ä»£å 535 ¥å¯è½ãã©ããããã§ãã¯ããªã 536 # :VAR, :ATTRIBUTE, :CONSTANT ã¯ããããã§ãã§ãã¯ãã 507 # p @initializer ここでは代入可能かどうか、チェックしない 508 # :VAR, :ATTRIBUTE, :CONSTANT はそれぞれでチェックする 537 509 # return @type.check_init( @identifier, @initializer, @kind ) 538 510 else … … 552 524 end 553 525 554 #== ãã¤ã³ã¿ã¬ãã«ãå¾ã555 # æ»ãå¤ï¼556 # éãã¤ã³ã¿å¤æ°= 0557 # ãã¤ã³ã¿å¤æ°= 1558 # äºéãã¤ã³ã¿å¤æ°= 2526 #== ポインタレベルを得る 527 # 戻り値: 528 # 非ポインタ変数 = 0 529 # ポインタ変数 = 1 530 # 二重ポインタ変数 = 2 559 531 def get_ptr_level 560 532 level = 0 … … 564 536 level += 1 565 537 type = type.get_referto 566 # elsif type.kind_of?( ArrayType ) then # æ·»æ°ãªãé 567 åã¯ãã¤ã³ã¿ã¨ã¿ãªã 538 # elsif type.kind_of?( ArrayType ) then # 添数なし配列はポインタとみなす 568 539 # if type.get_subscript == nil then 569 540 # level += 1 … … 572 543 # break 573 544 # end 574 # mikan ãã¤ã³ã¿ã®æ·»æ°ããé 575 åã®ãã¤ã³ã¿ã¬ãã«ã¯ï¼ã§ããï¼ 545 # mikan ポインタの添数あり配列のポインタレベルは0でよい? 576 546 elsif type.kind_of?( DefinedType ) then 577 547 type = type.get_type … … 596 566 @type = type 597 567 else 598 @type.set_type( type ) # èã«è¨å®568 @type.set_type( type ) # 葉に設定 599 569 end 600 570 end … … 731 701 end 732 702 733 # é¢æ°ãã©ã¡ã¼ã¿ã®å®£è¨703 # 関数パラメータの宣言 734 704 class ParamDecl < BDNode 735 705 736 706 # @declarator:: Decl: Token, ArrayType, FuncType, PtrType 737 707 # @direction:: :IN, :OUT, :INOUT, :SEND, :RECEIVE 738 # @size:: Expr (size_is å¼æ°)739 # @count:: Expr (count_is å¼æ°)740 # @max:: Expr (size_is ã®ç¬¬äºå¼æ°)708 # @size:: Expr (size_is 引数) 709 # @count:: Expr (count_is 引数) 710 # @max:: Expr (size_is の第二引数) 741 711 # @b_nullable:: Bool : nullable 742 # @string:: Expr or -1(if size not specified) ï¼string å¼æ°ï¼712 # @string:: Expr or -1(if size not specified) (string 引数) 743 713 # @allocator:: Signature of allocator 744 # @b_ref:: bool : size_is, count_is, string_is å¼æ°ã¨ãã¦åç 745 §ããã¦ãã 714 # @b_ref:: bool : size_is, count_is, string_is 引数として参照されている 746 715 # 747 # 1. é¢æ°åã§ãªãã㨠748 # 2. ï¼æ¬¡å 749 以ä¸ã®é 750 åã§ãã£ã¦æãå 751 å´ä»¥å¤ã®æ·»æ°ãããã㨠752 # 3. in, out, ..., size_is, count_is, ... ã®éè¤æå®ããªãã㨠753 # 4. ãã¤ã³ã¿ã¬ãã«ãé©åãªã㨠716 # 1. 関数型でないこと 717 # 2. 2次元以上の配列であって最も内側以外の添数があること 718 # 3. in, out, ..., size_is, count_is, ... の重複指定がないこと 719 # 4. ポインタレベルが適切なこと 754 720 755 721 def initialize( declarator, specifier, param_specifier ) … … 818 784 end 819 785 when :MAX_IS 820 # max_is ã¯ãå 821 é¨çãªãã® bnf.y.rb åç 822 § 823 # size_is ã§éè¤ãã§ãã¯ããã 786 # max_is は、内部的なもの bnf.y.rb 参照 787 # size_is で重複チェックされる 824 788 @max = i[1] 825 789 when :NULLABLE … … 841 805 end 842 806 843 # mikan ãã¤ã³ã¿ã®é 844 åï¼æ·»æ°æï¼ã®ã¬ãã«ãï¼ 807 # mikan ポインタの配列(添数有)のレベルが0 845 808 ptr_level = @declarator.get_ptr_level 846 809 … … 885 848 cdl_error( "S2014 $1 need pointer or more pointer" , @declarator.get_identifier ) 886 849 elsif ptr_level > max_level then 887 # note: æ§æ解æ段éã§å®è¡ã®ãã get_current å¯850 # note: 構文解析段階で実行のため get_current 可 888 851 if Signature.get_current == nil || Signature.get_current.is_deviate? == false then 889 852 cdl_warning( "W3003 $1 pointer level mismatch" , @declarator.get_identifier ) … … 897 860 898 861 if ptr_level > 0 then 899 # size_is, count_is, string ãã»ãã862 # size_is, count_is, string をセット 900 863 if @direction == :RECEIVE && ptr_level > 1 then 901 864 type.get_type.set_scs( @size, @count, @string, @max, @b_nullable ) … … 907 870 #type.show_tree 1 908 871 909 # ãã¤ã³ã¿ãæãã¦ããå 910 ã®ãã¼ã¿åãå¾ã 872 # ポインタが指している先のデータ型を得る 911 873 i = 0 912 874 t2 = type … … 923 885 # p t2.is_const? 924 886 925 # const 修飾ãé©åããã§ãã¯887 # const 修飾が適切かチェック 926 888 if @direction == :IN then 927 889 if ! t2.is_const? then … … 934 896 end 935 897 else 936 # éãã¤ã³ã¿ã¿ã¤ã898 # 非ポインタタイプ 937 899 if @size != nil || @count != nil || @string != nil || @max != nil || @b_nullable then 938 900 type.set_scs( @size, @count, @string, @max, @b_nullable ) … … 1006 968 end 1007 969 1008 #=== PPAllocator ãå¿ 1009 è¦ã 1010 # Transparent RPC ã®å ´å in 㧠size_is, count_is, string ã®ãããããæå®ããã¦ããå ´å oneway ã§ã¯ PPAllocator ãå¿ 1011 è¦ 1012 # Transparent PC 㧠oneway ãã©ããã¯ãããã§ã¯å¤æããªãã®ã§å¥éå¤æãå¿ 1013 è¦ 1014 # Opaque RPC ã®å ´å size_is, count_is, string ã®ãããããæå®ããã¦ããå ´åãPPAllocator ãå¿ 1015 è¦ 970 #=== PPAllocator が必要か 971 # Transparent RPC の場合 in で size_is, count_is, string のいずれかが指定されている場合 oneway では PPAllocator が必要 972 # Transparent PC で oneway かどうかは、ここでは判断しないので別途判断が必要 973 # Opaque RPC の場合 size_is, count_is, string のいずれかが指定されている場合、PPAllocator が必要 1016 974 def need_PPAllocator?( b_opaque = false ) 1017 975 if ! b_opaque then … … 1060 1018 end 1061 1019 1062 # é¢æ°ãã©ã¡ã¼ã¿ãªã¹ã1020 # 関数パラメータリスト 1063 1021 class ParamList < BDNode 1064 1022 # @param_list:: NamedList : item: ParamDecl … … 1073 1031 1074 1032 def add_param( paramdecl ) 1075 return if paramdecl == nil # æ¢ã«ã¨ã©ã¼1033 return if paramdecl == nil # 既にエラー 1076 1034 1077 1035 @param_list.add_item( paramdecl ) … … 1083 1041 end 1084 1042 1085 #=== size_is, count_is, string ã®å¼æ°ã®å¼ããã§ã㯠1086 # å¤æ°ã¯åæ¹åç 1087 §å¯è½ãªãããé¢æ°é é¨ã®æ§æ解éãçµãã£ãå¾ã«ãã§ãã¯ãã 1043 #=== size_is, count_is, string の引数の式をチェック 1044 # 変数は前方参照可能なため、関数頭部の構文解釈が終わった後にチェックする 1088 1045 def check_param 1089 1046 @param_list.get_items.each { |i| 1090 next if i == nil # i == nil : ã¨ã©ã¼æ1047 next if i == nil # i == nil : エラー時 1091 1048 1092 1049 if i.get_type.class == VoidType then 1093 # åä¸ã® void åã¯ããã«ã¯ããªã1050 # 単一の void 型はここにはこない 1094 1051 cdl_error( "S2027 '$1' parameter cannot be void type", i.get_name ) 1095 1052 end … … 1098 1055 if size then 1099 1056 val = size.eval_const( @param_list ) 1100 if val == nil then # å®æ°å¼ã§ãªããï¼1101 # mikan å¤æ°ãå«ãå¼ï¼åä¸ã®å¤æ°ã®ã¿OK1057 if val == nil then # 定数式でないか? 1058 # mikan 変数を含む式:単一の変数のみ OK 1102 1059 type = size.get_type( @param_list ) 1103 1060 unless type.kind_of?( IntType ) then … … 1137 1094 if count then 1138 1095 val = count.eval_const( @param_list ) 1139 if val == nil then # å®æ°å¼ã§ãªããï¼1140 # mikan å¤æ°ãå«ãå¼ï¼åä¸ã®å¤æ°ã®ã¿OK1096 if val == nil then # 定数式でないか? 1097 # mikan 変数を含む式:単一の変数のみ OK 1141 1098 type = count.get_type( @param_list ) 1142 1099 unless type.kind_of?( IntType ) then … … 1157 1114 if string != -1 && string then 1158 1115 val = string.eval_const( @param_list ) 1159 if val == nil then # å®æ°å¼ã§ãªããï¼1160 # mikan å¤æ°ãå«ãå¼ï¼åä¸ã®å¤æ°ã®ã¿OK1116 if val == nil then # 定数式でないか? 1117 # mikan 変数を含む式:単一の変数のみ OK 1161 1118 type = string.get_type( @param_list ) 1162 1119 unless type.kind_of?( IntType ) then … … 1182 1139 end 1183 1140 1184 #=== Push Pop Allocator ãå¿ 1185 è¦ãï¼ 1186 # Transparent RPC ã®å ´å (oneway ãã¤) in ã®é 1187 å(size_is, count_is, string ã®ããããã§ä¿®é£¾ï¼ããã 1141 #=== Push Pop Allocator が必要か? 1142 # Transparent RPC の場合 (oneway かつ) in の配列(size_is, count_is, string のいずれかで修飾)がある 1188 1143 def need_PPAllocator?( b_opaque = false ) 1189 1144 @param_list.get_items.each { |i| … … 1199 1154 end 1200 1155 1201 #== ParamList# æååå1202 #b_name:: Bool: ãã©ã¡ã¼ã¿åãå«ãã1156 #== ParamList# 文字列化 1157 #b_name:: Bool: パラメータ名を含める 1203 1158 def to_str( b_name ) 1204 1159 str = "(" … … 1223 1178 end 1224 1179 1225 #== CDL ã®æååãªãã©ã«ãæ±ãããã®ã¯ã©ã¹1226 # CDL ã®æååãªãã©ã«ãã®ãã®ã§ã¯ãªã1180 #== CDL の文字列リテラルを扱うためのクラス 1181 # CDL の文字列リテラルそのものではない 1227 1182 class CDLString 1228 # ã¨ã¹ã±ã¼ãæåãå¤æ1183 # エスケープ文字を変換 1229 1184 def self.escape str 1230 1185 str = str.dup … … 1238 1193 str.gsub!( /(\\[Xx][0-9A-Fa-f]{1,2})/, '{printf \"\\1\"}' ) 1239 1194 str.gsub!( /(\\[0-7]{1,3})/, '{printf \"\\1\"}' ) 1240 str.gsub!( /\\(.)/, "\\1" ) # mikan æªå®ç¾©ã®ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãå¤æãã¦ãã¾ã (gcc V3.4.4 ã§ã¯è¦åãåºããã)1195 str.gsub!( /\\(.)/, "\\1" ) # mikan 未定義のエスケープシーケンスを変換してしまう (gcc V3.4.4 では警告が出される) 1241 1196 return str 1242 1197 end 1243 1198 1244 #=== CDLString# åå¾ã® " ãåãé¤ã1199 #=== CDLString#前後の " を取り除く 1245 1200 def self.remove_dquote str 1246 1201 s = str.sub( /\A"/, "" ) … … 1250 1205 end 1251 1206 1252 #== CDL ã®åæååãæ±ãããã®ã¯ã©ã¹1253 # CDL ã®åæååãã®ãã®ã§ã¯ãªã1207 #== CDL の初期化子を扱うためのクラス 1208 # CDL の初期化子そのものではない 1254 1209 class CDLInitializer 1255 #=== åæååã®ã¯ãã¼ã³1256 # åæåå㯠Expression, C_EXP, Array ã®ãããã1210 #=== 初期化子のクローン 1211 # 初期化子は Expression, C_EXP, Array のいずれか 1257 1212 def self.clone_for_composite( rhs, ct_name, cell_name, locale ) 1258 1213 if rhs.instance_of? C_EXP then 1259 # C_EXP ã® clone ãä½ãã¨ã¨ãã«ç½®æ1214 # C_EXP の clone を作るとともに置換 1260 1215 rhs = rhs.clone_for_composite( ct_name, cell_name, locale ) 1261 1216 elsif rhs.instance_of? Expression then … … 1269 1224 end 1270 1225 1271 #=== åæååï¼é 1272 åï¼ã®ã¯ãã¼ã³ 1273 # è¦ç´ 㯠clone_for_composite ãæã¤ãã®ã ã 1226 #=== 初期化子(配列)のクローン 1227 # 要素は clone_for_composite を持つものだけ 1274 1228 def self.clone_for_compoiste_array( array, ct_name, cell_name, locale ) 1275 # "compoiste.identifier" ã®å ´å (CDL ã¨ãã¦ã¯èª¤ã)1229 # "compoiste.identifier" の場合 (CDL としては誤り) 1276 1230 if array[0] == :COMPOSITE then 1277 1231 return array.clone -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/tecs_lang.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : tecs_lang.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 #== è¨èªã«é¢ããå¤æ°ãè¨å®56 # ã¡ãã»ã¼ã¸ãã¡ã¤ã«ã®èªã¿è¾¼ã¿ãè¡ã (èªã¿è¾¼ã¿ã«å¤±æããå ´åãããã©ã«ãã®æåã³ã¼ãã«å¤æ´ãã)40 #== 言語に関する変数を設定 41 # メッセージファイルの読み込みも行う (読み込みに失敗した場合、デフォルトの文字コードに変更する) 57 42 class TECS_LANG 58 # ããã·ã¥ã®ã¿ã°ã¯ case insensitive ã®ããã大æåã®æååã¨ãã43 # ハッシュのタグは case insensitive のため、大文字の文字列とする 59 44 CHARSET_ALIAS = { 60 45 "UJIS" => :eucJP, 61 46 "UTF-8" => :utf8, 62 "EUCJP" => :eucJP, # ä»¥ä¸ case insensitive ã«ãããã47 "EUCJP" => :eucJP, # 以下 case insensitive にするため 63 48 "SJIS" => :sjis, 64 49 "UTF8" => :utf8, … … 67 52 LANG_ALIAS = { 68 53 "C" => :en_US, 69 "EN_US" => :en_US, # ä»¥ä¸ case insensitive ã«ãããã54 "EN_US" => :en_US, # 以下 case insensitive にするため 70 55 "JA_JP" => :ja_JP 71 56 } … … 75 60 } 76 61 77 #=== LANG ã®ãã¼ã¹78 #lang::String "ja_JP.eucJP@cjknarrow", "C" ãªã©62 #=== LANG のパース 63 #lang::String "ja_JP.eucJP@cjknarrow", "C" など 79 64 #RETURN:: [ :ja_JP, :eucJP, :cjknarrow ] 80 65 def self.parse_lang( lang ) … … 82 67 83 68 lang_terri = $1.to_sym if $1 != nil && $1 != "" 84 # set_kcode_binary ã«ãããC.UTF-8 ã®ã¿ãç¹å¥æ±ãããå¿ 85 è¦ããªããªã£ã 86 # if lang_terri == :C then # LANG=C.* ã¯ããã¹ã¦ 1 byte æåã³ã¼ãã¨ãã¦æ±ã 69 # set_kcode_binary により、C.UTF-8 のみを特別扱いする必要がなくなった 70 # if lang_terri == :C then # LANG=C.* は、すべて 1 byte 文字コードとして扱う 87 71 # codeset = nil 88 72 # modifier = nil … … 94 78 end 95 79 96 #=== lang, charset ã®å¥æ解決ããã³å¦¥å½æ§ã®ãã§ãã¯97 #lang::Symbol : :en_US, :ja_JP ãªã©98 #charset::Symbol : :eucJP, :utf8 ãªã©80 #=== lang, charset の別明解決および妥当性のチェック 81 #lang::Symbol : :en_US, :ja_JP など 82 #charset::Symbol : :eucJP, :utf8 など 99 83 #RETURN: 100 # [ lang, charset, result ]:: ããresult = false ã®å ´å lang, charset ã¯ä¸é©å84 # [ lang, charset, result ]:: result = false の場合 lang, charset は不適切 101 85 def self.resolve_alias_and_check( lang, charset ) 102 86 if LANG_ALIAS[ lang.to_s.upcase ] then … … 122 106 end 123 107 124 #=== codepage ãåãåºã125 #codepage ã¯3ï½5æ¡ã®æ´æ°ã¨ãã¦ä»®å®108 #=== codepage を取り出す 109 #codepage は3~5桁の整数として仮定 126 110 def self.get_win_codepage 127 111 cmd_pipe = IO.popen('cmd /c chcp','r') … … 132 116 end 133 117 134 #=== codepage ãã LANG ã®è¨å®æååã«å¤æ118 #=== codepage から LANG の設定文字列に変換 135 119 def self.codepage_to_lang cp 136 120 if cp == "932" then … … 141 125 end 142 126 143 #=== è¨èªãæåã³ã¼ãã«é¢ããå¤æ°ãè¨å®144 # 以ä¸ã®é ã«ãã§ãã¯ãããä¸çªæå¾ã«è¨å®ãããå¤ãæ¡ç¨ããã145 # ã»ããã©ã«ã146 # ã»codepage (exerb ç㧠TERM æªè¨å®ã¾ã㯠TERM=cygwin ã®å ´åã®ã¿)147 # ã»LANG ç°å¢å¤æ°148 # ã»TECSGEN_LANG ç°å¢å¤æ°149 # ã»TECSGEN_FILE_LANG ç°å¢å¤æ° (ãã¡ã¤ã«ã®æåã³ã¼ãã®ã¿)150 # ã»-k ãªãã·ã§ã³ (ãã¡ã¤ã«ã®æåã³ã¼ãã®ã¿)127 #=== 言語、文字コードに関する変数を設定 128 # 以下の順にチェックされ、一番最後に設定された値が採用される 129 # ・デフォルト 130 # ・codepage (exerb 版で TERM 未設定または TERM=cygwin の場合のみ) 131 # ・LANG 環境変数 132 # ・TECSGEN_LANG 環境変数 133 # ・TECSGEN_FILE_LANG 環境変数 (ファイルの文字コードのみ) 134 # ・-k オプション (ファイルの文字コードのみ) 151 135 def self.set_lang_var 152 136 153 137 if $IN_EXERB && ( ENV[ 'TERM' ] == nil || ENV[ 'TERM' ] == "cygwin" ) then 154 # exerb çã§ç«¯æ« cygwin ã®æ㯠codepage ã®ã¿ãè¦ã138 # exerb 版で端末 cygwin の時は codepage のみを見る 155 139 cp = get_win_codepage 156 140 lang = codepage_to_lang cp … … 160 144 161 145 elsif ENV[ 'LANG' ]then 162 # é exerb çã§ã¯ LANG ç°å¢å¤æ°ãè¦ã163 # cygwin console ã§ã¯ codepage ã«å¾ã£ã¦åºåããæ¹ãå¹³åãªãã146 # 非 exerb 版では LANG 環境変数を見る 147 # cygwin console では codepage に従って出力した方が平和なため 164 148 165 149 $LANG_FILE, $CHARSET_FILE, *dum = self.parse_lang( ENV[ 'LANG' ] ) … … 181 165 end 182 166 183 #=== -k ãªãã·ã§ã³ãããã¡ã¤ã«ç¨ã®è¨èªãæåã³ã¼ãå¤æ°ãè¨å®167 #=== -k オプションからファイル用の言語、文字コード変数を設定 184 168 def self.set_lang_by_option 185 169 if $kcode == nil … … 211 195 end 212 196 213 #=== Kconv ã¯ã©ã¹ç¨ã®å¤æ°ãè¨å® 214 # è¨èªæ 215 å ±ãã Kconv ã«é¢ããå¤æ°ãè¨å® 197 #=== Kconv クラス用の変数を設定 198 # 言語情報から Kconv に関する変数を設定 216 199 def self.set_kconv_var 217 200 218 # æåã³ã¼ãã®è¨å®201 # 文字コードの設定 219 202 case $CHARSET_FILE # string: "EUC" | "SJIS" | "NONE" | "UTF8" 220 203 when :eucJP … … 251 234 end 252 235 253 $KCODE_TECSGEN = "UTF8" # string: "EUC" ãã®ãã¡ã¤ã«ã®æåã³ã¼ãï¼ãªãã·ã§ã³ã§ã¯ãªãå®æ°ï¼236 $KCODE_TECSGEN = "UTF8" # string: "EUC" このファイルの文字コード(オプションではなく定数) 254 237 $KCONV_TECSGEN = Kconv::UTF8 # const: 255 set_kcode $KCODE_TECSGEN # ãã®ãã¡ã¤ã«ã®æåã³ã¼ããè¨å®256 end 257 258 #=== ä¸æçã« KCODE ã BINARY ã«å¤æ´ãã259 # EUC ã UTF8 ã§èªã¿è¾¼ãã å ´åã«æååºåãã誤ãåé¡ã®å¯¾å¿260 # ã³ã¡ã³ãã®èªã¿é£ã°ãã誤ãç¹ãåé¡261 # ãã ããSJIS ã®å ´åã¯ãã¨ã¹ã±ã¼ãæåã®åé¡ããããããå¤æ´ããªã238 set_kcode $KCODE_TECSGEN # このファイルの文字コードを設定 239 end 240 241 #=== 一時的に KCODE を BINARY に変更する 242 # EUC を UTF8 で読み込んだ場合に文字区切りを誤る問題の対応 243 # コメントの読み飛ばしを誤る点が問題 244 # ただし、SJIS の場合は、エスケープ文字の問題があるため、変更しない 262 245 def self.set_kcode_binary 263 246 … … 273 256 end 274 257 275 #=== ä¸æçãªã KCODE ã®å¤æ´ãå 276 ã«æ»ã 258 #=== 一時的なあ KCODE の変更を元に戻す 277 259 def self.reset_kcode 278 260 set_kcode $KCODE_BACK … … 280 262 281 263 ##### 282 # $LANG_FILE è¨èª (C 㯠en_US ã«å¤æããã)283 # $LANG_CONSOLE è¨èª (C 㯠en_US ã«å¤æããã)284 # $CHARSET_FILE ãã¡ã¤ã«ã®æåã³ã¼ã285 # $CHARSET_CONSOLE ã³ã³ã½ã¼ã«æåã³ã¼ã286 287 # ããã©ã«ãã®è¨å®ï¼æ£è¦åæ¸ã¿ã®ãã¨ï¼264 # $LANG_FILE 言語 (C は en_US に変換される) 265 # $LANG_CONSOLE 言語 (C は en_US に変換される) 266 # $CHARSET_FILE ファイルの文字コード 267 # $CHARSET_CONSOLE コンソール文字コード 268 269 # デフォルトの設定(正規化済みのこと) 288 270 $LANG_FILE_DEFAULT = :en_US 289 271 $CHARSET_FILE_DEFAULT = nil … … 296 278 $CHARSET_CONSOLE = $CHARSET_CONSOLE_DEFAULT 297 279 298 # -k ã§æå®å¯è½ãªã³ã¼ã280 # -k で指定可能なコード 299 281 $CODE_TYPE_ARRAY = [ "euc", "sjis", "none", "utf8" ] 300 282 301 # è¨èªã決å®ãã283 # 言語を決定する 302 284 self.set_lang_var 303 285 304 # è¨èªãã³ã¼ãã®ãã§ãã¯ã¨æ£è¦å286 # 言語、コードのチェックと正規化 305 287 lang_file, charset_file, res = 306 288 self.resolve_alias_and_check( $LANG_FILE, $CHARSET_FILE ) … … 316 298 end 317 299 318 # ã¡ãã»ã¼ã¸ã¢ã¸ã¥ã¼ã«ããã¼ã300 # メッセージモジュールをロード 319 301 if require_tecsgen_lib( "tecslib/messages/messages_console_#{lang_console}.rb", false ) == false then 320 302 require_tecsgen_lib( "tecslib/messages/messages_console_#{$LANG_CONSOLE_DEFAULT}.rb" ) … … 330 312 end 331 313 332 # Kconv ã¯ã©ã¹ã®ããã®å¤æ°ãè¨å®314 # Kconv クラスのための変数を設定 333 315 self.set_kconv_var 334 316 … … 337 319 dbgPrint "Ruby19_File_Encode=#{$Ruby19_File_Encode}\n" 338 320 339 #=== åä½ãã¹ãå®è¡321 #=== 単体テスト実行 340 322 if $unit_test then 341 323 print "unit test: set_lang_var\n" … … 350 332 end 351 333 352 #= Console ã¯ã©ã¹353 # æåã³ã¼ããå¤æãã334 #= Console クラス 335 # 文字コードを変換する 354 336 class Console 355 337 def self.print str -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/tecsgen.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : tecsgen.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 … … 56 41 class TECSGEN 57 42 58 #=== import ãã¹ (-I) ãæ«å°¾ã«è¿½å59 # æ¢ã«ç»é²æ¸ã¿ã§ããã°ã追å ããªã43 #=== import パス (-I) を末尾に追加 44 # 既に登録済みであれば、追加しない 60 45 def self.add_import_path path 61 46 if $import_path.index( path ) == nil then … … 65 50 end 66 51 67 #=== EXEB çã®ãã¹ã®èª¿æ´68 # ç°å¢å¤æ° TECSPATH ã cygwin ã¹ã¿ã¤ã«ã ã¨ãexerb çã§ã¯æ±ããªã69 # $import_path 㨠$TECSPATH ã調æ´ãã52 #=== EXEB 版のパスの調整 53 # 環境変数 TECSPATH が cygwin スタイルだと、exerb 版では扱えない 54 # $import_path と $TECSPATH を調整する 70 55 def self.adjust_exerb_path 71 56 if $IN_EXERB then … … 74 59 paths = [] 75 60 $import_path.each{ |path| 76 # cygpath 㯠'..' ãç°¡ç´ãã¦ãã¾ãã®ã§ãnew_tecspath ã§ç½®æãã61 # cygpath は '..' を簡約してしまうので、new_tecspath で置換する 77 62 # paths << cygpath( path, path ) 78 63 paths << path.sub( pattern, new_tecspath ) … … 85 70 end 86 71 87 #=== $(TECSPATH) ã¸ã®ç½®æ88 #path::String : ENV[ 'TECSPATH' ] ã«ä¸è´ããé¨åãããã°ã "$(TECSPATH)" ã«ç½®æ89 #b_global::Bool : true ãªã gsub ã§ç½®æãfalse ãªã sub ã§ç½®æ72 #=== $(TECSPATH) への置換 73 #path::String : ENV[ 'TECSPATH' ] に一致する部分があれば、 "$(TECSPATH)" に置換 74 #b_global::Bool : true なら gsub で置換。false なら sub で置換 90 75 def self.subst_tecspath( path, b_global = false ) 91 76 tp = $tecspath.dup … … 102 87 end 103 88 104 #=== path ã¯çµ¶å¯¾ãã¹ã?89 #=== path は絶対パスか? 105 90 #path:: String : 106 # '/' ã¾ã㯠'$' ã§å§ã¾ãå ´åã絶対ãã¹ã¨å¤å®ãã91 # '/' または '$' で始まる場合、絶対パスと判定する 107 92 def self.is_absolute_path?( path ) 108 93 pa = path[0..0]; pa2 = path[0..1] … … 116 101 end 117 102 118 #=== tecsgen ã®ããã©ã«ããè¨å®103 #=== tecsgen のデフォルトを設定 119 104 def self.set_default_config 120 105 Makefile::set_default_config … … 122 107 123 108 ### 124 #== Makefile.templ ã®åºåå 125 容ã追å ãå¤æ´ããããã®æä½ 109 #== Makefile.templ の出力内容を追加、変更するための操作 126 110 module Makefile 127 # åºå®ããã¦ããå¤æ°(add_var ã§å¤æ´ã§ããªã)111 # 固定されている変数(add_var で変更できない) 128 112 @@fixed_vars = { :INCLUDES => nil, :DEFINES => nil, :TARGET_BASE => nil, :BASE_DIR => nil } 129 113 @@config_mode = false … … 140 124 @@lines = [] 141 125 142 #=== OTHER_OBJS ã«è¿½å ãã126 #=== OTHER_OBJS に追加する 143 127 def self.add_obj obj 144 128 @@objs << obj 145 129 end 146 #=== 追å ããå¤æ°147 # ãã©ã°ã¤ã³ããã¯ãããã©ã«ãå¤ãå¤æ´ã§ãã148 # config ã«ãã130 #=== 追加する変数 131 # プラグインからは、デフォルト値を変更できる 132 # config により 149 133 def self.add_var( var, val, comment = nil ) 150 134 if @@fixed_vars[ var ] … … 159 143 end 160 144 end 161 #=== LDFLAGS ã«è¿½å ãã145 #=== LDFLAGS に追加する 162 146 def self.add_ldflag ldflag 163 147 @@ldflags += " " + ldflag 164 148 end 165 #=== ãµã¼ããã¹ã追å ãã166 # CFLAGS, vpath ã«è¿½å ãã149 #=== サーチパスを追加する 150 # CFLAGS, vpath に追加する 167 151 def self.add_search_path path 168 152 @@search_path << path 169 153 end 170 #=== PRE_TECSGEN_TARGET ã«è¿½å ãã171 # PRE_TECSGEN_TARGET ã« target ã追å ãã154 #=== PRE_TECSGEN_TARGET に追加する 155 # PRE_TECSGEN_TARGET に target を追加する 172 156 def self.add_pre_tecsgen_target target 173 157 @@pre_tecsgen_target << pre_tecsgen_target 174 158 end 175 #=== POST_TECSGEN_TARGET ã«è¿½å ãã176 # POST_TECSGEN_TARGET ã« target ã追å ãã159 #=== POST_TECSGEN_TARGET に追加する 160 # POST_TECSGEN_TARGET に target を追加する 177 161 def self.add_post_tecsgen_target target 178 162 @@post_tecsgen_target << pre_tecsgen_target 179 163 end 180 #=== 追å ããå¤æ°164 #=== 追加する変数 181 165 def self.add_line( line ) 182 166 @@lines << line.to_s + "\n" 183 167 end 184 168 185 def self.get_objs # Array ãè¿ã169 def self.get_objs # Array を返す 186 170 return @@objs.uniq 187 171 end 188 def self.get_vars # Array ãè¿ã172 def self.get_vars # Array を返す 189 173 if RUBY_VERSION >= '1.9' then 190 174 return (@@vars.keys + @@vars_default.keys).sort.uniq 191 175 else 192 # V1.8 ã§ã¯ãSymbol ã® sort ãã§ããªãã®ã§ãä¸æ¦ String ã«ç½®æãã176 # V1.8 では、Symbol の sort ができないので、一旦 String に置換する 193 177 return (@@vars.keys + @@vars_default.keys).map{|s| s.to_s }.sort.uniq.map!{|s| s.to_sym } 194 178 end … … 200 184 return @@var_comments[ var ] 201 185 end 202 def self.get_ldflags # String ãè¿ã186 def self.get_ldflags # String を返す 203 187 return @@ldflags 204 188 end 205 def self.get_search_path # Array ãè¿ã189 def self.get_search_path # Array を返す 206 190 return @@search_path.uniq 207 191 end 208 def self.get_pre_tecsgen_target # Array ãè¿ã192 def self.get_pre_tecsgen_target # Array を返す 209 193 return @@pre_tecsgen_target.uniq 210 194 end 211 def self.get_post_tecsgen_target # Array ãè¿ã195 def self.get_post_tecsgen_target # Array を返す 212 196 return @@post_tecsgen_target.uniq 213 197 end 214 def self.get_lines # ä»å ããè¡ãå¾ã198 def self.get_lines # 付加する行を得る 215 199 return @@lines.uniq 216 200 end 217 201 218 #=== TECSGEN ã®ããã©ã«ãè¨å®ãè¡ã202 #=== TECSGEN のデフォルト設定を行う 219 203 # Makefile 220 # @@fixed_vars ã§å®ç¾©ããã¦ããå¤æ°ã¯ãå¤æ´ã§ãããå®æ°å®ç¾©ããã¦ãã204 # @@fixed_vars で定義されている変数は、変更できず、定数定義されている 221 205 def self.set_default_config 222 206 add_var( "TARGET", "$(TARGET_BASE).exe", "default target name" ) … … 235 219 236 220 def syntax_analisys argv 237 # ã«ã¼ã namespace (region) ãçæ221 # ルート namespace (region) を生成 238 222 @root_namespace = Region.new("::") 239 223 240 #### æ§æ解æ (post ã³ã¼ããé¤ã) ####241 # ãã¹ã¦ã® cdl ã import ãã224 #### 構文解析 (post コードを除く) #### 225 # すべての cdl を import する 242 226 argv.each{ |f| 243 227 dbgPrint( "## Import: #{f}\n") … … 245 229 } 246 230 247 # ãã¹ã¦ã®æ§æ解éãå®äºãããã¨ã®å ±å248 # å®éã«ã¯ãå¾ãããã©ã°ã¤ã³ã®çæãã CDL ã®ãã¼ã¹ãè¡ããã249 # ã¨ã©ã¼è¡æ°ã®æ±ºå®æ¹æ³ã®å¤æ´ã®ããã«è¡ã231 # すべての構文解釈が完了したことの報告 232 # 実際には、後からプラグインの生成する CDL のパースが行われる 233 # エラー行数の決定方法の変更のために行う 250 234 Generator.end_all_parse 251 235 dbgPrint( "## End all parse (except Post Code)\n") … … 253 237 254 238 def semantics_analisys_1 255 #### æå³è§£æï¼ (post ã³ã¼ããé¤ã) ####239 #### 意味解析1 (post コードを除く) #### 256 240 dbgPrint( "## Creating reverse join \n") 257 241 Cell.create_reverse_join 258 242 259 #0 set_definition_join ã¯2åå¼ã³åºãããï¼1åç®ï¼243 #0 set_definition_join は2回呼び出される(1回目) 260 244 dbgPrint( "## Checking all join\n") 261 245 @root_namespace.set_definition_join 262 # @root_namespace.set_require_join ### ãã£ããè¦åãããéè¤ã¨ã©ã¼ãè¦éã263 # through ãã©ã°ã¤ã³ã§çæãããã»ã«ã«ã require ãçæã§ãã (set_definition_join ã®å¾ãã§å®æ½)264 265 #### post ã³ã¼ãã®çæã¨æ§æ解æ####266 # å¼æ°ããªããã°ããã©ã°ã¤ã³ã®ãã¹ãã³ã¼ããåºåããªã246 # @root_namespace.set_require_join ### いったん見合わせ。重複エラーを見逃す 247 # through プラグインで生成されたセルにも require も生成できる (set_definition_join の後ろで実施) 248 249 #### post コードの生成と構文解析 #### 250 # 引数がなければ、プラグインのポストコードを出力しない 267 251 if ARGV.length > 0 then 268 252 dbgPrint( "## Generating Post Code\n") 269 # ãã©ã°ã¤ã³ã®ãã¹ãã³ã¼ãã®åºåã¨import253 # プラグインのポストコードの出力と import 270 254 tmp_file_name = "#{$gen}/tmp_plugin_post_code.cdl" 271 255 file = nil … … 277 261 278 262 if file then 279 # through ãã©ã°ã¤ã³ã®ãã¹ãã³ã¼ãçæ263 # through プラグインのポストコード生成 280 264 PluginModule.gen_plugin_post_code file 281 265 … … 290 274 end 291 275 292 #### æå³è§£æï¼ (post ã³ã¼ã) ####276 #### 意味解析1 (post コード) #### 293 277 dbgPrint( "## Creating reverse join (for post code) \n") 294 278 Cell.create_reverse_join 295 279 296 # Join ã®å®ç¾©ã®è¨å®ã¨ãã§ã㯠297 #0 # åæ¹åç 298 §å¯¾å¿ 299 #0 set_definition_join ã¯2åå¼ã³åºãããï¼2åç®ï¼ post_code ã§çæããã 280 # Join の定義の設定とチェック 281 #0 # 前方参照対応 282 #0 set_definition_join は2回呼び出される(2回目) post_code で生成された 300 283 dbgPrint( "## Checking all join (for cells generated by Post Code\n") 301 284 @root_namespace.set_definition_join 302 285 303 286 dbgPrint( "## Set require join\n") 304 @root_namespace.set_require_join # mikan post ã®åã«ã 305 # ãã¹ãã³ã¼ãã§çæãããã»ã«ã® require ã®join ãçæ 306 # mikan require 㧠through ãé©ç¨ããã¦ããã¹ãã³ã¼ããå¿ 307 è¦ã¨ãªã£ã¦ãåºåãããªã 287 @root_namespace.set_require_join # mikan post の前にも 288 # ポストコードで生成されたセルの require のjoin を生成 289 # mikan require で through が適用されて、ポストコードが必要となっても出力されない 308 290 end # semantics_analisys_1 309 291 310 292 def semantics_analisys_2 311 #### æå³è§£æï¼####293 #### 意味解析2 #### 312 294 Cell.make_cell_list2 313 295 dbgPrint( "## Set fixed join\n") 314 296 Cell.create_reverse_require_join 315 # create_reverse_require_join 㯠set_detinition_join ã«åãè¾¼ããã¨ãã§ããªã 316 # namespace ã«ä¾åããªãåºç¾é ã§è¡ã 317 # mikan through ãã©ã°ã¤ã³ãé©ç¨ãããã¹ãã³ã¼ãã«å½±é¿ãä¸ããå ´åãèæ 318 ®ã§ãã¦ããªã 319 # mikan post code ã«å½±é¿ã®ãããã®ã§ããã°ãæ©ãã« reverse_require_join ã®çµåãå¿ 320 è¦ 297 # create_reverse_require_join は set_detinition_join に埋め込むことができない 298 # namespace に依存しない出現順で行う 299 # mikan through プラグインが適用されポストコードに影響を与える場合が考慮できていない 300 # mikan post code に影響のあるものであれば、早くに reverse_require_join の結合が必要 321 301 dbgPrint( "## Setting port reference count\n") 322 302 @root_namespace.set_port_reference_count … … 325 305 @root_namespace.check_join 326 306 327 # mikan ãã©ã°ã¤ã³ã§çæãããã³ã³ãã¼ãã³ãã®set_def_and_check_join307 # mikan プラグインで生成されたコンポーネントの set_def_and_check_join 328 308 329 309 dbgPrint( "## Checking referenced but undefined cell\n") … … 332 312 333 313 def optimize_and_generate 334 #### Region link root ãã¨ã«ãªããã£ãã¤ãºããã³çæ####314 #### Region link root ごとにオプティマイズおよび生成 #### 335 315 Region.get_link_roots.each { |region| 336 316 … … 354 334 end 355 335 356 # ã»ã«ãä¸ã¤ããªããã°çæããªã357 # ã»ã«ã®çæããªãå ´å336 # セルが一つもなければ生成しない 337 # セルの生成がない場合 358 338 if region.get_n_cells == 0 then 359 339 if $region_list.length > 0 then … … 385 365 386 366 dbgPrint( "## Unset optimize variables\n") 387 @root_namespace.reset_optimize # æé©åããªã»ãããã367 @root_namespace.reset_optimize # 最適化をリセットする 388 368 389 369 if Generator.get_n_error == 0 then 390 # ã¨ã©ã¼ãçºçãã¦ããããè¨å®ããªã370 # エラーが発生していたら、設定しない 391 371 dbgPrint( "## Set cell id\n") 392 @root_namespace.set_cell_id_and_domain # ã»ã«ã® ID ã¨ãã¡ã¤ã³æ 393 å ±ãè¨å®ï¼linkunit æ¯ã«0ããã¤ããï¼ 394 395 # ã¨ã©ã¼ãçºçãã¦ããããæé©åã¯å®æ½ããªã 372 @root_namespace.set_cell_id_and_domain # セルの ID とドメイン情報を設定(linkunit 毎に0からつける) 373 374 # エラーが発生していたら、最適化は実施しない 396 375 if ! $unopt then 397 376 dbgPrint( "## Optimizing: Link Region=#{@root_namespace.get_name}\n") … … 401 380 402 381 if $show_tree then 403 # ã¨ã©ã¼ãçºçãã¦ãã¦ã表示ï¼ã¨ã©ã¼çºçæã¯æé©åããã¦ããªãã®ã§æ³¨æï¼382 # エラーが発生していても表示(エラー発生時は最適化されていないので注意) 404 383 print "##### show_tree LinkRegion=#{region.get_name} #####\n" 405 384 @root_namespace.show_tree(0) … … 407 386 end 408 387 409 # æ§æ解éãæå³è§£æã§ã¨ã©ã¼çºçãã¦ããããã³ã¼ãçæãããªã388 # 構文解釈、意味解析でエラー発生していたら、コード生成をしない 410 389 if Generator.get_n_error != 0 then 411 390 print_report … … 413 392 end 414 393 415 #### ã³ã¼ãçæ####394 #### コード生成 #### 416 395 begin 417 396 dbgPrint( "## Generating: Link Region=#{@root_namespace.get_name}\n") … … 420 399 @root_namespace.generate_post 421 400 rescue 422 # é常ããã¸ã¯æ¥ãªã (generate, generate_post ã§å¦ç½®ããã)401 # 通常ここへは来ない (generate, generate_post で処置される) 423 402 Generator.error( "G9999 fail to generate" ) 424 403 end … … 438 417 } 439 418 440 # update ãã441 # APPFile ã§çæããããã¡ã¤ã«ã¯ãããå¤åãããã°ãããã§æ´æ°ãã442 # ã³ã¼ãçæ段éã§ã¨ã©ã¼ãçºçããã°ãæ´æ°ããªã443 # CFile ã§çæããããã®ã¯ãæ´æ°ããã¦ãã419 # update する 420 # APPFile で生成されたファイルは、もし変化があれば、ここで更新する 421 # コード生成段階でエラーが発生すれば、更新しない 422 # CFile で生成されたものは、更新されている 444 423 if Generator.get_n_error == 0 then 445 424 begin -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/types.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2015 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 : types.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 #= HasType: @type ãå 56 é¨ã«æã¤åã®ããã®ã¢ã¸ã¥ã¼ã« 40 #= HasType: @type を内部に持つ型のためのモジュール 57 41 # @b_cloned::Bool : true if @type is cloned 58 42 # 59 # ãã®ã¢ã¸ã¥ã¼ã«ã¯ DefinedType, PtrType, ArrayType ã« include ããã 60 # æ¬å½ã¯ typedef ãããæã® Decl ã®è¦ç´ ã®ã¿ clone ããã°ããã®ã ããget_type, get_original_type 㧠61 # åãåºãããã¨ããset_scs, set_qualifier ãããã¨ãã«ç¡æ¡ä»¶ã§ clone ãã (ç¡é§ã«ã¡ã¢ãªã使ç¨ãã) 62 # ãã ããclone ããã®ã¯ä¸åã®ã¿ã§ãã (äºå clone ããã¨å¥ã®åãåç 63 §ãã¦ãã¾ã) 43 # このモジュールは DefinedType, PtrType, ArrayType に include される 44 # 本当は typedef された時の Decl の要素のみ clone すればよいのだが、get_type, get_original_type で 45 # 取り出されたとき、set_scs, set_qualifier されたときに無条件で clone する (無駄にメモリを使用する) 46 # ただし、clone するのは一回のみである (二回 clone すると別の型を参照してしまう) 64 47 # 65 # initialize 㧠clone ãã¦ããå 66 ±æããã¦ããã¨ãã« clone ãããªã 48 # initialize で clone しても、共有されているときに clone されない 67 49 # 68 50 module HasType … … 71 53 end 72 54 73 #=== HasType# @type ãã¯ãã¼ã³ãã55 #=== HasType# @type をクローンする 74 56 def clone_type 75 57 # if @b_cloned == false then … … 131 113 end 132 114 133 #=== size_is, count_is, string ãè¨å®134 # æ´¾çã¯ã©ã¹ã§ãªã¼ãã¼ã©ã¤ãããï¼ããã©ã«ãã§ã¯ã¨ã©ã¼ï¼115 #=== size_is, count_is, string を設定 116 # 派生クラスでオーバーライドする(デフォルトではエラー) 135 117 def set_scs( size, count, string, max = nil, b_nullable = false ) 136 118 str = "" … … 170 152 end 171 153 172 #=== åããã§ãã¯173 # æ£å½ãªåå®ç¾©ãã©ããããã§ãã¯ãã154 #=== 型をチェック 155 # 正当な型定義かどうか、チェックする 174 156 def check 175 # åã«èª¤ããããã°ãã¨ã©ã¼æååãè¿ã 176 end 177 178 #=== struct ã® tag ããã§ã㯠179 # æ£å½ãªåå®ç¾©ãã©ããããã§ãã¯ãã 180 #kind:: Decl ã® @kind ãåç 181 § 157 # 型に誤りがあれば、エラー文字列を返す 158 end 159 160 #=== struct の tag をチェック 161 # 正当な型定義かどうか、チェックする 162 #kind:: Decl の @kind を参照 182 163 def check_struct_tag kind 183 # tag ãåå¨ããªããã°ã¨ã©ã¼ãåºåãã 184 # é 185 ååã§ã¯ãè¦ç´ ã®åãå帰çã«ãã§ã㯠186 # ãã¤ã³ã¿åã§ã¯ãæãå 187 ã® tag ãã§ãã¯ã¯ããªã 188 # é¢æ°åã§ã¯ãã©ã¡ã¼ã¿ãªã¹ãã®ãã¹ã¦ã«ã¤ãã¦è¡ã 189 end 190 191 #=== åæåå¯è½ããã§ã㯠192 # attribute ãªã©åæåå¯è½ããã§ãã¯ããï¼åã«å¯¾ãæ£å½ãªåæååãä¸ãããã¦ãããï¼ 193 #ident:: string 被代å 194 ¥å¤æ°å½ 164 # tag が存在しなければエラーを出力する 165 # 配列型では、要素の型を再帰的にチェック 166 # ポインタ型では、指す先の tag チェックはしない 167 # 関数型ではパラメータリストのすべてについて行う 168 end 169 170 #=== 初期化可能かチェック 171 # attribute など初期化可能かチェックする(型に対し正当な初期化子が与えられているか) 172 #ident:: string 被代入変数命 195 173 #initialize:: Expression, Array of initializer or C_EXP 196 # 代å 197 ¥å¤ãC_EXP ãä¸ããããã®ã¯ IntType ã®å ´åã®ã¿ 174 # 代入値、C_EXP が与えられるのは IntType の場合のみ 198 175 #kind:: symbol (:ATTRIBUTE, :VAR, :CONSTNAT ) 199 #attribute:: NameList kind == :VAR ã®ã¨ãåç 200 §ã§ãã attribute 176 #attribute:: NameList kind == :VAR のとき参照できる attribute 201 177 # 202 # locale ã第ä¸å¼æ°ã¨ãã¦åãã®ã¯ã以ä¸ã®çç±ã«ããã 203 # ãã®ã¡ã½ããã¯ãå¤æ°ã¸ã®ä»£å 204 ¥ãè¡ããããè¡ãã«å¯¾ãã¦å¼ã³åºããããã 205 # Type ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã¯ãå¤æ°ãå®ç¾©ããããè¡ããè¨æ¶ãã¦ããã 178 # locale を第一引数として取るのは、以下の理由による。 179 # このメソッドは、変数への代入が行われる「行」に対して呼び出されるが、 180 # Type クラスのインスタンスは、変数が定義された「行」を記憶している。 206 181 # 207 182 # STAGE: S … … 210 185 end 211 186 212 #=== const_val ãæå®ã®åã«ãã£ã¹ããã213 # æ´¾çã¯ã©ã¹ã§ãªã¼ãã¼ã©ã¤ããã¦ããªãã¨ã¨ã©ã¼187 #=== const_val を指定の型にキャストする 188 # 派生クラスでオーバーライドしていないとエラー 214 189 def cast( const_val ) 215 190 cdl_error( "T1004 cannot cast to $1" , self.class ) 216 191 end 217 192 218 #=== åãä¸è´ãããã®ãã§ã㯠219 # ååã®åé¢ã§ãã§ãã¯ï¼ 220 # typedef ãããåãåé¢ã§ä¸è´ãè¦ããããå 221 ã®åãåãã§ãååãç°ãªãã°ä¸ä¸è´ã¨ãªã 193 #=== 型が一致するかのチェック 194 # 型名の字面でチェック. 195 # typedef された型も字面で一致を見るため、元の型が同じでも型名が異なれば不一致となる 222 196 def equal? type2 223 197 return ( get_type_str == type2.get_type_str ) && ( get_type_str_post == type2.get_type_str_post ) 224 198 end 225 199 226 #=== bit size ãå¾ã227 # IntType, FloatType 以å¤ã¯0200 #=== bit size を得る 201 # IntType, FloatType 以外は0 228 202 def get_bit_size 229 203 return 0 230 204 end 231 205 232 #=== å 233 ã®åãå¾ã 234 # typedef ãããåã®å ´åããã®å 235 ã®åãè¿ã. 236 # ãã以å¤ã¯ãèªåèªèº«ãè¿ãï¼ 237 # (DefinedType ã§ã¯æ¬ã¡ã½ããããªã¼ãã¼ã©ã¤ãããã) 206 #=== 元の型を得る 207 # typedef された型の場合、その元の型を返す. 208 # それ以外は、自分自身を返す. 209 # (DefinedType では本メソッドがオーバーライドされる) 238 210 def get_original_type 239 211 return self 240 212 end 241 213 242 #=== å 243 é¨ã«ãã¤ã³ã¿åãæ㤠244 # ãã¤ã³ã¿åãã¾ãã¯ãã¤ã³ã¿åã¡ã³ããæã¤æ§é ä½ãã¾ãã¯è¦ç´ ããã¤ã³ã¿åãæã¤é 245 å 214 #=== 内部にポインタ型を持つ 215 # ポインタ型、またはポインタ型メンバを持つ構造体、または要素がポインタ型を持つ配列 246 216 def has_pointer? 247 217 false 248 218 end 249 219 250 #=== size_is, count_is, string æå®ããããã¤ã³ã¿ãæã¤ã 251 # size_is, count_is, string æå®ããããã¤ã³ã¿åãã¾ãã¯ãããã¡ã³ãã«æã¤æ§é ä½ãã¾ãã¯ããããè¦ç´ ã«æã¤é 252 å 220 #=== size_is, count_is, string 指定されたポインタを持つか 221 # size_is, count_is, string 指定されたポインタ型、またはそれをメンバに持つ構造体、またはそれをを要素に持つ配列 253 222 def has_sized_pointer? 254 223 false 255 224 end 256 225 257 #=== é·ãæå®ã®ãªã string ãæ㤠258 # ãªãæå®ã®ãªã string æå®ããããã¤ã³ã¿åãã¾ãã¯ãããã¡ã³ãã«æã¤æ§é ä½ãã¾ãã¯ãããè¦ç´ ã«æã¤é 259 å 226 #=== 長さ指定のない string を持つ 227 # なさ指定のない string 指定されたポインタ型、またはそれをメンバに持つ構造体、またはそれを要素に持つ配列 260 228 def has_unsized_string? 261 229 false … … 281 249 @type_name = type_name 282 250 283 # mikan type_name ã path ã«ãªã£ã¦ããªãããæ«å®251 # mikan type_name が path になっていないため暫定 284 252 @typedef = Namespace.find( [ type_name ] ) #1 285 253 … … 317 285 end 318 286 319 #=== qualifier(const, volatile) ã®è¨å®287 #=== qualifier(const, volatile) の設定 320 288 def set_qualifier( qualifier ) 321 289 clone_type … … 338 306 end 339 307 340 def check # æå³ç誤ããããã°ãæååãè¿ã341 nil # typedef ã®æ®µéã§æå³ãã§ãã¯ããã¦ãã308 def check # 意味的誤りがあれば、文字列を返す 309 nil # typedef の段階で意味チェックされている 342 310 end 343 311 … … 346 314 end 347 315 348 #=== å 349 é¨ã«ãã¤ã³ã¿åãæ㤠350 # ãã¤ã³ã¿åãã¾ãã¯ãã¤ã³ã¿åã¡ã³ããæã¤æ§é ä½ãã¾ãã¯è¦ç´ ããã¤ã³ã¿åãæã¤é 351 å 316 #=== 内部にポインタ型を持つ 317 # ポインタ型、またはポインタ型メンバを持つ構造体、または要素がポインタ型を持つ配列 352 318 def has_pointer? 353 319 @type.has_pointer? 354 320 end 355 321 356 #=== size_is, count_is, string æå®ããããã¤ã³ã¿ãæã¤ã 357 # size_is, count_is, string æå®ããããã¤ã³ã¿åãã¾ãã¯ãããã¡ã³ãã«æã¤æ§é ä½ãã¾ãã¯ããããè¦ç´ ã«æã¤é 358 å 322 #=== size_is, count_is, string 指定されたポインタを持つか 323 # size_is, count_is, string 指定されたポインタ型、またはそれをメンバに持つ構造体、またはそれをを要素に持つ配列 359 324 def has_sized_pointer? 360 325 @type.has_sized_pointer? 361 326 end 362 327 363 #=== é·ãæå®ã®ãªã string ãæ㤠364 # ãªãæå®ã®ãªã string æå®ããããã¤ã³ã¿åãã¾ãã¯ãããã¡ã³ãã«æã¤æ§é ä½ãã¾ãã¯ãããè¦ç´ ã«æã¤é 365 å 328 #=== 長さ指定のない string を持つ 329 # なさ指定のない string 指定されたポインタ型、またはそれをメンバに持つ構造体、またはそれを要素に持つ配列 366 330 def has_unsized_string? 367 331 @type.has_unsized_string? … … 383 347 class VoidType < Type 384 348 385 def check # æå³ç誤ããããã°ãæååãè¿ã349 def check # 意味的誤りがあれば、文字列を返す 386 350 nil 387 351 end … … 408 372 class BoolType < Type 409 373 410 def check # æå³ç誤ããããã°ãæååãè¿ã374 def check # 意味的誤りがあれば、文字列を返す 411 375 nil 412 376 end … … 458 422 end 459 423 460 def check # æå³ç誤ããããã°ãæååãè¿ã424 def check # 意味的誤りがあれば、文字列を返す 461 425 nil 462 426 end … … 466 430 if val.instance_of?( Expression ) then 467 431 val = val.eval_const2( nil, attribute ) 468 # è©ä¾¡ã®çµæ C_EXP ã Array ã¨ãªãå¯è½æ§ããã 469 end 470 471 if val.instance_of? Token then # StringVal å°å 472 ¥ã«ããããã¯ã Token ã¯æ¥ãªãã¯ã 473 # val ã Token ã®å ´å == ã®å³è¾ºã String ã ã¨ã¨ã©ã¼ãèµ·ãã (#198) 432 # 評価の結果 C_EXP や Array となる可能性がある 433 end 434 435 if val.instance_of? Token then # StringVal 導入により、もはや Token は来ないはず 436 # val が Token の場合 == の右辺が String だとエラーを起こす (#198) 474 437 cdl_error2( locale, "T1009 $1: $2: not integer" , ident, val ) 475 438 return 476 439 elsif val.is_a? C_EXP then 477 # #192 var ã attribute ãåç 478 §ããattribute ã®å³è¾ºã C_EXP ã®å ´å 479 # const ã®å³è¾ºã C_EXP ã®å ´åã 440 # #192 var が attribute を参照し、attribute の右辺が C_EXP の場合 441 # const の右辺が C_EXP の場合も 480 442 return 481 443 elsif val.kind_of? FloatVal then … … 521 483 end 522 484 523 #=== IntType# æ大å¤ãæå°å¤ããã§ãã¯ãã¦ã¯ãªãããã524 # ãã£ã¹ãæ¼ç®ãè¡ã525 #in_val:: IntegerVal, FloatVal: ãã®åã«ãã£ã¹ãããå¤526 #from_type:: Symbol: :IntType, :FloatType IntType ã®å ´åã¯ãããæ°ã§ã¯ãªãããFloatType ã®å ´åã¯æ大å¤ã§ã¯ãªãã485 #=== IntType# 最大値、最小値をチェックしてクリップする 486 # キャスト演算を行う 487 #in_val:: IntegerVal, FloatVal: この型にキャストする値 488 #from_type:: Symbol: :IntType, :FloatType IntType の場合はビット数でクリップ、FloatType の場合は最大値でクリップ 527 489 def check_and_clip( in_val, from_type = :IntType ) 528 490 bit_size = get_bit_size … … 533 495 if get_max && val > get_max then 534 496 if from_type == :IntType then 535 rval = ((1 << bit_size)-1) & val # bit æ°ã§ã¯ãªãã497 rval = ((1 << bit_size)-1) & val # bit 数でクリップ 536 498 else 537 rval = get_max # æ大å¤ã§ã¯ãªãã(FloatType)499 rval = get_max # 最大値でクリップ (FloatType) 538 500 end 539 501 cdl_warning( "W2003 $1: too large to cast to $2, clipped($3)" , in_val, get_type_str, rval ) … … 546 508 if @sign == :SIGNED || @sign == nil then 547 509 cdl_warning( "W2004 $1: too small to cast to $2, clipped($3)" , in_val, get_type_str, rval ) 548 else # @sign == :UNSIGNED || @sign == nil (char ã®å ´å)510 else # @sign == :UNSIGNED || @sign == nil (char の場合) 549 511 cdl_warning( "W2005 $1: negative value for unsigned: convert to $2" , in_val, rval ) 550 512 end … … 558 520 if @sign == :SIGNED || @sign == nil then 559 521 if @bit_size == -1 then 560 bit_sz = 8 # char_t ã¯ãæ符å·ã«æ±ã522 bit_sz = 8 # char_t は、有符号に扱う 561 523 else 562 524 bit_sz = @bit_size … … 576 538 if @bit_size == -1 then 577 539 if @sign == nil then 578 return 255 # char_t ã¯ãç¡ç¬¦å·ã«æ±ã540 return 255 # char_t は、無符号に扱う 579 541 else 580 542 bit_sz = 8 … … 600 562 end 601 563 602 #=== IntType# C è¨èªã«ãããååï¼ä¿®é£¾åä»ãï¼564 #=== IntType# C 言語における型名(修飾子付き) 603 565 def get_type_str 604 566 str = super … … 620 582 621 583 case @bit_size 622 when -1 # char_t å584 when -1 # char_t 型 623 585 if @sign == :SIGNED then 624 586 sign = "s" 625 587 end 626 588 str = "#{str}#{sign}char_t" 627 when -11 # char å(obsolete)589 when -11 # char 型(obsolete) 628 590 str = "#{str}#{signL}char" 629 when -2 # short å591 when -2 # short 型 630 592 str = "#{str}#{signL}short" 631 when -3 # int å593 when -3 # int 型 632 594 str = "#{str}#{signL}int" 633 when -4 # long å595 when -4 # long 型 634 596 str = "#{str}#{signL}long" 635 when -5 # long long å597 when -5 # long long 型 636 598 str = "#{str}#{signL}long long" 637 when 8, 16, 32, 64, 128 # int16, int32, int64, int128 å599 when 8, 16, 32, 64, 128 # int16, int32, int64, int128 型 638 600 str = "#{str}#{sign}int#{@bit_size}_t" 639 601 end … … 642 604 end 643 605 644 #=== IntType# C è¨èªã«ãããååï¼å¾ç½®æååï¼606 #=== IntType# C 言語における型名(後置文字列) 645 607 def get_type_str_post 646 608 "" 647 609 end 648 610 649 #=== IntType#bit_size ãå¾ã 650 # è¿ãããå¤ã¯ @bit_size ã®ä»æ§ãåç 651 § 611 #=== IntType#bit_size を得る 612 # 返される値は @bit_size の仕様を参照 652 613 def get_bit_size 653 614 return @bit_size 654 615 end 655 616 656 #=== IntType# sign ãå¾ã 657 # @sign ã®èª¬æãåç 658 § 617 #=== IntType# sign を得る 618 # @sign の説明を参照 659 619 def get_sign 660 620 @sign … … 676 636 end 677 637 678 def check # æå³ç誤ããããã°ãæååãè¿ã638 def check # 意味的誤りがあれば、文字列を返す 679 639 nil 680 640 end 681 641 682 # mikan Float åã® C_EXP å¯¾å¿ (generate.rb ã«ãå¤æ´å¿ 683 è¦) 642 # mikan Float 型の C_EXP 対応 (generate.rb にも変更必要) 684 643 def check_init( locale, ident, initializer, kind, attribute = nil ) 685 # åã«å¯¾ããåæå¤ã«èª¤ããããã°ãã¨ã©ã¼æååãè¿ã644 # 型に対する初期値に誤りがあれば、エラー文字列を返す 686 645 val = initializer 687 646 if val.instance_of?( Expression ) then 688 647 val = val.eval_const2( nil, attribute ) 689 # è©ä¾¡ã®çµæ C_EXP ã Array ã¨ãªãå¯è½æ§ããã648 # 評価の結果 C_EXP や Array となる可能性がある 690 649 end 691 650 692 651 if val.instance_of? Token then 693 # val ã Token ã®å ´å == ã®å³è¾ºã String ã ã¨ã¨ã©ã¼ãèµ·ãã652 # val が Token の場合 == の右辺が String だとエラーを起こす 694 653 cdl_error2( locale, "T1018 $1: $2: not number" , ident, val ) 695 654 return … … 772 731 # @members_decl:: NamedList 773 732 # @definition:: StructType 774 # @b_has_pointer_member:: bool : ã¡ã³ãã«ãã¤ã³ã¿åããã775 # @b_has_sized_pointer_member:: bool : ã¡ã³ãã«ãã¤ã³ã¿åããã776 # @b_has_unsized_string_member:: bool : ã¡ã³ãã«ãã¤ã³ã¿åããã777 # @member_types_symbol:: Symbol : tag ãç¡ãæã®ã¿è¨å® (ãã以å¤ã§ã¯nil)733 # @b_has_pointer_member:: bool : メンバにポインタ型がある 734 # @b_has_sized_pointer_member:: bool : メンバにポインタ型がある 735 # @b_has_unsized_string_member:: bool : メンバにポインタ型がある 736 # @member_types_symbol:: Symbol : tag が無い時のみ設定 (それ以外では nil) 778 737 779 738 @@structtype_current_stack = [] 780 739 @@structtype_current_sp = -1 781 740 782 # tag ãªãstruct741 # tag なし struct 783 742 @@no_struct_tag_num = 0 784 743 @@no_tag_struct_list = {} … … 803 762 if @b_define then 804 763 @members_decl = NamedList.new( nil, "in struct #{@tag}" ) 805 # if @tag then ç»é²ã¿ã¤ãã³ã°ãçµããã«å¤æ´V1.0.2.19764 # if @tag then 登録タイミングを終わりに変更 V1.0.2.19 806 765 # Namespace.new_structtype( self ) 807 766 # end 808 767 else 809 768 @definition = Namespace.find_tag( @tag ) 810 # check_struct_tag ã«ç§»ãV1.0.2.19769 # check_struct_tag に移す V1.0.2.19 811 770 # if @definition == nil then 812 771 # cdl_error( "T1021 \'$1\': struct not defined" , @tag ) … … 833 792 end 834 793 835 def check # æå³ç誤ããããã°ãæååãè¿ã794 def check # 意味的誤りがあれば、文字列を返す 836 795 nil 837 796 end 838 797 839 #=== æ§é ä½ã®ã¿ã°ããã§ã㯠840 # declarator ã®æç¹ã§ãã§ãã¯ãã 841 #kind:: Decl ã® @kind ãåç 842 § 798 #=== 構造体のタグをチェック 799 # declarator の時点でチェックする 800 #kind:: Decl の @kind を参照 843 801 def check_struct_tag kind 844 802 if @tag == nil … … 852 810 end 853 811 854 # mikan Float åã® C_EXP å¯¾å¿ (generate.rb ã«ãå¤æ´å¿ 855 è¦) 812 # mikan Float 型の C_EXP 対応 (generate.rb にも変更必要) 856 813 def check_init( locale, ident, initializer, kind, attribute = nil ) 857 814 … … 862 819 end 863 820 864 # åæååãå¼ã®å ´åãåï¼ã¿ã°ï¼ãä¸è´ããããã§ãã¯821 # 初期化子が式の場合、型(タグ)が一致するかチェック 865 822 if initializer.instance_of?( Expression ) then 866 823 t = initializer.get_type( attribute ) … … 898 855 899 856 def end_of_parse() 900 if @members_decl == nil # @b_define = false ã¾ãã¯ã¡ã³ãã¼ã®ãªãæ§é ä½ï¼ã¨ã©ã¼ï¼857 if @members_decl == nil # @b_define = false またはメンバーのない構造体(エラー) 901 858 return 902 859 end … … 924 881 string = md.get_string 925 882 if string == -1 then 926 # é·ãæå®ãªã883 # 長さ指定なし 927 884 elsif string then 928 885 val = string.eval_const( @members_decl ) … … 962 919 963 920 if @tag then 964 # typedef struct tag StructType; ã®å½¢å¼ã®å ´å965 # struct ã®æ¬ä½ã¯ãå¥ã«çæããã921 # typedef struct tag StructType; の形式の場合 922 # struct の本体は、別に生成される 966 923 return "#{str}struct #{@tag} " 967 924 968 925 else 969 # typedef struct { int a; } StructType; ã®å½¢å¼ã®å ´å926 # typedef struct { int a; } StructType; の形式の場合 970 927 str += "struct {\n" 971 928 @members_decl.get_items.each{ |i| … … 1018 975 end 1019 976 1020 #=== åãæ§é ä½ãã©ãããã§ãã¯ãã1021 # tag ã®ãã§ãã¯ã¯è¡ããªã1022 # ãã¹ã¦ã®ã¡ã³ãã®ååã¨åãä¸è´ãããã¨ã確èªãã977 #=== 同じ構造体かどうかチェックする 978 # tag のチェックは行わない 979 # すべてのメンバの名前と型が一致することを確認する 1023 980 def same? another 1024 981 md = another.get_members_decl … … 1110 1067 end 1111 1068 1112 def check # æå³ç誤ããããã°ãæååãè¿ã 1113 if @type.class == ArrayType then # é 1114 åãè¿ãé¢æ° 1069 def check # 意味的誤りがあれば、文字列を返す 1070 if @type.class == ArrayType then # 配列を返す関数 1115 1071 return "function returning array" 1116 elsif @type.class == FuncType then # é¢æ°ãè¿ãé¢æ°1072 elsif @type.class == FuncType then # 関数を返す関数 1117 1073 return "function returning function" 1118 1074 end 1119 return @type.check # é¢æ°ã® return ããåã®ãã§ãã¯1120 1121 # ãã©ã¡ã¼ã¿ã®åã®ãã§ãã¯ã¯ ParamList#check_param ã§è¡ã1075 return @type.check # 関数の return する型のチェック 1076 1077 # パラメータの型のチェックは ParamList#check_param で行う 1122 1078 end 1123 1079 1124 1080 def check_struct_tag kind 1125 1081 @type.check_struct_tag kind 1126 # ParamDecl ã§ããã§ãã¯ãããã®ã§ãããã§ã¯ãã§ãã¯ããªã1082 # ParamDecl でもチェックされるので、ここではチェックしない 1127 1083 # @paramlist.check_struct_tag kind 1128 1084 end … … 1141 1097 end 1142 1098 1143 #=== return type ãè¿ã1099 #=== return type を返す 1144 1100 # 1145 # return type ãè¿ã1146 # get_return_type ã¨ãã¹ãã ã£ã1101 # return type を返す 1102 # get_return_type とすべきだった 1147 1103 def get_type 1148 1104 @type … … 1154 1110 1155 1111 def get_type_str_post 1156 # åã ããè¿ã (ä»®å¼æ°ã®ååãå«ããªã)1112 # 型だけを返す (仮引数の名前を含めない) 1157 1113 @paramlist.to_str( false ) 1158 1114 end … … 1182 1138 end 1183 1139 1184 #=== Push Pop Allocator ãå¿ 1185 è¦ãï¼ 1186 # Transparent RPC ã®å ´å oneway ã㤠in ã®é 1187 å(size_is, count_is, string ã®ããããã§ä¿®é£¾ï¼ããã 1140 #=== Push Pop Allocator が必要か? 1141 # Transparent RPC の場合 oneway かつ in の配列(size_is, count_is, string のいずれかで修飾)がある 1188 1142 def need_PPAllocator?( b_opaque = false ) 1189 1143 if @b_oneway || b_opaque then … … 1194 1148 end 1195 1149 1196 #=== ãã©ã¡ã¼ã¿ã in, inout, out, send, receive ãæã¤ã1150 #=== パラメータが in, inout, out, send, receive を持つか 1197 1151 def has_in? 1198 1152 @has_in … … 1211 1165 end 1212 1166 1213 #=== å 1214 ¥åæ¹åã®ãã©ã¡ã¼ã¿ãæã¤ã 1167 #=== 入力方向のパラメータを持つか 1215 1168 def has_inward? 1216 1169 @has_in || @has_inout || @has_send 1217 1170 end 1218 #=== åºåæ¹åã®ãã©ã¡ã¼ã¿ãæã¤ã1171 #=== 出力方向のパラメータを持つか 1219 1172 def has_outward? 1220 1173 @has_inout || @has_out || @has_receive … … 1258 1211 end 1259 1212 1260 #=== Array#qualifier(const, volatile) ã®è¨å®1213 #=== Array#qualifier(const, volatile) の設定 1261 1214 def set_qualifier( qualifier ) 1262 1215 clone_type … … 1265 1218 end 1266 1219 1267 # é 1268 åè¦ç´ ã const ãªã const 1220 # 配列要素が const なら const 1269 1221 def is_const? 1270 1222 @type.is_const? 1271 1223 end 1272 1224 1273 # é 1274 åè¦ç´ ã volatile ãªã volatile 1225 # 配列要素が volatile なら volatile 1275 1226 def is_volatile? 1276 1227 @type.is_volatile? … … 1298 1249 end 1299 1250 1300 def check # æå³ç誤ããããã°ãæååãè¿ã 1301 if @type.class == FuncType then # é¢æ°ã®é 1302 å 1251 def check # 意味的誤りがあれば、文字列を返す 1252 if @type.class == FuncType then # 関数の配列 1303 1253 return "array of function" 1304 elsif @type.class == ArrayType then # æ·»æ°ãªãé 1305 åã®é 1306 å 1254 elsif @type.class == ArrayType then # 添数なし配列の配列 1307 1255 unless @type.get_subscript then 1308 1256 return "subscript not specified" … … 1310 1258 end 1311 1259 1312 return @type.check # é 1313 åè¦ç´ ã®åããã§ã㯠1260 return @type.check # 配列要素の型をチェック 1314 1261 end 1315 1262 … … 1364 1311 # @size:: Expr, or nil if not specified 1365 1312 # @count:: Expr, or nil if not specified 1366 # @string:: Expr or -1(if size not specified) ï¼string å¼æ°ï¼, or nil if not specified1313 # @string:: Expr or -1(if size not specified) (string 引数), or nil if not specified 1367 1314 1368 1315 include HasType … … 1381 1328 @type = type 1382 1329 else 1383 @type.set_type( type ) # æå 1384 ã® type ãè¨å® 1330 @type.set_type( type ) # 枝先の type を設定 1385 1331 end 1386 1332 end … … 1404 1350 end 1405 1351 1406 def check # æå³ç誤ããããã°ãæååãè¿ã1352 def check # 意味的誤りがあれば、文字列を返す 1407 1353 return nil if @type == nil 1408 1354 @type.check … … 1410 1356 1411 1357 def check_struct_tag kind 1412 if kind != :MEMBER # æ§é ä½ã¡ã³ãã¼ã®å ´åããã¤ã³ã¿ã®å 1413 ã®æ§é ä½ã¿ã°ããã§ãã¯ããªã 1358 if kind != :MEMBER # 構造体メンバーの場合、ポインタの先の構造体タグをチェックしない 1414 1359 @type.check_struct_tag kind 1415 1360 end … … 1428 1373 if ( t1.class == t2.class ) && ( t1.get_bit_size == t2.get_bit_size ) then 1429 1374 elsif ( t1.kind_of?( CDefinedType) || t2.kind_of?( CDefinedType ) )&& t1.get_type_str == t2.get_type_str && t1.get_type_str_post && t2.get_type_str_post then 1430 # int8_t ãªã©ããä¸æ¹ã¯ .h ã«å®ç¾©ããã¦ããã±ã¼ã¹1375 # int8_t などが、一方は .h に定義されているケース 1431 1376 else 1432 1377 cdl_error2( locale, "T1032 $1: incompatible pointer type" , ident ) … … 1439 1384 end 1440 1385 elsif val.kind_of? StringVal then 1441 # æååå®æ°1386 # 文字列定数 1442 1387 # mikan L"wide string" 1443 1388 if @type.get_bit_size != -1 && @type.get_bit_size != -11 then # -1: char_t … … 1483 1428 @b_nullable = b_nullable 1484 1429 1485 # string ã¯æãå·¦å´ã® ptr ã«ä½ç¨ãã1430 # string は最も左側の ptr に作用する 1486 1431 if @type.kind_of?( PtrType ) then 1487 # ptr_level ã 2 以ä¸ã§ãããã¨ã¯ ParamDecl#initializer ã§ãã§ãã¯ããã1432 # ptr_level が 2 以上であることは ParamDecl#initializer でチェックされる 1488 1433 clone_type 1489 1434 @type.set_scs( nil, nil, string, nil, false ) … … 1532 1477 end 1533 1478 1534 #=== PtrType# size_is ã®æ大å¤1479 #=== PtrType# size_is の最大値 1535 1480 def get_max 1536 1481 @max … … 1595 1540 end 1596 1541 1597 #== DescriptorType ã¯ã©ã¹1598 # åççµåã§æ¸¡ããã¹ã¯ãªãã¿å1542 #== DescriptorType クラス 1543 # 動的結合で渡すデスクリプタ型 1599 1544 class DescriptorType < Type 1600 1545 # @sinagure_nsp::NamespacePath … … 1630 1575 case kind 1631 1576 when :PARAMETER 1632 # å¼æ°ã¯åæåã§ããªã1577 # 引数は初期化できない 1633 1578 else 1634 1579 cdl_error2( locale, "T9999 Descriptor cannot be used for $1", kind) … … 1637 1582 1638 1583 #== DescriptorType# 1639 # æå³è§£æ段éã§ã¯ nil ãè¿ãããå¯è½æ§ã«æ³¨æ1584 # 意味解析段階では nil が返される可能性に注意 1640 1585 def get_signature 1641 1586 Namespace.find @signature_nsp … … 1643 1588 end 1644 1589 1645 # 以ä¸åä½ãã¹ãã³ã¼ã1590 # 以下単体テストコード 1646 1591 if $unit_test then 1647 1592 puts( "===== Unit Test: IntType ===== (types.rb)") -
Property svn:mime-type
changed from
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/value.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 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 : value.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 #= BaseVal æ´æ°ãæµ®åå°æ°ãªã©ã®å¤ãæ±ãã¯ã©ã¹ã®åºåºã¯ã©ã¹40 #= BaseVal 整数、浮動小数などの値を扱うクラスの基底クラス 56 41 # 57 # TECS ã® CDL ã§æ±ãå¤ã¯ã以ä¸ã«åé¡ããã 58 # ã»æ´æ° 59 # ã»æµ®åå°æ° 60 # ã»æåå 61 # ã»ãã¼ã«å¤ 62 # éæåï¼æ§é ä½ãé 63 åï¼ã¨ C_EXP ã¯ããã§ã¯æ±ããªã 42 # TECS の CDL で扱う値は、以下に分類される 43 # ・整数 44 # ・浮動小数 45 # ・文字列 46 # ・ブール値 47 # 集成型(構造体、配列)と C_EXP はここでは扱わない 64 48 # 65 # ãã®ã¯ã©ã¹ã§å®ç¾©æ¸ã¿ã®æ¼ç®åã¯ãã¨ã©ã¼ã¨ãªã66 # åã«ããæ¼ç®å¯è½ãªå ´åãæ¼ç®åããªã¼ãã¼ã©ã¤ããã49 # このクラスで定義済みの演算子は、エラーとなる 50 # 型により演算可能な場合、演算子をオーバーライドする 67 51 # 68 52 class BaseVal < Node … … 160 144 end 161 145 162 #= Pointer å¤ (IntegerVal ã® Pointer ç)146 #= Pointer 値 (IntegerVal の Pointer 版) 163 147 # 164 # ãã¤ã³ã¿å¤ã¯ãCDL ã§ç´æ¥çæããããã¨ã¯ãªã165 # æ´æ°å¤ã®ãã£ã¹ãæ¼ç®ã«ããçæããã148 # ポインタ値は、CDL で直接生成されることはない 149 # 整数値のキャスト演算により生成される 166 150 class PointerVal < BaseVal 167 #@int_val:: IntegerVal: IntegerVal ã§ãªãã¦ã¯ãªããªã 168 #@ptr_type:: PtrType: ãã¤ã³ã¿ã®æãå 169 ã®å 151 #@int_val:: IntegerVal: IntegerVal でなくてはならない 152 #@ptr_type:: PtrType: ポインタの指す先の型 170 153 171 154 def initialize( int_val, ptr_type ) … … 175 158 end 176 159 177 #=== ãã¤ã³ã¿ã®æãå 178 ã®åãå¾ã 179 # PointerVal å°ç¨ã®ã¡ã½ãã 160 #=== ポインタの指す先の型を得る 161 # PointerVal 専用のメソッド 180 162 def get_type 181 163 @ptr_type … … 183 165 184 166 def cast type 185 t = type.get_original_type # typedef ã®å 186 ãå¾ã 167 t = type.get_original_type # typedef の元を得る 187 168 if t.kind_of? IntType then 188 169 val = t.check_and_clip( @int_val, :IntType ) … … 213 194 end 214 195 215 #= IntegerVal: æ´æ°å¤ãæ±ãã¯ã©ã¹196 #= IntegerVal: 整数値を扱うクラス 216 197 class IntegerVal < BaseVal 217 198 #@val:: Integer: value … … 250 231 def / val 251 232 if val.kind_of? FloatVal then 252 v2 = val.to_f # to_f ã2åè©ä¾¡ããªã233 v2 = val.to_f # to_f を2回評価しない 253 234 if v2 == 0.0 then 254 235 cdl_error( "V1009 / : divieded by zero" ) … … 257 238 return FloatVal.new( @val.to_f / v2 ) 258 239 else 259 v2 = val.to_i # to_i ã2åè©ä¾¡ããªã240 v2 = val.to_i # to_i を2回評価しない 260 241 if v2 == 0 then 261 242 cdl_error( "V1010 / : divieded by zero" ) … … 267 248 def % val 268 249 if val.kind_of? FloatVal then 269 v2 = val.to_f # to_f ã2åè©ä¾¡ããªã250 v2 = val.to_f # to_f を2回評価しない 270 251 if v2 == 0.0 then 271 252 cdl_error( "V1011 % : divieded by zero" ) … … 274 255 return FloatVal.new( @val.to_f % v2 ) 275 256 else 276 v2 = val.to_i # to_i ã2åè©ä¾¡ããªã257 v2 = val.to_i # to_i を2回評価しない 277 258 if v2 == 0 then 278 259 cdl_error( "V1012 % : divieded by zero" ) … … 360 341 end 361 342 def cast( type ) 362 t = type.get_original_type # typedef ã®å 363 ãå¾ã 343 t = type.get_original_type # typedef の元を得る 364 344 if t.kind_of? IntType then 365 345 val = t.check_and_clip( @val, :IntType ) … … 395 375 end 396 376 397 #= BoolVal: bool å¤ãæ±ãã¯ã©ã¹377 #= BoolVal: bool 値を扱うクラス 398 378 class BoolVal < BaseVal 399 379 #@val:: bool: true, false … … 437 417 end 438 418 def cast( type ) 439 t = type.get_original_type # typedef ã®å 440 ãå¾ã 419 t = type.get_original_type # typedef の元を得る 441 420 if @val then 442 421 val = 1 … … 478 457 end 479 458 480 #= FloatVal: å®æ°å¤ãæ±ãã¯ã©ã¹459 #= FloatVal: 実数値を扱うクラス 481 460 class FloatVal < BaseVal 482 461 #@val:: Float … … 496 475 end 497 476 def / val 498 v2 = val.to_f # to_f ã2åè©ä¾¡ããªã477 v2 = val.to_f # to_f を2回評価しない 499 478 if v2 == 0.0 then 500 479 cdl_error( "V1017 / : divieded by zero" ) … … 504 483 end 505 484 def % val 506 v2 = val.to_f # to_f ã2åè©ä¾¡ããªã485 v2 = val.to_f # to_f を2回評価しない 507 486 if v2 == 0.0 then 508 487 cdl_error( "V1018 % : divieded by zero" ) … … 536 515 end 537 516 def cast( type ) 538 t = type.get_original_type # typedef ã®å 539 ãå¾ã 517 t = type.get_original_type # typedef の元を得る 540 518 if t.kind_of? IntType then 541 519 val = t.check_and_clip( @val, :FloatType ) … … 565 543 end 566 544 567 #= æååãªãã©ã«ãæ±ãã¯ã©ã¹545 #= 文字列リテラルを扱うクラス 568 546 class StringVal < BaseVal 569 547 #@str:: Token: … … 573 551 super() 574 552 @str = str 575 @specifier = spec # mikan L"str" wide æååæªå¯¾å¿553 @specifier = spec # mikan L"str" wide 文字列未対応 576 554 end 577 555 578 556 #=== 579 557 # 580 # string ã® cast ã¯ã§ããªã mikan ãã¤ã³ã¿åã¸ã® cast ã¯ã§ããã¹ã558 # string の cast はできない mikan ポインタ型への cast はできるべき 581 559 def cast type 582 t = type.get_original_type # typedef ã®å 583 ãå¾ã 560 t = type.get_original_type # typedef の元を得る 584 561 if t.kind_of? IntType then 585 562 cdl_error( "V1022 string cannot cast to integer" ) … … 598 575 599 576 def val 600 @str.to_s # Token ã§æ±ããã¦ããåæ® (val ãåãåºã)577 @str.to_s # Token で扱われていた名残 (val を取り出す) 601 578 end 602 579 end -
Property svn:mime-type
changed from
Note:
See TracChangeset
for help on using the changeset viewer.