Changeset 389 for azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core
- Timestamp:
- May 22, 2019, 10:03:37 PM (5 years ago)
- Location:
- azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub/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
r388 r389 107 107 # b_asm = false 108 108 109 # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµããã誤ãåé¡ã®å¯¾ç109 # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策 110 110 TECS_LANG::set_kcode_binary 111 111 112 # 800U, 0xffLL ãªã© (æ´æ°ãªãã©ã«ã«å 113 ±éã®ä¿®é£¾å) 112 # 800U, 0xffLL など (整数リテラルに共通の修飾子) 114 113 integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?" 115 114 … … 126 125 if comment 127 126 case line 128 # ã³ã¡ã³ãçµäº127 # コメント終了 129 128 when /\A\*\// 130 129 comment = false … … 134 133 else 135 134 case line 136 # 空ç½ãããªããã»ã¹ãã£ã¬ã¯ãã£ã135 # 空白、プリプロセスディレクティブ 137 136 when /\A\s+/ 138 137 ; 139 # èå¥å138 # 識別子 140 139 when /\A[a-zA-Z_]\w*/ 141 140 word = $& 142 141 @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)] 143 # 16 é²æ°å®æ°142 # 16 進数定数 144 143 when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/ 145 144 @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)] 146 # 8 é²æ°å®æ°145 # 8 進数定数 147 146 when /\A0[0-7]+#{integer_qualifier}/ 148 147 @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)] 149 # æµ®åå°æ°å®æ°148 # 浮動小数定数 150 149 when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/ 151 150 @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)] 152 # æ´æ°å®æ°151 # 整数定数 153 152 when /\A\d+#{integer_qualifier}/ 154 153 # when /\A\d+/ 155 154 @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)] 156 # æå155 # 文字 157 156 when /\A'(?:[^'\\]|\\.)'/ 158 157 @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)] 159 # æåå160 # "#include #include #include \"../systask/logtask.cfg\" æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã158 # 文字列 159 # "#include #include #include \"../systask/logtask.cfg\" 最後の " 忘れ)で無限ループ 161 160 # when /\A"(?:[^"\\]+|\\.)*"/ 162 when /\A"(?:[^"\\]|\\.)*"/ # ããã¯ãã¾ãè¡ãããã161 when /\A"(?:[^"\\]|\\.)*"/ # これはうまく行くようだ 163 162 @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)] 164 # è¡ã³ã¡ã³ã163 # 行コメント 165 164 when /\A\/\/.*$/ 166 # èªã¿é£ã°ãã ã167 # ã³ã¡ã³ãéå§165 # 読み飛ばすだけ 166 # コメント開始 168 167 when /\A\/\*/ 169 168 comment = true … … 196 195 } 197 196 198 # çµäºã®å°197 # 終了の印 199 198 @q << nil 200 199 … … 223 222 end 224 223 225 # TYPE_NAME ãã¼ã¯ã³ã¸ç½®ãæã224 # TYPE_NAME トークンへ置き換え 226 225 if @b_no_type_name == false 227 226 if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then … … 232 231 end 233 232 234 if $debug then # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç)233 if $debug then # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生) 235 234 locale = @@current_locale[@@generator_nest] 236 235 if token then … … 262 261 @@n_info = 0 263 262 264 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼263 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切) 265 264 def self.error( msg ) 266 265 @@n_error += 1 … … 274 273 end 275 274 276 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼275 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切) 277 276 def self.warning( msg ) 278 277 @@n_warning += 1 … … 281 280 end 282 281 283 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯282 # このメソッドは構文解析、意味解析からのみ呼出し可 284 283 def self.info( msg ) 285 284 @@n_info += 1 … … 1796 1795 module_eval(<<'.,.,', 'C_parser.y.rb', 228) 1797 1796 def _reduce_83(val, _values, result) 1798 result = Expression.new( val[2] ) # ',' ã®å¾ããæ¡ç¨1797 result = Expression.new( val[2] ) # ',' の後ろを採用 1799 1798 1800 1799 result … … 1822 1821 module_eval(<<'.,.,', 'C_parser.y.rb', 261) 1823 1822 def _reduce_86(val, _values, result) 1824 result = CIntType.new( -3 ) # storage class ã¯ç¡è¦1823 result = CIntType.new( -3 ) # storage class は無視 1825 1824 1826 1825 result … … 1830 1829 module_eval(<<'.,.,', 'C_parser.y.rb', 265) 1831 1830 def _reduce_87(val, _values, result) 1832 result = val[1] # storage class ã¯ç¡è¦1831 result = val[1] # storage class は無視 1833 1832 1834 1833 result … … 2587 2586 def _reduce_268(val, _values, result) 2588 2587 while true 2589 # ';' ã表ããã¾ã§ããã¼ã¯ã³ãèªã¿é£ã°ãã 2590 # gcc ã®æ§ææ¡å¼µã«å¯¾å¿ãã¹ãã ããåç´ãªå®è£ 2591 ã¨ãã¦ã';' ã¾ã§èªã¿é£ã°ãã 2592 # ãã¼ã¯ã³åä½ã§èªã¿é£ã°ãã¦ããã®ã§ãæååãã³ã¡ã³ãå 2593 ã® ';' ã¯å¯¾è±¡ã«ãªããªãã 2588 # ';' が表れるまで、トークンを読み飛ばす。 2589 # gcc の構文拡張に対応すべきだが、単純な実装として、';' まで読み飛ばす。 2590 # トークン単位で読み飛ばしているので、文字列やコメント内の ';' は対象にならない。 2594 2591 token = next_token 2595 2592 if token[1].val == ";" -
Property svn:mime-type
changed from
-
azure_iot_hub/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
r388 r389 6 6 # Copyright (C) 2008-2018 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ã(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 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 # 2019/3/28 é·å³¶ ä¸è¨ã®C99ã®æ§æã«è¿ã¥ãããå¤æ´69 # ï¼èªããªããããã¼ãã¡ã¤ã«ããã£ãããï¼51 # 2019/3/28 長島 下記のC99の構文に近づくよう変更 52 #(読めないヘッダーファイルがあったため) 70 53 # http://www.quut.com/c/ANSI-C-grammar-y-1999.html 71 # å 72 ã 73 ã®ã³ã¡ã³ãã¨åããªããªã£ã¦ãã¾ã 54 # 元々のコメントと合わなくなっています 74 55 75 56 primary_expression 76 57 : namespace_identifier 77 58 { result = [ :IDENTIFIER, val[0] ] } #1ok 78 # : IDENTIFIER # mikan namespace ã¸ã®å¯¾å¿59 # : IDENTIFIER # mikan namespace への対応 79 60 # { result = [ :IDENTIFIER, val[0] ] } 80 61 # | TRUE … … 103 84 { result << val[1] } 104 85 105 # é¢æ°å¼ã³åºãã¨å¾ç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®åããªã86 # 関数呼び出しと後置インクリメント、デクリメント演算子がない 106 87 postfix_expression 107 88 : primary_expression … … 115 96 | postfix_expression '->' IDENTIFIER 116 97 { result = [ :OP_REF, val[0], val[2] ] } 117 | postfix_expression '++' { result = val[0] } # ++, -- ã¯ç¡è¦ãã98 | postfix_expression '++' { result = val[0] } # ++, -- は無視する 118 99 | postfix_expression '--' { result = val[0] } 119 100 | '(' type_name ')' '{' initializer_list '}' … … 125 106 126 107 127 # åç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®åããªã108 # 前置インクリメント、デクリメント演算子がない 128 109 unary_expression 129 110 : postfix_expression … … 134 115 | SIZEOF '(' type_name ')' 135 116 { result = [ :OP_SIZEOF_TYPE, val[1] ] } 136 | '++' unary_expression { result = val[1] } # ++, -- ã¯ç¡è¦ãã117 | '++' unary_expression { result = val[1] } # ++, -- は無視する 137 118 | '--' unary_expression { result = val[1] } 138 119 … … 246 227 | expression ',' assignment_expression 247 228 { 248 result = Expression.new( val[2] ) # ',' ã®å¾ããæ¡ç¨229 result = Expression.new( val[2] ) # ',' の後ろを採用 249 230 } 250 231 … … 264 245 265 246 # Types 266 ########################## 宣è¨##########################267 # 宣è¨ãK&Rã¨ä¸é¨ç°ãªã268 269 # declaration ã¯ã»ã«ã®å±æ§ã§ä½¿ããã270 # K&R ã¨ã®éã: storage classãæå®ã§ããªããåãçç¥ã§ããªã247 ########################## 宣言 ########################## 248 # 宣言もK&Rと一部異なる 249 250 # declarationはセルの属性で使われる 251 # K&Rとの違い: storage classが指定できない、型が省略できない 271 252 declaration 272 253 : declaration_specifiers init_declarator_list ';' 273 254 # : specifier_qualifier_list init_declarator_list ';' 274 255 275 # declaration_specifiers ã¯é¢æ°ã®ãã©ã¡ã¼ã¿ã§ä½¿ããããã276 # specifier_qualifier_list ã§ååãããããªã256 # declaration_specifiersは関数のパラメータで使われるが、 257 # specifier_qualifier_listで十分かもしれない 277 258 278 259 declaration_specifiers 279 260 : storage_class_specifier 280 261 { 281 result = CIntType.new( -3 ) # storage class ã¯ç¡è¦262 result = CIntType.new( -3 ) # storage class は無視 282 263 } 283 264 | storage_class_specifier declaration_specifiers 284 265 { 285 result = val[1] # storage class ã¯ç¡è¦266 result = val[1] # storage class は無視 286 267 } 287 268 | type_specifier … … 350 331 { set_no_type_name true; result = CBoolType.new } 351 332 | struct_specifier 352 { set_no_type_name true; result = val[0] } # set_no_type_name true 㯠struct_tag ã§ãå¼ã°ãã333 { set_no_type_name true; result = val[0] } # set_no_type_name true は struct_tag でも呼ばれる 353 334 | union_specifier 354 { set_no_type_name true; result = CVoidType.new } # void ã宣è¨ãããã¨ãã335 { set_no_type_name true; result = CVoidType.new } # void が宣言されたとする 355 336 | enum_specifier 356 { set_no_type_name true; result = CVoidType.new } # void ã宣è¨ãããã¨ãã337 { set_no_type_name true; result = CVoidType.new } # void が宣言されたとする 357 338 | TYPE_NAME 358 339 { set_no_type_name true; result = CDefinedType.new( val[0].val ) } 359 340 360 # mikan K&R ã®struct_or_union_specifierã«ç¸å½ããããunionã¯ä½¿ããªã, bit field ã«ã対å¿ããªã341 # mikan K&Rのstruct_or_union_specifierに相当するが、unionは使えない, bit field にも対応しない 361 342 struct_specifier # mikan 362 343 # : STRUCT struct_tag '{' … … 379 360 result = val[1] 380 361 } 381 # | STRUCT struct_tag # mikan struct_tag 㯠namespace 対å¿ãå¿ 382 è¦ 383 | struct_term struct_tag # mikan struct_tag 㯠namespace 対å¿ãå¿ 384 è¦ 362 # | STRUCT struct_tag # mikan struct_tag は namespace 対応が必要 363 | struct_term struct_tag # mikan struct_tag は namespace 対応が必要 385 364 { 386 365 StructType.set_define( false ) … … 403 382 } 404 383 405 # ãã¤ã³ã¿ä¿®é£¾åã追å384 # ポインタ修飾子を追加 406 385 struct_declaration 407 386 : declaration_specifiers struct_declarator_list ';' … … 416 395 result = val[1] 417 396 } 418 # ããããã£ã¼ã«ããèªã¿é£ã°ã397 # ビットフィールドを読み飛ばし 419 398 | declaration_specifiers struct_declarator_list ':' constant_expression ';' 420 399 { … … 427 406 result = val[1] 428 407 } 429 | union_specifier ';' # ç¡å430 | struct_specifier ';' # ç¡å431 432 433 434 # K&R ã®specifier_qualifier_listã¨åã435 # ååãã¾ãããããã£ãã®ã§type_ãä»ãã408 | union_specifier ';' # 無名 409 | struct_specifier ';' # 無名 410 411 412 413 # K&Rのspecifier_qualifier_listと同じ 414 # 名前がまぎらわしかったのでtype_を付けた 436 415 specifier_qualifier_list 437 416 : type_specifier specifier_qualifier_list … … 457 436 { result << val[2] } 458 437 459 # ããããã£ã¼ã«ãã¯ä½¿ããªã438 # ビットフィールドは使えない 460 439 struct_declarator 461 440 : declarator … … 466 445 # : UNION union_tag '{' union_declaration_list '}' 467 446 # | UNION '{' union_declaration_list '}' 468 # | UNION union_tag # mikan struct_tag 㯠namespace 対å¿ãå¿ 469 è¦ 447 # | UNION union_tag # mikan struct_tag は namespace 対応が必要 470 448 : union_term union_tag '{' union_declaration_list '}' 471 449 | union_term '{' union_declaration_list '}' 472 | union_term union_tag # mikan struct_tag 㯠namespace 対å¿ãå¿ 473 è¦ 450 | union_term union_tag # mikan struct_tag は namespace 対応が必要 474 451 475 452 union_term … … 485 462 union_declaration 486 463 : declaration_specifiers union_declarator_list ';' 487 | union_specifier ';' # ç¡å488 | struct_specifier ';' # ç¡å464 | union_specifier ';' # 無名 465 | struct_specifier ';' # 無名 489 466 490 467 union_declarator_list … … 535 512 } 536 513 | direct_declarator 537 | pointer TYPE_NAME # é¢æ°ãã¤ã³ã¿ã® typedef ãäºéå®ç¾©ã®å ´å514 | pointer TYPE_NAME # 関数ポインタの typedef が二重定義の場合 538 515 { 539 516 result = Decl.new( val[1].val ) … … 562 539 result = val[0] 563 540 } 564 | direct_declarator '(' identifier_list ')' # ããã¯ä½ã®ããã«å¿ 565 è¦ï¼ 060211 541 | direct_declarator '(' identifier_list ')' # これは何のために必要? 060211 566 542 | direct_declarator '(' ')' 567 543 { … … 599 575 : parameter_list 600 576 | parameter_list ',' '.' '.' '.' 601 # mikan å¯å¤é·ãã©ã¡ã¼ã¿, ... ã®éã®ã¹ãã¼ã¹ã許ãããï¼ææãï¼577 # mikan 可変長パラメータ, ... の間のスペースが許される(手抜き) 602 578 603 579 parameter_list … … 607 583 # { 608 584 # val[0].add_param( val[2] ) 609 # # result = val[0] ä¸è¦585 # # result = val[0] 不要 610 586 # } 611 587 612 588 613 # ãã©ã¡ã¼ã¿ä¿®é£¾åã追å589 # パラメータ修飾子を追加 614 590 parameter_declaration 615 591 : declaration_specifiers declarator … … 620 596 # } 621 597 622 # 以ä¸ã¯ã¨ã©ã¼ã¨ãã623 # | declaration_specifiers # ä»®å¼æ°ãªãã¯ãã¨ããããæ±ããªã060210598 # 以下はエラーとする 599 # | declaration_specifiers # 仮引数なしは、とりあえず扱わない 060210 624 600 # { 625 601 # unless val[0].kind_of?( VoidType ) then … … 628 604 # result = nil 629 605 # } 630 | declaration_specifiers abstract_declarator # ä»®å¼æ°ãªã631 | declaration_specifiers # ä»®å¼æ°ãªã632 633 634 identifier_list # 060211 ä¸ç¨ã«ãªã£ã606 | declaration_specifiers abstract_declarator # 仮引数なし 607 | declaration_specifiers # 仮引数なし 608 609 610 identifier_list # 060211 不用になった 635 611 : IDENTIFIER 636 612 | identifier_list ',' IDENTIFIER … … 662 638 | direct_abstract_declarator '(' parameter_type_list ')' 663 639 664 # assignment_expression ãconstant_expressionã«å¤æ´640 # assignment_expressionをconstant_expressionに変更 665 641 initializer # mikan 666 642 : assignment_expression … … 685 661 686 662 687 ########################## ããããã¯CDLç¬èª##########################688 689 # ãããã¬ãã«ã®æ§æè¦å663 ########################## ここからはCDL独自 ########################## 664 665 #トップレベルの構文規則 690 666 C_parser 691 667 : … … 703 679 | declaration 704 680 | ';' 705 | error # ã¨ã©ã¼å復ãã¤ã³ã681 | error # エラー回復ポイント 706 682 707 683 typedef … … 792 768 : _ASM { 793 769 while true 794 # ';' ã表ããã¾ã§ããã¼ã¯ã³ãèªã¿é£ã°ãã 795 # gcc ã®æ§ææ¡å¼µã«å¯¾å¿ãã¹ãã ããåç´ãªå®è£ 796 ã¨ãã¦ã';' ã¾ã§èªã¿é£ã°ãã 797 # ãã¼ã¯ã³åä½ã§èªã¿é£ã°ãã¦ããã®ã§ãæååãã³ã¡ã³ãå 798 ã® ';' ã¯å¯¾è±¡ã«ãªããªãã 770 # ';' が表れるまで、トークンを読み飛ばす。 771 # gcc の構文拡張に対応すべきだが、単純な実装として、';' まで読み飛ばす。 772 # トークン単位で読み飛ばしているので、文字列やコメント内の ';' は対象にならない。 799 773 token = next_token 800 774 if token[1].val == ";" … … 906 880 # b_asm = false 907 881 908 # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµããã誤ãåé¡ã®å¯¾ç882 # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策 909 883 TECS_LANG::set_kcode_binary 910 884 911 # 800U, 0xffLL ãªã© (æ´æ°ãªãã©ã«ã«å 912 ±éã®ä¿®é£¾å) 885 # 800U, 0xffLL など (整数リテラルに共通の修飾子) 913 886 integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?" 914 887 … … 925 898 if comment 926 899 case line 927 # ã³ã¡ã³ãçµäº900 # コメント終了 928 901 when /\A\*\// 929 902 comment = false … … 933 906 else 934 907 case line 935 # 空ç½ãããªããã»ã¹ãã£ã¬ã¯ãã£ã908 # 空白、プリプロセスディレクティブ 936 909 when /\A\s+/ 937 910 ; 938 # èå¥å911 # 識別子 939 912 when /\A[a-zA-Z_]\w*/ 940 913 word = $& 941 914 @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)] 942 # 16 é²æ°å®æ°915 # 16 進数定数 943 916 when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/ 944 917 @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)] 945 # 8 é²æ°å®æ°918 # 8 進数定数 946 919 when /\A0[0-7]+#{integer_qualifier}/ 947 920 @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)] 948 # æµ®åå°æ°å®æ°921 # 浮動小数定数 949 922 when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/ 950 923 @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)] 951 # æ´æ°å®æ°924 # 整数定数 952 925 when /\A\d+#{integer_qualifier}/ 953 926 # when /\A\d+/ 954 927 @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)] 955 # æå928 # 文字 956 929 when /\A'(?:[^'\\]|\\.)'/ 957 930 @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)] 958 # æåå959 # "#include #include #include \"../systask/logtask.cfg\" æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã931 # 文字列 932 # "#include #include #include \"../systask/logtask.cfg\" 最後の " 忘れ)で無限ループ 960 933 # when /\A"(?:[^"\\]+|\\.)*"/ 961 when /\A"(?:[^"\\]|\\.)*"/ # ããã¯ãã¾ãè¡ãããã934 when /\A"(?:[^"\\]|\\.)*"/ # これはうまく行くようだ 962 935 @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)] 963 # è¡ã³ã¡ã³ã936 # 行コメント 964 937 when /\A\/\/.*$/ 965 # èªã¿é£ã°ãã ã966 # ã³ã¡ã³ãéå§938 # 読み飛ばすだけ 939 # コメント開始 967 940 when /\A\/\*/ 968 941 comment = true … … 995 968 } 996 969 997 # çµäºã®å°970 # 終了の印 998 971 @q << nil 999 972 … … 1022 995 end 1023 996 1024 # TYPE_NAME ãã¼ã¯ã³ã¸ç½®ãæã997 # TYPE_NAME トークンへ置き換え 1025 998 if @b_no_type_name == false 1026 999 if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then … … 1031 1004 end 1032 1005 1033 if $debug then # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç)1006 if $debug then # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生) 1034 1007 locale = @@current_locale[@@generator_nest] 1035 1008 if token then … … 1061 1034 @@n_info = 0 1062 1035 1063 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼1036 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切) 1064 1037 def self.error( msg ) 1065 1038 @@n_error += 1 … … 1073 1046 end 1074 1047 1075 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼1048 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切) 1076 1049 def self.warning( msg ) 1077 1050 @@n_warning += 1 … … 1080 1053 end 1081 1054 1082 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯1055 # このメソッドは構文解析、意味解析からのみ呼出し可 1083 1056 def self.info( msg ) 1084 1057 @@n_info += 1 -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/bnf.tab.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 95 95 } 96 96 97 # æå®å '[]' å 98 ã§ã®ã¿ä½¿ç¨ã§ãããã¼ã¯ã¼ã 97 # 指定子 '[]' 内でのみ使用できるキーワード 99 98 RESERVED2 = { 100 99 # specifier … … 113 112 # port (entry) 114 113 'inline' => :INLINE, 115 'ref_desc' => :REF_DESC, # call ãå¯114 'ref_desc' => :REF_DESC, # call も可 116 115 117 116 # port (call) … … 157 156 } 158 157 159 # å帰çãªãã¼ãµã®ããã®ã¹ã¿ãã¯158 # 再帰的なパーサのためのスタック 160 159 @@generator_nest = -1 161 160 @@generator_stack = [] 162 161 @@current_locale = [] 163 162 164 # import_C ä¸ã§ãã163 # import_C 中である 165 164 @@import_C = false 166 165 167 # ãã¹ã¦ã®æ§æ解æãå®äºãã166 # すべての構文解析が完了した 168 167 @@b_end_all_parse = false 169 168 170 # tag ãªãstruct169 # tag なし struct 171 170 @@no_struct_tag_num = 0 172 171 173 172 def self.parse( file_name, plugin = nil, b_reuse = false ) 174 # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èªã¿è¾¼ã)173 # パーサインスタンスを生成(別パーサで読み込む) 175 174 parser = Generator.new 176 175 177 # plugin ãã import ããã¦ããå ´åã® plugin è¨å®176 # plugin から import されている場合の plugin 設定 178 177 parser.set_plugin plugin 179 178 180 # reuse ãã©ã°ãè¨å®179 # reuse フラグを設定 181 180 parser.set_reuse b_reuse 182 181 183 # cdl ããã¼ã¹182 # cdl をパース 184 183 parser.parse( [file_name] ) 185 184 186 # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã185 # 終期化 パーサスタックを戻す 187 186 parser.finalize 188 187 end … … 204 203 def self.get_plugin 205 204 if @@generator_stack[@@generator_nest] then 206 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil205 # tecsgen 引数の cdl が import される場合は nil 207 206 return @@generator_stack[@@generator_nest].get_plugin 208 207 else … … 221 220 def self.is_reuse? 222 221 if @@generator_stack[@@generator_nest] then 223 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil222 # tecsgen 引数の cdl が import される場合は nil 224 223 return @@generator_stack[@@generator_nest].is_reuse? 225 224 else … … 251 250 b_in_string = false 252 251 253 # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµããã誤ãåé¡ã®å¯¾ç252 # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策 254 253 TECS_LANG::set_kcode_binary 255 254 … … 261 260 TECSIO.foreach(file) {|line| 262 261 col = 1 263 # line.rstrip! æ¹è¡å«ãæååãæ±ãããã«ãªã£ãã®ã§ãããã§ç©ºç½ãåãé¤ããªããªã£ã262 # line.rstrip! 改行含む文字列を扱うようになったので、ここで空白を取り除けなくなった 264 263 265 264 until line.empty? … … 267 266 if b_in_comment 268 267 case line 269 # ã³ã¡ã³ãçµäº268 # コメント終了 270 269 when /\A\*\// 271 270 b_in_comment = false 272 271 when /\A./ 273 272 ; 274 when /\s+/ # line.rstrip! ãæ¢ãããã \n ãªã©ã®ç©ºç½æåã¨ã¾ã£ã¡ããã«ã¼ã«ãå¿ 275 è¦ã«ãªã£ã 273 when /\s+/ # line.rstrip! を止めたため \n などの空白文字とまっちするルールが必要になった 276 274 ; 277 275 end … … 281 279 @q << [:STRING_LITERAL, Token.new(string, file, lineno, col)] 282 280 b_in_string = false 283 elsif line =~ /\A.*\\\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã281 elsif line =~ /\A.*\\\n/ # 改行 \n は '.' にマッチしない 284 282 string += $& 285 elsif line =~ /\A.*\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã283 elsif line =~ /\A.*\n/ # 改行 \n は '.' にマッチしない 286 284 string += line 287 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå)285 # この位置では error メソッドは使えない (token 読出し前) 288 286 puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape" 289 287 @@n_error += 1 … … 291 289 else 292 290 case line 293 # 空ç½ãããªããã»ã¹ãã£ã¬ã¯ãã£ã291 # 空白、プリプロセスディレクティブ 294 292 when /\A\s+/ 295 293 ; 296 # èå¥å294 # 識別子 297 295 when /\A[a-zA-Z_]\w*/ 298 296 word = $& 299 297 @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)] 300 # 16 é²æ°å®æ°298 # 16 進数定数 301 299 when /\A0x[0-9A-Fa-f]+/ 302 300 @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)] 303 # 8 é²æ°å®æ°301 # 8 進数定数 304 302 when /\A0[0-7]+/ 305 303 @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)] 306 # æµ®åå°æ°å®æ°304 # 浮動小数定数 307 305 when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/ 308 306 @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)] 309 # æ´æ°å®æ°307 # 整数定数 310 308 when /\A\d+/ 311 309 @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)] 312 # æåå®æ°310 # 文字定数 313 311 when /\A'(?:[^'\\]|\\.)'/ 314 312 @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)] 315 # æåå316 # "#include #include #include \"../systask/logtask.cfg\" æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã313 # 文字列 314 # "#include #include #include \"../systask/logtask.cfg\" 最後の " 忘れ)で無限ループ 317 315 # when /\A"(?:[^"\\]+|\\.)*"/ 318 when /\A"(?:[^"\\]|\\.)*"/ # ããã¯ãã¾ãè¡ãããã316 when /\A"(?:[^"\\]|\\.)*"/ # これはうまく行くようだ 319 317 @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)] 320 # æåå (æ¹è¡ãã)318 # 文字列 (改行あり) 321 319 when /\A"(?:[^"\\]|\\.)*\\\n$/ 322 320 string = $& 323 321 b_in_string = true 324 # æåå (æ¹è¡ãã, escape ãªã)322 # 文字列 (改行あり, escape なし) 325 323 when /\A("(?:[^"\\]|\e\.)*)\n$/ 326 324 string = $1 + "\\\n" 327 325 b_in_string = true 328 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå) # mikan cdl_error ã§ã¯ãªã326 # この位置では error メソッドは使えない (token 読出し前) # mikan cdl_error ではない 329 327 puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape" 330 328 @@n_error += 1 331 # å±±æ¬å¼§ã§å²ã¾ããæåå329 # 山括弧で囲まれた文字列 332 330 # when /\A<[0-9A-Za-z_\. \/]+>/ # AB: angle bracke 333 when /\A<(?:[^>\\]|\\.)*>/ # ããã¯ãã¾ãè¡ãããã331 when /\A<(?:[^>\\]|\\.)*>/ # これはうまく行くようだ 334 332 @q << [:AB_STRING_LITERAL, Token.new($&, file, lineno, col)] 335 # è¡ã³ã¡ã³ã333 # 行コメント 336 334 when /\A\/\/.*$/ 337 # èªã¿é£ã°ãã ã338 # ã³ã¡ã³ãéå§335 # 読み飛ばすだけ 336 # コメント開始 339 337 when /\A\/\*/ 340 338 b_in_comment = true 341 # '>>', '<<' ãªã©339 # '>>', '<<' など 342 340 when /\A>>/, /\A<</, /\A==/, /\A!=/, /\A\&\&/, /\A\|\|/ 343 341 @q << [$&, Token.new($&, file, lineno, col)] 344 342 when /\A::/, /\A=>/, /\A<=/, /\A>=/ 345 343 @q << [$&, Token.new($&, file, lineno, col)] 346 # '(', ')' ãªã©ä¸æåã®è¨å·ãã¾ãã¯æªç¥ã®è¨å·344 # '(', ')' など一文字の記号、または未知の記号 347 345 when /\A./ 348 346 @q << [$&, Token.new($&, file, lineno, col)] … … 368 366 } 369 367 370 # çµäºã®å°368 # 終了の印 371 369 @q << nil 372 370 … … 388 386 389 387 if token[0] == :IDENTIFIER then 390 # TYPE_NAME ãã¼ã¯ã³ã¸ç½®æã388 # TYPE_NAME トークンへ置換え 391 389 if Namespace.is_typename?( token[1].val ) then 392 390 token[0] = :TYPE_NAME 393 391 elsif @in_specifier && RESERVED2[ token[1].val.to_s ] then 394 # æå®åãã¼ã¯ã¼ãï¼ '[', ']' å 395 ã§ã®ã¿æå¹) 392 # 指定子キーワード( '[', ']' 内でのみ有効) 396 393 token[0] = RESERVED2[ token[1].val.to_s ] 397 394 end 398 395 end 399 396 400 if $debug then # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç)397 if $debug then # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生) 401 398 locale = @@current_locale[@@generator_nest] 402 399 if token then … … 430 427 @@n_info = 0 431 428 432 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼429 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切) 433 430 def self.error( msg, *arg ) 434 431 locale = nil … … 440 437 441 438 msg = TECSMsg.get_error_message( msg ) 442 # $1, $2, ... ã arg ã§ç½®æ439 # $1, $2, ... を arg で置換 443 440 count = 1 444 441 arg.each{ |a| … … 448 445 } 449 446 450 # import_C ã®ä¸ã§ã®ã¨ã©ã¼ï¼447 # import_C の中でのエラー? 451 448 if @@import_C then 452 449 C_parser.error( msg ) 453 450 else 454 451 455 # Node ã®è¨æ¶ãã ä½ç½® (locale) ã使ç¨ããå ´åãå¤æ´ä»¥åã«æ¯ã¹ã456 # åé¡çºçç®æã¨ç°ãªãä½ç½®ã«ã¨ã©ã¼ãåºããããæ§æ解æä¸ã®ã¨ã©ã¼457 # ã¯ã解æä¸ã®ä½ç½®ãåºåããï¼(new_XXX 㧠owner ãåè¦ç´ ã®ãã§ã458 # ã¯ããã㨠owner ã®è¡çªå·ãåºã¦ãã¾ãç¹ã§ããããçãã¦ãã)452 # Node の記憶する 位置 (locale) を使用した場合、変更以前に比べ、 453 # 問題発生箇所と異なる位置にエラーが出るため、構文解析中のエラー 454 # は、解析中の位置を出力する.(new_XXX で owner が子要素のチェッ 455 # クをすると owner の行番号が出てしまう点で、ずれが生じている) 459 456 460 457 if @@b_end_all_parse == false || locale == nil then … … 469 466 end 470 467 471 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼468 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切) 472 469 def self.warning( msg, *arg ) 473 470 locale = nil … … 479 476 480 477 msg = TECSMsg.get_warning_message( msg ) 481 # $1, $2, ... ã arg ã§ç½®æ478 # $1, $2, ... を arg で置換 482 479 count = 1 483 480 arg.each{ |a| … … 487 484 } 488 485 489 # import_C ã®ä¸ã§ã®ã¦ã©ã¼ãã³ã°ï¼486 # import_C の中でのウォーニング? 490 487 if @@import_C then 491 488 C_parser.warning( msg ) … … 502 499 end 503 500 504 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯501 # このメソッドは構文解析、意味解析からのみ呼出し可 505 502 def self.info( msg, *arg ) 506 503 locale = nil … … 512 509 513 510 msg = TECSMsg.get_info_message( msg ) 514 # $1, $2, ... ã arg ã§ç½®æ511 # $1, $2, ... を arg で置換 515 512 count = 1 516 513 arg.each{ |a| … … 520 517 } 521 518 522 # import_C ã®ä¸ã§ã®ã¦ã©ã¼ãã³ã°ï¼519 # import_C の中でのウォーニング? 523 520 if @@import_C then 524 521 C_parser.info( msg ) … … 555 552 end 556 553 557 #=== '[' specifier å§ã554 #=== '[' specifier 始め 558 555 def set_in_specifier 559 556 # p "set_in_specifier" … … 561 558 end 562 559 563 #=== ']' specifier çµãã560 #=== ']' specifier 終わり 564 561 def unset_in_specifier 565 562 # p "unset_in_specifier" … … 567 564 end 568 565 569 # statement_specifier ã¯æ§æ解ééä¸ã§åç 570 §ããããã 566 # statement_specifier は構文解釈途中で参照したいため 571 567 @@statement_specifier_stack = [] 572 568 def self.add_statement_specifier( ss ) … … 585 581 end 586 582 587 #=== ãã¹ã¦ã®æ§æ解æãå®äºãããã¨ãå ±å583 #=== すべての構文解析が完了したことを報告 588 584 def self.end_all_parse 589 585 @@b_end_all_parse = true … … 2369 2365 module_eval(<<'.,.,', 'bnf.y.rb', 76) 2370 2366 def _reduce_13(val, _values, result) 2371 # é£æ¥ããæååã1ã¤ã®æååã«ã¾ã¨ãã2367 # 連接した文字列を1つの文字列にまとめる 2372 2368 str = "\"" + val[0].val.gsub( /\"(.*)\"/, "\\1" ) + val[1].val.gsub( /\"(.*)\"/, "\\1" ) + "\"" 2373 2369 result = Token.new( str, val[0].file, val[0].lineno, val[0].col ) … … 2947 2943 module_eval(<<'.,.,', 'bnf.y.rb', 379) 2948 2944 def _reduce_104(val, _values, result) 2949 # tag ãç¡ãå ´åãå 2950 é¨åãä¸ãã 2945 # tag が無い場合、内部名を与える 2951 2946 result = StructType.new( :"TAG__#{@@no_struct_tag_num}__" ) 2952 2947 @@no_struct_tag_num += 1 … … 3267 3262 def _reduce_153(val, _values, result) 3268 3263 val[0].add_param( val[2] ) 3269 # result = val[0] ä¸è¦3264 # result = val[0] 不要 3270 3265 3271 3266 result … … 3422 3417 result = val[1] 3423 3418 else 3424 # ã¨ã©ã¼ï¼ä»®ã§ val[0] ãè¿ã3419 # エラー:仮で val[0] を返す 3425 3420 result = val[0] 3426 3421 end … … 3568 3563 obj = val[3] 3569 3564 if obj.kind_of?( Cell ) || obj.kind_of?( Signature ) || obj.kind_of?( Celltype ) || obj.kind_of?( CompositeCelltype )then 3570 # cell, signature 以å¤ã¯ãæå®åãç½®ããªã3565 # cell, signature 以外は、指定子を置けない 3571 3566 else 3572 Generator.get_statement_specifier # ã¯ãªã¢3567 Generator.get_statement_specifier # クリア 3573 3568 Generator.error( "G1009 unexpected specifier" ) 3574 3569 end … … 3941 3936 val[1].check 3942 3937 else 3943 # mikan é¢æ°ã®é 3944 åã以ä¸ã®ã¡ãã»ã¼ã¸ã«ãªã 3938 # mikan 関数の配列も以下のメッセージになる 3945 3939 Generator.error( "G1010 Not function" ) 3946 3940 result = nil … … 3997 3991 def _reduce_265(val, _values, result) 3998 3992 if val[3].kind_of? Port then 3999 val[3].set_specifier val[1] # è¨å®é åºãã3993 val[3].set_specifier val[1] # 設定順序あり 4000 3994 Celltype.new_port( val[3] ) 4001 3995 else 4002 # Port 以å¤ã§ã¯æå®åã¯ã¨ã©ã¼3996 # Port 以外では指定子はエラー 4003 3997 Generator.error( "G1012 $1 : cannot put specifier here" , val[1] ) 4004 3998 end … … 4205 4199 def _reduce_298(val, _values, result) 4206 4200 val[3].each{ |i| # i:Decl 4207 i.set_kind( :ATTRIBUTE ) # è¨å®é åºãã4201 i.set_kind( :ATTRIBUTE ) # 設定順序あり 4208 4202 i.set_specifier_list( [val[1]] ) 4209 4203 i.check … … 4287 4281 def _reduce_309(val, _values, result) 4288 4282 val[3].each{ |i| # i:Decl 4289 i.set_kind( :VAR ) # è¨å®é åºãã4283 i.set_kind( :VAR ) # 設定順序あり 4290 4284 i.set_specifier_list( [val[1]] ) 4291 4285 i.check … … 4568 4562 def _reduce_354(val, _values, result) 4569 4563 if val[0].kind_of?( Port ) then 4570 CompositeCelltype.new_port( val[0] ) # é 4571 延ãã¦ç»é² 4564 CompositeCelltype.new_port( val[0] ) # 遅延して登録 4572 4565 end 4573 4566 … … 4579 4572 def _reduce_355(val, _values, result) 4580 4573 if val[3].kind_of?( Port ) then 4581 # port ä»¥å¤ val[3] ã«æå¹ãªå¤ãå 4582 ¥ã£ã¦ããªãã®ã§ã以ä¸ã®ã¡ã½ãããé©ç¨ã§ããªã 4583 # ç¾ç¶ port, cell 以å¤ã¯æå®åãåãä»ããªã 4584 # ï¼ãããå°æ¥ä»ã®æãæå®åãåãä»ããå¯è½æ§ãããã®ã§ããã®ä½ç½®ã«è¨è¿°ããï¼ 4574 # port 以外 val[3] に有効な値が入っていないので、以下のメソッドを適用できない 4575 # 現状 port, cell 以外は指定子を受け付けない 4576 # (しかし将来他の文も指定子を受け付ける可能性があるので、この位置に記述する) 4585 4577 val[3].set_specifier( Generator.get_statement_specifier ) 4586 CompositeCelltype.new_port( val[3] ) # é 4587 延ãã¦ç»é² (set_specifier å¾) 4578 CompositeCelltype.new_port( val[3] ) # 遅延して登録 (set_specifier 後) 4588 4579 elsif val[3].kind_of?( Cell ) then 4589 # Cell.end_of_parse ã«ã¦è¨å®4580 # Cell.end_of_parse にて設定 4590 4581 else 4591 Generator.get_statement_specifier # ã¯ãªã¢4582 Generator.get_statement_specifier # クリア 4592 4583 Generator.error( "G1013 unexpected specifier" ) 4593 4584 end … … 4877 4868 if obj.kind_of?( Cell ) then 4878 4869 else 4879 Generator.get_statement_specifier # ã¯ãªã¢4870 Generator.get_statement_specifier # クリア 4880 4871 Generator.error( "G9999 unexpected specifier" ) 4881 4872 end … … 5102 5093 5103 5094 5104 # ãã¡ã¤ã« => INCLUDE("header")ã®é 5105 å 5095 # ファイル => INCLUDE("header")の配列 5106 5096 Include = Hash.new {|hash, key| hash[key] = []} 5107 5097 … … 5157 5147 5158 5148 #= TECSIO 5159 # Ruby2.0(1.9) 対å¿ã«ä¼´ãå°å 5160 ¥ããã¯ã©ã¹ 5161 # SJIS 以å¤ã§ã¯ãASCII-8BIT ã¨ãã¦å 5162 ¥åãã 5149 # Ruby2.0(1.9) 対応に伴い導入したクラス 5150 # SJIS 以外では、ASCII-8BIT として入力する 5163 5151 class TECSIO 5164 def self.foreach(file) # ãããã¯å¼æ° { |line| } 5165 pr = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°ã pr ã«ä»£å 5166 ¥ 5152 def self.foreach(file) # ブロック引数 { |line| } 5153 pr = Proc.new # このメソッドのブロック引数を pr に代入 5167 5154 if $b_no_kcode then 5168 5155 msg = "E".encode $Ruby19_File_Encode 5169 5156 if( $Ruby19_File_Encode == "Shift_JIS" ) 5170 5157 5171 # Shift JIS ã¯ããã£ãã Windows-31J ã¨ãã¦èªã¿è¾¼ã¾ããShift_JIS ã«å¤æãããï¼5172 # ã³ã¡ã³ãçã«å«ã¾ãã SJIS ã«ä¸é©åãªæåã³ã¼ã㯠'?' ã¾ã㯠REPLACEMENT CHARACTER ã«å¤æãããï¼5173 # EUC ã UTF-8 ã§è¨è¿°ããã CDL ãæ··å¨ãã¦ãã¦ããRuby ä¾å¤ãçºçãããã¨ãªãå¦çãé²ãããã¨ãã§ããï¼5174 # æåã³ã¼ãæå®ã SJIS ã§ãã£ã¦ãæååãªãã©ã«ã®ä¸ã«ãæåã³ã¼ããSJIS 以å¤ã®é ASCII ãå«ã¾ãã¦ããå ´åã5175 # Ruby 1.8 ã® tecsgen ã§ã¯æåã³ã¼ãæå®ã«å½±é¿ãªãå¦çããããã®ããRuby 1.9 以éã§ã¯ '?' ã«ç½®ãæããå¯è½æ§ãããï¼5158 # Shift JIS は、いったん Windows-31J として読み込ませ、Shift_JIS に変換させる. 5159 # コメント等に含まれる SJIS に不適切な文字コードは '?' または REPLACEMENT CHARACTER に変換される. 5160 # EUC や UTF-8 で記述された CDL が混在していても、Ruby 例外が発生することなく処理を進めることができる. 5161 # 文字コード指定が SJIS であって、文字列リテラルの中に、文字コードがSJIS 以外の非 ASCII が含まれている場合、 5162 # Ruby 1.8 の tecsgen では文字コード指定に影響なく処理されたものが、Ruby 1.9 以降では '?' に置き換わる可能性がある. 5176 5163 5177 5164 mode = "r:Windows-31J" … … 5197 5184 end 5198 5185 5199 #=== æåã³ã¼ããç¸éããå ´åä¸è´ããã5200 # msg 㨠str ã®æåã³ã¼ããç¸éããå ´åãstr ã msg ã®æåã³ã¼ãã«å¤æãã5201 # å¤æä¸å¯ã®æåã³ã¼ã㯠'?' (utf-8 ã®å ´å U+FFFD (REPLACEMENT CHARACTER )) ã«å¤æ5186 #=== 文字コードが相違する場合一致させる 5187 # msg と str の文字コードが相違する場合、str を msg の文字コードに変換する 5188 # 変換不可の文字コードは '?' (utf-8 の場合 U+FFFD (REPLACEMENT CHARACTER )) に変換 5202 5189 # 5203 # ãã®ã¡ã½ããã¯ãã¨ã©ã¼ã¡ãã»ã¼ã¸åºåã§ã使ç¨ããã¦ãããã¨ã«æ³¨æï¼5190 # このメソッドは、エラーメッセージ出力でも使用されていることに注意. 5204 5191 # 5205 5192 #msg_enc::Encode | String 5206 5193 def self.str_code_convert( msg, str ) 5207 5194 if $b_no_kcode == false then 5208 return str # Ruby V1.8 ã¾ã§5195 return str # Ruby V1.8 まで 5209 5196 end 5210 5197 if msg.encoding != str.encoding then 5211 option = { :invalid => :replace, :undef => :replace } # ä¾å¤ãçºçãããã'?' ã«å¤æãã(utf-8 ã¯0xfffd)5198 option = { :invalid => :replace, :undef => :replace } # 例外を発生させず、'?' に変換する(utf-8 は 0xfffd) 5212 5199 # return str.encode( msg.encoding, option ) 5213 5200 str = str.encode( "utf-8", option ) -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/bnf.y.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2018 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 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 '{' … … 397 378 | STRUCT 398 379 { 399 # tag ãç¡ãå ´åãå 400 é¨åãä¸ãã 380 # tag が無い場合、内部名を与える 401 381 result = StructType.new( :"TAG__#{@@no_struct_tag_num}__" ) 402 382 @@no_struct_tag_num += 1 … … 408 388 result = val[1] 409 389 } 410 | STRUCT struct_tag # mikan struct_tag 㯠namespace 対å¿ãå¿ 411 è¦ 390 | STRUCT struct_tag # mikan struct_tag は namespace 対応が必要 412 391 { 413 392 StructType.set_define( false ) … … 424 403 { result = StructType.new( val[0].val ) } 425 404 426 # ãã¤ã³ã¿ä¿®é£¾åã追å405 # ポインタ修飾子を追加 427 406 struct_declaration 428 407 : type_specifier_qualifier_list struct_declarator_list ';' … … 459 438 460 439 461 # K&R ã®specifier_qualifier_listã¨åã462 # ååãã¾ãããããã£ãã®ã§type_ãä»ãã440 # K&Rのspecifier_qualifier_listと同じ 441 # 名前がまぎらわしかったのでtype_を付けた 463 442 type_specifier_qualifier_list 464 # Oyama type_specifier ãç¹°ãè¿ãã¦æå®ãããã¨ã¯ãªããªã£ã (sign_int_type ã¨ããããï¼443 # Oyama type_specifier を繰り返して指定することはなくなった (sign_int_type としたため) 465 444 # : type_specifier type_specifier_qualifier_list 466 445 : type_specifier … … 470 449 result = val[1] 471 450 } 472 # mikan Oyama type_qualifier ã ãã§ã¯åæå®ã«ãªããªã : æ§æã¨ã©ã¼ã¨ãããããæå³ã¨ã©ã¼ã¨ããæ¹ã親å451 # mikan Oyama type_qualifier だけでは型指定にならない : 構文エラーとするより、意味エラーとした方が親切 473 452 # | type_qualifier 474 453 … … 480 459 { result << val[2] } 481 460 482 # ããããã£ã¼ã«ãã¯ä½¿ããªã461 # ビットフィールドは使えない 483 462 struct_declarator 484 463 : declarator 485 464 486 # enum ã®ç¨®é¡ã追å465 # enumの種類を追加 487 466 enum_specifier # mikan 488 467 : enum_type '{' enumerator_list '}' … … 538 517 result = val[0] 539 518 } 540 # | direct_declarator '(' identifier_list ')' # ããã¯ä½ã®ããã«å¿ 541 è¦ï¼ 060211 519 # | direct_declarator '(' identifier_list ')' # これは何のために必要? 060211 542 520 | direct_declarator '(' ')' 543 521 { … … 572 550 : parameter_list 573 551 | parameter_list ',' '...' 574 # mikan å¯å¤é·ãã©ã¡ã¼ã¿552 # mikan 可変長パラメータ 575 553 576 554 parameter_list … … 580 558 { 581 559 val[0].add_param( val[2] ) 582 # result = val[0] ä¸è¦583 } 584 585 586 # ãã©ã¡ã¼ã¿ä¿®é£¾åã追å560 # result = val[0] 不要 561 } 562 563 564 # パラメータ修飾子を追加 587 565 parameter_declaration 588 566 # : spec_L parameter_specifier_list spec_R declaration_specifiers declarator … … 595 573 } 596 574 597 # 以ä¸ã¯ã¨ã©ã¼ã¨ãã598 | declaration_specifiers declarator # parameter_specifier ãªãã¯æ±ããªã575 # 以下はエラーとする 576 | declaration_specifiers declarator # parameter_specifier なしは扱わない 599 577 { 600 578 Generator.error( "G1001 need specifier for \'$1\'" , val[1].get_name ) 601 579 result = nil 602 580 } 603 | declaration_specifiers # ä»®å¼æ°ãªãã¯ãã¨ããããæ±ããªã060210581 | declaration_specifiers # 仮引数なしは、とりあえず扱わない 060210 604 582 { 605 583 unless val[0].instance_of?( VoidType ) then … … 608 586 result = nil 609 587 } 610 # | '[' parameter_specifier_list ']' declaration_specifiers # å060210611 | parameter_specifier_list_bracket declaration_specifiers # å060210588 # | '[' parameter_specifier_list ']' declaration_specifiers # 同 060210 589 | parameter_specifier_list_bracket declaration_specifiers # 同 060210 612 590 { 613 591 unless val[1].instance_of?( VoidType ) then … … 650 628 result = val[1] 651 629 else 652 # ã¨ã©ã¼ï¼ä»®ã§ val[0] ãè¿ã630 # エラー:仮で val[0] を返す 653 631 result = val[0] 654 632 end 655 633 } 656 # mikan abstract_declarator ã pointer 以å¤ã§ã¯ãã¾ãåããªããã¨ãããã '*' CAST ã®ã¿æã£ã634 # mikan abstract_declarator が pointer 以外ではうまく動かない、とりあえず '*' CAST のみ救った 657 635 658 636 abstract_declarator # mikan … … 663 641 direct_abstract_declarator 664 642 : '(' abstract_declarator ')' 665 { result = val[1] } # é¢æ°ãã¤ã³ã¿åãæã643 { result = val[1] } # 関数ポインタ型を救う 666 644 | '[' ']' 667 645 { … … 702 680 } 703 681 704 # assignment_expression ãconstant_expressionã«å¤æ´682 # assignment_expressionをconstant_expressionに変更 705 683 initializer # mikan 706 684 : constant_expression … … 726 704 727 705 728 ########################## ããããã¯CDLç¬èª##########################729 730 # ãããã¬ãã«ã®æ§æè¦å731 # ã³ã³ãã¼ãã³ãè¨è¿°706 ########################## ここからはCDL独自 ########################## 707 708 #トップレベルの構文規則 709 #コンポーネント記述 732 710 component_description 733 711 : component_description specified_statement … … 742 720 obj = val[3] 743 721 if obj.kind_of?( Cell ) || obj.kind_of?( Signature ) || obj.kind_of?( Celltype ) || obj.kind_of?( CompositeCelltype )then 744 # cell, signature 以å¤ã¯ãæå®åãç½®ããªã722 # cell, signature 以外は、指定子を置けない 745 723 else 746 Generator.get_statement_specifier # ã¯ãªã¢724 Generator.get_statement_specifier # クリア 747 725 Generator.error( "G1009 unexpected specifier" ) 748 726 end 749 727 } 750 # ããã¨åãè¨è¿°ã composite_celltype ã«ããã728 # これと同じ記述が composite_celltype にもある 751 729 752 730 statement … … 764 742 | import_C 765 743 | generate_statement 766 | error # ã¨ã©ã¼å復ãã¤ã³ã744 | error # エラー回復ポイント 767 745 768 746 … … 803 781 | IDENTIFIER '[' constant_expression ']' '.' IDENTIFIER '.' IDENTIFIER '=' initializer 804 782 { result = [ :NORMAL_ALLOC, val[0], val[2], val[5], val[7], val[9] ] } 805 # mikan å°æ¥çãªæ¡å¼µ ('*' ã§ã¾ã¨ãã¦æå®å¯è½ã¨ãã)783 # mikan 将来的な拡張 ('*' でまとめて指定可能とする) 806 784 # | IDENTIFIER '.' IDENTIFIER '.' '*' '=' initializer 807 785 # { result = [ val[0], val[ ], val[ ], val[ ] ] } … … 828 806 829 807 const_statement 830 : declaration # å®æ°å®ç¾©808 : declaration # 定数定義 831 809 { 832 810 val[0].each { |decl| … … 883 861 } 884 862 } 885 # mikan typedef_specifier æªå¦ç½®863 # mikan typedef_specifier 未処置 886 864 887 865 … … 903 881 : IDENTIFIER 904 882 {result = Namespace.new(val[0].val)} 905 # namespace ã¤ã³ã¹ã¿ã³ã¹ã« statement ãè¨æ¶ãããããããã§çæ883 # namespace インスタンスに statement を記憶させるためここで生成 906 884 907 885 statement_list … … 915 893 { result = val[0].append!( val[2].val ) } 916 894 917 # ã·ã°ããã£895 #シグニチャ 918 896 signature 919 897 : SIGNATURE signature_name '{' function_head_list '}' ';' … … 924 902 {result = Signature.new( val[0].val ) } 925 903 926 function_head_list # result: function_head ã®é 927 å 904 function_head_list # result: function_head の配列 928 905 # : function_head 929 906 # { result = NamedList.new( val[0], "function" ) } … … 942 919 val[1].check 943 920 else 944 # mikan é¢æ°ã®é 945 åã以ä¸ã®ã¡ãã»ã¼ã¸ã«ãªã 921 # mikan 関数の配列も以下のメッセージになる 946 922 Generator.error( "G1010 Not function" ) 947 923 result = nil … … 959 935 960 936 961 # ã»ã«ã¿ã¤ã937 #セルタイプ 962 938 celltype 963 939 : CELLTYPE celltype_name '{' celltype_statement_list '}' ';' … … 985 961 { 986 962 if val[3].kind_of? Port then 987 val[3].set_specifier val[1] # è¨å®é åºãã963 val[3].set_specifier val[1] # 設定順序あり 988 964 Celltype.new_port( val[3] ) 989 965 else 990 # Port 以å¤ã§ã¯æå®åã¯ã¨ã©ã¼966 # Port 以外では指定子はエラー 991 967 Generator.error( "G1012 $1 : cannot put specifier here" , val[1] ) 992 968 end … … 999 975 | require 1000 976 | factory 1001 # | error # ã¨ã©ã¼å復ãã¤ã³ã (#513 ç¡éã«ã¼ãã«é¥ãã±ã¼ã¹ãããã®ã§ãããã§ã®ã¨ã©ã¼å復ã¯åããã)977 # | error # エラー回復ポイント (#513 無限ループに陥るケースがあるので、ここでのエラー回復は取りやめ) 1002 978 1003 979 celltype_statement_specifier_list … … 1016 992 1017 993 alloc_list2 1018 : alloc2 { result = [ val[0] ] } # åãå£ã®ã¢ãã±ã¼ã¿æå® 1019 | alloc { result = [ val[0] ] } # å 1020 é¨ã»ã«ã®ã¢ãã±ã¼ã¿æå® 994 : alloc2 { result = [ val[0] ] } # 受け口のアロケータ指定 995 | alloc { result = [ val[0] ] } # 内部セルのアロケータ指定 1021 996 | alloc_list2 ',' alloc2 { result << val[2] } 1022 997 | alloc_list2 ',' alloc { result << val[2] } 1023 998 1024 999 alloc2 1025 : IDENTIFIER '.' IDENTIFIER '=' initializer # å 1026 é¨ã¢ãã±ã¼ã¿ (ãããã©åãã¢ãã±ã¼ã¿)æå® 1000 : IDENTIFIER '.' IDENTIFIER '=' initializer # 内部アロケータ (デバドラ向きアロケータ)指定 1027 1001 { result = [ :INTERNAL_ALLOC, val[0].val, val[2].val, val[4] ] } 1028 | IDENTIFIER '.' IDENTIFIER '<=' initializer # å¤æ®µãªã¬ã¼ã¢ãã«åãã¢ãã±ã¼ã¿æå®1002 | IDENTIFIER '.' IDENTIFIER '<=' initializer # 多段リレーモデル向きアロケータ指定 1029 1003 { result = [ :RELAY_ALLOC, val[0].val, val[2].val, val[4] ] } 1030 1004 1031 1005 1032 # å¼ã³å£ãåãå£1006 #呼び口、受け口 1033 1007 port 1034 1008 : port_type namespace_signature_name port_name ';' … … 1056 1030 1057 1031 1058 # å±æ§1032 #属性 1059 1033 attribute 1060 1034 : ATTRIBUTE '{' attribute_declaration_list '}' ';' … … 1080 1054 { 1081 1055 val[3].each{ |i| # i:Decl 1082 i.set_kind( :ATTRIBUTE ) # è¨å®é åºãã1056 i.set_kind( :ATTRIBUTE ) # 設定順序あり 1083 1057 i.set_specifier_list( [val[1]] ) 1084 1058 i.check … … 1099 1073 : STRING_LITERAL 1100 1074 1101 #å 1102 é¨å¤æ° 1075 #内部変数 1103 1076 var 1104 1077 : VAR '{' var_declaration_list '}' ';' … … 1122 1095 { 1123 1096 val[3].each{ |i| # i:Decl 1124 i.set_kind( :VAR ) # è¨å®é åºãã1097 i.set_kind( :VAR ) # 設定順序あり 1125 1098 i.set_specifier_list( [val[1]] ) 1126 1099 i.check … … 1132 1105 : SIZE_IS '(' expression ')' { result = [:SIZE_IS,val[2]] } 1133 1106 1134 # ãªã¯ã¯ã¤ã¢1107 # リクワイア 1135 1108 require 1136 1109 : REQUIRE namespace_identifier '.' IDENTIFIER';' # mikan namespace #1 … … 1143 1116 } 1144 1117 1145 # ãã¡ã¯ããª1118 #ファクトリ 1146 1119 factory 1147 1120 : factory_head '{' factory_function_list '}' ';' … … 1152 1125 1153 1126 factory_function_list 1154 : # 空1127 : # 空 1155 1128 | factory_function_list factory_function 1156 1129 … … 1164 1137 : IDENTIFIER 1165 1138 1166 arg_list # factory ã® write é¢æ°ã®ç¬¬ä¸å¼æ°ä»¥é1139 arg_list # factory の write 関数の第三引数以降 1167 1140 : IDENTIFIER 1168 1141 { result = [ [ :IDENTIFIER, val[0].val ] ] } … … 1174 1147 { result << [ :STRING_LITERAL, val[2].val ] } 1175 1148 1176 # ã»ã«çæ1149 #セル生成 1177 1150 cell 1178 1151 : CELL namespace_celltype_name cell_name '{' … … 1180 1153 join_list '}' ';' 1181 1154 { result = Cell.end_of_parse true } 1182 | CELL namespace_celltype_name cell_name ';' # oyama ãããã¿ã¤ã宣è¨1155 | CELL namespace_celltype_name cell_name ';' # oyama プロトタイプ宣言 1183 1156 { result = Cell.end_of_parse false } 1184 1157 … … 1192 1165 1193 1166 join_list 1194 : # 空è¡0610071167 : # 空行 061007 1195 1168 | join_list specified_join 1196 1169 | join_list reverse_join … … 1235 1208 Cell.new_join( result, true ) 1236 1209 } 1237 | cae_name '=' initializer ';' # åæååï¼ '{', '}' ãå¯1210 | cae_name '=' initializer ';' # 初期化子: '{', '}' も可 1238 1211 { 1239 1212 result = Join.new( val[0].val, nil, val[2] ) … … 1279 1252 : constant_expression 1280 1253 1281 # è¤å種1254 #複合種 1282 1255 composite_celltype 1283 1256 : COMPOSITE composite_celltype_name '{' composite_celltype_statement_list '}' ';' … … 1299 1272 { 1300 1273 if val[0].kind_of?( Port ) then 1301 CompositeCelltype.new_port( val[0] ) # é 1302 延ãã¦ç»é² 1274 CompositeCelltype.new_port( val[0] ) # 遅延して登録 1303 1275 end 1304 1276 } … … 1306 1278 { 1307 1279 if val[3].kind_of?( Port ) then 1308 # port ä»¥å¤ val[3] ã«æå¹ãªå¤ãå 1309 ¥ã£ã¦ããªãã®ã§ã以ä¸ã®ã¡ã½ãããé©ç¨ã§ããªã 1310 # ç¾ç¶ port, cell 以å¤ã¯æå®åãåãä»ããªã 1311 # ï¼ãããå°æ¥ä»ã®æãæå®åãåãä»ããå¯è½æ§ãããã®ã§ããã®ä½ç½®ã«è¨è¿°ããï¼ 1280 # port 以外 val[3] に有効な値が入っていないので、以下のメソッドを適用できない 1281 # 現状 port, cell 以外は指定子を受け付けない 1282 # (しかし将来他の文も指定子を受け付ける可能性があるので、この位置に記述する) 1312 1283 val[3].set_specifier( Generator.get_statement_specifier ) 1313 CompositeCelltype.new_port( val[3] ) # é 1314 延ãã¦ç»é² (set_specifier å¾) 1284 CompositeCelltype.new_port( val[3] ) # 遅延して登録 (set_specifier 後) 1315 1285 elsif val[3].kind_of?( Cell ) then 1316 # Cell.end_of_parse ã«ã¦è¨å®1286 # Cell.end_of_parse にて設定 1317 1287 else 1318 Generator.get_statement_specifier # ã¯ãªã¢1288 Generator.get_statement_specifier # クリア 1319 1289 Generator.error( "G1013 unexpected specifier" ) 1320 1290 end … … 1326 1296 | internal_cell 1327 1297 | export_join 1328 # | error # ã¨ã©ã¼å復ãã¤ã³ã (#513 ç¡éã«ã¼ãã«é¥ãã±ã¼ã¹ãããã®ã§ãããã§ã®ã¨ã©ã¼å復ã¯åããã)1298 # | error # エラー回復ポイント (#513 無限ループに陥るケースがあるので、ここでのエラー回復は取りやめ) 1329 1299 1330 1300 composite_celltype_statement_specifier_list … … 1354 1324 } 1355 1325 1356 # å±æ§1326 #属性 1357 1327 composite_attribute 1358 1328 : ATTRIBUTE '{' composite_attribute_declaration_list '}' ';' … … 1385 1355 1386 1356 internal_join_list 1387 : # 空è¡0610071357 : # 空行 061007 1388 1358 | internal_join_list specified_join 1389 1359 | internal_join_list external_join 1390 1360 | internal_join_list reverse_join 1391 1361 1392 external_join # cell å 1393 ã«è¨è¿°ããå¼ã³å£ã®å¤é¨çµå 1362 external_join # cell 内に記述する呼び口の外部結合 1394 1363 : internal_cell_elem_name '=>' COMPOSITE '.' export_name ';' 1395 1364 { Cell.external_join( val[0].val, val[4].val, true ) } 1396 1365 | internal_cell_elem_name '=>' export_name ';' 1397 1366 { Cell.external_join( val[0].val, val[2].val, false ) } 1398 # 以åã®ææ³ã§ã¯ãå¼ã³å£å´ã cell ã®å¤ã«è¨è¿°ãã¦ãã 1399 # ãã®æã®å®è£ 1400 ã 1401 1402 export_join # cell å¤ã«è¨è¿°ããåãå£ã®å¤é¨çµå 1367 # 以前の文法では、呼び口側も cell の外に記述していた 1368 # その時の実装を 1369 1370 export_join # cell 外に記述する受け口の外部結合 1403 1371 : export_name '=>' internal_ref_cell_name '.' internal_cell_elem_name ';' 1404 1372 { … … 1421 1389 : IDENTIFIER 1422 1390 1423 # ãªã¼ã¸ã§ã³1391 # リージョン 1424 1392 region 1425 1393 : spec_L region_specifier_list spec_R REGION region_name '{' region_statement '}' ';' … … 1436 1404 : IN_THROUGH '(' plugin_name ',' plugin_arg ')' 1437 1405 { Region.new_in_through( val[2].val, val[4].val ) } 1438 | IN_THROUGH '(' ')' # in 許å¯1406 | IN_THROUGH '(' ')' # in 許可 1439 1407 { Region.new_in_through } 1440 1408 | OUT_THROUGH '(' plugin_name ',' plugin_arg ')' 1441 1409 { Region.new_out_through( val[2].val, val[4].val ) } 1442 | OUT_THROUGH '(' ')' # out 許å¯1410 | OUT_THROUGH '(' ')' # out 許可 1443 1411 { Region.new_out_through() } 1444 1412 | TO_THROUGH '(' namespace_region_name ',' plugin_name ',' plugin_arg ')' 1445 1413 { Region.new_to_through( val[2], val[4].val, val[6].val ) } 1446 | TO_THROUGH '('namespace_region_name ')' # to 許å¯1414 | TO_THROUGH '('namespace_region_name ')' # to 許可 1447 1415 { Region.new_to_through( val[2], nil, nil ) } 1448 1416 | NODE … … 1471 1439 if obj.kind_of?( Cell ) then 1472 1440 else 1473 Generator.get_statement_specifier # ã¯ãªã¢1441 Generator.get_statement_specifier # クリア 1474 1442 Generator.error( "G9999 unexpected specifier" ) 1475 1443 end … … 1490 1458 namespace_region_name 1491 1459 : :IDENTIFIER 1492 { result = [ val[0].val ] } # mikan é 1493 åã§ããå¿ 1494 è¦ã¯ãªã 1460 { result = [ val[0].val ] } # mikan 配列である必要はない 1495 1461 # : namespace_identifier 1496 1462 1497 # æå®åã®æ¬å¼§ (in, out ãªã©ã®ãã¼ã¯ã¼ãåãæ¿ãã®ããåé¢)1463 # 指定子の括弧 (in, out などのキーワード切り替えのため分離) 1498 1464 spec_L 1499 1465 : '[' { set_in_specifier } … … 1652 1618 } 1653 1619 1654 # æå®å '[]' å 1655 ã§ã®ã¿ä½¿ç¨ã§ãããã¼ã¯ã¼ã 1620 # 指定子 '[]' 内でのみ使用できるキーワード 1656 1621 RESERVED2 = { 1657 1622 # specifier … … 1670 1635 # port (entry) 1671 1636 'inline' => :INLINE, 1672 'ref_desc' => :REF_DESC, # call ãå¯1637 'ref_desc' => :REF_DESC, # call も可 1673 1638 1674 1639 # port (call) … … 1714 1679 } 1715 1680 1716 # å帰çãªãã¼ãµã®ããã®ã¹ã¿ãã¯1681 # 再帰的なパーサのためのスタック 1717 1682 @@generator_nest = -1 1718 1683 @@generator_stack = [] 1719 1684 @@current_locale = [] 1720 1685 1721 # import_C ä¸ã§ãã1686 # import_C 中である 1722 1687 @@import_C = false 1723 1688 1724 # ãã¹ã¦ã®æ§æ解æãå®äºãã1689 # すべての構文解析が完了した 1725 1690 @@b_end_all_parse = false 1726 1691 1727 # tag ãªãstruct1692 # tag なし struct 1728 1693 @@no_struct_tag_num = 0 1729 1694 1730 1695 def self.parse( file_name, plugin = nil, b_reuse = false ) 1731 # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èªã¿è¾¼ã)1696 # パーサインスタンスを生成(別パーサで読み込む) 1732 1697 parser = Generator.new 1733 1698 1734 # plugin ãã import ããã¦ããå ´åã® plugin è¨å®1699 # plugin から import されている場合の plugin 設定 1735 1700 parser.set_plugin plugin 1736 1701 1737 # reuse ãã©ã°ãè¨å®1702 # reuse フラグを設定 1738 1703 parser.set_reuse b_reuse 1739 1704 1740 # cdl ããã¼ã¹1705 # cdl をパース 1741 1706 parser.parse( [file_name] ) 1742 1707 1743 # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã1708 # 終期化 パーサスタックを戻す 1744 1709 parser.finalize 1745 1710 end … … 1761 1726 def self.get_plugin 1762 1727 if @@generator_stack[@@generator_nest] then 1763 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil1728 # tecsgen 引数の cdl が import される場合は nil 1764 1729 return @@generator_stack[@@generator_nest].get_plugin 1765 1730 else … … 1778 1743 def self.is_reuse? 1779 1744 if @@generator_stack[@@generator_nest] then 1780 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil1745 # tecsgen 引数の cdl が import される場合は nil 1781 1746 return @@generator_stack[@@generator_nest].is_reuse? 1782 1747 else … … 1808 1773 b_in_string = false 1809 1774 1810 # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµããã誤ãåé¡ã®å¯¾ç1775 # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策 1811 1776 TECS_LANG::set_kcode_binary 1812 1777 … … 1818 1783 TECSIO.foreach(file) {|line| 1819 1784 col = 1 1820 # line.rstrip! æ¹è¡å«ãæååãæ±ãããã«ãªã£ãã®ã§ãããã§ç©ºç½ãåãé¤ããªããªã£ã1785 # line.rstrip! 改行含む文字列を扱うようになったので、ここで空白を取り除けなくなった 1821 1786 1822 1787 until line.empty? … … 1824 1789 if b_in_comment 1825 1790 case line 1826 # ã³ã¡ã³ãçµäº1791 # コメント終了 1827 1792 when /\A\*\// 1828 1793 b_in_comment = false 1829 1794 when /\A./ 1830 1795 ; 1831 when /\s+/ # line.rstrip! ãæ¢ãããã \n ãªã©ã®ç©ºç½æåã¨ã¾ã£ã¡ããã«ã¼ã«ãå¿ 1832 è¦ã«ãªã£ã 1796 when /\s+/ # line.rstrip! を止めたため \n などの空白文字とまっちするルールが必要になった 1833 1797 ; 1834 1798 end … … 1838 1802 @q << [:STRING_LITERAL, Token.new(string, file, lineno, col)] 1839 1803 b_in_string = false 1840 elsif line =~ /\A.*\\\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã1804 elsif line =~ /\A.*\\\n/ # 改行 \n は '.' にマッチしない 1841 1805 string += $& 1842 elsif line =~ /\A.*\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã1806 elsif line =~ /\A.*\n/ # 改行 \n は '.' にマッチしない 1843 1807 string += line 1844 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå)1808 # この位置では error メソッドは使えない (token 読出し前) 1845 1809 puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape" 1846 1810 @@n_error += 1 … … 1848 1812 else 1849 1813 case line 1850 # 空ç½ãããªããã»ã¹ãã£ã¬ã¯ãã£ã1814 # 空白、プリプロセスディレクティブ 1851 1815 when /\A\s+/ 1852 1816 ; 1853 # èå¥å1817 # 識別子 1854 1818 when /\A[a-zA-Z_]\w*/ 1855 1819 word = $& 1856 1820 @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)] 1857 # 16 é²æ°å®æ°1821 # 16 進数定数 1858 1822 when /\A0x[0-9A-Fa-f]+/ 1859 1823 @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)] 1860 # 8 é²æ°å®æ°1824 # 8 進数定数 1861 1825 when /\A0[0-7]+/ 1862 1826 @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)] 1863 # æµ®åå°æ°å®æ°1827 # 浮動小数定数 1864 1828 when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/ 1865 1829 @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)] 1866 # æ´æ°å®æ°1830 # 整数定数 1867 1831 when /\A\d+/ 1868 1832 @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)] 1869 # æåå®æ°1833 # 文字定数 1870 1834 when /\A'(?:[^'\\]|\\.)'/ 1871 1835 @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)] 1872 # æåå1873 # "#include #include #include \"../systask/logtask.cfg\" æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã1836 # 文字列 1837 # "#include #include #include \"../systask/logtask.cfg\" 最後の " 忘れ)で無限ループ 1874 1838 # when /\A"(?:[^"\\]+|\\.)*"/ 1875 when /\A"(?:[^"\\]|\\.)*"/ # ããã¯ãã¾ãè¡ãããã1839 when /\A"(?:[^"\\]|\\.)*"/ # これはうまく行くようだ 1876 1840 @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)] 1877 # æåå (æ¹è¡ãã)1841 # 文字列 (改行あり) 1878 1842 when /\A"(?:[^"\\]|\\.)*\\\n$/ 1879 1843 string = $& 1880 1844 b_in_string = true 1881 # æåå (æ¹è¡ãã, escape ãªã)1845 # 文字列 (改行あり, escape なし) 1882 1846 when /\A("(?:[^"\\]|\e\.)*)\n$/ 1883 1847 string = $1 + "\\\n" 1884 1848 b_in_string = true 1885 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå) # mikan cdl_error ã§ã¯ãªã1849 # この位置では error メソッドは使えない (token 読出し前) # mikan cdl_error ではない 1886 1850 puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape" 1887 1851 @@n_error += 1 1888 # å±±æ¬å¼§ã§å²ã¾ããæåå1852 # 山括弧で囲まれた文字列 1889 1853 # when /\A<[0-9A-Za-z_\. \/]+>/ # AB: angle bracke 1890 when /\A<(?:[^>\\]|\\.)*>/ # ããã¯ãã¾ãè¡ãããã1854 when /\A<(?:[^>\\]|\\.)*>/ # これはうまく行くようだ 1891 1855 @q << [:AB_STRING_LITERAL, Token.new($&, file, lineno, col)] 1892 # è¡ã³ã¡ã³ã1856 # 行コメント 1893 1857 when /\A\/\/.*$/ 1894 # èªã¿é£ã°ãã ã1895 # ã³ã¡ã³ãéå§1858 # 読み飛ばすだけ 1859 # コメント開始 1896 1860 when /\A\/\*/ 1897 1861 b_in_comment = true 1898 # '>>', '<<' ãªã©1862 # '>>', '<<' など 1899 1863 when /\A>>/, /\A<</, /\A==/, /\A!=/, /\A\&\&/, /\A\|\|/ 1900 1864 @q << [$&, Token.new($&, file, lineno, col)] 1901 1865 when /\A::/, /\A=>/, /\A<=/, /\A>=/ 1902 1866 @q << [$&, Token.new($&, file, lineno, col)] 1903 # '(', ')' ãªã©ä¸æåã®è¨å·ãã¾ãã¯æªç¥ã®è¨å·1867 # '(', ')' など一文字の記号、または未知の記号 1904 1868 when /\A./ 1905 1869 @q << [$&, Token.new($&, file, lineno, col)] … … 1925 1889 } 1926 1890 1927 # çµäºã®å°1891 # 終了の印 1928 1892 @q << nil 1929 1893 … … 1945 1909 1946 1910 if token[0] == :IDENTIFIER then 1947 # TYPE_NAME ãã¼ã¯ã³ã¸ç½®æã1911 # TYPE_NAME トークンへ置換え 1948 1912 if Namespace.is_typename?( token[1].val ) then 1949 1913 token[0] = :TYPE_NAME 1950 1914 elsif @in_specifier && RESERVED2[ token[1].val.to_s ] then 1951 # æå®åãã¼ã¯ã¼ãï¼ '[', ']' å 1952 ã§ã®ã¿æå¹) 1915 # 指定子キーワード( '[', ']' 内でのみ有効) 1953 1916 token[0] = RESERVED2[ token[1].val.to_s ] 1954 1917 end 1955 1918 end 1956 1919 1957 if $debug then # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç)1920 if $debug then # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生) 1958 1921 locale = @@current_locale[@@generator_nest] 1959 1922 if token then … … 1987 1950 @@n_info = 0 1988 1951 1989 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼1952 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切) 1990 1953 def self.error( msg, *arg ) 1991 1954 locale = nil … … 1997 1960 1998 1961 msg = TECSMsg.get_error_message( msg ) 1999 # $1, $2, ... ã arg ã§ç½®æ1962 # $1, $2, ... を arg で置換 2000 1963 count = 1 2001 1964 arg.each{ |a| … … 2005 1968 } 2006 1969 2007 # import_C ã®ä¸ã§ã®ã¨ã©ã¼ï¼1970 # import_C の中でのエラー? 2008 1971 if @@import_C then 2009 1972 C_parser.error( msg ) 2010 1973 else 2011 1974 2012 # Node ã®è¨æ¶ãã ä½ç½® (locale) ã使ç¨ããå ´åãå¤æ´ä»¥åã«æ¯ã¹ã2013 # åé¡çºçç®æã¨ç°ãªãä½ç½®ã«ã¨ã©ã¼ãåºããããæ§æ解æä¸ã®ã¨ã©ã¼2014 # ã¯ã解æä¸ã®ä½ç½®ãåºåããï¼(new_XXX 㧠owner ãåè¦ç´ ã®ãã§ã2015 # ã¯ããã㨠owner ã®è¡çªå·ãåºã¦ãã¾ãç¹ã§ããããçãã¦ãã)1975 # Node の記憶する 位置 (locale) を使用した場合、変更以前に比べ、 1976 # 問題発生箇所と異なる位置にエラーが出るため、構文解析中のエラー 1977 # は、解析中の位置を出力する.(new_XXX で owner が子要素のチェッ 1978 # クをすると owner の行番号が出てしまう点で、ずれが生じている) 2016 1979 2017 1980 if @@b_end_all_parse == false || locale == nil then … … 2026 1989 end 2027 1990 2028 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼1991 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切) 2029 1992 def self.warning( msg, *arg ) 2030 1993 locale = nil … … 2036 1999 2037 2000 msg = TECSMsg.get_warning_message( msg ) 2038 # $1, $2, ... ã arg ã§ç½®æ2001 # $1, $2, ... を arg で置換 2039 2002 count = 1 2040 2003 arg.each{ |a| … … 2044 2007 } 2045 2008 2046 # import_C ã®ä¸ã§ã®ã¦ã©ã¼ãã³ã°ï¼2009 # import_C の中でのウォーニング? 2047 2010 if @@import_C then 2048 2011 C_parser.warning( msg ) … … 2059 2022 end 2060 2023 2061 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯2024 # このメソッドは構文解析、意味解析からのみ呼出し可 2062 2025 def self.info( msg, *arg ) 2063 2026 locale = nil … … 2069 2032 2070 2033 msg = TECSMsg.get_info_message( msg ) 2071 # $1, $2, ... ã arg ã§ç½®æ2034 # $1, $2, ... を arg で置換 2072 2035 count = 1 2073 2036 arg.each{ |a| … … 2077 2040 } 2078 2041 2079 # import_C ã®ä¸ã§ã®ã¦ã©ã¼ãã³ã°ï¼2042 # import_C の中でのウォーニング? 2080 2043 if @@import_C then 2081 2044 C_parser.info( msg ) … … 2112 2075 end 2113 2076 2114 #=== '[' specifier å§ã2077 #=== '[' specifier 始め 2115 2078 def set_in_specifier 2116 2079 # p "set_in_specifier" … … 2118 2081 end 2119 2082 2120 #=== ']' specifier çµãã2083 #=== ']' specifier 終わり 2121 2084 def unset_in_specifier 2122 2085 # p "unset_in_specifier" … … 2124 2087 end 2125 2088 2126 # statement_specifier ã¯æ§æ解ééä¸ã§åç 2127 §ããããã 2089 # statement_specifier は構文解釈途中で参照したいため 2128 2090 @@statement_specifier_stack = [] 2129 2091 def self.add_statement_specifier( ss ) … … 2142 2104 end 2143 2105 2144 #=== ãã¹ã¦ã®æ§æ解æãå®äºãããã¨ãå ±å2106 #=== すべての構文解析が完了したことを報告 2145 2107 def self.end_all_parse 2146 2108 @@b_end_all_parse = true … … 2150 2112 2151 2113 2152 # ãã¡ã¤ã« => INCLUDE("header")ã®é 2153 å 2114 # ファイル => INCLUDE("header")の配列 2154 2115 Include = Hash.new {|hash, key| hash[key] = []} 2155 2116 … … 2205 2166 2206 2167 #= TECSIO 2207 # Ruby2.0(1.9) 対å¿ã«ä¼´ãå°å 2208 ¥ããã¯ã©ã¹ 2209 # SJIS 以å¤ã§ã¯ãASCII-8BIT ã¨ãã¦å 2210 ¥åãã 2168 # Ruby2.0(1.9) 対応に伴い導入したクラス 2169 # SJIS 以外では、ASCII-8BIT として入力する 2211 2170 class TECSIO 2212 def self.foreach(file) # ãããã¯å¼æ° { |line| } 2213 pr = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°ã pr ã«ä»£å 2214 ¥ 2171 def self.foreach(file) # ブロック引数 { |line| } 2172 pr = Proc.new # このメソッドのブロック引数を pr に代入 2215 2173 if $b_no_kcode then 2216 2174 msg = "E".encode $Ruby19_File_Encode 2217 2175 if( $Ruby19_File_Encode == "Shift_JIS" ) 2218 2176 2219 # Shift JIS ã¯ããã£ãã Windows-31J ã¨ãã¦èªã¿è¾¼ã¾ããShift_JIS ã«å¤æãããï¼2220 # ã³ã¡ã³ãçã«å«ã¾ãã SJIS ã«ä¸é©åãªæåã³ã¼ã㯠'?' ã¾ã㯠REPLACEMENT CHARACTER ã«å¤æãããï¼2221 # EUC ã UTF-8 ã§è¨è¿°ããã CDL ãæ··å¨ãã¦ãã¦ããRuby ä¾å¤ãçºçãããã¨ãªãå¦çãé²ãããã¨ãã§ããï¼2222 # æåã³ã¼ãæå®ã SJIS ã§ãã£ã¦ãæååãªãã©ã«ã®ä¸ã«ãæåã³ã¼ããSJIS 以å¤ã®é ASCII ãå«ã¾ãã¦ããå ´åã2223 # Ruby 1.8 ã® tecsgen ã§ã¯æåã³ã¼ãæå®ã«å½±é¿ãªãå¦çããããã®ããRuby 1.9 以éã§ã¯ '?' ã«ç½®ãæããå¯è½æ§ãããï¼2177 # Shift JIS は、いったん Windows-31J として読み込ませ、Shift_JIS に変換させる. 2178 # コメント等に含まれる SJIS に不適切な文字コードは '?' または REPLACEMENT CHARACTER に変換される. 2179 # EUC や UTF-8 で記述された CDL が混在していても、Ruby 例外が発生することなく処理を進めることができる. 2180 # 文字コード指定が SJIS であって、文字列リテラルの中に、文字コードがSJIS 以外の非 ASCII が含まれている場合、 2181 # Ruby 1.8 の tecsgen では文字コード指定に影響なく処理されたものが、Ruby 1.9 以降では '?' に置き換わる可能性がある. 2224 2182 2225 2183 mode = "r:Windows-31J" … … 2245 2203 end 2246 2204 2247 #=== æåã³ã¼ããç¸éããå ´åä¸è´ããã2248 # msg 㨠str ã®æåã³ã¼ããç¸éããå ´åãstr ã msg ã®æåã³ã¼ãã«å¤æãã2249 # å¤æä¸å¯ã®æåã³ã¼ã㯠'?' (utf-8 ã®å ´å U+FFFD (REPLACEMENT CHARACTER )) ã«å¤æ2205 #=== 文字コードが相違する場合一致させる 2206 # msg と str の文字コードが相違する場合、str を msg の文字コードに変換する 2207 # 変換不可の文字コードは '?' (utf-8 の場合 U+FFFD (REPLACEMENT CHARACTER )) に変換 2250 2208 # 2251 # ãã®ã¡ã½ããã¯ãã¨ã©ã¼ã¡ãã»ã¼ã¸åºåã§ã使ç¨ããã¦ãããã¨ã«æ³¨æï¼2209 # このメソッドは、エラーメッセージ出力でも使用されていることに注意. 2252 2210 # 2253 2211 #msg_enc::Encode | String 2254 2212 def self.str_code_convert( msg, str ) 2255 2213 if $b_no_kcode == false then 2256 return str # Ruby V1.8 ã¾ã§2214 return str # Ruby V1.8 まで 2257 2215 end 2258 2216 if msg.encoding != str.encoding then 2259 option = { :invalid => :replace, :undef => :replace } # ä¾å¤ãçºçãããã'?' ã«å¤æãã(utf-8 ã¯0xfffd)2217 option = { :invalid => :replace, :undef => :replace } # 例外を発生させず、'?' に変換する(utf-8 は 0xfffd) 2260 2218 # return str.encode( msg.encoding, option ) 2261 2219 str = str.encode( "utf-8", option ) -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/componentobj.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2019 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 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 ) 101 # @descriptor_list:: nil | { Signature => ParamDecl } æå¾ã® ParamDecl ããè¨æ¶ããªããã¨ã«æ³¨æ 102 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin ã¯çæå¾ã«è¿½å ããã 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: 空(関数が一つもない状態) 81 # @descriptor_list:: nil | { Signature => ParamDecl } 最後の ParamDecl しか記憶しないことに注意 82 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 103 83 104 84 include PluginModule … … 123 103 124 104 # STAGE: P 125 # ãã®ã¡ã½ãã㯠parse ä¸ã®ã¿å¼ã³åºããã105 # このメソッドは parse 中のみ呼び出される 126 106 def self.get_current 127 107 @@current_object … … 134 114 @name = name 135 115 Namespace.new_signature( self ) 136 set_namespace_path # @NamespacePath ã®è¨å®116 set_namespace_path # @NamespacePath の設定 137 117 if "#{Namespace.get_global_name}" == "" then 138 118 @global_name = @name … … 158 138 @function_head_list = function_head_list 159 139 160 # id ãå²ä»ãã140 # id を割付ける 161 141 id = 1 162 142 function_head_list.get_items.each{ |f| … … 180 160 end 181 161 182 #=== Signature# signature ã®æå®åãè¨å®162 #=== Signature# signature の指定子を設定 183 163 # STAGE: B 184 164 #spec_list:: [ [ :CONTEXT, String ], ... ] 185 165 # s[0] s[1] 186 166 def set_specifier_list( spec_list ) 187 return if spec_list == nil # 空ãªãã°ä½ãããªã167 return if spec_list == nil # 空ならば何もしない 188 168 189 169 spec_list.each { |s| … … 235 215 end 236 216 237 #=== Signature# é¢æ°åãã signature å 238 ã® id ãå¾ã 217 #=== Signature# 関数名から signature 内の id を得る 239 218 def get_id_from_func_name func_name 240 219 @func_name_to_id[ func_name ] 241 220 end 242 221 243 #=== Signature# context ãå¾ã244 # context æååãè¿ã"task", "non-task", "any"245 # æªæå®æã®ããã©ã«ãã¨ã㦠task ãè¿ã222 #=== Signature# context を得る 223 # context 文字列を返す "task", "non-task", "any" 224 # 未指定時のデフォルトとして task を返す 246 225 def get_context 247 226 if @context then … … 252 231 end 253 232 254 #=== Signature# signaure ã®ãã¹ã¦ã®é¢æ°ã®ãã¹ã¦ã®ãã©ã¡ã¼ã¿ããã©ã 255 #block:: ãããã¯ãå¼æ°ã«åã 256 # ãããã¯ã¯2ã¤ã®å¼æ°ãåãåã Decl, ParamDecl ( Decl: é¢æ°ããã ) 257 # Port ã¯ã©ã¹ã«ã each_param ãããï¼åãåãï¼ 258 def each_param # ãããã¯å¼æ° { |func_decl, param_decl| } 259 fha = get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 260 å 261 return if fha == nil # nil ãªãææ³ã¨ã©ã¼ã§æå¹å¤ãè¨å®ãããªãã£ã 262 263 pr = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°ã pr ã«ä»£å 264 ¥ 265 fha.each{ |fh| # fh: FuncHead # é¢æ°é 266 åä¸ã®åé¢æ°é é¨ 267 fd = fh.get_declarator # fd: Decl (é¢æ°é é¨ããDeclarotorãå¾ã) 268 if fd.is_function? then # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼ 269 fd.get_type.get_paramlist.get_items.each{ |par| # ãã¹ã¦ã®ãã©ã¡ã¼ã¿ã«ã¤ã㦠233 #=== Signature# signaure のすべての関数のすべてのパラメータをたどる 234 #block:: ブロックを引数に取る 235 # ブロックは2つの引数を受け取る Decl, ParamDecl ( Decl: 関数ヘッダ ) 236 # Port クラスにも each_param がある(同じ働き) 237 def each_param # ブロック引数 { |func_decl, param_decl| } 238 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 239 return if fha == nil # nil なら文法エラーで有効値が設定されなかった 240 241 pr = Proc.new # このメソッドのブロック引数を pr に代入 242 fha.each{ |fh| # fh: FuncHead # 関数配列中の各関数頭部 243 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 244 if fd.is_function? then # fd が関数でなければ、すでにエラー 245 fd.get_type.get_paramlist.get_items.each{ |par| # すべてのパラメータについて 270 246 pr.call( fd, par ) 271 247 } … … 274 250 end 275 251 276 #=== Signature# æ£å½ãªã¢ãã±ã¼ã¿ ã·ã°ããã£ããã¹ããã277 # alloc, dealloc é¢æ°ãæã¤ãã©ããã第ä¸å¼ãæ°ããããããæ´æ°ããã¤ã³ã¿ã第äºå¼ãæ°ãããã¤ã³ã¿ã¸ã®ãã¤ã³ã¿ããªã252 #=== Signature# 正当なアロケータ シグニチャかテストする 253 # alloc, dealloc 関数を持つかどうか、第一引き数がそれぞれ、整数、ポインタ、第二引き数が、ポインタへのポインタ、なし 278 254 def is_allocator? 279 255 280 # ä¸åã ããã§ãã¯ãã256 # 一回だけチェックする 281 257 if @b_checked_as_allocator_signature == true then 282 258 return true … … 284 260 @b_checked_as_allocator_signature = true 285 261 286 fha = get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 287 å 288 if fha == nil then # nil ãªãææ³ã¨ã©ã¼ã§æå¹å¤ãè¨å®ãããªãã£ã 262 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 263 if fha == nil then # nil なら文法エラーで有効値が設定されなかった 289 264 return false 290 265 end 291 266 292 267 found_alloc = false; found_dealloc = false 293 fha.each{ |fh| # fh: FuncHead # é¢æ°é 294 åä¸ã®åé¢æ°é é¨ 295 fd = fh.get_declarator # fd: Decl (é¢æ°é é¨ããDeclarotorãå¾ã) 296 if fd.is_function? then # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼ 268 fha.each{ |fh| # fh: FuncHead # 関数配列中の各関数頭部 269 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 270 if fd.is_function? then # fd が関数でなければ、すでにエラー 297 271 func_name = fd.get_name.to_sym 298 272 if func_name == :alloc then … … 303 277 ! params[0].get_type.get_original_type.kind_of?( IntType ) || 304 278 params[0].get_direction != :IN then 305 # 第ä¸å¼æ°ã int åã§ãªã279 # 第一引数が int 型でない 306 280 if ! params[0].instance_of?( ParamDecl ) || 307 281 ! params[0].get_type.kind_of?( PtrType ) || … … 309 283 params[0].get_type.get_type.get_type.kind_of?( PtrType ) || 310 284 params[0].get_direction != :OUT then 311 # 第ä¸å¼æ°ããã¤ã³ã¿åã§ããªã285 # 第一引数がポインタ型でもない 312 286 cdl_error3( @locale, "S1003 $1: \'alloc\' 1st parameter neither [in] integer type nor [out] double pointer type", @name ) 313 287 end … … 317 291 params[1].get_type.get_type.get_type.kind_of?( PtrType ) || 318 292 params[0].get_direction != :IN then 319 # ( 第ä¸å¼æ°ãæ´æ°ã§) 第äºå¼æ°ããã¤ã³ã¿ã§ãªã293 # (第一引数が整数で) 第二引数がポインタでない 320 294 cdl_error3( @locale, "S1004 $1: \'alloc\' 2nd parameter not [in] double pointer" , @name ) 321 295 end … … 332 306 params[0].get_direction != :IN then 333 307 cdl_error3( @locale, "S1006 $1: \'dealloc\' 1st parameter not [in] pointer type" , @name ) 334 # elsif params[1] != nil then # 第äºå¼ãæ°ã¯ãã§ãã¯ããªã308 # elsif params[1] != nil then # 第二引き数はチェックしない 335 309 # cdl_error3( @locale, "S1007 Error message is changed to empty" ) 336 310 # cdl_error3( @locale, "S1007 $1: \'dealloc\' cannot has 2nd parameter" , @name ) … … 354 328 end 355 329 356 #=== Signature# ã·ã°ããã£ãã©ã°ã¤ã³ (generate æå®å)330 #=== Signature# シグニチャプラグイン (generate 指定子) 357 331 def signature_plugin 358 332 plugin_name = @generate[0] … … 384 358 end 385 359 386 #== Signature# å¼æ°ã§åç 387 §ããã¦ãã Descriptor åã®ãªã¹ãã 388 #RETURN:: Hash { Signature => ParamDecl }: è¤æ°ã® ParamDecl ããåç 389 §ããã¦ããå ´åãæå¾ã®ãã®ããè¿ããªã 360 #== Signature# 引数で参照されている Descriptor 型のリストを 361 #RETURN:: Hash { Signature => ParamDecl }: 複数の ParamDecl から参照されている場合、最後のものしか返さない 390 362 def get_descriptor_list 391 363 @descriptor_list … … 402 374 end 403 375 404 #== Signature# å¼æ°ã§åç 405 §ããã¦ãã Descriptor åã®ãªã¹ããä½æãã 376 #== Signature# 引数で参照されている Descriptor 型のリストを作成する 406 377 def set_descriptor_list 407 378 desc_list = { } 408 379 # p "has_desc #{@name}" 409 fha = get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 410 å 411 if fha == nil then # nil ã®å ´åãèªå·±åç 412 §ã«ããã±ã¼ã¹ã¨ä»®å® 380 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 381 if fha == nil then # nil の場合、自己参照によるケースと仮定 413 382 @descriptor_list = desc_list 414 383 return desc_list 415 384 end 416 385 fha.each{ |fh| 417 fd = fh.get_declarator # fd: Decl ( é¢æ°é é¨ããDeclarotorãå¾ã)418 if fd.is_function? then # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼386 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 387 if fd.is_function? then # fd が関数でなければ、すでにエラー 419 388 params = fd.get_type.get_paramlist.get_items 420 389 if params then … … 443 412 end 444 413 445 #=== Signature# å¼æ°ã« Descriptor ããããï¼414 #=== Signature# 引数に Descriptor があるか? 446 415 def has_descriptor? 447 416 if get_descriptor_list == nil then 448 # end_of_parse ãå¼ã³åºãããåã« has_descriptor? ãå¼ã³åºããã 449 # å¼ã³åºãå 450 㯠DescriptorType#initialize 451 # ãã®å ´åãåãã·ã°ããã£å 452 ã®å¼æ°ã Descriptor åã§ãã 417 # end_of_parse が呼び出される前に has_descriptor? が呼び出された 418 # 呼び出し元は DescriptorType#initialize 419 # この場合、同じシグニチャ内の引数が Descriptor 型である 453 420 return true 454 421 elsif get_descriptor_list.length > 0 then … … 459 426 end 460 427 461 #=== Signature# ã³ã¼ã«ããã¯ãï¼462 # æå®å callback ãæå®ããã¦ããã°true428 #=== Signature# コールバックか? 429 # 指定子 callback が指定されていれば true 463 430 def is_callback? 464 431 @b_callback 465 432 end 466 433 467 #=== Signature# é¸è±ãï¼468 # æå®å deviate ãæå®ããã¦ããã°true434 #=== Signature# 逸脱か? 435 # 指定子 deviate が指定されていれば true 469 436 def is_deviate? 470 437 @b_deviate 471 438 end 472 439 473 #=== Signature# 空ãï¼440 #=== Signature# 空か? 474 441 def is_empty? 475 442 @b_empty 476 443 end 477 444 478 #=== Signature# Push Pop Allocator ãå¿ 479 è¦ãï¼ 480 # Transparent RPC ã®å ´å oneway ã㤠in ã®é 481 å(size_is, count_is, string ã®ããããã§ä¿®é£¾ï¼ããã 445 #=== Signature# Push Pop Allocator が必要か? 446 # Transparent RPC の場合 oneway かつ in の配列(size_is, count_is, string のいずれかで修飾)がある 482 447 def need_PPAllocator?( b_opaque = false ) 483 fha = get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 484 å 448 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 485 449 fha.each{ |fh| 486 450 fd = fh.get_declarator … … 508 472 509 473 module CelltypePluginModule 510 #=== Celltype# ã»ã«ã¿ã¤ããã©ã°ã¤ã³ (generate æå®å)474 #=== Celltype# セルタイププラグイン (generate 指定子) 511 475 def celltype_plugin 512 476 plugin_name = @generate[0] … … 515 479 end 516 480 517 #=== Celltype# ã»ã«ã¿ã¤ããã©ã°ã¤ã³ããã®ã»ã«ã¿ã¤ãã«é©ç¨481 #=== Celltype# セルタイププラグインをこのセルタイプに適用 518 482 def apply_plugin( plugin_name, option ) 519 483 … … 543 507 end 544 508 545 # æ¢ã«åå¨ããã»ã«ã« new_cell ãé©ç¨509 # 既に存在するセルに new_cell を適用 546 510 @cell_list.each{ |cell| 547 511 apply_plugin_cell plugin_object, cell … … 583 547 # @factory_list:: Factory[] 584 548 # @ct_factory_list:: Factory[] : celltype factory 585 # @cell_list:: Cell[] : å®ç¾©ã®ã¿ (V1.0.0.2 以é)586 # @ordered_cell_list:: Cell[] : ID é ã«é åºä»ããããã»ã«ãªã¹ããæé©å以éæå¹ (ãªã³ã¯åä½ãã¨ã«çæãããªãã)549 # @cell_list:: Cell[] : 定義のみ (V1.0.0.2 以降) 550 # @ordered_cell_list:: Cell[] : ID 順に順序付けされたセルリスト、最適化以降有効 (リンク単位ごとに生成されなおす) 587 551 # @singleton:: bool 588 552 # @idx_is_id:: bool … … 590 554 # @b_need_ptab:: bool: true if having cells in multi-domain 591 555 # @active:: bool 592 # @b_reuse:: bool : reuse æå®ãã㦠import ããã(template ä¸è¦)593 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin ã¯çæå¾ã«è¿½å ããã594 # @generate_list:: [ [ Symbol, String, Plugin ], ... ] generate æã§è¿½å ãããgenerate556 # @b_reuse:: bool : reuse 指定されて import された(template 不要) 557 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 558 # @generate_list:: [ [ Symbol, String, Plugin ], ... ] generate 文で追加された generate 595 559 # 596 560 # @n_attribute_ro:: int >= 0 none specified … … 599 563 # @n_var:: int >= 0 600 564 # @n_var_size_is:: int >= 0 # of [size_is] specified vars # mikan count_is 601 # @n_var_omit:: int >= 0 # of [omit] specified vars # mikan var ã® omit ã¯æï¼565 # @n_var_omit:: int >= 0 # of [omit] specified vars # mikan var の omit は有? 602 566 # @n_var_init:: int >= 0 # of vars with initializer 603 567 # @n_call_port:: int >= 0 # dynamic ports are included 604 568 # @n_call_port_array:: int >= 0 # dynamic ports are included 605 # @n_call_port_omitted_in_CB:: int >= 0 æé©åã§çç¥ãããå¼ã³å£569 # @n_call_port_omitted_in_CB:: int >= 0 最適化で省略される呼び口 606 570 # @n_call_port_dynamic:: int >= 0 # 607 571 # @n_call_port_array_dynamic:: int >= 0 … … 611 575 # @n_entry_port_array:: int >= 0 612 576 # @n_entry_port_inline:: int >= 0 613 # @n_cell_gen:: int >= 0 çæããã»ã«ã®æ°ï¼ã³ã¼ãçæã®é ã§ç®åºããï¼æå³è§£æ段éã§ã¯åç 614 §ä¸å¯ 615 # @id_base:: Integer : cell ã® ID ã®æå°å¤(æ大å¤ã¯ @id_base + @n_cell) 577 # @n_cell_gen:: int >= 0 生成するセルの数.コード生成の頭で算出する.意味解析段階では参照不可 578 # @id_base:: Integer : cell の ID の最小値(最大値は @id_base + @n_cell) 616 579 # 617 # @b_cp_optimized:: bool : å¼ã³å£æé©åå®æ½618 # @plugin:: PluginObject ãã®ã»ã«ã¿ã¤ãããã©ã°ã¤ã³ã«ããçæããã CDL ããçæãããå ´åã«æå¹ã619 # generate ã®æå®ã¯ @generate ã«ãã©ã°ã¤ã³ãä¿æããã580 # @b_cp_optimized:: bool : 呼び口最適化実施 581 # @plugin:: PluginObject このセルタイプがプラグインにより生成された CDL から生成された場合に有効。 582 # generate の指定は @generate にプラグインが保持される 620 583 # 621 # @included_header:: Hash : include ãããããããã¡ã¤ã« 622 # @domain_roots::Hash { DomainTypeName(Symbol) => [ Region ] } ãã¡ã¤ã³ã¿ã¤ãå㨠Region ã®é 623 å (optimize.rb ã§è¨å®) 624 # ã«ã¼ããªã¼ã¸ã§ã³ã¯ãã¡ã¤ã³åããnil 584 # @included_header:: Hash : include されたヘッダファイル 585 # @domain_roots::Hash { DomainTypeName(Symbol) => [ Region ] } ドメインタイプ名と Region の配列 (optimize.rb で設定) 586 # ルートリージョンはドメイン名が nil 625 587 626 588 include PluginModule … … 692 654 693 655 @plugin = Generator.get_plugin 694 # plugin ã®å ´å PluginObject ãè¿ããã 695 # å 696 ã® Generator ããå¼åºããã Generator ã®ä¸ã§ãã¼ã¹ããã³æå³ãã§ãã¯ããã¦ãã 656 # plugin の場合 PluginObject が返される 657 # 元の Generator から呼出された Generator の中でパースおよび意味チェックされている 697 658 698 659 # if @plugin then 699 # # plugin çæãããã»ã«ã¿ã¤ãã¯åå©ç¨ã§ã¯ãªã #833 ä¸å 700 ·åä¿®æ£ 660 # # plugin 生成されるセルタイプは再利用ではない #833 不具合修正 701 661 # @b_reuse = false 702 662 # else … … 715 675 716 676 Namespace.new_celltype( self ) 717 set_namespace_path # @NamespacePath ã®è¨å®677 set_namespace_path # @NamespacePath の設定 718 678 set_specifier_list( Generator.get_statement_specifier ) 719 679 … … 727 687 end 728 688 729 #== Celltype#ãã¡ã¤ã³ã«ã¼ããè¿ã 730 # @domain_roots ã®èª¬æãåç 731 § 689 #== Celltype#ドメインルートを返す 690 # @domain_roots の説明を参照 732 691 def get_domain_roots 733 692 @domain_roots … … 736 695 # Celltype# end_of_parse 737 696 def end_of_parse 738 # å±æ§ã»å¤æ°ã®ãã§ãã¯697 # 属性・変数のチェック 739 698 check_attribute 740 699 741 # ã¢ãã±ã¼ã¿å¼ã³å£ãå 742 é¨çæ 700 # アロケータ呼び口を内部生成 743 701 generate_allocator_port 744 702 745 # ãªã¬ã¼ã¢ãã±ã¼ã¿ãå 746 é¨ã¢ãã±ã¼ã¿ã®è¨å® 703 # リレーアロケータ、内部アロケータの設定 747 704 @port.each { |p| 748 705 p.set_allocator_instance … … 814 771 end 815 772 if a.get_initializer then 816 # ç»é²å¾ã«ãã§ãã¯ãã¦ãåé¡ãªãï¼attr ãåç 817 §ã§ããªãã®ã§ãèªå·±åç 818 §ããªãï¼ 773 # 登録後にチェックしても問題ない(attr を参照できないので、自己参照しない) 819 774 a.get_type.check_init( @locale, a.get_identifier, a.get_initializer, :ATTRIBUTE ) 820 775 end … … 822 777 end 823 778 824 #=== Celltype# celltype ã® attribute/var ã®ãã§ãã¯779 #=== Celltype# celltype の attribute/var のチェック 825 780 # STAGE: S 826 781 # 827 # ãã®ã¡ã½ãã㯠celltype ã®ãã¼ã¹ãå®äºããæç¹ã§å¼åºãããï¼782 # このメソッドは celltype のパースが完了した時点で呼出される. 828 783 def check_attribute 829 # attribute ã® size_is æå®ã妥å½ããã§ãã¯784 # attribute の size_is 指定が妥当かチェック 830 785 (@attribute+@var).each{ |a| 831 786 if a.get_size_is then 832 787 if ! a.get_type.kind_of?( PtrType ) then 833 # size_is ããã¤ã³ã¿å以å¤ã«æå®ããã788 # size_is がポインタ型以外に指定された 834 789 cdl_error( "S1011 $1: size_is specified for non-pointer type" , a.get_identifier ) 835 790 else 836 791 837 # åç 838 §ããå¤æ°ãåå¨ããè¨ç®å¯è½ãªåããã§ãã¯ãã 839 size = a.get_size_is.eval_const( @name_list ) # C_EXP ã®å¯è½æ§ãã 792 # 参照する変数が存在し、計算可能な型かチェックする 793 size = a.get_size_is.eval_const( @name_list ) # C_EXP の可能性あり 840 794 init = a.get_initializer 841 795 if init then 842 796 if ! init.instance_of?( Array ) then 843 # åæååãé 844 åã§ã¯ãªã 797 # 初期化子が配列ではない 845 798 cdl_error( "S1012 $1: unsuitable initializer, need array initializer" , a.get_identifier ) 846 799 elsif size.kind_of?( Integer ) && size < init.length then 847 # size_is æå®ãããåæ°ãããåæååã®é 848 åè¦ç´ ãå¤ã 800 # size_is 指定された個数よりも初期化子の配列要素が多い 849 801 cdl_error( "S1013 $1: too many initializer, $2 for $3" , a.get_identifier, init.length, size ) 850 # elsif a.get_size_is.eval_const( nil ) == nil # C_EXP ã®å¯è½æ§ãã802 # elsif a.get_size_is.eval_const( nil ) == nil # C_EXP の可能性あり 851 803 end 852 804 … … 858 810 ( a.get_initializer.instance_of?( Expression ) && 859 811 a.get_initializer.eval_const2(@name_list).instance_of?( Array ) ) then 860 # size_is æå®ããã¦ããªããã¤ã³ã¿ã Array ã§åæåããã¦ããããã¨ã©ã¼812 # size_is 指定されていないポインタが Array で初期化されていたら、エラー 861 813 cdl_error( "S1159 $1: non-size_is pointer cannot be initialized with array initializer" , a.get_identifier ) 862 814 end … … 870 822 end 871 823 872 #=== Celltype# ã¢ãã±ã¼ã¿å¼ã³å£ãçæ873 # send, receive å¼æ°ã®ã¢ãã±ã¼ã¿ãå¼åºãããã®å¼ã³å£ãçæ824 #=== Celltype# アロケータ呼び口を生成 825 # send, receive 引数のアロケータを呼出すための呼び口を生成 874 826 def generate_allocator_port 875 827 @port.each { |port| 876 # ãã¼ãã®ãã¹ã¦ã®ãã©ã¡ã¼ã¿ã辿ã828 # ポートのすべてのパラメータを辿る 877 829 port.each_param { |port, fd, par| 878 case par.get_direction # å¼æ°ã®æ¹åæå®å(in, out, inout, send, receive )830 case par.get_direction # 引数の方向指定子 (in, out, inout, send, receive ) 879 831 when :SEND, :RECEIVE 880 832 if par.get_allocator then 881 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # ã¢ãã±ã¼ã¿å¼ã³å£ã®åå882 # ãã¼ãå é¢æ°å ãã©ã¡ã¼ã¿å883 # alloc_sig_path = [ par.get_allocator.get_name ] # mikan Namespace ã¢ãã±ã¼ã¿å¼ã³å£ã®ã·ã°ããã£#1833 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # アロケータ呼び口の名前 834 # ポート名 関数名 パラメータ名 835 # alloc_sig_path = [ par.get_allocator.get_name ] # mikan Namespace アロケータ呼び口のシグニチャ #1 884 836 alloc_sig_path = par.get_allocator.get_namespace_path 885 array_size = port.get_array_size # å¼ã³å£ã¾ãã¯åãå£é 886 åã®ãµã¤ãº 887 created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # å¼ã³å£ãçæ 837 array_size = port.get_array_size # 呼び口または受け口配列のサイズ 838 created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # 呼び口を生成 888 839 created_port.set_allocator_port( port, fd, par ) 889 840 if port.is_optional? then … … 893 844 created_port.set_omit 894 845 end 895 new_port( created_port ) # ã»ã«ã¿ã¤ãã«æ°ããå¼ã³å£ã追å846 new_port( created_port ) # セルタイプに新しい呼び口を追加 896 847 # else 897 848 # already error "not found or not signature" in class ParamDecl … … 910 861 end 911 862 912 #=== Celltype# æ°ããå 913 é¨å¤æ° 863 #=== Celltype# 新しい内部変数 914 864 #var:: [Decl] 915 865 def new_var( var ) … … 924 874 @name_list.add_item( i ) 925 875 926 # size_is æå®ãããé 927 å? mikan count_is 876 # size_is 指定された配列? mikan count_is 928 877 if i.get_size_is then 929 878 @n_var_size_is += 1 … … 941 890 end 942 891 943 #=== Celltype# celltype ã®æå®åãè¨å®892 #=== Celltype# celltype の指定子を設定 944 893 def set_specifier_list( spec_list ) 945 894 return if spec_list == nil … … 976 925 977 926 def new_require( ct_or_cell_nsp, ep_name, cp_name ) 978 # Require: set_owner ãããã®ããªã927 # Require: set_owner するものがない 979 928 obj = Namespace.find( ct_or_cell_nsp ) #1 980 929 if obj.instance_of? Celltype then 981 # Celltype åã§æå®930 # Celltype 名で指定 982 931 ct = obj 983 932 elsif obj.instance_of? Cell then 984 # Cell åã§æå®933 # Cell 名で指定 985 934 ct = obj.get_celltype 986 935 elsif obj == nil then … … 993 942 994 943 if( ! ct.is_singleton? ) then 995 # ã·ã³ã°ã«ãã³ã§ã¯ãªã944 # シングルトンではない 996 945 cdl_error( "S1018 $1 : not singleton cell" , obj.get_name ) 997 946 end 998 947 999 # åãå£ãæ¢ã948 # 受け口を探す 1000 949 obj2 = ct.find( ep_name ) 1001 950 if( ( ! obj2.instance_of? Port ) || obj2.get_port_type != :ENTRY ) then … … 1008 957 1009 958 if obj2.get_signature == nil then 1010 # signature ãæªå®ç¾©ï¼æ¢ã«ã¨ã©ã¼959 # signature が未定義:既にエラー 1011 960 return 1012 961 end … … 1014 963 require_call_port_prefix = :_require_call_port 1015 964 if cp_name == nil then 1016 # é¢æ°åéè¤ãã§ãã¯965 # 関数名重複チェック 1017 966 @require.each{ |req| 1018 967 unless req[0].to_s =~ /^#{require_call_port_prefix}/ then 1019 next # ååããã® require ã¯é¢æ°åéè¤ãã§ãã¯ããªã968 next # 名前ありの require は関数名重複チェックしない 1020 969 end 1021 970 port = req[2] 1022 971 if port.get_signature == obj2.get_signature then 1023 # åã signature ï¼ãã¹ã¦åãé¢æ°åãæã¤ï¼åå¥ã«åºãã®ã§ã¯ãªããã¾ã¨ãã¦ã¨ã©ã¼ã¨ãã972 # 同じ signature (すべて同じ関数名を持つ)個別に出すのではなく、まとめてエラーとする 1024 973 cdl_error( "S1021 $1 : require cannot have same signature with \'$2\'" , obj2.get_name, port.get_name ) 1025 974 next 1026 975 end 1027 976 port.get_signature.get_function_head_array.each{ |f| 1028 # mikan ããã¯ãnamedList ããã®æ¤ç´¢ã«ãªããªãã®ï¼ï¼å¹çãæªãï¼977 # mikan ここは、namedList からの検索にならないの?(効率が悪い) 1029 978 obj2.get_signature.get_function_head_array.each{ |f2| 1030 979 if( f.get_name == f2.get_name ) then … … 1042 991 b_has_name = true 1043 992 end 1044 # require ã追å993 # require を追加 1045 994 @require << [ cp_name, obj, obj2 ] # [ lhs:cp_name, rhs:Celltype, rhs:Port ] 1046 995 1047 # require port ã追å (å¼ã³å£ã¨ãã¦è¿½å ããããã ã require ãã»ãããã¦ãã)996 # require port を追加 (呼び口として追加する。ただし require をセットしておく) 1048 997 port = Port.new( cp_name, obj2.get_signature.get_namespace_path, :CALL ) 1049 998 port.set_require( b_has_name ) … … 1077 1026 end 1078 1027 1079 #=== Celltype#dynamic ã®é©åæ§ãã§ãã¯1028 #=== Celltype#dynamic の適合性チェック 1080 1029 def check_dynamic_join 1081 1030 return if ! $verbose 1082 1031 @port.each{ |port| 1083 1032 signature = port.get_signature 1084 next if signature == nil # ãã§ã«ã¨ã©ã¼1033 next if signature == nil # すでにエラー 1085 1034 if port.is_dynamic? then 1086 1035 dbgPrint( "[DYNAMIC] checking dynamic port: #{@global_name}.#{port.get_name}\n" ) … … 1133 1082 end 1134 1083 def find_ref_desc_port signature 1135 if signature == nil then # ãã§ã«ã¨ã©ã¼1084 if signature == nil then # すでにエラー 1136 1085 return nil 1137 1086 end … … 1143 1092 return nil 1144 1093 end 1145 #=== Celltype# ãã£ã¹ã¯ãªãã¿åã§ã·ã°ããã£ãä¸è´ã dyn_ref ã«å¯¾å¿ã¥ãå¼æ°ãæ¢ã1146 #dyn_ref::Symbol: :DYNAMIC= ãã£ã¹ã¯ãªãã¿ãå¾ãæ段ã¨ãªãå¼æ°ãæ¢ãï¼:REF_DESC=渡ãæ段ã¨ãªãå¼æ°ãæ¢ã1094 #=== Celltype#ディスクリプタ型でシグニチャが一致し dyn_ref に対応づく引数を探す 1095 #dyn_ref::Symbol: :DYNAMIC=ディスクリプタを得る手段となる引数を探す.:REF_DESC=渡す手段となる引数を探す 1147 1096 def find_descriptor_param signature, dyn_ref 1148 1097 param_list = [] … … 1186 1135 end 1187 1136 1188 #=== Celltype# celltype ã«æ°ãã cell ã追å1137 #=== Celltype# celltype に新しい cell を追加 1189 1138 #cell:: Cell 1190 # æ°ããã»ã«ãã»ã«ã¿ã¤ãã«è¿½å ï¼1191 # ã»ã«ã®æ§æ解éã®æå¾ã§ãã®ã¡ã½ããå¼åºãããï¼1192 # ã·ã³ã°ã«ãã³ã»ã«ãåã linkunit ã«è¤æ°ãªãããã§ãã¯1139 # 新しいセルをセルタイプに追加. 1140 # セルの構文解釈の最後でこのメソドを呼出される. 1141 # シングルトンセルが同じ linkunit に複数ないかチェック 1193 1142 def new_cell( cell ) 1194 1143 dbgPrint "Celltype#new_cell( #{cell.get_name} )\n" 1195 # Celltype ã§ã¯ Cell ã® set_owner ããªã1196 # ã·ã³ã°ã«ãã³ã§ããããã¿ã¤ã宣è¨ã§ãªãå ´åãã³ã¼ãçæ対象ãªã¼ã¸ã§ã³ã®å ´å1144 # Celltype では Cell の set_owner しない 1145 # シングルトンで、プロトタイプ宣言でない場合、コード生成対象リージョンの場合 1197 1146 if @singleton then 1198 1147 @cell_list.each{ |c| … … 1204 1153 @cell_list << cell 1205 1154 1206 # ãã©ã°ã¤ã³ã«ããçæãããã»ã«ã¿ã¤ãã?1155 # プラグインにより生成されたセルタイプか ? 1207 1156 if @plugin then 1208 1157 @plugin.new_cell cell 1209 1158 end 1210 1159 1211 # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ã®é©ç¨1160 # セルタイププラグインの適用 1212 1161 celltype_plugin_new_cell cell 1213 1162 end 1214 1163 1215 #=== Celltype# ã»ã«ã¿ã¤ã㯠INIB ãæã¤ãï¼1216 # ã»ã«ã¿ã¤ãã INIB ãæã¤ãã©ãããå¤å®ãã1217 # $rom == false ã®ã¨ã: INIB ãæããªãï¼ ï¼ãã¹ã¦ã¯ CB ã«ç½®ãããï¼1218 # $rom == true ã®ã¨ããINIB ã«ç½®ããããã®ãä¸ã¤ã§ãåå¨ããã° INIB ãæã¤1219 # INIB ã«ç½®ããããã®ã¯1220 # attribute (omit ã®ãã®ã¯é¤ãï¼ç¾ä»æ§ã§ã¯ rw ã®ãã®ã¯ãªã)1221 # size_is ãä¼´ãvar1222 # å¼ã³å£ï¼ãã ããæé©åã§ä¸è¦ã¨ãªããã®ã¯é¤ãï¼1164 #=== Celltype# セルタイプは INIB を持つか? 1165 # セルタイプが INIB を持つかどうかを判定する 1166 # $rom == false のとき: INIB を持たない. (すべては CB に置かれる) 1167 # $rom == true のとき、INIB に置かれるものが一つでも存在すれば INIB を持つ 1168 # INIB に置かれるものは 1169 # attribute (omit のものは除く.現仕様では rw のものはない) 1170 # size_is を伴う var 1171 # 呼び口(ただし、最適化で不要となるものは除く) 1223 1172 def has_INIB? 1224 1173 … … 1234 1183 end 1235 1184 1236 #=== Celltype# ã»ã«ã¿ã¤ã㯠CB ãæã¤ãï¼1237 # $rom == true ã®ã¨ããããã®ãã®ãç½®ãããï¼ãããã®ä¸ã¤ã§ãåå¨ããã° CB ãæã¤1238 # size_is ãæå®ããã¦ããªãvar1239 # rw æå®ããã attribute (ç¾ä»æ§ã§ã¯åå¨ããªã)1240 # $rom == false ã®ã¨ããããã®ãã®ãç½®ãããï¼ãããã®ä¸ã¤ã§ãåå¨ããã° CB ãæã¤1185 #=== Celltype# セルタイプは CB を持つか? 1186 # $rom == true のとき、いかのものが置かれる.それらの一つでも存在すれば CB を持つ 1187 # size_is が指定されていない var 1188 # rw 指定された attribute (現仕様では存在しない) 1189 # $rom == false のとき、いかのものが置かれる.それらの一つでも存在すれば CB を持つ 1241 1190 # attribute 1242 1191 # var 1243 # å¼ã³å£ï¼ãã ããæé©åã§ä¸è¦ã¨ãªããã®ã¯é¤ãï¼1192 # 呼び口(ただし、最適化で不要となるものは除く) 1244 1193 def has_CB? 1245 1194 if $rom then … … 1251 1200 end 1252 1201 1253 #=== Celltype# SET_CB_INIB_POINTER, INITIALIZE_CB ãå¿ 1254 è¦ã 1202 #=== Celltype# SET_CB_INIB_POINTER, INITIALIZE_CB が必要か 1255 1203 def need_CB_initializer? 1256 1204 @n_var_init > 0 || has_CB? || ( @n_call_port_dynamic && $ram_initializer ) 1257 1205 end 1258 1206 1259 #=== Celltype# érequire ã®çµåãçæãã1207 #=== Celltype# 逆require の結合を生成する 1260 1208 def create_reverse_require_join cell 1261 1209 @port.each{ |p| … … 1264 1212 end 1265 1213 1266 #=== Celltype# singleton ã»ã«ãå¾ã 1267 #region:: Region : singleton ãæ¢ã Region 1268 # è·é¢ãæãè¿ããã®ãè¿ã 1269 # mikan æ¬å½ã¯ region ã®ç¯å²ã® singleton ãæ¢ãå¿ 1270 è¦ããã 1214 #=== Celltype# singleton セルを得る 1215 #region:: Region : singleton を探す Region 1216 # 距離が最も近いものを返す 1217 # mikan 本当は region の範囲の singleton を探す必要がある 1271 1218 def get_singleton_cell region 1272 1219 cell = nil 1273 dist = 999999999 # mikan å¶éå¤ï¼ããã¯ååãããã»ã©ãã«ã¤ãï¼1274 # require: celltype ã§æå®1220 dist = 999999999 # mikan 制限値(これは十分すぎるほどデカイが) 1221 # require: celltype で指定 1275 1222 @cell_list.each{ |c| 1276 # å°éå¯è½ã§æãè¿ãã»ã«ãæ¢ãï¼è¤æ°ã® singleton ããããããããªãï¼1223 # 到達可能で最も近いセルを探す(複数の singleton があるかもしれない) 1277 1224 d = region.distance( c.get_region ) 1278 1225 #debug … … 1293 1240 end 1294 1241 1295 #=== Celltype# ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãå¾ã1242 #=== Celltype# セルタイププラグインを得る 1296 1243 def get_celltype_plugin 1297 1244 if @generate then … … 1320 1267 end 1321 1268 1322 #=== Celltype# ã¢ã¯ãã£ãã§ã¯ãªãã1323 # ãã®ã¡ã½ããã§ã¯ active ã®ä»ã« factory (singleton ã«ããã¦ã¯ FACTORYãå«ã)ããªããã° inactive ã¨ãã1269 #=== Celltype# アクティブではないか 1270 # このメソッドでは active の他に factory (singleton においては FACTORYを含む)がなければ inactive とする 1324 1271 def is_inactive? 1325 1272 if @active == false && @factory_list.length == 0 && … … 1342 1289 end 1343 1290 1344 #=== Celltype# ã³ã¼ãçæããå¿ 1345 è¦ããããå¤å® 1346 # ã»ã«ã®åæ°ã 0 ãªãã»ã«ã¿ã¤ãã³ã¼ãã¯çæä¸è¦ 1291 #=== Celltype# コード生成する必要があるか判定 1292 # セルの個数が 0 ならセルタイプコードは生成不要 1347 1293 def need_generate? 1348 1294 @n_cell_gen > 0 1349 1295 end 1350 1296 1351 #=== Celltype# require å¼ã³å£ã®çµåãè¡ã1297 #=== Celltype# require 呼び口の結合を行う 1352 1298 # STAGE: S 1353 # ã»ã«ã¿ã¤ãã® require å¼ã³å£ã«ã¤ãã¦ãçµåãè¡ã1354 # ã»ã«ãçæãããªãããã§ãã¯ãè¡ã1299 # セルタイプの require 呼び口について、結合を行う 1300 # セルが生成されないかチェックを行う 1355 1301 def set_require_join 1356 1302 @require.each{ |req| … … 1368 1314 end 1369 1315 1370 #=== Celltype# inline åãå£ãããªããï¼1371 # åãå£ãç¡ãå ´åããã¹ã¦ã®åãå£ã inline ã¨ã¯ããªã1316 #=== Celltype# inline 受け口しかないか? 1317 # 受け口が無い場合、すべての受け口が inline とはしない 1372 1318 def is_all_entry_inline? 1373 1319 @n_entry_port == @n_entry_port_inline && @n_entry_port > 0 … … 1408 1354 # @n_var:: int >= 0 1409 1355 # @n_var_size_is:: int >= 0 # of [size_is] specified cells # mikan count_is 1410 # @n_var_omit:: int >= 0 # of [omit] specified cells # mikan var ã® omit ã¯æï¼1356 # @n_var_omit:: int >= 0 # of [omit] specified cells # mikan var の omit は有? 1411 1357 # @n_call_port:: int >= 0 1412 1358 # @n_call_port_array:: int >= 0 1413 # @n_call_port_omitted_in_CB:: int >= 0 æé©åã§çç¥ãããå¼ã³å£1359 # @n_call_port_omitted_in_CB:: int >= 0 最適化で省略される呼び口 1414 1360 # @n_entry_port:: int >= 0 1415 1361 # @n_entry_port_array:: int >= 0 1416 1362 (indent+1).times { print " " } 1417 1363 puts "@n_entry_port_inline #{@n_entry_port_inline}" 1418 # @n_cell:: int >= 0 ã³ã¼ãçæã®é ã§ç®åºããï¼æå³è§£æ段éã§ã¯åç 1419 §ä¸å¯ 1420 # @id_base:: Integer : cell ã® ID ã®æå°å¤(æ大å¤ã¯ @id_base + @n_cell) 1364 # @n_cell:: int >= 0 コード生成の頭で算出する.意味解析段階では参照不可 1365 # @id_base:: Integer : cell の ID の最小値(最大値は @id_base + @n_cell) 1421 1366 1422 1367 end … … 1424 1369 1425 1370 class Cell < NSBDNode # < Nestable 1426 # @name:: Symbol : composite celltype ã®å 1427 å´ã®ã¤ã³ã¹ã¿ã³ã¹ã§ã¯å¤ã®ã»ã« 1428 # @global_name:: Symbol : C ã§ä½¿ããååï¼namespace ãå«ãï¼ 1429 # @local_name:: str : cell celltype name { ... } ã® name 1371 # @name:: Symbol : composite celltype の内側のインスタンスでは外のセル 1372 # @global_name:: Symbol : C で使える名前(namespace を含む) 1373 # @local_name:: str : cell celltype name { ... } の name 1430 1374 # @celltype:: Celltype | CompositeCelltype 1431 1375 # @join_list:: NamedList … … 1434 1378 # @b_prototype:: bool: prototype specified in current parsing cell. (@b_defined is used to determine whether definition done) 1435 1379 # @b_duplicate:: bool: definition duplicate 1436 # @b_checked:: bool: set_definition_join ãæ¸ãã§ããå ´åtrue1437 # @require_joined_list:: {cp_name=>true}: set_require_join ãæ¸ãã§ããå¼ã³å£ã¯true1380 # @b_checked:: bool: set_definition_join が済んでいる場合 true 1381 # @require_joined_list:: {cp_name=>true}: set_require_join が済んでいる呼び口は true 1438 1382 # @f_ref:: refercenced from others 1439 # @entry_array_max_subscript:: { @port=>Integer } : åãå£é 1440 åã®é 1441 åæ·»æ°ã®æ大å¤ï¼æ·»æ°ç¡ãåãå£é 1442 å対å¿ï¼ 1383 # @entry_array_max_subscript:: { @port=>Integer } : 受け口配列の配列添数の最大値(添数無し受け口配列対応) 1443 1384 # @plugin:: Plugin: avialble if cell is generated by plugin generated cdl code. 1444 # @referenced_port_list:: { Port => Integer } : åãå£ã®åç 1445 §æ° 1446 # ãã¹ã¦ã®æå³è§£æ(through, compositeå±é)ãçµãã£ãå¾ã«è¨å®ãã 1447 # érequire ãã¼ãã«å¯¾ãã¦è¤æ°ã®çµåããªãããã§ãã¯ãã 1448 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin ã¯çæå¾ã«è¿½å ããã 1385 # @referenced_port_list:: { Port => Integer } : 受け口の参照数 1386 # すべての意味解析(through, composite展開)が終わった後に設定する 1387 # 逆require ポートに対して複数の結合がないかチェックする 1388 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 1449 1389 # @b_post_code_generated:: Bool: true if generated in tmp_plugin_post_code.cdl 1450 1390 # 1451 # composite ã®ããã¤ã³ã¹ã¿ã³ã¹å¤æ°1391 # composite のためインスタンス変数 1452 1392 # @in_composite:: bool : true if in composite celltype 1453 1393 # @compositecelltypejoin_list:: NamedList : item= CompositeCelltypeJoin ( if @in_composite ) 1454 1394 # @f_cloned:: bool : true if cloned (instantiate of composite consist cell) 1455 # @my_clone:: Cell : Composite cell 㧠in_composite = true ã®å ´åã®ã¿æå¹ï¼ç´åã® clone ãä¸æè¨æ¶ï¼ 1456 # @cell_list:: Cell[local_name] : Composite cell 㧠clone ããå¾ã®ãªã¹ã cell_list 1457 # @cell_list2:: [ Cell ] : Composite cell 㧠clone ããå¾ã®ãªã¹ã cell_list 1458 # @cell_list2 㯠composite å 1459 ã§ã®åºç¾é 1395 # @my_clone:: Cell : Composite cell で in_composite = true の場合のみ有効(直前の clone を一時記憶) 1396 # @cell_list:: Cell[local_name] : Composite cell で clone した後のリスト cell_list 1397 # @cell_list2:: [ Cell ] : Composite cell で clone した後のリスト cell_list 1398 # @cell_list2 は composite 内での出現順 1460 1399 # 1461 # region ã®ããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°1462 # @region:: Region ( å±ããregion)1400 # region のためのインスタンス変数 1401 # @region:: Region (属するregion) 1463 1402 # 1464 # allocator ã®ããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°1403 # allocator のためのインスタンス変数 1465 1404 # @alloc_list:: [ [ NORMAL_ALLOC, ep_name, func_name, param_name, expr ], ... ] 1466 # åãå£å´ã®ã¢ãã±ã¼ã¿ã¸ã®çµåãè¨æ¶ã以ä¸ã®ã¡ã½ããã§è¿½å ããã1467 # set_specifier ⦠cell å®ç¾©æã«ã¢ãã±ã¼ã¿æå®ããã¦ããå ´å1468 # create_relay_allocator_join ⦠ãªã¬ã¼ã¢ãã±ã¼ã¿ã®å ´å1405 # 受け口側のアロケータへの結合を記憶。以下のメソッドで追加される 1406 # set_specifier … cell 定義時にアロケータ指定されている場合 1407 # create_relay_allocator_join … リレーアロケータの場合 1469 1408 # 1470 # ID ã®ããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°ï¼optimize.rb ã«ã¦è¨å®ï¼1471 # @id:: Integer : ã³ã¼ãçæç´åã«è¨å® (ãããã¿ã¤ã宣è¨ã®å ´å㯠-1 ã®ã¾ã¾æ¾ç½®)1472 # @id_specified::Integer : æå®ãããid1409 # ID のためのインスタンス変数(optimize.rb にて設定) 1410 # @id:: Integer : コード生成直前に設定 (プロトタイプ宣言の場合は -1 のまま放置) 1411 # @id_specified::Integer : 指定された id 1473 1412 # @restrict_list::{ entry_name => { func_name, [ region_path_str, ... ] } } 1474 1413 # @restrict_list2::{ entry_name => { func_name, [ domain_root_region, ... ] } } 1475 # @b_restrict_referenced::Bool: restrict_list ãåç 1476 §ãã 1414 # @b_restrict_referenced::Bool: restrict_list が参照れた 1477 1415 1478 1416 =begin 1479 # Cell ã¯ã©ã¹ã¯ã以ä¸ã®ãã®ãæ±ã 1480 # 1)æ®éã®ã»ã« 1481 # 2)composite ã»ã«ã¿ã¤ãã®ã»ã« 1482 # 3)composite ã»ã«ã¿ã¤ãã®å 1483 å´ã®ã»ã« (@in_composite) # composite ã®å 1484 å´ã® composite ã»ã«ã¿ã¤ãã®ã»ã«ããã 1417 # Cell クラスは、以下のものを扱う 1418 # 1)普通のセル 1419 # 2)composite セルタイプのセル 1420 # 3)composite セルタイプの内側のセル (@in_composite) # composite の内側の composite セルタイプのセルもある 1485 1421 # 1486 # 2) 㯠CellOfComposite ã¯ã©ã¹ã¨ãã¦åããã»ãããããããããªã 1487 # expand (composite ã»ã«ã®å±é) 㯠CellOfComposite ã«ã®ã¿å¿ 1488 è¦ãªã¡ã½ããã§ãã 1489 # get_real_cell, get_real_port ãªã© @celltype.instance_of?( CompositeCelltype ) ã®å¤å®ããªããã£ãããã 1490 # ãã ãåé¢ãã¦ããã¡ã³ããã³ã¹ãã¹ãç¯å²ãåãé¢ããã¦ãã¾ããå¿ãããããªãåé¡ã¨ã®ãã¬ã¼ããªããã 1422 # 2) は CellOfComposite クラスとして分けたほうがよいかもしれない 1423 # expand (composite セルの展開) は CellOfComposite にのみ必要なメソッドである 1424 # get_real_cell, get_real_port など @celltype.instance_of?( CompositeCelltype ) の判定がなくすっきりする 1425 # ただ、分離しても、メンテナンスすべき範囲が切り離されてしまい、忘れやすくなる問題とのトレードオフかも 1491 1426 # 1492 # 3) 㯠CellInCompoiste ã¯ã©ã¹ã¨ãã¦åããã»ãããããããããªã 1493 # @in_composite ã§å¤å®ãã¦ããå¦çãåãé¢ãã (ä¸è¨ 2) ãããåé¢ã¯å®¹æã§ã¯ãªã) 1494 # clone_for_composite 㯠CellInCompoiste ã«ã®ã¿å¿ 1495 è¦ãªã¡ã½ããã§ãã 1496 # ãã ããclone å¾ã« Cell, CellOfComposite ã«å¤åããå¿ 1497 è¦ãããã®ã§ãclone ã§ã¯ãªã new ããå®è£ 1498 ã«å¤æ´ããå¿ 1499 è¦ããã 1427 # 3) は CellInCompoiste クラスとして分けたほうがよいかもしれない 1428 # @in_composite で判定している処理を切り離せる (上記 2) よりも分離は容易ではない) 1429 # clone_for_composite は CellInCompoiste にのみ必要なメソッドである 1430 # ただし、clone 後に Cell, CellOfComposite に変化する必要があるので、clone ではなく new する実装に変更する必要がある 1500 1431 # 1501 1432 =end … … 1507 1438 @@current_object = nil 1508 1439 1509 # å®ç¾©ããããã¹ã¦ã®ã»ã«ï¼åºç¾é . namespace ã«å½±é¿ãããªãï¼ 1510 @@cell_list = [] # composite ã®å 1511 é¨ã®ã»ã«ãå«ã¾ãªã 1512 @@cell_list2 = [] # composite ã®å 1513 é¨ã®ã»ã«ãå«ã (å 1514 ã®ã»ã«ãå«ã) 1515 # æå³è§£æå¾ make_cell_list2 ã«ã¦è¨å®ããã 1440 # 定義されたすべてのセル(出現順. namespace に影響されない) 1441 @@cell_list = [] # composite の内部のセルを含まない 1442 @@cell_list2 = [] # composite の内部のセルを含む (元のセルを含む) 1443 # 意味解析後 make_cell_list2 にて設定される 1516 1444 1517 1445 def self.push … … 1533 1461 @region = Region.get_current 1534 1462 1535 # celltype ã®plugin/åå¨ããã§ãã¯1463 # celltype のplugin/存在をチェック 1536 1464 object = Namespace.find( ct_path ) #1 1537 1465 if object == nil then 1538 # mikan celltype ã®ååãä¸å®å 1539 ¨ "::ct1ct2" ã«ãªã 1466 # mikan celltype の名前が不完全 "::ct1ct2" になる 1540 1467 cdl_error( "S1027 \'$1\' celltype not found" , ct_path.get_path_str ) 1541 1468 elsif ! object.instance_of?( Celltype ) && ! object.instance_of?( CompositeCelltype ) then 1542 # mikan celltype ã®ååãä¸å®å 1543 ¨ 1469 # mikan celltype の名前が不完全 1544 1470 cdl_error( "S1028 \'$1\' not celltype" , ct_path.get_path_str ) 1545 1471 else … … 1592 1518 end 1593 1519 1594 # ãã®æç¹ã§ã¯ãããã¿ã¤ãããå®ç¾©ãåããªãããèªå·±åç 1595 §ã®ããã«ç»é² 1596 # set_f_def ã§å度ç»é²ããªãã 1597 # Celltype ã¸ã®ç»é²ã¯ãend_of_parse ã§è¡ã 1520 # この時点ではプロトタイプか、定義か分らないが、自己参照のために登録 1521 # set_f_def で再度登録しなおす 1522 # Celltype への登録は、end_of_parse で行う 1598 1523 if @in_composite then 1599 1524 cell_prev = CompositeCelltype.find( name ) … … 1602 1527 end 1603 1528 else 1604 # cell_prev = Namespace.find( [ name ] ) # 親ã¾ã§æãã«ãã1529 # cell_prev = Namespace.find( [ name ] ) # 親まで捜しにいく 1605 1530 cell_prev = Namespace.get_current.find( name ) 1606 1531 if cell_prev == nil then 1607 1532 Namespace.new_cell( self ) 1608 set_namespace_path # @NamespacePath ã®è¨å®1533 set_namespace_path # @NamespacePath の設定 1609 1534 end 1610 1535 end … … 1613 1538 if ! cell_prev.instance_of?( Cell ) then 1614 1539 cdl_error( "S1029 $1 mismatch with previous one" , name ) 1615 # celltype ãä¸è´ãã¦ããã?1540 # celltype が一致しているか ? 1616 1541 elsif get_celltype != cell_prev.get_celltype then 1617 1542 cdl_error( "S1030 $1: celltype mismatch with previous one" , name ) 1618 1543 else 1619 # region ãä¸è´ãã¦ããã?1544 # region が一致しているか? 1620 1545 if ! cell_prev.get_region.equal? get_region then 1621 1546 cdl_error( "S1031 $1 region \'$2\' mismatch with previous one \'$3\'" , name, @region.get_name, cell_prev.get_region.get_name ) … … 1623 1548 1624 1549 @@current_object = cell_prev 1625 # ãã®æç¹ã§ã¯ãã¾ã ãããã¿ã¤ã宣è¨ãå®ç¾©ãåããªã1626 # 以åãå®ç¾©ã§ãã£ã¦ãä»åãå®ç¾©ã®å ´åãéè¤ã¨ã©ã¼ã§ãã1550 # この時点では、まだプロトタイプ宣言か定義か分らない 1551 # 以前が定義であって、今回も定義の場合、重複エラーである 1627 1552 end 1628 1553 end … … 1634 1559 dbgPrint "Cell new_cell: #{@global_name} #{@in_composite} #{self}\n" 1635 1560 1636 # å 1637 é¨ã¢ãã±ã¼ã¿ã @alloc_list ã«è¿½å 1561 # 内部アロケータを @alloc_list に追加 1638 1562 if @celltype.instance_of? CompositeCelltype then 1639 1563 @celltype.get_internal_allocator_list.each{ |cell, cp_internal_name, port_name, fd_name, par_name, ext_alloc_ent| 1640 1564 nsp = NamespacePath.new( @name, false ) 1641 rhs = Expression.new( [:OP_DOT, [:IDENTIFIER, nsp], Token.new( ext_alloc_ent.to_s.to_sym, nil, nil, nil ) ] ) #1 æ§æ解æ段éãªã®ã§ locale ä¸è¦1565 rhs = Expression.new( [:OP_DOT, [:IDENTIFIER, nsp], Token.new( ext_alloc_ent.to_s.to_sym, nil, nil, nil ) ] ) #1 構文解析段階なので locale 不要 1642 1566 1643 1567 @alloc_list << [:NORMAL_ALLOC,port_name,nil,fd_name,par_name,rhs] … … 1647 1571 end 1648 1572 1649 #=== Cell# cell ã®å®ç¾©1650 # æ¬ä½(join)ã®å®ç¾©ã®ç´åã«å¼ã³åºããã1573 #=== Cell# cell の定義 1574 # 本体(join)の定義の直前に呼び出される 1651 1575 def self.new_def 1652 1576 @@current_object.new_def 1653 1577 end 1654 1578 1655 #=== Cell# cell ã®å®ç¾©1656 # æ¬ä½(join)ã®å®ç¾©ã®ç´åã«å¼ã³åºããã1657 # ãã®ã¡ã½ãã㯠cell tCelltype Cell { }; '{', '}' ã®é¨åãããå ´åã«å¼åºããã1579 #=== Cell# cell の定義 1580 # 本体(join)の定義の直前に呼び出される 1581 # このメソッドは cell tCelltype Cell { }; '{', '}' の部分がある場合に呼出される 1658 1582 def new_def 1659 1583 set_specifier_list( Generator.get_statement_specifier ) 1660 1584 1661 # prototype æå®åãªãã1585 # prototype 指定子ないか 1662 1586 if ! @b_prototype then 1663 # äºéå®ç¾©ã®ãã§ãã¯1587 # 二重定義のチェック 1664 1588 if @b_defined == true then 1665 1589 cdl_error( "S1032 $1: duplicate cell" , @name ) 1666 1590 dbgPrint "previous: #{@prev_locale[0]}: line #{@prev_locale[1]} '#{@name}' defined here\n" 1667 1591 1668 # ã»ã«ã®éè¤å®ç¾©ã¨ã©ã¼ã®å¦ç½®1669 # åã®å®ç¾©ã¯æ¨ã¦ã1592 # セルの重複定義エラーの処置 1593 # 前の定義は捨てる 1670 1594 @join_list = NamedList.new( nil, "in cell '#{@name}'" ) 1671 1595 end … … 1680 1604 end 1681 1605 1682 #=== Cell# æ°ããçµåããã§ãã¯1606 #=== Cell# 新しい結合をチェック 1683 1607 # STAGE: P 1684 1608 # 1685 #join:: Join : æ°ããçµå1686 #b_regular:: bool : é常ã®å ´æ (bnf.y.rb)ãããªãã° true, ãã以å¤(allocator, require) ã§ã¯false1609 #join:: Join : 新しい結合 1610 #b_regular:: bool : 通常の場所 (bnf.y.rb)からならば true, それ以外(allocator, require) では false 1687 1611 def new_join( join, b_regular = false ) 1688 1612 join.set_owner self 1689 1613 1690 # composite ã®æ°ææ³å¯¾å¿ï¼ 1691 # composite ã®ä¸ã®ã»ã«ã§ãattribute ã®å®ç¾©ã§ããå ´å 1692 # cell å 1693 ã® attr_ext = composite.attr; æ§æãå¦ç 1614 # composite の新文法対応. 1615 # composite の中のセルで、attribute の定義である場合 1616 # cell 内の attr_ext = composite.attr; 構文を処理 1694 1617 if @in_composite then 1695 1618 if @celltype then 1696 if @celltype.find(join.get_name).instance_of?( Decl ) then # mikan a::b ã§æå®ããã¦ãããã®ãã¨ã©ã¼ã«ãªããªããã1619 if @celltype.find(join.get_name).instance_of?( Decl ) then # mikan a::b で指定されていたものがエラーにならないかも 1697 1620 rhs = join.get_rhs 1698 1621 if rhs.instance_of? Expression then 1699 1622 ele = rhs.get_elements 1700 if( ele[0]==:IDENTIFIER )then # attr = attr_ext ï¼å³è¾ºåé 1701 ï¼ãï¼ #1 1702 if( CompositeCelltype.has_attribute?(ele[1].get_name ) )then # mikan a::b.ePort ãã¨ã©ã¼ã«ãªããªããã 1703 ident = ele[1].get_name # å³è¾ºã¯ attributeï¼ 1623 if( ele[0]==:IDENTIFIER )then # attr = attr_ext (右辺単項)か? #1 1624 if( CompositeCelltype.has_attribute?(ele[1].get_name ) )then # mikan a::b.ePort がエラーにならないかも 1625 ident = ele[1].get_name # 右辺は attribute. 1704 1626 else 1705 # å³è¾ºã¯ attribute ã«ãªãã®ã§ããã°ãå®æ°ã®ã¯ã1706 # å®æ°ã¯ä¸ã¸æ¸¡ã (cell ã® join ã«ãã)1627 # 右辺は attribute にないのであれば、定数のはず 1628 # 定数は下へ渡す (cell の join にする) 1707 1629 ident = nil 1708 1630 end 1709 1631 else 1710 if join.get_rhs.eval_const2(nil) == nil then # å®æ°å¼ã§ã¯ãªããï¼1711 # å³è¾ºããåä¸ã®ã·ã³ãã«ã§ãªãå ´åãç¾ç¶ã¯æ±ããªã1632 if join.get_rhs.eval_const2(nil) == nil then # 定数式ではないか? 1633 # 右辺が、単一のシンボルでない場合、現状は扱えない 1712 1634 cdl_error( "S1033 rhs expression is not supported. Only attribute is permitted on current version." ) 1713 1635 return 1714 1636 else 1715 # å®æ°ã¯ä¸ã¸æ¸¡ã (cell ã® join ã«ãã)1637 # 定数は下へ渡す (cell の join にする) 1716 1638 ident = nil 1717 1639 end … … 1719 1641 1720 1642 if ident then 1721 # attr = attr; ã®ãããªåç 1722 §ã¯ã¨ã©ã¼ (a = composite.a ã¨ããå¿ 1723 è¦ããã) 1643 # attr = attr; のような参照はエラー (a = composite.a とする必要がある) 1724 1644 if @celltype.find( ident ) then 1725 1645 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 ) … … 1727 1647 end 1728 1648 elsif rhs.instance_of? Array then 1729 if rhs[0] == :COMPOSITE then # å³è¾ºã¯ composite.attr ã®å½¢å¼1649 if rhs[0] == :COMPOSITE then # 右辺は composite.attr の形式 1730 1650 ident = rhs[1].to_sym 1731 1651 else 1732 ident = nil # å³è¾ºã¯ { 10, -10 } ã®å½¢å¼1652 ident = nil # 右辺は { 10, -10 } の形式 1733 1653 end 1734 1654 else 1735 ident = nil # å³è¾ºã¯ C_EXP ã®å½¢å¼1655 ident = nil # 右辺は C_EXP の形式 1736 1656 end 1737 1657 1738 # ident ãè¦ã¤ãã£ãï¼å³è¾ºã¯åä¸ã® identï¼1658 # ident が見つかった(右辺は単一の ident) 1739 1659 if ident then 1740 # composite ã®æ§ææ³ã®æ§æå¦çã¸æ¸¡ãï¼ã»ã«å¤ã® attr_ext = Cell.attr; æ§æã®å¦çã«æ¸¡ã1660 # composite の旧文法の構文処理へ渡す.セル外の attr_ext = Cell.attr; 構文の処理に渡す 1741 1661 # export_name, internal_cell_name, internal_cell_elem_name 1742 decl = CompositeCelltype.new_join( ident, @name, join.get_name, :ATTRIBUTE ) # mikan a::b.ePort ãã¨ã©ã¼ã«ãªããªããã1662 decl = CompositeCelltype.new_join( ident, @name, join.get_name, :ATTRIBUTE ) # mikan a::b.ePort がエラーにならないかも 1743 1663 if ! decl.instance_of? Decl then 1744 1664 return … … 1748 1668 return 1749 1669 end 1750 # 以ä¸ã®æ§ææ³å®è£ 1751 ã«æ¸¡ãï¼ 1752 # æ§ææ³ã§ã¯ cell ã«åæå¤ãä¸ãããã¨ã§ãcomposite ã§å±æ§ã®åæå¤ãæå®ãããã¨ãã§ãã 1753 # attribute ã§æå®ãããåæå¤ã cell ã®å±æ§ã¨ãã¦å¦çããã 1670 # 以下の旧文法実装に渡す. 1671 # 旧文法では cell に初期値を与えることで、composite で属性の初期値を指定することができた 1672 # attribute で指定された初期値を cell の属性として処理させる 1754 1673 join.change_rhs( ini ) 1755 1674 else 1756 # ident ããªãï¼å®æ°å¼1675 # ident がない.定数式 1757 1676 end 1758 1677 else 1759 # celltype ã®å±æ§ã¨ãã¦ããã® join ã®ååããªã1760 # 以ä¸ã® join.set_definition ã®ä¸ã§ã¨ã©ã¼ã¨ãªã1678 # celltype の属性として、この join の名前がない 1679 # 以下の join.set_definition の中でエラーとなる 1761 1680 end 1762 1681 else 1763 return # celltype ããªãï¼ãã§ã«ã¨ã©ã¼1682 return # celltype がない.すでにエラー 1764 1683 end 1765 1684 elsif join.get_rhs.instance_of? Array then 1766 1685 rhs = join.get_rhs 1767 1686 if rhs[0] == :COMPOSITE then 1768 # composite ã®ä¸ã§ãªãã®ã« attr = composite.attr ã使ããã1687 # composite の中でないのに attr = composite.attr が使われた 1769 1688 cdl_error( "S1035 composite : cannot specify out of composite celltype definition" ) 1770 1689 return … … 1772 1691 end 1773 1692 1774 # ä»¥ä¸ composite ææ³å¤æ´åããããå¦ç1775 1776 # æ¢ã«å·¦è¾ºãåãååã®åæåãåå¨ãããï¼1777 j = @join_list.get_item( join.get_name ) # mikan NamespacePath ããã¹ãæã£ã¦ãã1778 if j.instance_of? Join then # mikan ããã§ã¯ j ã Join or Nil 以å¤ã¯ããªãã¯ã1693 # 以下 composite 文法変更前からある処理 1694 1695 # 既に左辺が同じ名前の初期化が存在するか? 1696 j = @join_list.get_item( join.get_name ) # mikan NamespacePath がパスを持っている 1697 if j.instance_of? Join then # mikan ここでは j が Join or Nil 以外は、ないはず 1779 1698 1780 1699 # debug 1781 1700 dbgPrint "add_array_member: #{@name} port: #{j.get_port_name} rhs: #{j.get_rhs}, #{join.get_port_name} #{join.get_rhs}\n" 1782 # å¼ã³å£é 1783 åï¼ã§ããã¨ä»®å®ãã¦ï¼è¦ç´ ã追å 1701 # 呼び口配列(であると仮定して)要素を追加 1784 1702 j.add_array_member join 1785 1703 … … 1790 1708 end 1791 1709 1792 # if get_owner then # error S1030 çºçæ get_owner ãè¦ã¤ãããªãã¦ä¾å¤ã«ãªã1710 # if get_owner then # error S1030 発生時 get_owner が見つからなくて例外になる 1793 1711 # dbgPrint "Cell#new_join: #{get_owner.get_name}.#{@name}\n" 1794 1712 # else … … 1804 1722 end 1805 1723 1806 #=== Cell. æ°ããéçµå1724 #=== Cell.新しい逆結合 1807 1725 def self.new_reverse_join( reverse_join ) 1808 1726 @@current_object.new_reverse_join( reverse_join ) 1809 1727 end 1810 1728 1811 #=== Cell# æ°ããéçµå1729 #=== Cell#新しい逆結合 1812 1730 def new_reverse_join( reverse_join ) 1813 1731 dbgPrint( "new_reverse_join name=#{reverse_join.get_name}\n") … … 1834 1752 end 1835 1753 1836 #=== Cell# éçµåããçµåãçæ1754 #=== Cell#逆結合から結合を生成 1837 1755 # STAGE: S 1838 1756 def create_reverse_join … … 1844 1762 # @reverse_join_list.get_items.each{ |rj| 1845 1763 @reverse_join_list.each{ |rj| 1846 # éçµåã®æ 1847 å ±ãå¾ã 1764 # 逆結合の情報を得る 1848 1765 ep_name = rj.get_name 1849 1766 ep_subscript, cp_cell_nsp, cp_name, cp_subscript = rj.get_rhs_cell_and_port 1850 1767 1851 # å¼ã³å£å´ã®ã»ã«ã¨ããã®ã»ã«ã¿ã¤ã1768 # 呼び口側のセルと、そのセルタイプ 1852 1769 if ! @in_composite then 1853 1770 cell = Namespace.find cp_cell_nsp … … 1891 1808 end 1892 1809 1893 #=== Cell# cell å 1894 ã«è¨è¿°ããå¼ã³å£ã®å¤é¨çµå 1895 # internal_cell_elem_name:: string : å¼ã³å£å 1896 # export_name:: string: composite ã®å¤é¨ã«å 1897 ¬éããå¼ã³å£å 1898 # å¼ã³å£ãå¤é¨çµåããï¼ 1899 # ãã®ã¡ã½ããã¯ãcomposite ã®ä¸ã® cell ã§ããå¼ã°ããªãï¼ 1810 #=== Cell# cell 内に記述する呼び口の外部結合 1811 # internal_cell_elem_name:: string : 呼び口名 1812 # export_name:: string: composite の外部に公開する呼び口名 1813 # 呼び口を外部結合する. 1814 # このメソッドは、composite の中の cell でしか呼ばれない. 1900 1815 def external_join( internal_cell_elem_name, export_name, b_composite ) 1901 1816 1902 # cCall => composite.cCall; ã§ã¯ãªããï¼1817 # cCall => composite.cCall; ではないか? 1903 1818 if( b_composite == false )then 1904 # cCall => cCall; ã®ãããªå ´å1819 # cCall => cCall; のような場合 1905 1820 if @celltype.find( export_name ) then 1906 1821 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 ) 1907 1822 end 1908 1823 end 1909 # composite ã®æ§ææ³ã«ããããcell å¤ã® cCall = Cell.cCall; ã®æ§æå¦çã«æ¸¡ã1824 # composite の旧文法における、cell 外の cCall = Cell.cCall; の構文処理に渡す 1910 1825 CompositeCelltype.new_join( export_name, @name, internal_cell_elem_name, :CALL ) 1911 1826 end … … 1919 1834 1920 1835 def end_of_parse f_def 1921 if @b_prototype then # prototype æå®åãã£ãã?1922 f_def = false # ãããã¿ã¤ã宣è¨ã¨ãã1836 if @b_prototype then # prototype 指定子あったか? 1837 f_def = false # プロトタイプ宣言とする 1923 1838 @b_prototype = false 1924 1839 end 1925 1840 if f_def == false then 1926 # cell tCelltype Cell; ã®å½¢å¼ã®å ´å1927 # f_def == true ã®å ´å new_def ã§ãå¼åºããã1841 # cell tCelltype Cell; の形式の場合 1842 # f_def == true の場合 new_def で、呼出される 1928 1843 set_specifier_list( Generator.get_statement_specifier ) 1929 1844 end … … 1938 1853 end 1939 1854 1940 #=== Cell# ãããã¿ã¤ã宣è¨(false)ãå®ç¾©(true)ããè¨å®1941 # ãã®ã¡ã½ããã¯æ§æ解éã®æå¾ã«å¼åºããã1855 #=== Cell# プロトタイプ宣言(false)か定義(true)かを設定 1856 # このメソッドは構文解釈の最後に呼出される 1942 1857 #f_def:: bool false if prototype, true if definition 1943 1858 def set_f_def f_def … … 1948 1863 if ! @in_composite then 1949 1864 # if @celltype.instance_of? Celltype then 1950 if @celltype then # composite ã§ãå¼ã³ã ã, ã¨ã©ã¼ænil1865 if @celltype then # composite でも呼びだす, エラー時 nil 1951 1866 @celltype.new_cell self 1952 1867 end … … 1959 1874 @f_ref = true 1960 1875 1961 # composite ã®å 1962 é¨ã»ã«ãåç 1963 §ããããã¨ã«ãã 1964 # ä»ã®ã¨ããåé¡ãªãããæªåç 1965 §ã§ããã¹ããã®ã¾ã§åç 1966 §ããããã¨ã«ãªã 1876 # composite の内部セルを参照されたことにする 1877 # 今のところ問題ないが、未参照であるべきものまで参照されたことになる 1967 1878 if @cell_list then 1968 1879 @cell_list.each{ |cn,cell| … … 1972 1883 end 1973 1884 1974 #=== Cell# cell ã®æå®åãè¨å®1885 #=== Cell# cell の指定子を設定 1975 1886 # STAGE: B 1976 1887 # 1977 # bnf.y.rb ã®statement_specifiler_list1888 # bnf.y.rb の statement_specifiler_list 1978 1889 #spec_list:: [ :ALLOCATOR, [ [ :NORMAL_ALLOC, ep_name, subscript, func_name, param_name, expr ], ... ] ] 1979 1890 # s[0] s[1] a[0] a[1] a[2] a[3] a[4] a[5] 1980 # ã»ã«ã«æå®ãããã¢ãã±ã¼ã¿æå®å 1981 # a[1] ã® subscript ã¯ãã®ã¡ã½ããã®ä¸ã§ Expression ãã Integer ã«è©ä¾¡ããã 1982 # åãå£å´ã«çæãããã¢ãã±ã¼ã¿å¼ã³å£ã®çµåãå 1983 é¨çæãã 1984 # å¼ã³å£å´ã¯ Port ã® create_allocator_join ã«ã¦çæ 1985 # ãªã¬ã¼ã¢ãã±ã¼ã¿ã®å ´å create_relay_allocator_join ã«ã¦çæã 1891 # セルに指定されたアロケータ指定子 1892 # a[1] の subscript はこのメソッドの中で Expression から Integer に評価される 1893 # 受け口側に生成されるアロケータ呼び口の結合を内部生成する 1894 # 呼び口側は Port の create_allocator_join にて生成 1895 # リレーアロケータの場合 create_relay_allocator_join にて生成す 1986 1896 def set_specifier_list( spec_list ) 1987 return if spec_list == nil # 空ãªãã°ä½ãããªã1897 return if spec_list == nil # 空ならば何もしない 1988 1898 1989 1899 dbgPrint( "set_spec_list: #{@name}\n" ) 1990 b_generate = false # generate ãæå®ããã1900 b_generate = false # generate が指定された 1991 1901 1992 1902 spec_list.each{ |s| 1993 1903 case s[0] # statement_specifier 1994 1904 when :ALLOCATOR # [allocator(ePort.func.param=allocCell.eA,ePort.func2.param=allocCell.eA)] 1995 s[1].each { |a| # alloc_list : allocator ã®å 1996 é¨ã® ',' ã§åºåãããé¨åã®é 1997 å 1998 cp_name = :"#{a[0+1]}_#{a[2+1]}_#{a[3+1]}" # ã¢ãã±ã¼ã¿å¼ã³å£ã®ååï¼'=' ã®å·¦è¾ºã '.' ã«å¤ã㦠'_' ã§é£çµ 1905 s[1].each { |a| # alloc_list : allocator の内部の ',' で区切られた部分の配列 1906 cp_name = :"#{a[0+1]}_#{a[2+1]}_#{a[3+1]}" # アロケータ呼び口の名前:'=' の左辺を '.' に変えて '_' で連結 1999 1907 # p "#{a[0]} #{a[0+1]} #{a[2+1]} #{a[3+1]} #{cp_name}" 2000 1908 if a[1+1] then … … 2004 1912 subscript = nil 2005 1913 end 2006 # ã¢ãã±ã¼ã¿å¼ã³å£ã®çµåãçæ2007 join = Join.new( cp_name, subscript, a[4+1] ) # æ§æ解æ段éãªã®ã§ locale ä¸è¦1914 # アロケータ呼び口の結合を生成 1915 join = Join.new( cp_name, subscript, a[4+1] ) # 構文解析段階なので locale 不要 2008 1916 dbgPrint( "new allocator join #{cp_name} #{subscript} #{a[4+1]}\n" ) 2009 1917 Cell.new_join( join ) … … 2051 1959 def get_allocator_list 2052 1960 2053 # æå³ãã§ãã¯(set_definition)ããã¦ããªãï¼2054 # relay ã¢ãã±ã¼ã¿ã®å ´åãã»ã«ã®æå³ãã§ãã¯ãè¡ããã¦ããªãã¨ã@alloc_list ãå®æããªã1961 # 意味チェック(set_definition)されていない? 1962 # relay アロケータの場合、セルの意味チェックが行われていないと、@alloc_list が完成しない 2055 1963 if @b_checked == false then 2056 1964 set_definition_join … … 2063 1971 end 2064 1972 2065 #=== id æå®åã®å¤ãè¨å®2066 # ãã®ã¡ã½ããã¯ããã©ã°ã¤ã³ã§ cell ã®çæé åºãå¶å¾¡ãããå ´åã®ããã«è¨ãã2067 # é常㮠id æå®åã§ã¯ä½¿ã£ã¦ããªã1973 #=== id 指定子の値を設定 1974 # このメソッドは、プラグインで cell の生成順序を制御したい場合のために設けた 1975 # 通常の id 指定子では使っていない 2068 1976 def set_specified_id id 2069 1977 if Integer( id ) != id || id <= 0 then … … 2076 1984 end 2077 1985 2078 #=== Cell# ã»ã«ãã©ã°ã¤ã³ (generate æå®å)1986 #=== Cell# セルプラグイン (generate 指定子) 2079 1987 def cell_plugin 2080 1988 plugin_name = @generate[0] … … 2089 1997 2090 1998 plClass = load_plugin( plugin_name, CellPlugin ) 2091 # return if plClass == nil # å¾æ¥ã¨ä»æ§ãå¤ããã®ã§ãç¶ç¶ãã1999 # return if plClass == nil # 従来と仕様が変わるので、継続する 2092 2000 if $verbose then 2093 2001 print "new cell plugin: plugin_object = #{plClass.class.name}.new( #{@name}, #{option} )\n" … … 2109 2017 end 2110 2018 2111 #=== Cell# cell ã composite ã»ã«ã¿ã¤ãã®ã»ã«ç¨ã« clone ãã 2112 #name:: string : 親 cell ã®åå (cell tComposite cell1 ã§ã® cell1) 2113 #global_name:: string : 親 cell ã® global_name 2114 #join_array:: Join[] : composite ã® cell ã® join ã§ããã® cell ã«å¯¾å¿ãããã® 2115 #ct_name:: string : 親ã»ã«ã®ã»ã«ã¿ã¤ãå 2116 #region:: Region : å 2117 ã®ã»ã«ãå±ãã region 2118 #ãã®ã¡ã½ãã㯠CompositeCelltype ã® expand ããå¼åºããã 2019 #=== Cell# cell を composite セルタイプのセル用に clone する 2020 #name:: string : 親 cell の名前 (cell tComposite cell1 での cell1) 2021 #global_name:: string : 親 cell の global_name 2022 #join_array:: Join[] : composite の cell の join で、この cell に対応するもの 2023 #ct_name:: string : 親セルのセルタイプ名 2024 #region:: Region : 元のセルが属する region 2025 #このメソッドは CompositeCelltype の expand から呼出される 2119 2026 def clone_for_composite( name, global_name, namespacePath, join_array, ct_name, region, plugin, locale ) 2120 2027 … … 2125 2032 @my_clone = self.clone 2126 2033 2127 # clone ããã»ã«ã®å 2128 é¨ã«æã¤ååæ 2129 å ±ã調æ´ãã 2034 # clone したセルの内部に持つ名前情報を調整する 2130 2035 @my_clone.set_cloned( name, global_name, namespacePath, join_array, ct_name, region, plugin, locale ) 2131 2036 2132 # @celltype == nil ã¯ä»¥åã«ã»ã«ã¿ã¤ãæªå®ç¾©ã¨ã©ã¼2037 # @celltype == nil は以前にセルタイプ未定義エラー 2133 2038 if @b_defined == true && @celltype != nil then 2134 2039 if @celltype.instance_of?( Celltype ) then 2135 # celltype ã«ç»é²ï¼ã³ã¼ãçæã®å¯¾è±¡ã¨ãªãï¼2040 # celltype に登録(コード生成の対象となる) 2136 2041 @celltype.new_cell( @my_clone ) 2137 2042 end … … 2141 2046 end 2142 2047 2143 #=== Cell# clone ãããã»ã«ã®å 2144 é¨ã«æã¤ååæ 2145 å ±ã調æ´ãã 2146 #name:: string : 親 cell ã®åå (cell tComposite cell1 ã§ã® cell1) 2147 #global_name:: string : 親 cell ã® global_name 2148 #join_array:: Join[] : composite ã® cell ã® join ã§ããã® cell ã«å¯¾å¿ãããã® 2149 #parent_ct_name:: string : 親ã»ã«ã®ã»ã«ã¿ã¤ãåï¼composite ã»ã«ã¿ã¤ãï¼ 2150 # ãã®ã¡ã½ããã¯ããä¸ã® clone_for_composite ããå¼åºãããclone ãããã»ã«ãæ´ãã 2048 #=== Cell# clone されたセルの内部に持つ名前情報を調整する 2049 #name:: string : 親 cell の名前 (cell tComposite cell1 での cell1) 2050 #global_name:: string : 親 cell の global_name 2051 #join_array:: Join[] : composite の cell の join で、この cell に対応するもの 2052 #parent_ct_name:: string : 親セルのセルタイプ名(composite セルタイプ) 2053 # このメソッドはすぐ上の clone_for_composite から呼出され、clone されたセルを整える 2151 2054 def set_cloned( name, global_name, namespacePath, join_array, parent_ct_name, region, plugin, locale ) 2152 2055 … … 2165 2068 @f_cloned = true 2166 2069 2167 # Namespace.new_cell( self ) # mikan namespace 対å¿2168 region.new_cell( self ) # mikan namespace ã« cell ãç½®ããªããã¨ãä»®å®2169 2170 # join_list : NamedList ã® clone ãä½ã2070 # Namespace.new_cell( self ) # mikan namespace 対応 2071 region.new_cell( self ) # mikan namespace に cell を置けないことを仮定 2072 2073 # join_list : NamedList の clone を作る 2171 2074 if @celltype then 2172 2075 dbgPrint "set_cloned: #{@celltype.get_name} #{@name} #{region.get_name}\n" … … 2181 2084 @cell_list2 = [] 2182 2085 2183 # ãã®ã»ã«ã®ã°ãã¼ãã«åãä¸ãã2184 # C_EXP ã®$id$ ç½®æã¯ãã®ã»ã«ã®ååã«ãªã2086 # このセルのグローバル名を与える 2087 # C_EXP の$id$ 置換はこのセルの名前になる 2185 2088 join_array.each { |j| 2186 2089 @join_list.change_item j … … 2188 2091 end 2189 2092 2190 #=== clone ãããã»ã«ã composite ã®å ´åãå 2191 é¨ã»ã«ãå±éãã 2192 #self:: clone ãããã»ã«ã§ãªããã°ãªããªã 2093 #=== clone されたセルが composite の場合、内部セルを展開する 2094 #self:: clone されたセルでなければならない 2193 2095 def expand_inner 2194 2096 if ! @f_cloned then … … 2196 2098 end 2197 2099 2198 # clone ãããã¨ããã»ã«ã composit ã»ã«ã¿ã¤ãï¼2100 # clone しようとするセルが composit セルタイプ? 2199 2101 if @celltype.instance_of?( CompositeCelltype ) then 2200 # composite cell ãå帰çã«å±é2102 # composite cell を再帰的に展開 2201 2103 @cell_list, @cell_list2 = @celltype.expand( @name, @global_name, @NamespacePath, @join_list, @region, @plugin, @locale ) 2202 2104 end 2203 2105 end 2204 2106 2205 #=== Cell# clone ããã cell ã® join_list ã®å³è¾ºã®å¤æ´2206 # å¼ã³å£ã®å³è¾ºã® cell ãä»ã® clone ããã cell ã«ç½®æã2107 #=== Cell# clone された cell の join_list の右辺の変更 2108 # 呼び口の右辺の cell を他の clone された cell に置換え 2207 2109 def change_rhs_port cloned_cell_list 2208 2110 … … 2247 2149 end 2248 2150 2249 #=== Cell# çæãããã»ã«ãï¼2250 # æé©åãã³ã¼ãçæä¸ã«ã対象ã¨ãªã region ã«å±ããå ´å true ãè¿ã2151 #=== Cell# 生成されるセルか? 2152 # 最適化、コード生成中に、対象となる region に属する場合 true を返す 2251 2153 def is_generate? 2252 2154 if $generating_region == nil then 2253 # æ§æ解éãæå³è§£æ段éã§å¼ã°ããã¨ä¾å¤çºç2155 # 構文解釈、意味解析段階で呼ばれると例外発生 2254 2156 raise "is_generate? called before optimizing" 2255 2157 end … … 2263 2165 end 2264 2166 2265 #=== Cell# composite å 2266 é¨ã®è¤è£½ãããã»ã«ãï¼ 2267 # composite å®ç¾©ã®å 2268 é¨ã®ã»ã« (@in_composite = true) ã§ã¯ãªã 2167 #=== Cell# composite 内部の複製されたセルか? 2168 # composite 定義の内部のセル (@in_composite = true) ではない 2269 2169 def is_cloned? 2270 2170 @f_cloned 2271 2171 end 2272 2172 2273 #=== Cell# composite å 2274 é¨ã®ã»ã«ãï¼ 2173 #=== Cell# composite 内部のセルか? 2275 2174 def is_in_composite? 2276 2175 @in_composite 2277 2176 end 2278 2177 2279 #=== Cell# composite ã®ã»ã«ãï¼2178 #=== Cell# composite のセルか? 2280 2179 def is_of_composite? 2281 2180 if @celltype.kind_of? CompositeCelltype … … 2286 2185 end 2287 2186 2288 #=== Cell# tmp_plugin_post_code.cdl ã§çæãããã»ã«ãï¼2187 #=== Cell# tmp_plugin_post_code.cdl で生成されたセルか? 2289 2188 def post_code_generated? 2290 2189 @b_post_code_generated 2291 2190 end 2292 2191 2293 # composite cell ã® port ã«å¯¾å¿ããå 2294 é¨ã® cell ã® port ã®ååï¼ãªã³ã¯æã«å¿ 2295 è¦ãªååï¼ 2192 # composite cell の port に対応する内部の cell の port の名前(リンク時に必要な名前) 2296 2193 def get_real_global_name port_name 2297 2194 if @celltype.instance_of?( CompositeCelltype ) then … … 2321 2218 end 2322 2219 2323 #=== Cell# ã»ã«ã®åãå£ port_name ã«å¯¾ããå®éã®ã»ã«åãåãå£åã '_' ã§é£çµ2324 # namespace å + '_' + ã»ã«å + '_' + åãå£å ï¼ãã®ã»ã«ã composite ãªãã°å±éå¾ã®ã»ã«åãåãå£åï¼2220 #=== Cell# セルの受け口 port_name に対する実際のセル名、受け口名を '_' で連結 2221 # namespace 名 + '_' + セル名 + '_' + 受け口名 (このセルが composite ならば展開後のセル名、受け口名) 2325 2222 def get_real_global_port_name port_name 2326 2223 2327 # composite ãï¼2224 # composite か? 2328 2225 if @celltype.instance_of?( CompositeCelltype ) then 2329 2226 … … 2336 2233 } 2337 2234 2338 # ã»ã«ã¿ã¤ãå 2339 㧠port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçæ段éã§ã¯å¿ 2340 ãè¦ã¤ããï¼ 2235 # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる) 2341 2236 cj = @celltype.find_export( port_name ) 2342 2237 … … 2344 2239 dbgPrint " composite join name: #{cj.get_name} cell: #{cj.get_cell_name} cell elem: #{cj.get_cell_elem_name}\n" 2345 2240 2346 # composite ã®å 2347 é¨ã®ã»ã«ã«å¯¾ãå帰çã« get_real_global_port_name ãé©ç¨ 2241 # composite の内部のセルに対し再帰的に get_real_global_port_name を適用 2348 2242 name = @cell_list[ "#{cj.get_cell_name}" ].get_real_global_port_name( cj.get_cell_elem_name ) 2349 2243 return name … … 2357 2251 end 2358 2252 2359 #=== Cell# PORT (celltype ã®å®ç¾©) ãå¾ã2253 #=== Cell# PORT (celltype の定義) を得る 2360 2254 def get_real_port( port_name ) 2361 2255 2362 # composite ãï¼2256 # composite か? 2363 2257 if @celltype.instance_of?( CompositeCelltype ) then 2364 2258 2365 # ã»ã«ã¿ã¤ãå 2366 㧠port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçæ段éã§ã¯å¿ 2367 ãè¦ã¤ããï¼ 2259 # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる) 2368 2260 cj = @celltype.find_export( port_name ) 2369 2261 2370 # composite ã®å 2371 é¨ã®ã»ã«ã«å¯¾ãå帰çã« get_real_port ãé©ç¨ 2262 # composite の内部のセルに対し再帰的に get_real_port を適用 2372 2263 port = @cell_list[ "#{cj.get_cell_name}" ].get_real_port( cj.get_cell_elem_name ) 2373 2264 return port … … 2378 2269 end 2379 2270 2380 #=== Cell# cell ãå¾ã2381 # composite ã§ãªããã°èªåèªèº«ãè¿ã2271 #=== Cell# cell を得る 2272 # composite でなければ自分自身を返す 2382 2273 def get_real_cell( port_name ) 2383 2274 2384 # composite ãï¼2275 # composite か? 2385 2276 if @celltype.instance_of?( CompositeCelltype ) then 2386 2277 2387 # ã»ã«ã¿ã¤ãå 2388 㧠port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçæ段éã§ã¯å¿ 2389 ãè¦ã¤ããï¼ 2278 # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる) 2390 2279 # print "get_real_cell: cell=#{@name} port=#{port_name}\n" 2391 2280 # pp @cell_list 2392 2281 cj = @celltype.find_export( port_name ) 2393 2282 2394 # composite ã®å 2395 é¨ã®ã»ã«ã«å¯¾ãå帰çã« get_real_port ãé©ç¨ 2283 # composite の内部のセルに対し再帰的に get_real_port を適用 2396 2284 cell = @cell_list[ "#{cj.get_cell_name}" ].get_real_cell( cj.get_cell_elem_name ) 2397 2285 return cell … … 2412 2300 end 2413 2301 2414 #=== Cell# åãå£ã®port ã®åç 2415 §ã«ã¦ã³ããã¢ãããã 2416 #port_name:: Symbol : ãã¼ãå 2302 #=== Cell# 受け口のport の参照カウントをアップする 2303 #port_name:: Symbol : ポート名 2417 2304 def port_referenced port 2418 2305 if @referenced_port_list[ port ] then … … 2422 2309 end 2423 2310 2424 # composite ãï¼2311 # composite か? 2425 2312 if @celltype.instance_of?( CompositeCelltype ) then 2426 2313 2427 # ã»ã«ã¿ã¤ãå 2428 㧠port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçæ段éã§ã¯å¿ 2429 ãè¦ã¤ããï¼ 2314 # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる) 2430 2315 cj = @celltype.find_export( port.get_name ) 2431 2316 2432 2317 dbgPrint " port_referenced: #{@celltype.get_name} #{@name} cj=#{cj&&(cj.get_name)||"nil"}\n" 2433 2318 2434 if cj then # æ¢ã«ã¨ã©ã¼ 2435 # composite ã®å 2436 é¨ã®ã»ã«ã«å¯¾ãå帰çã« get_real_port ãé©ç¨ 2319 if cj then # 既にエラー 2320 # composite の内部のセルに対し再帰的に get_real_port を適用 2437 2321 cell = @cell_list[ "#{cj.get_cell_name}" ] 2438 2322 if cell && cell.get_celltype then … … 2457 2341 end 2458 2342 2459 #Cell#å±æ§ã®åæå¤ãå¾ã 2460 #attr_name::Symbol å¿ 2461 ãåæåããã¦ããªã㨠Ruby ä¾å¤ã¨ãªã 2343 #Cell#属性の初期値を得る 2344 #attr_name::Symbol 必ず初期化されていないと Ruby 例外となる 2462 2345 def get_attr_initializer attr_name 2463 2346 val = @join_list.get_item( attr_name ) … … 2499 2382 end 2500 2383 2501 #=== Cell# åãå£é 2502 åã®æ·»æ°ã®æ大å¤ãè¨å® 2384 #=== Cell# 受け口配列の添数の最大値を設定 2503 2385 def set_entry_port_max_subscript( port, num ) 2504 2386 dbgPrint( "set_entry_port_max_subscript: #{@name}.#{port.get_name}: #{num}\n" ) … … 2511 2393 end 2512 2394 2513 #=== Cell# composite ã®å 2514 å´ã»ã«ã®åãå£é 2515 åã®æ·»æ°ã®æ大å¤ãè¨å® 2395 #=== Cell# composite の内側セルの受け口配列の添数の最大値を設定 2516 2396 def set_entry_inner_port_max_subscript( port, num ) 2517 2397 if @cell_list == nil then 2518 return # ãããã¿ã¤ã宣è¨ããããã¦ããªãã¦ãå 2519 å´ã»ã«ãå±éããã¦ããªããor composite å±éå 2520 end 2521 2522 # composite ã®å 2523 å´ã®ã»ã«ã«ä¼æ 2398 return # プロトタイプ宣言しかされていなくて、内側セルが展開されていない or composite 展開前 2399 end 2400 2401 # composite の内側のセルに伝播 2524 2402 if @celltype.instance_of? CompositeCelltype then 2525 2403 dbgPrint "set_entry_inner_port_max_subscript #{@name} #{@port} #{num} cell_list.len=#{@cell_list.length}\n" … … 2538 2416 end 2539 2417 2540 #=== Cell# åãå£é 2541 åã®æ·»æ°ã®æ大å¤ãè¿ã 2542 # é·ã㯠+1 ãã 2543 # 1ã¤ããªãå ´å㯠-1 ãè¿ã 2418 #=== Cell# 受け口配列の添数の最大値を返す 2419 # 長さは +1 する 2420 # 1つもない場合は -1 を返す 2544 2421 def get_entry_port_max_subscript( port ) 2545 2422 subscript = @entry_array_max_subscript[port] … … 2550 2427 end 2551 2428 2552 #=== Cell# ãªã¬ã¼ã¢ãã±ã¼ã¿ã®çµåãçæ2429 #=== Cell# リレーアロケータの結合を生成 2553 2430 # STAGE: S 2554 # å¼ã³å£å´ã®çµåãå 2555 ã«åãå£å´ã®çµåãçæ 2431 # 呼び口側の結合を元に受け口側の結合を生成 2556 2432 def create_relay_allocator_join 2557 2433 2558 # celltype ããªããã°ãã§ãã¯ããªãï¼æ¢ã«ã¨ã©ã¼ï¼2434 # celltype がなければチェックしない(既にエラー) 2559 2435 return if @celltype == nil 2560 2436 2561 # relay allocator ãçæ2437 # relay allocator を生成 2562 2438 @celltype.get_port_list.each { |p| 2563 2439 ail = p.get_allocator_instance … … 2565 2441 dbgPrint "create_relay_allocator_join: #{@name}, #{p.get_name}\n" 2566 2442 if p.get_array_size then 2567 # mikan relay allocator ã array ã«å¯¾å¿ã§ãã¦ãããã®ã§ã¯ï¼2443 # mikan relay allocator が array に対応できてもよいのでは? 2568 2444 cdl_error( "S1040 array not supported for relay allocator" ) 2569 2445 next … … 2573 2449 if ai2[0] == :RELAY_ALLOC then 2574 2450 dbgPrint "create_relay_allocator_join: #{@name}, #{name}\n" 2575 # å¼ã³å£å´ã®çµåãåãåºã2451 # 呼び口側の結合を取り出す 2576 2452 ja = @join_list.get_item( :"#{ai2[3]}_#{ai2[4]}_#{ai2[5]}" ) 2577 2453 if ja == nil then 2578 # è¦ã¤ãããªãå ´å2454 # 見つからない場合 2579 2455 found = false 2580 2456 2581 # composite å 2582 ã§å¤é¨ã«çµåããã¦ããã 2457 # composite 内で外部に結合されているか 2583 2458 if @in_composite then 2584 2459 @compositecelltypejoin_list.get_items.each { |cj| … … 2597 2472 cdl_error( "S1041 \'$1_$2_$3\': not joined. cannot create internal join for relay allocator" , ai2[3], ai2[4], ai2[5] ) 2598 2473 print( " In cell #{get_name}\n" ) 2599 # join ãæªçµåã§ãããã¨ã®ã¨ã©ã¼ã¯äºåº¦ã§ã(S1043)2474 # join が未結合であることのエラーは二度でる (S1043) 2600 2475 end 2601 next # æã¡åã2476 next # 打ち切る 2602 2477 end 2603 2478 2604 2479 b_export = false 2605 # composite å 2606 ã®ã»ã«ã§ã¨ã¯ã¹ãã¼ãããã¦ããããã§ã㯠2607 # mikan ã¨ã¯ã¹ãã¼ãå´ã¨ããã¡ãå´ã§ããªã¬ã¼å 2608 ãä¸è´ããããã§ãã¯ãå¿ 2609 è¦ 2480 # composite 内のセルでエクスポートされているかチェック 2481 # mikan エクスポート側と、こちら側で、リレー先が一致するかチェックが必要 2610 2482 if @compositecelltypejoin_list then 2611 # export ããã¦ããã調ã¹ã2483 # export されているか調べる 2612 2484 @compositecelltypejoin_list.get_items.each{ |cj| 2613 # å±æ§å㨠composite ã® export ããååã¯ä¸è´ããã2485 # 属性名と composite の export する名前は一致するか 2614 2486 if p.get_name == cj.get_cell_elem_name then 2615 2487 print "export : #{p.get_name}\n" 2616 b_export = true # å±æ§ã¯ export ããã¦ããã®ã§ãã¨ããããæªåæåã¨ã¯ããªã2488 b_export = true # 属性は export されているので、とりあえず未初期化とはしない 2617 2489 break 2618 2490 end … … 2621 2493 end 2622 2494 2623 # mikan é 2624 å 2495 # mikan 配列 2625 2496 am = nil 2626 2497 if am then … … 2629 2500 subscript = ja2.get_subscript 2630 2501 if b_export == false then 2631 # CompositeCelltype ã®å ´åãå 2632 å´ã®ã»ã«ã§çæããã 2502 # CompositeCelltype の場合、内側のセルで生成させる 2633 2503 join = Join.new( :"#{p.get_name}_#{ai2[1]}_#{ai2[2]}", subscript, rhs, @loacle ) 2634 2504 # p ( "#{p.get_name}_#{ai2[1]}_#{ai2[2]}", subscript, rhs ) 2635 2505 new_join( join ) 2636 2506 join.set_definition( @celltype.find(join.get_name) ) 2637 # mikan relay mismatch ãã§ãã¯ãã§ãã¦ããªãï¼ä¸æ¹ãåç 2638 §ï¼ 2507 # mikan relay mismatch チェックができていない(下方を参照) 2639 2508 end 2640 2509 @alloc_list << [ :NORMAL_ALLOC, p.get_name, subscript, ai2[1], ai2[2], rhs ] … … 2642 2511 else 2643 2512 if b_export == false then 2644 # CompositeCelltype ã®å ´åãå 2645 å´ã®ã»ã«ã§çæããã 2513 # CompositeCelltype の場合、内側のセルで生成させる 2646 2514 join = Join.new( :"#{p.get_name}_#{ai2[1]}_#{ai2[2]}", nil, ja.get_rhs, @locale ) 2647 2515 new_join( join ) … … 2653 2521 "#{p.get_name}_#{ai2[1]}_#{ai2[2]}", 2654 2522 "#{ai2[3]}_#{ai2[4]}_#{ai2[5]}" ) 2655 # æ¬å½ã¯ composite ã®å¼ã³å£ã¨åãå£ã®éã§è¡ãã¹ãã ããå 2656 é¨ã§å¤æ®µæ¥ç¶ããã¦ããå ´å 2523 # 本当は composite の呼び口と受け口の間で行うべきだが、内部で多段接続されている場合 2657 2524 else 2658 2525 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" … … 2669 2536 end 2670 2537 2671 #=== Cell# @@cell_list2 ãä½ã 2672 # @@cell_list2 ã¯ãåºç¾é ã« composite å 2673 ãå«ãã»ã«ã®ãªã¹ã 2538 #=== Cell# @@cell_list2 を作る 2539 # @@cell_list2 は、出現順に composite 内を含むセルのリスト 2674 2540 def self.make_cell_list2 2675 2541 @@cell_list.each{ |c| … … 2679 2545 end 2680 2546 2681 #=== Cell# @@cell_list2 ãå¾ã 2682 # composite å 2683 ãå«ã (compositeãå«ã) 2684 # æå³è§£æå¾ã«ä½æããã 2547 #=== Cell# @@cell_list2 を得る 2548 # composite 内を含む (compositeも含む) 2549 # 意味解析後に作成される 2685 2550 def self.get_cell_list2 2686 2551 @@cell_list2 2687 2552 end 2688 2553 2689 #=== Cell# @@cell_list ãå¾ã2690 #composite ã®ä¸ãå«ã¾ãªã2554 #=== Cell# @@cell_list を得る 2555 #composite の中を含まない 2691 2556 def self.get_cell_list 2692 2557 @@cell_list 2693 2558 end 2694 2559 2695 #=== Cell# reverse_join ãçæãã2560 #=== Cell# reverse_join を生成する 2696 2561 def self.create_reverse_join 2697 2562 @@cell_list.each{ |c| … … 2705 2570 end 2706 2571 2707 #=== Cell# reverse_require_join ãçæãã2572 #=== Cell# reverse_require_join を生成する 2708 2573 def self.create_reverse_require_join 2709 2574 @@cell_list2.each{ |c| … … 2711 2576 # if c.is_generate? then 2712 2577 if ct then 2713 # self ã¸ã®å¼ã³å£å´ã®çµåãçæ2578 # self への呼び口側の結合を生成 2714 2579 ct.create_reverse_require_join c 2715 2580 end … … 2718 2583 end 2719 2584 2720 #=== Cell# åãå£ã®port ã®åç 2721 §ã«ã¦ã³ããè¨å®ãã 2722 # self ã¯å¼ã³å 2723 ã®ã»ã« 2724 # å¼ã³å 2725 ã»ã«ã®åãå£ã®åç 2726 §ã«ã¦ã³ããã¢ãããã 2585 #=== Cell# 受け口のport の参照カウントを設定する 2586 # self は呼び元のセル 2587 # 呼び先セルの受け口の参照カウントをアップする 2727 2588 def set_port_reference_count 2728 2589 @join_list.get_items.each { |j| 2729 2590 if j.get_definition.instance_of? Port then 2730 2591 am = j.get_array_member2 2731 if am then # å¼ã³å£é 2732 å 2592 if am then # 呼び口配列 2733 2593 am.each { |j2| 2734 next if j2 == nil # optional ã§ä¸é¨ãæ¬ è½ãã¦ããã±ã¼ã¹2594 next if j2 == nil # optional で一部が欠落しているケース 2735 2595 cell = j2.get_rhs_cell2 2736 next if cell == nil # å³è¾ºãè¦ã¤ãããªãã£ãï¼æ¢ã«ã¨ã©ã¼2596 next if cell == nil # 右辺が見つからなかった.既にエラー 2737 2597 port = cell.get_celltype.find( j2.get_rhs_port2 ) 2738 2598 dbgPrint( "set_port_reference_count: #{@name}.#{j2.get_name} => #{cell.get_name}.#{port.get_name}\n") … … 2741 2601 else 2742 2602 cell = j.get_rhs_cell2 2743 next if cell == nil || cell.get_celltype == nil # å³è¾ºãè¦ã¤ãããªãã£ãï¼æ¢ã«ã¨ã©ã¼2603 next if cell == nil || cell.get_celltype == nil # 右辺が見つからなかった.既にエラー 2744 2604 port = cell.get_celltype.find( j.get_rhs_port2 ) 2745 2605 if port == nil then 2746 2606 dbgPrint "set_port_ref: #{@name}.#{j.get_name} = #{cell.get_name}.#{j.get_rhs_port2}\n" 2747 # through ãã©ã°ã¤ã³ã§çæãããã»ã«ã®åãå£ãè¦ã¤ãããªãã±ã¼ã¹ (ã®ããº)2607 # through プラグインで生成されたセルの受け口が見つからないケース (のハズ) 2748 2608 cdl_error( "entry '$1' not found in '$2' refered from $3.$4", j.get_rhs_port2, cell.get_name, @name, j.get_name ) 2749 2609 next … … 2756 2616 end 2757 2617 2758 #=== Cell# çµå(Join)ã®ãã§ãã¯2759 # Join ã¯å¼ã³å£ã®çµåã¾ã㯠attribute ã®åæå2618 #=== Cell# 結合(Join)のチェック 2619 # Join は呼び口の結合または attribute の初期化 2760 2620 # 2761 # mikan ãã®ã¡ã½ããã¯ã以ä¸ã®ï¼ã¤ã®ãã§ãã¯ãããªãããåå²ããã»ããããé©åãªé·ãã®ã¡ã½ããã«ãªã 2762 # ã»ãªã¬ã¼ã¢ãã±ã¼ã¿ã®çæ => create_relay_allocator_join 2763 # ã»æªçµåã®å¼ã³å£ã®ãã§ã㯠2764 # ã»ãã¤ã³ã¿åãé 2765 åã§åæåãããå ´åã®ãã§ã㯠2766 # ã»æªåæåã®å±æ§ã®ãã§ã㯠2621 # mikan このメソッドは、以下の4つのチェックからなるが、分割したほうがより適切な長さのメソッドになる 2622 # ・リレーアロケータの生成 => create_relay_allocator_join 2623 # ・未結合の呼び口のチェック 2624 # ・ポインタ型が配列で初期化される場合のチェック 2625 # ・未初期化の属性のチェック 2767 2626 def check_join 2768 2627 2769 # celltype ããªããã°ãã§ãã¯ããªãï¼æ¢ã«ã¨ã©ã¼ï¼2628 # celltype がなければチェックしない(既にエラー) 2770 2629 return if @celltype == nil 2771 2630 return if @b_defined == false 2772 return if @f_cloned == true # å 2773 é¨ã»ã«ã«ã¤ãã¦ã¯ãcomposite ã®å®ç¾©æã«ãã§ãã¯ããã¦ãã 2631 return if @f_cloned == true # 内部セルについては、composite の定義時にチェックされている 2774 2632 2775 2633 # debug … … 2779 2637 # end 2780 2638 2781 # æªçµåã®å¼ã³å£ã®ãã§ãã¯2639 # 未結合の呼び口のチェック 2782 2640 @celltype.get_port_list.each { |p| 2783 2641 2784 # å¼ã³å£ã§ãªããã°ããã§ãã¯ããªã2642 # 呼び口でなければ、チェックしない 2785 2643 next if p.get_port_type != :CALL 2786 2644 … … 2788 2646 dbgPrint "check_join: #{@name} #{get_celltype.get_name} #{p.get_name}\n" 2789 2647 2790 # çµåãªã¹ãã®ä¸ããå¼ã³å£åã«ä¸è´ãããã®ãåãã ã2648 # 結合リストの中から呼び口名に一致するものを取りだす 2791 2649 j = @join_list.get_item( p.get_name ) 2792 2650 2793 2651 if j == nil then 2794 # æªçµåã®å¼ã³å£ 2795 2796 # composite celltype ã®å 2797 é¨ã®å ´åãcomposite celltype ã export ããå¼ã³å£ã«çµåããã¦ãããæ¢ã 2652 # 未結合の呼び口 2653 2654 # composite celltype の内部の場合、composite celltype が export する呼び口に結合されているか探す 2798 2655 found = false 2799 2656 if @in_composite then 2800 # composite celltype ã® export ãããã®ãã¹ã¦ããæ¢ã2801 # ï¼export ãããã®ã®å³è¾ºå¤ããæ¢ãããã« get_item ã§ã¯ãã¡ï¼2657 # composite celltype の export するものすべてから探す 2658 # (export するものの右辺値から探すために get_item ではダメ) 2802 2659 @compositecelltypejoin_list.get_items.each{ |cj| 2803 # å¼ã³å£å㨠composite ã® export ããååã¯ä¸è´ããã2660 # 呼び口名と composite の export する名前は一致するか 2804 2661 if p.get_name == cj.get_cell_elem_name then 2805 2662 found = true … … 2808 2665 end 2809 2666 2810 # å¼ã³å£é 2811 åã®å ´å optional ã§å 2812 ¨ã¦ã®è¦ç´ ãåæåãããªãå ´åã«ãããã¸æ¥ã 2667 # 呼び口配列の場合 optional で全ての要素が初期化されない場合に、ここへ来る 2813 2668 if ! found && ! p.is_require? && ! p.is_optional? then 2814 2669 if ! p.is_allocator_port? then … … 2819 2674 end 2820 2675 elsif p.get_array_size.kind_of? Integer then 2821 # æ·»æ°ããå¼ã³å£é 2822 åã®å ´åããã¹ã¦ã®æ·»æ°è¦ç´ ãåæåããã¦ããããã§ãã¯ãã 2676 # 添数あり呼び口配列の場合、すべての添数要素が初期化されているかチェックする 2823 2677 2824 2678 am = j.get_array_member2 2825 2679 if( am )then 2826 # join ã¯é 2827 å 2828 2829 # å¼ã³å£é 2830 åå®ç¾©ã§ã®é 2831 åã®å¤§ãã 2680 # join は配列 2681 2682 # 呼び口配列定義での配列の大きさ 2832 2683 length = p.get_array_size 2833 2684 2834 # é 2835 åã®å¤§ãããå¼ã³å£é 2836 åå®ç¾©ã¨çµåå®ç¾©ã§ä¸è´ãããï¼ 2685 # 配列の大きさが呼び口配列定義と結合定義で一致するか? 2837 2686 if am.length != length then 2838 2687 if ! p.is_optional? || am.length >= length then 2839 # optional ã®å ´åãè¦ç´ æ°ãå°ãªãããã®ã¯OK2688 # optional の場合、要素数が少なすぎるのは OK 2840 2689 cdl_error( "S1044 $1: array initializer too many or few, $2 for $3" , p.get_name, am.length, length ) 2841 2690 end 2842 2691 2843 # am ã®è¦ç´ ã« nil ã追å ãã¦ãã (#_CPA_# ã®ã³ã¼ãçææããã®é 2844 åè¦ç´ æ°åçæ) 2692 # am の要素に nil を追加しておく (#_CPA_# のコード生成時、この配列要素数分生成) 2845 2693 i = am.length 2846 2694 while i < length … … 2850 2698 end 2851 2699 2852 # # é 2853 åè¦ç´ ã®æãããªãããã§ã㯠2854 # if am.length < length then # æºããªãå ´åæ¢ã«ã¨ã©ã¼ã ãè¦ç´ ã®ããç¯å²ã§ãã§ã㯠2700 # # 配列要素の抜けがないかチェック 2701 # if am.length < length then # 満たない場合既にエラーだが要素のある範囲でチェック 2855 2702 # length = am.length 2856 2703 # end … … 2862 2709 end 2863 2710 else 2864 # çæãããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯2711 # 生成されないリージョンへの結合かチェック 2865 2712 if ! @in_composite then 2866 2713 am[i].check_region2 … … 2871 2718 2872 2719 # else 2873 # join ãéé 2874 åã§ããã°ãæ¢ã«ã¨ã©ã¼ 2720 # join が非配列であれば、既にエラー 2875 2721 end 2876 2722 elsif j.get_array_member then 2877 # æ·»æ°ãªãå¼ã³å£é 2878 åã®å ´å 2723 # 添数なし呼び口配列の場合 2879 2724 am = j.get_array_member2 2880 2725 length = am.length … … 2889 2734 end 2890 2735 2891 # çæãããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯2736 # 生成されないリージョンへの結合かチェック 2892 2737 if ! @in_composite then 2893 2738 am.each { |join| … … 2898 2743 end 2899 2744 else 2900 # å¼ã³å£ï¼»é 2901 åãã§ãªãå ´å 2902 2903 # çæãããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ã㯠2745 # 呼び口[配列」でない場合 2746 2747 # 生成されないリージョンへの結合かチェック 2904 2748 if ! @in_composite then 2905 2749 j.check_region2 … … 2909 2753 } 2910 2754 2911 # ãã¤ã³ã¿åãé 2912 åã§åæåãããå ´åã®ãã§ã㯠2755 # ポインタ型が配列で初期化される場合のチェック 2913 2756 (@celltype.get_attribute_list+@celltype.get_var_list).each { |a| 2914 2757 if a.get_size_is then 2915 2758 2916 2759 if a.instance_of? CompositeCelltypeJoin then 2917 # æ¢ã«ã¨ã©ã¼ã«ãªã£ã¦ãã2760 # 既にエラーになっている 2918 2761 # cdl_error( "S1047 size_is pointer cannot be exposed for composite attribute" ) 2919 2762 next … … 2925 2768 size = a.get_size_is.eval_const( @join_list, @celltype.get_name_list ) 2926 2769 a.get_type.set_scs( a.get_size_is, nil, nil, nil, false ) 2927 if( ! size.kind_of? Integer )then # C_EXP ã®å¯è½æ§ãã2928 # mikan å¤åããã§ã®ã¨ã©ã¼çºçã¯ä¸è¦ãeval_const ã®ä¸ã§å¤æ°ãåå¨ããªããåãä¸é©åãªã©ã®ã¨ã©ã¼ã«ãªãã¯ã2770 if( ! size.kind_of? Integer )then # C_EXP の可能性あり 2771 # mikan 多分ここでのエラー発生は不要、eval_const の中で変数が存在しない、型が不適切などのエラーになるはず 2929 2772 cdl_error( "S1049 $1: size_is arg not constant" , a.get_name ) 2930 2773 else … … 2942 2785 end 2943 2786 else 2944 # size_is å¼æ°ãã»ã«ã§æå®ããã¦ãã¦ãåæååãã»ã«ã¿ã¤ãã§æå®ããã¦ããã±ã¼ã¹ã®ãã§ãã¯2787 # size_is 引数がセルで指定されていて、初期化子がセルタイプで指定されているケースのチェック 2945 2788 ini = a.get_initializer 2946 2789 if ini.instance_of? Expression … … 2957 2800 else 2958 2801 if ! a.instance_of? CompositeCelltypeJoin then 2959 # composite 㯠size_is æå®ã§ããªã2802 # composite は size_is 指定できない 2960 2803 if a.get_type.kind_of?( PtrType ) then 2961 2804 j = @join_list.get_item( a.get_identifier ) 2962 2805 if j && j.get_rhs.instance_of?( Array ) then 2963 ## size_is æå®ããã¦ããªããã¤ã³ã¿ã Array ã§åæåããã¦ããããã¨ã©ã¼ã¨ãã2806 ## size_is 指定されていないポインタが Array で初期化されていたら、エラーとする 2964 2807 cdl_error( "S1169 $1: non-size_is pointer cannot be initialized with array initializer" , a.get_identifier ) 2965 2808 end … … 2969 2812 } 2970 2813 2971 # æªåæåã®å±æ§ããã§ãã¯2814 # 未初期化の属性をチェック 2972 2815 @celltype.get_attribute_list.each { |a| 2973 2816 b_init = false 2974 2817 # self.show_tree 1 2975 if a.get_initializer then # ã»ã«ã¿ã¤ãã§åæåããã¦ãã2818 if a.get_initializer then # セルタイプで初期化されている 2976 2819 b_init = true 2977 # @in_composite 㧠export ããã¦ããå ´åã«ã¯ããã®åæå¤ã¯ä½¿ãããªã2978 # export ããã¦ãããããªãã«é¢ããããåæåããã¦ãããã¨ãä¿è¨¼ããã2979 elsif @join_list.get_item( a.get_name ) then # ã»ã«ã§åæåããã¦ãã2820 # @in_composite で export されている場合には、この初期値は使われない 2821 # export されている、いないに関わらず、初期化されていることが保証される 2822 elsif @join_list.get_item( a.get_name ) then # セルで初期化されている 2980 2823 b_init = true 2981 2824 elsif @in_composite && @compositecelltypejoin_list then 2982 # å±æ§ã export ããã¦ããã調ã¹ããexport ããã¦ããã°æªåæåã¨ã¯ããªã2983 # mikan ãªãã¢ãµã¼ã2825 # 属性が export されているか調べる。export されていれば未初期化とはしない 2826 # mikan リニアサーチ 2984 2827 @compositecelltypejoin_list.get_items.each{ |cj| 2985 # å±æ§å㨠composite ã® export ããååã¯ä¸è´ããã2828 # 属性名と composite の export する名前は一致するか 2986 2829 if a.get_name.to_sym == cj.get_cell_elem_name.to_sym then 2987 b_init = true # å±æ§ã¯ export ããã¦ããã®ã§ãã¨ããããæªåæåã¨ã¯ããªã2830 b_init = true # 属性は export されているので、とりあえず未初期化とはしない 2988 2831 end 2989 2832 } 2990 2833 if b_init then 2991 # size_is ã®å¼æ°ããããããããã§ãã¯ãã 2992 # å 2993 é¨ã»ã«ã® size_is ãã¨ã¯ã¹ãã¼ããã size_is ã¨ãããããããã§ãã¯ãã 2994 # å 2995 é¨ã»ã«ã¨ã¨ã¯ã¹ãã¼ãã§ååãå¤ãã¦ããå¯è½æ§ãããã®ã§ãå 2996 é¨ã»ã«ã® size_is ã®ååãå¤æããä¸ã§ãã§ãã¯ãã 2834 # size_is の引数がマッチするかチェックする 2835 # 内部セルの size_is をエクスポートする size_is とマッチするかチェックする 2836 # 内部セルとエクスポートで名前を変えている可能性があるので、内部セルの size_is の名前を変換した上でチェックする 2997 2837 if a.get_size_is then 2998 2838 ### p "attr: get_size_is" … … 3000 2840 if cj.get_port_decl.instance_of? Decl then 3001 2841 ### p "attr: get_size_is 2" 3002 # cj_size_is ã¯ãå¤é¨å 3003 ¬éããã attr ã® size_is 2842 # cj_size_is は、外部公開される attr の size_is 3004 2843 cj_size_is = cj.get_port_decl.get_size_is 3005 2844 if cj_size_is == nil then … … 3010 2849 remain = exprs 3011 2850 inner_to_export = {} 3012 ### exprs ã«å«ã¾ããèå¥åãæãåºãã対å¿ãã export ãããååãæ¢ã2851 ### exprs に含まれる識別子を抜き出し、対応する export される名前を探す 3013 2852 while remain != "" && remain != nil 3014 2853 ### p "remain ", remain 3015 remain =~ /([^\w]*)([_A-Za-z][\w\d]*)/ # å¤æ°åæååãåãåºã2854 remain =~ /([^\w]*)([_A-Za-z][\w\d]*)/ # 変数名文字列を取り出す 3016 2855 if $2 == nil then 3017 2856 break … … 3020 2859 remain = $' 3021 2860 ### p exprs, $1, $2, $' 3022 # size_is ã«å«ã¾ããå¤æ°ã¯ãcomposite 㧠export ããã¦ããã2861 # size_is に含まれる変数は、composite で export されているか 3023 2862 cj2 = nil 3024 2863 @compositecelltypejoin_list.get_items.each{ |cj2t| … … 3033 2872 if cj2.get_port_decl.instance_of? Decl then 3034 2873 decl2 = cj2.get_port_decl 3035 # å 3036 é¨ã®ååã¨å¤é¨ã®ååã®å¯¾å¿é¢ä¿ãè¨æ¶ 2874 # 内部の名前と外部の名前の対応関係を記憶 3037 2875 inner_to_export[arg_name] = decl2.get_name 3038 # else cj2 㯠Port (æ¢ã«ã¨ã©ã¼)2876 # else cj2 は Port (既にエラー) 3039 2877 end 3040 2878 end 3041 # å 3042 é¨ã®ååãå¤é¨ã®ååã§ç½®æ 2879 # 内部の名前を外部の名前で置換 3043 2880 inner_to_export.each{ |arg_name, exp_name| 3044 2881 ### p "changing #{arg_name}=>#{exp_name}" 3045 2882 # exprs.gsub!( Regexp.new("#{arg_name}[^0-9A-Za-z_]"), exp_name.to_s ) 3046 exprs.gsub!( Regexp.new("#{arg_name}(\\W)"), exp_name.to_s+"\\1" ) # æååæ«å°¾ã«ãªãã±ã¼ã¹3047 exprs.gsub!( Regexp.new("#{arg_name}\\Z"), exp_name.to_s ) # æååæ«å°¾ã«ããã±ã¼ã¹2883 exprs.gsub!( Regexp.new("#{arg_name}(\\W)"), exp_name.to_s+"\\1" ) # 文字列末尾にないケース 2884 exprs.gsub!( Regexp.new("#{arg_name}\\Z"), exp_name.to_s ) # 文字列末尾にあるケース 3048 2885 } 3049 2886 ### p "changed: #{exprs} #{cj_size_is.to_s}" … … 3051 2888 cdl_error( "S1172 \'$1\' size_is argument mismatch with exporting one \'$2\'", a.get_name, cj.get_name ) 3052 2889 end 3053 # else cj 㯠Port (æ¢ã«ã¨ã©ã¼)2890 # else cj は Port (既にエラー) 3054 2891 end 3055 2892 end … … 3064 2901 end 3065 2902 3066 #=== Cell# é require ããã§ãã¯ãã 3067 # é require æå®ãããåãå£ã«è¤æ°ã®çµåããªãããã§ãã¯ãã 3068 # composite ã®å 3069 é¨ã»ã« (f_cloned=true) ããã§ãã¯ãã 2903 #=== Cell# 逆 require をチェックする 2904 # 逆 require 指定された受け口に複数の結合がないかチェックする 2905 # composite の内部セル (f_cloned=true) もチェックする 3070 2906 def check_reverse_require 3071 # celltype ããªããã°ãã§ãã¯ããªãï¼æ¢ã«ã¨ã©ã¼ï¼2907 # celltype がなければチェックしない(既にエラー) 3072 2908 return if @celltype == nil 3073 2909 return if @b_defined == false 3074 2910 3075 2911 # p "check reverse require #{@name}" 3076 # érequire æå®ãããåãå£ã«è¤æ°ã®çµåããªãããã§ãã¯2912 # 逆require 指定された受け口に複数の結合がないかチェック 3077 2913 @referenced_port_list.each{ |port,count| 3078 2914 # p port.class, count … … 3084 2920 end 3085 2921 3086 #=== Cell# require å¼ã³å£ã®çµåãè¡ã2922 #=== Cell# require 呼び口の結合を行う 3087 2923 # STAGE: S 3088 #cp_name:: Symbol : å¼ã³å£å3089 #cell_or_t:: Celltype|Cell : celltype ã® require ã®å³è¾ºã§æå®ãããã»ã«ã¿ã¤ãã¾ãã¯ã»ã«3090 #port:: Port : celltype ã® Port ãªãã¸ã§ã¯ã2924 #cp_name:: Symbol : 呼び口名 2925 #cell_or_t:: Celltype|Cell : celltype の require の右辺で指定されたセルタイプまたはセル 2926 #port:: Port : celltype の Port オブジェクト 3091 2927 def set_require_join( cp_name, cell_or_ct, port ) 3092 2928 3093 # set_require_join ã¯2度å¼ã³åºããã3094 # 2 度ç®ã¯ post ã³ã¼ããçæããå¾ ##### ãã£ããè¦åããï¼éè¤ã¨ã©ã¼ãè¦éãï¼2929 # set_require_join は2度呼び出される 2930 # 2度目は post コードを生成した後 ##### いったん見合わせ(重複エラーを見逃す) 3095 2931 # if @require_joined_list[ cp_name ] then 3096 2932 # return … … 3109 2945 end 3110 2946 else 3111 # require: cell ã§æå®2947 # require: cell で指定 3112 2948 cell = cell_or_ct 3113 2949 if @region.distance( cell.get_region ) == nil then … … 3119 2955 cdl_warning( "W1003 $1 : require call port overridden in $2" , cp_name, @name ) 3120 2956 else 3121 # require ã® join ãçæ(å¼ã³å£ã®çµå)2957 # require の join を生成(呼び口の結合) 3122 2958 # rhs = Expression.new( [ :OP_DOT, [ :IDENTIFIER, Token.new( cell.get_name, nil, nil, nil ) ], 3123 2959 nsp = NamespacePath.new( cell.get_name, false, cell.get_namespace ) … … 3132 2968 end 3133 2969 3134 #=== Cell# Join ã® definition ã®è¨å®ã¨ãã§ãã¯2970 #=== Cell# Join の definition の設定とチェック 3135 2971 # STAGE: S 3136 2972 def set_definition_join 3137 return if @celltype == nil # æ¢ã«ã¨ã©ã¼ï¼æã¡åã3138 return if @b_defined == false # ãããã¿ã¤ã宣è¨ã®ã¿3139 return if @b_checked == true # æ¢ã«è¨å®ï¼ãã§ãã¯ï¼æ¸ã¿2973 return if @celltype == nil # 既にエラー:打ち切る 2974 return if @b_defined == false # プロトタイプ宣言のみ 2975 return if @b_checked == true # 既に設定(チェック)済み 3140 2976 3141 2977 dbgPrint "set_definition_join in #{@name}\n" 3142 2978 3143 # relay allocator ããã©ã£ã¦åå 3144 ¥ããªããããå 3145 é 㧠@b_checked ã true ã«ãã 2979 # relay allocator をたどって再入しないよう、先頭で @b_checked を true にする 3146 2980 @b_checked = true 3147 2981 … … 3149 2983 check_restrict_list 3150 2984 3151 # compoiste ã»ã«ã®ã¯ãã¼ã³ããããã®ã¯ãset_definition ä¸è¦ 3152 # å 3153 ã® join ã¯æ¢ã« definition ããã¦ãã 3154 # å 3155 ã®ã»ã«ã«ããã¦ã代å 3156 ¥ãã§ãã¯ããã¦ããã®ã§ãäºéã«ãã§ãã¯(throughé©ç¨)ããã¦ãã¾ã 2985 # compoiste セルのクローンされたものは、set_definition 不要 2986 # 元の join は既に definition されている 2987 # 元のセルにおいて、代入チェックされているので、二重にチェック(through適用)されてしまう 3157 2988 @join_list.get_items.each{ |join| 3158 2989 dbgPrint " set_definition_join: checking #{@name}.#{join.get_name}\n" … … 3160 2991 port = @celltype.find(join.get_name) 3161 2992 join.get_array_member2.each { |am| 3162 if am == nil then # æªçµåã®å ´åãã¨ã©ã¼ãã§ãã¯ã¯check_join2993 if am == nil then # 未結合の場合、エラーチェックは check_join 3163 2994 if port && ! port.is_optional? then 3164 # ãã¹ãç¨ã«ã¨ã©ã¼ã¡ãã»ã¼ã¸åºå2995 # テスト用にエラーメッセージ出力 3165 2996 # cdl_error( "TEMPORAL set_definition_join: uninitialized array member" ) 3166 2997 end … … 3176 3007 end 3177 3008 3178 # ãªã¬ã¼ join 㯠through ãã©ã°ã¤ã³çæå¾ã«ããã§ããªã 3179 # through å¾ã«çµåå 3180 ãå 3181 ¥ãæ¿ãããã 3009 # リレー join は through プラグイン生成後にしかできない 3010 # through 後に結合先が入れ替えられる 3182 3011 create_relay_allocator_join 3183 3012 3184 # composite ã»ã«ã®å±é3013 # composite セルの展開 3185 3014 if ! @in_composite && ! @f_cloned && @celltype.instance_of?( CompositeCelltype ) then 3186 # composite ã»ã«ã¿ã¤ãå 3187 ã® composite ã¯å±éããªã 3188 # compoiste ã»ã«å±éä¸ã® composite ã¯å±éããªã (CompositeCelltype::expand å 3189 ã§å帰çã« expnad) 3015 # composite セルタイプ内の composite は展開しない 3016 # compoiste セル展開中の composite は展開しない (CompositeCelltype::expand 内で再帰的に expnad) 3190 3017 expand 3191 3018 end 3192 3019 end 3193 3020 3194 #=== Cell# composite ã»ã«ã®å±é3195 # ãã®ã»ã«ã composite ã»ã«ã¿ã¤ã3021 #=== Cell# composite セルの展開 3022 # このセルが composite セルタイプ 3196 3023 def expand 3197 3024 … … 3199 3026 dbgPrint "===== expanding #{@name} =====\n" 3200 3027 3201 # composite celltype ã® cell ãå±é3028 # composite celltype の cell を展開 3202 3029 @cell_list, @cell_list2 = @celltype.expand( @name, @global_name, @NamespacePath, @join_list, @region, @plugin, @locale ) 3203 3030 3204 # ãããã¿ã¤ããåç 3205 §ããã¦ããå ´åãåãåç 3206 §ããã¦ãããã¨ã«ãã 3031 # プロトタイプが参照されている場合、子も参照されていることにする 3207 3032 if @f_ref then 3208 3033 dbgPrint "expand: set_f_ref\n" … … 3211 3036 end 3212 3037 3213 #=== Cell#å 3214 é¨ã»ã«ã®åãå£æ·»æ°æ大å¤ãè¨å® 3038 #=== Cell#内部セルの受け口添数最大値を設定 3215 3039 def set_max_entry_port_inner_cell 3216 3040 if @cell_list == nil then … … 3220 3044 dbgPrint "set_max_entry_port_inner_cell name=#{@name} entry_array_max_subscript.len=#{@entry_array_max_subscript.length}\n" 3221 3045 3222 # ãããã¿ã¤ã宣è¨ã§è¨å®ããã¦ãããã®ãåæ ãã3046 # プロトタイプ宣言で設定されていたものを反映する 3223 3047 @entry_array_max_subscript.each{ |port,name| 3224 3048 dbgPrint "set_entry_inner_port_max_subscript( #{port}, #{name} )\n" … … 3227 3051 end 3228 3052 3229 #=== Cell#restrict ã追å3053 #=== Cell#restrict を追加 3230 3054 def add_restrict( entry_name, func_name, region_name_list ) 3231 3055 if @restrict_list[ entry_name ] == nil then … … 3260 3084 else 3261 3085 cdl_info( "I9999 $1: restrict calling domain to $2, which is same domain as the cell locates", @name, rp.to_s ) 3262 # restrict ãåããã¡ã¤ã³ãæå®ãã¦ããããã¨ã¨ãã (HRP3) 3263 # KernelDoamin å 3264 ã®ã»ã«ã«å¯¾ããKernelDomain ã« restrict ãã¦ããå ´åã 3265 # ç¡æå±çµç±ã§çµåããã¦ããããKernelDomain ããå¼åºããã¨ãæ³å®ããè¨±å¯ 3086 # restrict を同じドメインを指定してもよいこととする (HRP3) 3087 # KernelDoamin 内のセルに対し、KernelDomain に restrict している場合、 3088 # 無所属経由で結合されているが、KernelDomain から呼出すことを想定した許可 3266 3089 end 3267 3090 else … … 3311 3134 3312 3135 #=== Cell#get_callable_regions( entry_name, func_name ) 3313 # func_name=nil ã®å ´åãentry_name ã®å¯å¦ããã§ãã¯æ°ã3314 # nil ãè¿ãå ´åãå¶éããã¦ããªããã¨ãæå³ãã3136 # func_name=nil の場合、entry_name の可否をチェック数る 3137 # nil が返る場合、制限されていないことを意味する 3315 3138 def get_restricted_regions( entry_name, func_name ) 3316 3139 # p "get_restricted_regions #{@name}" … … 3327 3150 3328 3151 #=== Cell#has_ineffective_restrict_specifier 3329 # restrict æå®åãæå®ããã¦ãã¦ãåç 3330 §ããã¦ããªãå ´å true 3331 # åç 3332 §ã¯ãHRPSVCPlugin ã®ã¿ 3152 # restrict 指定子が指定されていて、参照されていない場合 true 3153 # 参照は、HRPSVCPlugin のみ 3333 3154 def has_ineffective_restrict_specifier 3334 3155 if @restrict_list.length != 0 && @b_restrict_referenced == false then … … 3358 3179 puts "entry array #{port.get_name}: max subscript=#{num}" 3359 3180 } 3360 if @cell_list then # ãã㧠@cell_list ã nil ãªã®ã¯Bug3181 if @cell_list then # ここで @cell_list が nil なのは Bug 3361 3182 (indent+1).times { print " " } 3362 3183 puts "cloned cell list:" … … 3382 3203 subscript = "" 3383 3204 end 3384 # ã¢ãã±ã¼ã¿å¼ã³å£ã®çµåãçæ3205 # アロケータ呼び口の結合を生成 3385 3206 (indent+2).times { print " " } 3386 3207 puts "#{cp_name}#{subscript} = #{a[4+1]}" … … 3407 3228 # @real_singleton:: bool : has singleton cell in this composite celltype 3408 3229 # @real_active:: bool : has active cell in this composite celltype 3409 # @name_list:: NamedList item: Decl (attribute), Port ã¨ã¯ã¹ãã¼ãå®ç¾©3230 # @name_list:: NamedList item: Decl (attribute), Port エクスポート定義 3410 3231 # @internal_allocator_list:: [ [cell, internal_cp_name, port_name, func_name, param_name, ext_alloc_ent], ... ] 3411 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin ã¯çæå¾ã«è¿½å ããã3412 # @generate_list:: [ [ Symbol, String, Plugin ], ... ] generate æã§è¿½å ãããgenerate3232 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 3233 # @generate_list:: [ [ Symbol, String, Plugin ], ... ] generate 文で追加された generate 3413 3234 3414 3235 @@nest_stack_index = -1 … … 3453 3274 3454 3275 Namespace.new_compositecelltype( self ) 3455 set_namespace_path # @NamespacePath ã®è¨å®3276 set_namespace_path # @NamespacePath の設定 3456 3277 3457 3278 @port_list = [] … … 3469 3290 # CompositeCelltype#end_of_parse 3470 3291 def end_of_parse 3471 # singleton ã«é¢ãããã§ãã¯3292 # singleton に関するチェック 3472 3293 if @b_singleton && @real_singleton == nil then 3473 3294 cdl_warning( "W1004 $1 : specified singleton but has no singleton in this celltype" , @name ) … … 3478 3299 end 3479 3300 3480 # active ã«é¢ãããã§ãã¯3301 # active に関するチェック 3481 3302 if @b_active && @real_active == nil then 3482 3303 cdl_error( "S1054 $1 : specified active but has no active in this celltype" , @name ) … … 3485 3306 end 3486 3307 3487 # @allocator_instance ãè¨å®ãã3308 # @allocator_instance を設定する 3488 3309 @name_list.get_items.each{ |n| 3489 3310 if n.instance_of? Port then … … 3492 3313 } 3493 3314 3494 # ãªã¬ã¼ã¢ãã±ã¼ã¿ã® entry å´3315 # リレーアロケータの entry 側 3495 3316 @port_list.each{ |p| 3496 3317 if p.get_port_type == :ENTRY then … … 3506 3327 end 3507 3328 } 3508 # mikan relay ãæ£ããæãã¦ããããã§ãã¯ããã¦ããªã3509 3510 # callback çµå3329 # mikan relay が正しく抜けているかチェックされていない 3330 3331 # callback 結合 3511 3332 @cell_list_in_composite.get_items.each{ |c| 3512 3333 ct = c.get_celltype … … 3516 3337 } 3517 3338 3518 # æå³è§£æ3339 # 意味解析 3519 3340 @cell_list_in_composite.get_items.each{ |c| 3520 3341 c.set_definition_join 3521 3342 } 3522 3343 3523 # cell ã®æªçµåã®å¼ã³å£ããªãããã§ãã¯3344 # cell の未結合の呼び口がないかチェック 3524 3345 @cell_list_in_composite.get_items.each{ |c| 3525 3346 c.check_join … … 3527 3348 } 3528 3349 3529 # å¼ã³å£ã®çµåã«ã¤ãã¦ãexport ã¨å 3530 é¨çµåã®ä¸¡æ¹ããªãããã§ã㯠3531 # ãªã¬ã¼ã¢ãã±ã¼ã¿ãå 3532 é¨ã¢ãã±ã¼ã¿ã®è¨å® 3350 # 呼び口の結合について、export と内部結合の両方がないかチェック 3351 # リレーアロケータ、内部アロケータの設定 3533 3352 @port_list.each{ |p| 3534 3353 p.check_dup_init 3535 3354 } 3536 3355 3537 # ãã¹ã¦ã®ã¨ã¯ã¹ãã¼ãå®ç¾©ã«å¯¾å¿ããå¼ã³å£ãåãå£ãå±æ§ãåå¨ããããã§ãã¯3356 # すべてのエクスポート定義に対応した呼び口、受け口、属性が存在するかチェック 3538 3357 @name_list.get_items.each{ |n| 3539 3358 if( @export_name_list.get_item( n.get_name ) == nil )then … … 3542 3361 } 3543 3362 3544 # å 3545 é¨ã¢ãã±ã¼ã¿ãè¨å®ãã 3363 # 内部アロケータを設定する 3546 3364 @internal_allocator_list.each{ |cell, cp_internal_name, port_name, fd_name, par_name, ext_alloc_ent| 3547 3365 res = ext_alloc_ent.get_allocator_rhs_elements( :INTERNAL_ALLOC ) … … 3564 3382 } 3565 3383 3566 # composite ãã©ã°ã¤ã³3384 # composite プラグイン 3567 3385 if @generate then 3568 3386 celltype_plugin … … 3579 3397 cell.set_owner self # Cell (in_omposite) 3580 3398 @cell_list_in_composite.add_item( cell ) 3581 if cell.get_celltype then # nil ãªãã°ããã§ã«ã»ã«ã¿ã¤ããªãã¨ã©ã¼3399 if cell.get_celltype then # nil ならば、すでにセルタイプなしエラー 3582 3400 if cell.get_celltype.is_singleton? then 3583 3401 @real_singleton = cell … … 3601 3419 @cell_list << cell 3602 3420 3603 # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ã®é©ç¨3421 # セルタイププラグインの適用 3604 3422 celltype_plugin_new_cell cell 3605 3423 end 3606 3424 3607 #=== CompositeCelltype# CompositeCelltypeJoin ãä½æ3425 #=== CompositeCelltype# CompositeCelltypeJoin を作成 3608 3426 # STAGE: B 3609 #export_name:: Symbol : å¤é¨ã«å 3610 ¬éããåå 3611 #internal_cell_name:: Symbol : å 3612 é¨ã»ã«å 3613 #internal_cell_elem_name:: Symbol : å 3614 é¨ã»ã«ã®è¦ç´ åï¼å¼ã³å£åãåãå£åãå±æ§åã®ããããï¼ 3615 #type:: :CALL, :ENTRY, :ATTRIBUTE ã®ããããï¼æ§æè¦ç´ ã¨ãã¦ããã¹ããã®ï¼ 3616 #RETURN:: Decl | Port : ã¨ã¯ã¹ãã¼ãå®ç¾© 3617 # new_join 㯠3618 # cCall => composite.cCall; (ã»ã«å 3619 ) 3620 # attr = composite.attr; (ã»ã«å 3621 ) 3622 # composite.eEnt => cell2.eEnt; (ã»ã«å¤) 3623 # ã®æ§æè¦ç´ ã®åºç¾ã«å¯¾ãã¦å¼ã³åºããã 3427 #export_name:: Symbol : 外部に公開する名前 3428 #internal_cell_name:: Symbol : 内部セル名 3429 #internal_cell_elem_name:: Symbol : 内部セルの要素名(呼び口名、受け口名、属性名のいずれか) 3430 #type:: :CALL, :ENTRY, :ATTRIBUTE のいずれか(構文要素としてあるべきもの) 3431 #RETURN:: Decl | Port : エクスポート定義 3432 # new_join は 3433 # cCall => composite.cCall; (セル内) 3434 # attr = composite.attr; (セル内) 3435 # composite.eEnt => cell2.eEnt; (セル外) 3436 # の構文要素の出現に対して呼び出される 3624 3437 def new_join( export_name, internal_cell_name, 3625 3438 internal_cell_elem_name, type ) … … 3634 3447 3635 3448 celltype = cell.get_celltype 3636 return if celltype == nil # celltype == nil ãªããã§ã«ã¨ã©ã¼ 3637 3638 # å 3639 é¨ã»ã«ã®ã»ã«ã¿ã¤ããã対å¿è¦ç´ ãæ¢ã 3640 # ãã®ã¡ã½ããã¯ãæ§æä¸ãå¼ã³å£ãåãå£ãå±æ§ãè¨è¿°ã§ããç®æããå¼åºããã 3641 # æ§æä¸ã®å¼åºãä½ç½®ï¼è¨è¿°ä½ç½®ï¼ã¨ãè¦ç´ ã対å¿ãããã®ããã§ã㯠3449 return if celltype == nil # celltype == nil ならすでにエラー 3450 3451 # 内部セルのセルタイプから対応要素を探す 3452 # このメソッドは、構文上、呼び口、受け口、属性が記述できる箇所から呼出される 3453 # 構文上の呼出し位置(記述位置)と、要素が対応したものかチェック 3642 3454 obj = celltype.find( internal_cell_elem_name ) 3643 3455 if obj.instance_of?( Decl ) then … … 3647 3459 elsif type != :ATTRIBUTE then 3648 3460 cdl_error( "S1059 \'$1\' : exporting attribute. write in cell or use \'=\' to export attribute" , export_name ) 3649 # return 次ã®ã¨ã©ã¼ãé¿ããããã«å¦çç¶è¡ããä»ãå ãã¦ã¿ã3461 # return 次のエラーを避けるために処理続行し、付け加えてみる 3650 3462 end 3651 3463 elsif obj.instance_of?( Port ) then 3652 3464 if obj.get_port_type != type then 3653 3465 cdl_error( "S1060 \'$1\' : port type mismatch. $2 type is allowed here." , export_name, type ) 3654 # return 次ã®ã¨ã©ã¼ãé¿ããããã«å¦çç¶è¡ããä»ãå ãã¦ã¿ã3466 # return 次のエラーを避けるために処理続行し、付け加えてみる 3655 3467 end 3656 3468 else … … 3660 3472 end 3661 3473 3662 # ã¨ã¯ã¹ãã¼ãå®ç¾©ã¨ä¸è´ãããã©ãããã§ãã¯3474 # エクスポート定義と一致するかどうかチェック 3663 3475 obj2 = @name_list.get_item( export_name ) 3664 3476 if( obj2 == nil )then … … 3676 3488 elsif obj.get_signature != obj2.get_signature then 3677 3489 if obj.get_signature != nil && obj2.get_signature != nil then 3678 # nil ãªãã°æ¢ã«ã¨ã©ã¼ãªã®ã§å ±åããªã3490 # nil ならば既にエラーなので報告しない 3679 3491 cdl_error( "S1066 $1 : signature \'$2\' mismatch with previous definition \'$3\'" , export_name, obj.get_signature.get_name, obj2.get_signature.get_name ) 3680 3492 end … … 3705 3517 if obj.instance_of?( Decl ) then 3706 3518 # attribute 3707 # # å 3708 é¨ããå¤é¨ã¸è¤æ°ã®çµåããªãããã§ã㯠3519 # # 内部から外部へ複数の結合がないかチェック 3709 3520 # found = false 3710 3521 # @attr_list.each{ |a| … … 3719 3530 else 3720 3531 # call/entry port 3721 # # å 3722 é¨ããå¤é¨ã¸è¤æ°ã®çµåããªãããã§ã㯠3532 # # 内部から外部へ複数の結合がないかチェック 3723 3533 # found = false 3724 3534 # @port_list.each{ |port| … … 3733 3543 end 3734 3544 3735 # join ã @export_name_list ã«ç»é²ï¼éè¤ãã§ãã¯ã¨ã¨ãã«ï¼å¾ã§è¡ããã CompositeCelltypeJoin ã® clone ã«åããï¼3545 # join を @export_name_list に登録(重複チェックとともに,後で行われる CompositeCelltypeJoin の clone に備える) 3736 3546 if obj.instance_of?( Decl ) && @export_name_list.get_item( export_name ) then 3737 # æ¢ã«åå¨ããã追å ããªããæ°ä»æ§ã§ã¯ã@export_name_list ã«åãååãå«ã¾ãããã¨ãããã3547 # 既に存在する。追加しない。新仕様では、@export_name_list に同じ名前が含まれることがある。 3738 3548 elsif obj.instance_of?( Port ) && obj.get_port_type == :CALL && @export_name_list.get_item( export_name ) then 3739 # æ¢ã«åå¨ããã追å ããªããæ°ä»æ§ã§ã¯ã@export_name_list ã«åãååãå«ã¾ãããã¨ãããã3549 # 既に存在する。追加しない。新仕様では、@export_name_list に同じ名前が含まれることがある。 3740 3550 else 3741 3551 @export_name_list.add_item( join ) 3742 3552 end 3743 3553 3744 # export ãããã¼ãã«å«ã¾ãã send/receive ãã©ã¡ã¼ã¿ã®ã¢ãã±ã¼ã¿(allocator)å¼ã³å£ãã»ã«ã¨çµå3554 # export するポートに含まれる send/receive パラメータのアロケータ(allocator)呼び口をセルと結合 3745 3555 if obj2.instance_of? Port then 3746 3556 obj2.each_param{ |port, fd, par| 3747 case par.get_direction # å¼æ°ã®æ¹åæå®å(in, out, inout, send, receive )3557 case par.get_direction # 引数の方向指定子 (in, out, inout, send, receive ) 3748 3558 when :SEND, :RECEIVE 3749 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # ã¢ãã±ã¼ã¿å¼ã³å£ã®åå3750 # ãã¼ãå é¢æ°å ãã©ã¡ã¼ã¿å3559 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # アロケータ呼び口の名前 3560 # ポート名 関数名 パラメータ名 3751 3561 cp_internal_name = :"#{internal_cell_elem_name}_#{fd.get_name}_#{par.get_name}" 3752 3562 3753 # ãªã¬ã¼ã¢ãã±ã¼ã¿ or å 3754 é¨ã¢ãã±ã¼ã¿æå®ããªããã¦ããå ´åãã¢ãã±ã¼ã¿å¼ã³å£ã追å ããªã 3755 # ãã®æç¹ã§ã¯ get_allocator_instance ã§ã¯å¾ãããªããã tmp ãå¾ã 3563 # リレーアロケータ or 内部アロケータ指定がなされている場合、アロケータ呼び口を追加しない 3564 # この時点では get_allocator_instance では得られないため tmp を得る 3756 3565 if port.get_allocator_instance_tmp then 3757 3566 found = false … … 3761 3570 3762 3571 if s[0] == :INTERNAL_ALLOC then 3763 # å 3764 é¨ã¢ãã±ã¼ã¿ã®å ´å # mikan ããã¯å 3765 é¨ã®ã»ã«ã«ç´çµãããå¤é¨ã®ãã¼ãã«æ¹ããã¹ã 3572 # 内部アロケータの場合 # mikan これは内部のセルに直結する。外部のポートに改めるべき 3766 3573 @internal_allocator_list << [ cell, cp_internal_name, port.get_name, fd.get_name, par.get_name, s[3] ] 3767 3574 end … … 3773 3580 end 3774 3581 3775 # å¤é¨ã¢ãã±ã¼ã¿ã®å ´å3582 # 外部アロケータの場合 3776 3583 new_join( cp_name, internal_cell_name, cp_internal_name, :CALL ) 3777 3584 end … … 3779 3586 end 3780 3587 3781 # ã¨ã¯ã¹ãã¼ãå®ç¾©ãè¿ã3588 # エクスポート定義を返す 3782 3589 return obj2 3783 3590 end … … 3801 3608 @name_list.add_item port 3802 3609 3803 # export ãããã¼ãã«å«ã¾ãã send/receive ãã©ã¡ã¼ã¿ã®ã¢ãã±ã¼ã¿å¼ã³å£ã® export ãçæãã¦ãã¼ãã«è¿½å 3804 # ãã®æç¹ã§ã¯å 3805 é¨ã¢ãã±ã¼ã¿ãã©ããå¤æã§ããªãã®ã§ãã¨ããããçæãã¦ãã 3610 # export するポートに含まれる send/receive パラメータのアロケータ呼び口の export を生成してポートに追加 3611 # この時点では内部アロケータかどうか判断できないので、とりあえず生成しておく 3806 3612 port.each_param { |port, fd, par| 3807 case par.get_direction # å¼æ°ã®æ¹åæå®å(in, out, inout, send, receive )3613 case par.get_direction # 引数の方向指定子 (in, out, inout, send, receive ) 3808 3614 when :SEND, :RECEIVE 3809 #### ãªã¬ã¼ã¢ãã±ã¼ã¿ or å 3810 é¨ã¢ãã±ã¼ã¿æå®ããªããã¦ããå ´åãã¢ãã±ã¼ã¿å¼ã³å£ã追å ããªã 3811 # å 3812 é¨ã¢ãã±ã¼ã¿æå®ããªããã¦ããå ´åãã¢ãã±ã¼ã¿å¼ã³å£ã追å ããªã 3813 # ãã®æç¹ã§ã¯ get_allocator_instance ã§ã¯å¾ãããªããã tmp ãå¾ã 3615 #### リレーアロケータ or 内部アロケータ指定がなされている場合、アロケータ呼び口を追加しない 3616 # 内部アロケータ指定がなされている場合、アロケータ呼び口を追加しない 3617 # この時点では get_allocator_instance では得られないため tmp を得る 3814 3618 if port.get_allocator_instance_tmp then 3815 3619 found = false … … 3826 3630 3827 3631 if par.get_allocator then 3828 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # ã¢ãã±ã¼ã¿å¼ã³å£ã®åå 3829 # ãã¼ãå é¢æ°å ãã©ã¡ã¼ã¿å 3830 alloc_sig_path = [ par.get_allocator.get_name ] # mikan Namespace ã¢ãã±ã¼ã¿å¼ã³å£ã®ã·ã°ãã㣠3831 array_size = port.get_array_size # å¼ã³å£ã¾ãã¯åãå£é 3832 åã®ãµã¤ãº 3833 created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # å¼ã³å£ãçæ 3632 cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}" # アロケータ呼び口の名前 3633 # ポート名 関数名 パラメータ名 3634 alloc_sig_path = [ par.get_allocator.get_name ] # mikan Namespace アロケータ呼び口のシグニチャ 3635 array_size = port.get_array_size # 呼び口または受け口配列のサイズ 3636 created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # 呼び口を生成 3834 3637 created_port.set_allocator_port( port, fd, par ) 3835 3638 if port.is_omit? then 3836 3639 created_port.set_omit 3837 3640 end 3838 new_port( created_port ) # ã»ã«ã¿ã¤ãã«æ°ããå¼ã³å£ã追å3641 new_port( created_port ) # セルタイプに新しい呼び口を追加 3839 3642 # else 3840 3643 # already error … … 3853 3656 attribute.each { |a| 3854 3657 a.set_owner self # Decl (CompositeCelltype) 3855 # V1.1.0.10 composite ã® attr ã® size_is ã¯å¯ã¨ãªã£ã3658 # V1.1.0.10 composite の attr の size_is は可となった 3856 3659 # if a.get_size_is then 3857 3660 # cdl_error( "S1070 $1: size_is pointer cannot be exposed for composite attribute" , a.get_name ) … … 3864 3667 end 3865 3668 3866 #=== CompositeCelltype# érequire ã®çµåãçæãã3669 #=== CompositeCelltype# 逆require の結合を生成する 3867 3670 def create_reverse_require_join cell 3868 3671 @name_list.get_items.each{ |n| … … 3889 3692 return @name_list.get_item( name ) 3890 3693 3891 # å¾æ¥ä»æ§3694 # 従来仕様 3892 3695 # cj = @export_name_list.get_item( name ) 3893 3696 #p "#{name}, #{cj.get_port_decl}" … … 3899 3702 end 3900 3703 3901 #=== CompositeCelltype# export ãã CompositeCelltypeJoin ãå¾ã3704 #=== CompositeCelltype# export する CompositeCelltypeJoin を得る 3902 3705 #name:: string: 3903 # attribute ã®å ´åãåãååã«å¯¾ãè¤æ°åå¨ããå¯è½æ§ãããããæåã®ãã®ããè¿ããªã3706 # attribute の場合、同じ名前に対し複数存在する可能性があるが、最初のものしか返さない 3904 3707 def find_export name 3905 3708 return @export_name_list.get_item( name ) 3906 3709 end 3907 3710 3908 #=== CompositeCelltype# composite celltype ã® cell ãå±é3909 #name:: string: Composite cell ã®åå3910 #global_name:: string: Composite cell ã® global name (C è¨èªå)3911 #join_list:: NamedList : Composite cell ã«å¯¾ãã Join ã®NamedList3711 #=== CompositeCelltype# composite celltype の cell を展開 3712 #name:: string: Composite cell の名前 3713 #global_name:: string: Composite cell の global name (C 言語名) 3714 #join_list:: NamedList : Composite cell に対する Join の NamedList 3912 3715 #RETURN: 3913 3716 # [ { name => cell }, [ cell, ... ] ] 3914 # æ»ãå¤ å㯠ååâcloneãããå 3915 é¨ã»ã«ãå¾ã㯠composite ã®åºç¾é ã®ãªã¹ã 3717 # 戻り値 前は 名前⇒cloneされた内部セル、後ろは composite の出現順のリスト 3916 3718 def expand( name, global_name, namespacePath, join_list, region, plugin, locale ) 3917 3719 … … 3922 3724 } 3923 3725 3924 # å±é㧠clone ãããã»ã«ã®ãªã¹ããå³è¾ºã¯ Cell (composite ã®å ´å composite 㪠cell ã®clone)3726 # 展開で clone されたセルのリスト、右辺は Cell (composite の場合 composite な cell の clone) 3925 3727 clone_cell_list = {} 3926 3728 clone_cell_list2 = [] 3927 3729 clone_cell_list3 = {} 3928 3730 3929 # composite å 3930 é¨ã®ãã¹ã¦ã® cell ã«ã¤ã㦠3731 # composite 内部のすべての cell について 3931 3732 @cell_list_in_composite.get_items.each { |c| 3932 3733 … … 3934 3735 dbgPrint "expand : cell #{c.get_name}\n" 3935 3736 3936 # Join ã®é 3937 å 3737 # Join の配列 3938 3738 ja = [] 3939 3739 3940 # CompositeCelltype ã export ããå¼ã³å£ãåãå£ãå±æ§ã®ãªã¹ãã«ã¤ãã¦3740 # CompositeCelltype が export する呼び口、受け口、属性のリストについて 3941 3741 # @export_name_list.get_items.each{ |cj| # cj: CompositeCelltypeJoin 3942 # æ°ä»æ§ã§ã¯ã@export_name_list ã«å 3943 ¥ã£ã¦ããªã attr ããããã 3742 # 新仕様では、@export_name_list に入っていない attr がありうる 3944 3743 (@port_list+@attr_list).each{ |cj| # cj: CompositeCelltypeJoin 3945 3744 … … 3947 3746 dbgPrint " cj : #{cj.get_name}\n" 3948 3747 3949 # CompositeCelltypeJoin (export) ã®å¯¾è±¡ã»ã«ãï¼3748 # CompositeCelltypeJoin (export) の対象セルか? 3950 3749 if cj.match?( c ) then 3951 3750 3952 # 対象ã»ã«å 3953 ã® CompositeCelltype ã® export ãã Join (attribute ã¾ã㯠call port) 3751 # 対象セル内の CompositeCelltype の export する Join (attribute または call port) 3954 3752 j = join_list.get_item( cj.get_name ) 3955 3753 … … 3962 3760 3963 3761 if j then 3964 # å¼ã³å£ãå±æ§ã®å ´å3965 # ComositeCell ç¨ã®ãã®(j) ã対象ã»ã«ç¨ã« clone (@through_list ãã³ãã¼ããã)3762 # 呼び口、属性の場合 3763 # ComositeCell 用のもの(j) を対象セル用に clone (@through_list もコピーされる) 3966 3764 # p "expand: cloning Join #{j.get_name} #{@name} #{name}" 3967 3765 jc = j.clone_for_composite( @name, name, locale ) … … 3971 3769 # p "cn #{jc.get_name} #{cj.get_cell_elem_name}" 3972 3770 3973 # 対象ã»ã«ã®å¼ã³å£ã¾ãã¯å±æ§ã®ååã«å¤æ´3771 # 対象セルの呼び口または属性の名前に変更 3974 3772 jc.change_name( cj.get_cell_elem_name ) 3975 3773 3976 # 対象ã»ã«ã«å¯¾ãã Join ã®é 3977 å 3774 # 対象セルに対する Join の配列 3978 3775 ja << jc 3979 3776 end … … 3987 3784 dbgPrint "expand : clone #{name}_#{c.get_name}\n" 3988 3785 3989 # ã»ã«ã® clone ãçæ3786 # セルの clone を生成 3990 3787 # clone_cell_list[ "#{name}_#{c.get_name}" ] = c.clone_for_composite( name, global_name, ja ) 3991 3788 c2 = c.clone_for_composite( name, global_name, namespacePath, ja, @name, region, plugin, locale ) … … 3998 3795 clone_cell_list.each { |nm,c| 3999 3796 dbgPrint " cloned: #{nm} = #{c.get_global_name}\n" 4000 # join ã® owner ã clone ãããã»ã«ã«å¤æ´ããV1.1.0.253797 # join の owner を clone されたセルに変更する V1.1.0.25 4001 3798 c.get_join_list.get_items.each{ |j| 4002 3799 j.set_cloned( clone_cell_list[ "#{c.get_local_name}" ] ) … … 4011 3808 end 4012 3809 4013 #=== CompositeCelltype æå®åãªã¹ãã®è¨å®3810 #=== CompositeCelltype 指定子リストの設定 4014 3811 def set_specifier_list( spec_list ) 4015 3812 return if spec_list == nil … … 4051 3848 4052 3849 def get_var_list 4053 [] # 空ã®é 4054 åãè¿ã 3850 [] # 空の配列を返す 4055 3851 end 4056 3852 … … 4060 3856 4061 3857 #== CompositeCelltype#get_real_celltype 4062 # port_name ã«æ¥ç¶ããã¦ããå 4063 é¨ã®ã»ã«ã¿ã¤ããå¾ã 3858 # port_name に接続されている内部のセルタイプを得る 4064 3859 def get_real_celltype( port_name ) 4065 3860 cj = find_export port_name … … 4072 3867 end 4073 3868 4074 #== CompositeCelltype# generate æå®åã®æ 4075 å ± 4076 # CompositeCelltype ã«ã¯ generate ãæå®ã§ããªãã®ã§ nil ãè¿ã 4077 # Celltype::@generate ãåç 4078 §ã®ã㨠3869 #== CompositeCelltype# generate 指定子の情報 3870 # CompositeCelltype には generate が指定できないので nil を返す 3871 # Celltype::@generate を参照のこと 4079 3872 def get_celltype_plugin 4080 3873 nil … … 4089 3882 end 4090 3883 4091 #=== CompositeCelltype# ã¢ã¯ãã£ãã§ã¯ãªã 4092 # active ã§ã¯ãªãã«å ããå 4093 ¨ã¦ã®å 4094 é¨ã»ã«ã®ã»ã«ã¿ã¤ãã inactive ã®å ´åã« inactive 4095 # ï¼å 4096 é¨ã®ã»ã«ã active ã¾ã㯠factory ãæã£ã¦ããï¼ 3884 #=== CompositeCelltype# アクティブではない 3885 # active ではないに加え、全ての内部セルのセルタイプが inactive の場合に inactive 3886 # (内部のセルが active または factory を持っている) 4097 3887 def is_inactive? 4098 3888 if @b_active == false then 4099 3889 @cell_list_in_composite.get_items.each{ |c| 4100 3890 if c.get_celltype && c.get_celltype.is_inactive? == false then 4101 # c.get_celltype == nil ã®å ´åã¯ã»ã«ã¿ã¤ãæªå®ç¾©ã§ãã§ã«ã¨ã©ã¼3891 # c.get_celltype == nil の場合はセルタイプ未定義ですでにエラー 4102 3892 return false 4103 3893 end … … 4139 3929 4140 3930 4141 #== æ§æè¦ç´ ï¼å£ã表ãã¯ã©ã¹ï¼ã»ã«ã¿ã¤ãã®å¼ã³å£ãåãå£ï¼3931 #== 構文要素:口を表すクラス(セルタイプの呼び口、受け口) 4142 3932 class Port < BDNode 4143 3933 # @name:: str … … 4145 3935 # @port_type:: :CALL, :ENTRY 4146 3936 # @array_size:: nil: not array, "[]": sizeless, Integer: sized array 4147 # @reverse_require_cell_path:: NamespacePath : érequireå¼ã³å 4148 ã»ã« mikan namespace (å¼ã³å£ã®ã¿æå®å¯è½) 4149 # @reverse_require_callport_name:: Symbol: érequireå¼ã³å 4150 ã»ã«ã®å¼ã³å£å 3937 # @reverse_require_cell_path:: NamespacePath : 逆require呼び元セル mikan namespace (呼び口のみ指定可能) 3938 # @reverse_require_callport_name:: Symbol: 逆require呼び元セルの呼び口名 4151 3939 # 4152 # set_allocator_port ã«ãã£ã¦è¨å®ãããï¼è¨å®ãããå ´åããã®ãã¼ãã¯ã¢ãã±ã¼ã¿ãã¼ãã§ããã 4153 # @allocator_port:: Port : ãã®å¼ã³å£ãã§ããå 4154 ã¨ãªã£ãå¼ã³å£ã¾ãã¯åãå£ 4155 # @allocator_func_decl:: Decl : ãã®å¼ã³å£ãã§ããå 4156 ã¨ãªã£ãå¼ã³å£ã¾ãã¯åãå£ã®é¢æ° 4157 # @allocator_param_decl:: ParamDecl : ãã®å¼ã³å£ãã§ããå 4158 ã¨ãªã£ãå¼ã³å£ã¾ãã¯åãå£ã®ãã©ã¡ã¼ã¿ 3940 # set_allocator_port によって設定される.設定された場合、このポートはアロケータポートである。 3941 # @allocator_port:: Port : この呼び口ができる元となった呼び口または受け口 3942 # @allocator_func_decl:: Decl : この呼び口ができる元となった呼び口または受け口の関数 3943 # @allocator_param_decl:: ParamDecl : この呼び口ができる元となった呼び口または受け口のパラメータ 4159 3944 # 4160 # set_specifier ã«ãã£ã¦è¨å®ããã(3945 # set_specifier によって設定される( 4161 3946 # @allocator_instance:: Hash : {"func_param" => [ :RELAY_ALLOC, func_name, param_name, rhs_cp_name, rhs_func_name, rhs_param_name ]} 4162 3947 # [:INTERNAL_ALLOC, func_name, param_name, rhs_ep_name ] … … 4164 3949 # function parameter rhs 4165 3950 # 4166 # @b_require:: bool : require ã«ããçæããã call port ã®å ´åtrue4167 # @b_has_name:: bool : require : ååããã®ãªã¯ã¯ã¤ã¢å¼ã³å£4168 # @b_inline:: bool : entry port ã®ã¿4169 # @b_omit:: bool : omit æå®åãæå®ããã (call port ã®ã¿)4170 # @b_optional:: bool : call port ã®ã¿4171 # @b_ref_desc:: bool : ref_desc ãã¼ã¯ã¼ããæå®ããã4172 # @b_dynamic:: bool : dynamic ãã¼ã¯ã¼ããæå®ããã (å¼ã³å£ã®ã¿)3951 # @b_require:: bool : require により生成された call port の場合 true 3952 # @b_has_name:: bool : require : 名前ありのリクワイア呼び口 3953 # @b_inline:: bool : entry port のみ 3954 # @b_omit:: bool : omit 指定子が指定された (call port のみ) 3955 # @b_optional:: bool : call port のみ 3956 # @b_ref_desc:: bool : ref_desc キーワードが指定された 3957 # @b_dynamic:: bool : dynamic キーワードが指定された (呼び口のみ) 4173 3958 # 4174 3959 # optimize:: 4175 # @celltype:: å±ããã»ã«ã¿ã¤ã3960 # @celltype:: 属するセルタイプ 4176 3961 # 4177 # :CALL ã®å ´åã®æé©å 4178 # @b_VMT_useless:: bool # VMT é¢æ°ãã¼ãã«ã使ç¨ããªã 4179 # @b_skelton_useless:: bool # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã) 4180 # @b_cell_unique:: bool # å¼ã³å 4181 ã¯å¯ä¸ã®ã»ã« 4182 # @only_callee_port:: Port # å¯ä¸ã®å¼ã³å 4183 ãã¼ã 4184 # @only_callee_cell:: Cell # å¯ä¸ã®å¼ã³å 4185 ã»ã« (@b_PEPDES_in_CB_useless = true ã®ææå¹) 3962 # :CALL の場合の最適化 3963 # @b_VMT_useless:: bool # VMT 関数テーブルを使用しない 3964 # @b_skelton_useless:: bool # スケルトン関数不要 (true の時、受け口関数を呼出す) 3965 # @b_cell_unique:: bool # 呼び先は唯一のセル 3966 # @only_callee_port:: Port # 唯一の呼び先ポート 3967 # @only_callee_cell:: Cell # 唯一の呼び先セル (@b_PEPDES_in_CB_useless = true の時有効) 4186 3968 # 4187 # :ENTRY ã®å ´åã®æé©åï¼å¼ã³å£æé©åã¨åãå¤æ°åã使ç¨ï¼4188 # @b_VMT_useless:: bool # VMT é¢æ°ãã¼ãã«ãä¸è¦4189 # @b_skelton_useless:: bool # ã¹ã±ã«ãã³é¢æ°ä¸è¦3969 # :ENTRY の場合の最適化(呼び口最適化と同じ変数名を使用) 3970 # @b_VMT_useless:: bool # VMT 関数テーブルが不要 3971 # @b_skelton_useless:: bool # スケルトン関数不要 4190 3972 4191 3973 def initialize( name, sig_path, port_type, array_size = nil, reverse_require_cell_path = nil, reverse_require_entry_port_name = nil ) … … 4203 3985 @array_size = array_size.eval_const(nil) 4204 3986 else 4205 @array_size = array_size # ããã¯ã¢ãã±ã¼ã¿å¼ã³å£ã®å ´åï¼å 4206 ã®å¼ã³å£ã§æ¢ã«è©ä¾¡æ¸ã¿ï¼ 3987 @array_size = array_size # これはアロケータ呼び口の場合(元の呼び口で既に評価済み) 4207 3988 end 4208 3989 if @array_size == nil then … … 4219 4000 object = Namespace.find( sig_path ) #1 4220 4001 if object == nil then 4221 # mikan signature ã®ååãä¸å®å 4222 ¨ 4002 # mikan signature の名前が不完全 4223 4003 cdl_error( "S1075 \'$1\' signature not found" , sig_path ) 4224 4004 elsif ! object.instance_of?( Signature ) then 4225 # mikan signature ã®ååãä¸å®å 4226 ¨ 4005 # mikan signature の名前が不完全 4227 4006 cdl_error( "S1076 \'$1\' not signature" , sig_path ) 4228 4007 else … … 4231 4010 end 4232 4011 4233 # érequire4012 # 逆require 4234 4013 @reverse_require_cell_path = nil 4235 4014 @reverse_require_entry_port_name = nil … … 4241 4020 @reverse_require_entry_port_name = reverse_require_entry_port_name 4242 4021 4243 # åãå£é 4244 åãï¼ 4022 # 受け口配列か? 4245 4023 if array_size then 4246 4024 cdl_error( "S1153 $1: cannot be entry port array for fixed join port", @name ) 4247 4025 end 4248 4026 4249 # å¼ã³å£ã®ã»ã«ã¿ã¤ããæ¢ã4027 # 呼び口のセルタイプを探す 4250 4028 ct_or_cell = Namespace.find( @reverse_require_cell_path ) #1 4251 4029 if ct_or_cell.instance_of? Cell then … … 4262 4040 4263 4041 if ct == nil then 4264 return # æ¢ã«ã¨ã©ã¼ 4265 end 4266 4267 # æ·»ãåãªãã®å¼ã³å£é 4268 åãï¼ 4042 return # 既にエラー 4043 end 4044 4045 # 添え字なしの呼び口配列か? 4269 4046 port = ct.find( @reverse_require_entry_port_name ) 4270 4047 if port == nil || port.get_port_type != :CALL … … 4289 4066 end 4290 4067 4291 #=== Port# æé©åã«é¢ããå¤æ°ããªã»ãããã4292 # Region ãã¨ã«æé©åã®ãããªãããããããããªã»ãããã4068 #=== Port#最適化に関する変数をリセットする 4069 # Region ごとに最適化のやりなおしをするため、リセットする 4293 4070 def reset_optimize 4294 4071 if @port_type == :CALL then 4295 4072 # call port optimize 4296 @b_VMT_useless = false # VMT ä¸è¦ (true ã®æ VMT ãä»ãããã¨ãªãå¼åºã) 4297 @b_skelton_useless = false # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã) 4298 @b_cell_unique = false # å¯ä¸ã®å¼ã³å 4299 ã»ã« 4300 @only_callee_port = nil # å¯ä¸ã®å¼ã³å 4301 ãã¼ã 4302 @only_callee_cell = nil # å¯ä¸ã®å¼ã³å 4303 ã»ã« 4073 @b_VMT_useless = false # VMT 不要 (true の時 VMT を介することなく呼出す) 4074 @b_skelton_useless = false # スケルトン関数不要 (true の時、受け口関数を呼出す) 4075 @b_cell_unique = false # 唯一の呼び先セル 4076 @only_callee_port = nil # 唯一の呼び先ポート 4077 @only_callee_cell = nil # 唯一の呼び先セル 4304 4078 else 4305 4079 # entry port optimize 4306 4080 if $unopt || $unopt_entry then 4307 # æé©åãªã4308 @b_VMT_useless = false # VMT ä¸è¦ (true ã®æ VMT ãä»ãããã¨ãªãå¼åºã)4309 @b_skelton_useless = false # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã)4081 # 最適化なし 4082 @b_VMT_useless = false # VMT 不要 (true の時 VMT を介することなく呼出す) 4083 @b_skelton_useless = false # スケルトン関数不要 (true の時、受け口関数を呼出す) 4310 4084 else 4311 # æé©åãã4312 @b_VMT_useless = true # VMT ä¸è¦ (true ã®æ VMT ãä»ãããã¨ãªãå¼åºã)4313 @b_skelton_useless = true # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã)4085 # 最適化あり 4086 @b_VMT_useless = true # VMT 不要 (true の時 VMT を介することなく呼出す) 4087 @b_skelton_useless = true # スケルトン関数不要 (true の時、受け口関数を呼出す) 4314 4088 end 4315 4089 end … … 4340 4114 end 4341 4115 4342 #=== Port# ã¢ãã±ã¼ã¿ãã¼ãã®è¨å® 4343 #port:: Port : send/receive ã®ãã£ãå¼ã³å£ã¾ãã¯åãå£ 4344 #fd:: Decl : é¢æ°ã® declarator 4345 #par:: ParamDecl : send/receive ã®ãã£ãå¼æ° 4346 # ãã®å¼ã³å£ãçæããããã¨ã«ãªã£ãå¼ã³å£ã¾ãã¯åãå£ã®æ 4347 å ±ãè¨å® 4116 #=== Port# アロケータポートの設定 4117 #port:: Port : send/receive のあった呼び口または受け口 4118 #fd:: Decl : 関数の declarator 4119 #par:: ParamDecl : send/receive のあった引数 4120 # この呼び口が生成されるもとになった呼び口または受け口の情報を設定 4348 4121 def set_allocator_port( port, fd, par ) 4349 4122 @allocator_port = port … … 4377 4150 end 4378 4151 4379 #=== Port# require å¼ã³å£ãååãæã¤ï¼4380 # require éå®4152 #=== Port# require 呼び口が名前を持つ? 4153 # require 限定 4381 4154 def has_name? 4382 4155 @b_has_name … … 4391 4164 end 4392 4165 4393 #=== Port# omit æå®ããã¦ãã?4166 #=== Port# omit 指定されている? 4394 4167 def is_omit? 4395 4168 @b_omit || ( @signature && @signature.is_empty? ) … … 4400 4173 end 4401 4174 4402 def set_VMT_useless # VMT é¢æ°ãã¼ãã«ã使ç¨ããªã4175 def set_VMT_useless # VMT 関数テーブルを使用しない 4403 4176 @b_VMT_useless = true 4404 4177 end 4405 4178 4406 def set_skelton_useless # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã)4179 def set_skelton_useless # スケルトン関数不要 (true の時、受け口関数を呼出す) 4407 4180 @b_skelton_useless = true 4408 4181 end 4409 4182 4410 def set_cell_unique # å¼ã³å 4411 ã»ã«ã¯ä¸ã¤ã ã 4183 def set_cell_unique # 呼び先セルは一つだけ 4412 4184 @b_cell_unique = true 4413 4185 end 4414 4186 4415 #=== Port# å¼ã³å£/åãå£ã®æå®åã®è¨å®4416 # inline, allocator ã®æå®4187 #=== Port# 呼び口/受け口の指定子の設定 4188 # inline, allocator の指定 4417 4189 def set_specifier spec_list 4418 4190 spec_list.each { |s| … … 4467 4239 dyn_ref = "ref_desc" 4468 4240 end 4469 if @b_omit then # is_omit? 㯠is_empty? ãå«ãã§ããã®ã§ä½¿ããªã4241 if @b_omit then # is_omit? は is_empty? も含んでいるので使えない 4470 4242 cdl_error( "S9999 omit cannot be specified with $1", dyn_ref ) 4471 4243 elsif @signature && @signature.is_empty? then … … 4480 4252 end 4481 4253 4482 #=== Port# ãªã¬ã¼ã¢ãã±ã¼ã¿ãå 4483 é¨ã¢ãã±ã¼ã¿ã®ã¤ã³ã¹ã¿ã³ã¹ãè¨å® 4484 # å¼ã³å£ã®åæ¹åç 4485 §å¯è½ãªããã«ãã»ã«ã¿ã¤ãã®è§£éã®æå¾ã§è¡ã 4254 #=== Port# リレーアロケータ、内部アロケータのインスタンスを設定 4255 # 呼び口の前方参照可能なように、セルタイプの解釈の最後で行う 4486 4256 def set_allocator_instance 4487 4257 if @allocator_instance_tmp == nil then … … 4496 4266 case alloc_type 4497 4267 when :INTERNAL_ALLOC 4498 if ! @owner.instance_of? CompositeCelltype then # ãã¹ãé²ãããã« composite ã§ãªããã°ã¨ãã4499 cdl_error( "S1081 self allocator not supported yet" ) # mikan ããã¯ãµãã¼ãããã¦ããã¯ããè¦èª¿æ»12/1/154268 if ! @owner.instance_of? CompositeCelltype then # ミスを防ぐために composite でなければとした 4269 cdl_error( "S1081 self allocator not supported yet" ) # mikan これはサポートされているはず。要調査 12/1/15 4500 4270 next 4501 4271 end … … 4504 4274 # OK 4505 4275 when :NORMAL_ALLOC 4506 # ããã¸æ¥ãã®ã¯ composite ã®åãå£ã§å³è¾ºã "eEnt.func.param" å½¢å¼ã§æå®ããã¦ããå ´å4276 # ここへ来るのは composite の受け口で右辺が "eEnt.func.param" 形式で指定されていた場合 4507 4277 cdl_error( "S1174 $1 not suitable for lhs, suitable lhs: 'func.param'", "#{ai[1]}.#{ai[3]}.#{ai[4]}" ) 4508 4278 next … … 4511 4281 end 4512 4282 4513 # '=' 左辺(func_name,param_name)ã¯å®å¨ããã?4514 if @signature then # signature = nil ãªãæ¢ã«ã¨ã©ã¼4283 # '=' 左辺(func_name,param_name)は実在するか? 4284 if @signature then # signature = nil なら既にエラー 4515 4285 fh = @signature.get_function_head( ai[1] ) 4516 4286 if fh == nil then … … 4520 4290 decl = fh.get_declarator 4521 4291 if ! decl.is_function? then 4522 next # æ¢ã«ã¨ã©ã¼4292 next # 既にエラー 4523 4293 end 4524 4294 paramdecl = decl.get_type.get_paramlist.find( ai[2] ) … … 4537 4307 end 4538 4308 4539 # éè¤æå®ããªãã?4309 # 重複指定がないか? 4540 4310 if @allocator_instance[ "#{@name}_#{ai[1]}_#{ai[2]}" ] then 4541 4311 cdl_error( "S1085 duplicate allocator specifier for \'$1_$2\'" , ai[1], ai[2] ) 4542 4312 end 4543 4313 4544 # å³è¾ºã®ãã§ãã¯4314 # 右辺のチェック 4545 4315 case alloc_type 4546 4316 when :INTERNAL_ALLOC … … 4552 4322 end 4553 4323 4554 ep_name = ele[1] # ã¢ãã±ã¼ã¿åãå£å4324 ep_name = ele[1] # アロケータ受け口名 4555 4325 ep = @owner.find ep_name.get_path[0] # mikan "a::b" 4556 4326 if ep == nil || ! ep.instance_of?( Port ) || ep.get_port_type != :ENTRY || ! ep.get_signature.is_allocator? then 4557 4327 cdl_error( "S1175 $1 not found or not allocator entry port for $2" , ep_name, ai[1] ) 4558 4328 end 4559 # å³è¾ºãã§ãã¯çµãã4329 # 右辺チェック終わり 4560 4330 # ai2 = [ :INTERNAL_ALLOC, func_name, param_name, rhs_ep_name ] 4561 4331 ai2 = [ ai[0], ai[1], ai[2], ep_name ] … … 4569 4339 # ele[0] ele[1][0] ele[1][1][0] ele[1][1][1] ele[1][2] ele[2] 4570 4340 # name_space_path.Token(1).Token(2) === call_port.func.param 4571 # mikan Expression#analyze_cell_join_expression ã®å¤ç¨®ãä½æãã¦ç½®ãæããã¹ã4341 # mikan Expression#analyze_cell_join_expression の変種を作成して置き換えるべき 4572 4342 4573 4343 cdl_error( "S1176 rhs not in 'call_port.func.param' form for for $1_$2" , ai[1], ai[2] ) # S1086 … … 4575 4345 end 4576 4346 func_name = ele[1][2]; cp_name = ele[1][1][1].get_name; param_name = ele[2].to_sym 4577 cp = @owner.find cp_name # ãªã¬ã¼ããå 4578 ã®å¼ã³å£ 4347 cp = @owner.find cp_name # リレーする先の呼び口 4579 4348 if cp then 4580 # mikan cp ãå¼ã³å£ã§ãããã¨ã®ãã§ãã¯ï¼å±æ§ã®å ´åãããï¼ 4581 # mikan åãå£ããåãå£ã¸ã®ãªã¬ã¼ã¸ã®å¯¾å¿ (å¼ã³å£ããå¼ã³å£ã¸ã®ãªã¬ã¼ã¯ããããªã) <=== ææ³ã«ããããäºé 4582 ï¼å¼ã³å£å´ã§ã¢ãã±ã¼ã¿ã決å®ãããï¼ 4349 # mikan cp が呼び口であることのチェック(属性の場合もある) 4350 # mikan 受け口から受け口へのリレーへの対応 (呼び口から呼び口へのリレーはありえない) <=== 文法にかかわる事項(呼び口側でアロケータが決定される) 4583 4351 sig = cp.get_signature 4584 4352 if sig && @signature then … … 4590 4358 decl = fh.get_declarator 4591 4359 if ! decl.is_function? then 4592 next # æ¢ã«ã¨ã©ã¼4360 next # 既にエラー 4593 4361 end 4594 4362 paramdecl = decl.get_type.get_paramlist.find( param_name ) … … 4609 4377 4610 4378 # else 4611 # sig == nil ãªãã°æ¢ã«ã¨ã©ã¼4379 # sig == nil ならば既にエラー 4612 4380 end 4613 4381 else … … 4620 4388 next 4621 4389 end 4622 # å³è¾ºãã§ãã¯çµãã4390 # 右辺チェック終わり 4623 4391 # ai2 = [ :RELAY_ALLOC, func_name, param_name, rhs_cp_name, rhs_func_name, rhs_param_name ] 4624 4392 ai2 = [ ai[0], ai[1], ai[2], cp_name, func_name, param_name ] … … 4633 4401 end 4634 4402 4635 def is_VMT_useless? # VMT é¢æ°ãã¼ãã«ã使ç¨ããªã4403 def is_VMT_useless? # VMT 関数テーブルを使用しない 4636 4404 if @port_type == :ENTRY && $unopt_entry == true then 4637 # ãã©ã°ã¤ã³ãã $unopt_entry ãè¨å®ããã±ã¼ã¹ã®ãã4638 # ããã§èªã¿åºãã¨ãã«ãfalse ãè¿ã (reset_optimize ã§ã®è¨å®å¤æ´ã¯éããã)4405 # プラグインから $unopt_entry を設定するケースのため 4406 # ここで読み出すときに、false を返す (reset_optimize での設定変更は速すぎる) 4639 4407 return false 4640 4408 else … … 4643 4411 end 4644 4412 4645 def is_skelton_useless? # ã¹ã±ã«ãã³é¢æ°ä¸è¦ (true ã®æãåãå£é¢æ°ãå¼åºã)4413 def is_skelton_useless? # スケルトン関数不要 (true の時、受け口関数を呼出す) 4646 4414 if @port_type == :ENTRY && $unopt_entry == true then 4647 # ãã©ã°ã¤ã³ãã $unopt_entry ãè¨å®ããã±ã¼ã¹ã®ãã4648 # ããã§èªã¿åºãã¨ãã«ãfalse ãè¿ã (reset_optimize ã§ã®è¨å®å¤æ´ã¯éããã)4415 # プラグインから $unopt_entry を設定するケースのため 4416 # ここで読み出すときに、false を返す (reset_optimize での設定変更は速すぎる) 4649 4417 return false 4650 4418 else … … 4653 4421 end 4654 4422 4655 def is_cell_unique? # å¼ã³å 4656 ã®ã»ã«ã¯ä¸ã¤ï¼ 4423 def is_cell_unique? # 呼び先のセルは一つ? 4657 4424 @b_cell_unique 4658 4425 end 4659 4426 4660 #=== Port# åãå£æé©åã®è¨å® 4661 # ãã®åãå£ãåç 4662 §ããå¼ã³å£ã VMT, skelton ãå¿ 4663 è¦ã¨ãã¦ãããã©ãããè¨å® 4664 # ä¸ã¤ã§ãå¼ã³å£ãå¿ 4665 è¦ã¨ãã¦ããï¼ããªãã¡ b_*_useless ã falseï¼å ´åã¯ã 4666 # ãã®åãå£ã®æé©åã false ã¨ãã 4427 #=== Port# 受け口最適化の設定 4428 # この受け口を参照する呼び口が VMT, skelton を必要としているかどうかを設定 4429 # 一つでも呼び口が必要としている(すなわち b_*_useless が false)場合は、 4430 # この受け口の最適化を false とする 4667 4431 def set_entry_VMT_skelton_useless( b_VMT_useless, b_skelton_useless ) 4668 4432 if ! b_VMT_useless then … … 4674 4438 end 4675 4439 4676 #=== Port# å¯ä¸ã®çµåå 4677 ãè¨å® 4678 # æé©åã§ä½¿ç¨ 4679 # b_VMT_useless == true || b_skelton_useless == true ã®æã«è¨å®ããã 4680 # optional ã®å ´å callee_cell, callee_port ã nil ã¨ãªã 4440 #=== Port# 唯一の結合先を設定 4441 # 最適化で使用 4442 # b_VMT_useless == true || b_skelton_useless == true の時に設定される 4443 # optional の場合 callee_cell, callee_port が nil となる 4681 4444 def set_only_callee( callee_port, callee_cell ) 4682 4445 @only_callee_port = callee_port … … 4684 4447 end 4685 4448 4686 #=== Port# å¯ä¸ã®çµåå 4687 ãã¼ããè¿ã(compositeã®å ´åå®ã»ã«) 4688 # optional å¼ã³å£ã§æªçµåã®å ´å nil ãè¿ã 4449 #=== Port# 唯一の結合先ポートを返す(compositeの場合実セル) 4450 # optional 呼び口で未結合の場合 nil を返す 4689 4451 def get_real_callee_port 4690 4452 if @only_callee_cell then … … 4693 4455 end 4694 4456 4695 #=== Port# å¯ä¸ã®çµåå 4696 ã»ã«ãè¿ã(compositeã®å ´åå®ã»ã«) 4697 # optional å¼ã³å£ã§æªçµåã®å ´å nil ãè¿ã 4457 #=== Port# 唯一の結合先セルを返す(compositeの場合実セル) 4458 # optional 呼び口で未結合の場合 nil を返す 4698 4459 def get_real_callee_cell 4699 4460 if @only_callee_cell then … … 4710 4471 end 4711 4472 4712 #=== Port# érequire ã®çµåãçæãã4473 #=== Port# 逆require の結合を生成する 4713 4474 # STAGE: S 4714 4475 def create_reverse_require_join cell … … 4717 4478 end 4718 4479 4719 # å¼ã³å 4720 ã»ã«ãæ¢ã 4480 # 呼び元セルを探す 4721 4481 ct_or_cell = Namespace.find( @reverse_require_cell_path ) # mikan namespace #1 4722 4482 if ct_or_cell.instance_of? Cell then … … 4724 4484 ct = cell2.get_celltype 4725 4485 if ct == nil then 4726 return # æ¢ã«ã¨ã©ã¼4486 return # 既にエラー 4727 4487 end 4728 4488 elsif ct_or_cell.instance_of? Celltype then … … 4734 4494 ct = ct_or_cell 4735 4495 else 4736 # æ¢ã«ã¨ã©ã¼ï¼ç¡è¦4496 # 既にエラー:無視 4737 4497 return 4738 4498 end 4739 4499 4740 # çµåãçæãã4500 # 結合を生成する 4741 4501 dbgPrint "create_reverse_require_join #{cell2.get_name}.#{@reverse_require_entry_port_name}[] = #{cell.get_name}.#{@name}" 4742 4502 nsp = NamespacePath.new( cell.get_name, false, cell.get_namespace ) … … 4750 4510 end 4751 4511 4752 #=== Port# signature ã®ãã¹ã¦ã®é¢æ°ã®ãã¹ã¦ã®ãã©ã¡ã¼ã¿ããã©ã 4753 #block:: ãããã¯ãå¼æ°ã¨ãã¦åã(ruby ã®ææ³ã§æ¸ããªã) 4754 # ãããã¯ã¯3ã¤ã®å¼æ°ãåãåã(Port, Decl, ParamDecl) Decl: é¢æ°ããã 4755 # Signature ã¯ã©ã¹ã«ã each_param ãããï¼åãåãï¼ 4756 def each_param # ãããã¯å¼æ°{ |port, func_decl, param_decl| } 4757 return if @signature == nil # signature æªå®ç¾©ï¼æ¢ã«ã¨ã©ã¼ï¼ 4758 fha = @signature.get_function_head_array # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é 4759 å 4760 return if fha == nil # nil ãªãææ³ã¨ã©ã¼ã§æå¹å¤ãè¨å®ãããªãã£ã 4761 4762 pr = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°ã pr ã«ä»£å 4763 ¥ 4512 #=== Port# signature のすべての関数のすべてのパラメータをたどる 4513 #block:: ブロックを引数として取る(ruby の文法で書かない) 4514 # ブロックは3つの引数を受け取る(Port, Decl, ParamDecl) Decl: 関数ヘッダ 4515 # Signature クラスにも each_param がある(同じ働き) 4516 def each_param # ブロック引数{ |port, func_decl, param_decl| } 4517 return if @signature == nil # signature 未定義(既にエラー) 4518 fha = @signature.get_function_head_array # 呼び口または受け口のシグニチャの関数配列 4519 return if fha == nil # nil なら文法エラーで有効値が設定されなかった 4520 4521 pr = Proc.new # このメソッドのブロック引数を pr に代入 4764 4522 port = self 4765 fha.each{ |fh| # fh: FuncHead # é¢æ°é 4766 åä¸ã®åé¢æ°é é¨ 4767 fd = fh.get_declarator # fd: Decl (é¢æ°é é¨ããDeclarotorãå¾ã) 4768 if fd.is_function? then # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼ 4769 fd.get_type.get_paramlist.get_items.each{ |par| # ãã¹ã¦ã®ãã©ã¡ã¼ã¿ã«ã¤ã㦠4523 fha.each{ |fh| # fh: FuncHead # 関数配列中の各関数頭部 4524 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 4525 if fd.is_function? then # fd が関数でなければ、すでにエラー 4526 fd.get_type.get_paramlist.get_items.each{ |par| # すべてのパラメータについて 4770 4527 pr.call( port, fd, par ) 4771 4528 } … … 4774 4531 end 4775 4532 4776 #=== Port# érequireæå®ããã¦ããï¼4533 #=== Port# 逆require指定されている? 4777 4534 def is_reverse_required? 4778 4535 @reverse_require_cell_path != nil … … 4826 4583 #== Namespace 4827 4584 # 4828 # root namespace ã ããRegion ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã¨ãã¦çæããã 4829 # root namespace ã¯ãroot region ãå 4830 ¼ãããã 4585 # root namespace だけ、Region クラスのインスタンスとして生成される 4586 # root namespace は、root region を兼ねるため 4831 4587 # 4832 # @cell_list 㯠Region ã®å ´åã«ã®ã¿æ㤠(mikan @cell_list é¢é£ã¯ Region ã«ç§»ãã¹ã)4588 # @cell_list は Region の場合にのみ持つ (mikan @cell_list 関連は Region に移すべき) 4833 4589 # 4834 4590 class Namespace < NSBDNode 4835 # @name:: Symbol # root ã®å ´å"::" (String)4591 # @name:: Symbol # root の場合 "::" (String) 4836 4592 # @global_name:: str 4837 4593 # @name_list:: NamedList Signature,Celltype,CompositeCelltype,Cell,Typedef,Namespace 4838 4594 # @struct_tag_list:: NamedList : StructType 4839 # @namespace_list:: Namespace[] : Region 㯠Namespace ã®åã¯ã©ã¹ã§ãããå«ã¾ãã4595 # @namespace_list:: Namespace[] : Region は Namespace の子クラスであり、含まれる 4840 4596 # @signature_list:: Sginature[] 4841 4597 # @celltype_list:: Celltype[] … … 4843 4599 # @cell_list:: Cell[] 4844 4600 # @typedef_list:: Typedef[] 4845 # @decl_list:: ( Typedef | StructType | EnumType )[] ä¾åé¢ä¿ãããå ´åã«åãã¦ãé çªã©ããã«é 4846 åã«æ ¼ç´ mikan enum 4601 # @decl_list:: ( Typedef | StructType | EnumType )[] 依存関係がある場合に備えて、順番どおりに配列に格納 mikan enum 4847 4602 # @const_decl_list:: Decl[] 4848 # @cache_n_cells:: Integer : get_n_cells ã®çµæããã£ãã·ã¥ãã4849 # @cache_generating_region:: Region : get_n_cells ã®çµæããã£ãã·ã¥ãããã¦ãããªã¼ã¸ã§ã³4850 4851 # mikan namespace ã®push, pop4852 4853 # namespace é層ç¨ã®ã¹ã¿ãã¯4603 # @cache_n_cells:: Integer : get_n_cells の結果をキャッシュする 4604 # @cache_generating_region:: Region : get_n_cells の結果をキャッシュするしているリージョン 4605 4606 # mikan namespace の push, pop 4607 4608 # namespace 階層用のスタック 4854 4609 @@namespace_stack = [] # @@namespace_stack[0] = "::" (generator.rb) 4855 4610 @@namespace_sp = -1 4856 4611 4857 # Generator ãã¹ãç¨ã®ã¹ã¿ã㯠(namespace é層ç¨ã®ã¹ã¿ãã¯ã対æ¯ãã)4612 # Generator ネスト用のスタック (namespace 階層用のスタックを対比する) 4858 4613 @@nest_stack_index = -1 4859 4614 @@nest_stack = [] … … 4861 4616 @@root_namespace = nil 4862 4617 4863 # Generator ãã¹ãç¨ã¹ã¿ãã¯ã® push, pop (ã¯ã©ã¹ã¡ã½ãã)4618 # Generator ネスト用スタックの push, pop (クラスメソッド) 4864 4619 def self.push 4865 4620 dbgPrint "push Namespace\n" … … 4881 4636 end 4882 4637 4883 # namespace é層ç¨ã¹ã¿ãã¯ã® push, pop (ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã)4638 # namespace 階層用スタックの push, pop (インスタンスメソッド) 4884 4639 def push ns 4885 4640 @@namespace_sp += 1 … … 4903 4658 if( name == "::" )then 4904 4659 if( @@root_namespace != nil )then 4905 # root ã¯ä¸åã®ã¿çæã§ãã4660 # root は一回のみ生成できる 4906 4661 raise "try to re-create root namespace" 4907 4662 end … … 4912 4667 if ns.kind_of? Namespace then 4913 4668 dbgPrint "namespace: re-appear #{@name}\n" 4914 # ç»é²æ¸ã¿ namespace ã®åç»é²4669 # 登録済み namespace の再登録 4915 4670 ns.push ns 4916 4671 return … … 4923 4678 end 4924 4679 4925 if @@namespace_sp >= 0 then # root ã¯é¤å¤4680 if @@namespace_sp >= 0 then # root は除外 4926 4681 @@namespace_stack[@@namespace_sp].new_namespace( self ) 4927 4682 end 4928 4683 push self 4929 4684 4930 @global_name = Namespace.get_global_name # stack ç»é²å¾åã4685 @global_name = Namespace.get_global_name # stack 登録後取る 4931 4686 @name_list = NamedList.new( nil, "symbol in namespace '#{@name}'" ) 4932 4687 @struct_tag_list = NamedList.new( nil, "struct tag" ) … … 4943 4698 @cache_generating_region = nil 4944 4699 if @NamespacePath == nil then 4945 # root namespace ã®å ´åã¯è¨å®æ¸ (親 namespace ãè¦ã¤ãããä¾å¤ã«ãªã)4946 set_namespace_path # @NamespacePath ã®è¨å®4700 # root namespace の場合は設定済 (親 namespace が見つからず例外になる) 4701 set_namespace_path # @NamespacePath の設定 4947 4702 end 4948 4703 end … … 4956 4711 end 4957 4712 4958 #=== Namespace:: global_name ãå¾ã4959 # parse ä¸ã®ã¿ãã®ã¡ã½ããã¯ä½¿ãã4713 #=== Namespace:: global_name を得る 4714 # parse 中のみこのメソッドは使える 4960 4715 # STAGE: P 4961 def self.get_global_name # parse ä¸æå¹4716 def self.get_global_name # parse 中有効 4962 4717 if @@namespace_sp <= 0 then 4963 4718 return "" … … 4978 4733 end 4979 4734 4980 #=== Namespace# ã»ã«ã®åæ°ãå¾ã4981 # å region ã linkunit, node æå®ããã¦ããã°ãå«ããªãï¼å¥ã®ãªã³ã¯åä½ï¼4982 # ãããã¿ã¤ã宣è¨ã®ãã®ã®ã¿ã®åæ°ãå«ããªã4983 # mikan namespace ä¸ã« cell ãç½®ããªãä»æ§ã«ãªãã¨ããã®ã¡ã½ãã㯠Region ã®ãã®ã§ãã4984 # mikan ä¸è¨ã®å ´å instance_of? Namespace ã®æ¡ä»¶å¤å®ã¯ä¸è¦ã¨ãªã4735 #=== Namespace#セルの個数を得る 4736 # 子 region が linkunit, node 指定されていれば、含めない(別のリンク単位) 4737 # プロトタイプ宣言のもののみの個数を含めない 4738 # mikan namespace 下に cell を置けない仕様になると、このメソッドは Region のものでよい 4739 # mikan 上記の場合 instance_of? Namespace の条件判定は不要となる 4985 4740 def get_n_cells 4986 4741 if @cache_generating_region == $generating_region then 4987 # ãã®ã¡ã½ããã¯ç¹°ãè¿ãå¼ã³åºããããããçµæããã£ãã·ã¥ãã4742 # このメソッドは繰り返し呼び出されるため、結果をキャッシュする 4988 4743 return @cache_n_cells 4989 4744 end … … 4991 4746 count = 0 4992 4747 @cell_list.each{ |c| 4993 # å®ç¾©ããããã¿ã¤ã宣è¨ã ããã¯ãnew_cell ã®æ®µéã§å¤æã§ããªããããã«ã¦ã³ãããªãã4748 # 定義かプロトタイプ宣言だけかは、new_cell の段階で判断できないため、カウントしなおす 4994 4749 if c.get_f_def == true then 4995 4750 # print "get_n_cells: cell: #{c.get_name}\n" … … 5002 4757 count += ns.get_n_cells 5003 4758 else 5004 # ns 㯠Region ã§ãã4759 # ns は Region である 5005 4760 rt = ns.get_region_type 5006 4761 # print "get_n_cells: region: #{ns.get_name}: #{rt}\n" 5007 4762 if rt == :NODE || rt == :LINKUNIT then 5008 # å¥ã® linkunit ãªã®ã§å ç®ããªã4763 # 別の linkunit なので加算しない 5009 4764 else 5010 4765 count += ns.get_n_cells … … 5018 4773 end 5019 4774 5020 #=== Namespace.find : in_path ã§ç¤ºããããªãã¸ã§ã¯ããæ¢ã4775 #=== Namespace.find : in_path で示されるオブジェクトを探す 5021 4776 #in_path:: NamespacePath 5022 #in_path:: Array : å¤ãå½¢å¼4777 #in_path:: Array : 古い形式 5023 4778 # path [ "::", "ns1", "ns2" ] absolute 5024 4779 # path [ "ns1", "ns2" ] relative … … 5035 4790 if name == "::" then 5036 4791 i = 1 5037 name = path[i] # æ§æçã«å¿ 5038 ãåå¨ 4792 name = path[i] # 構文的に必ず存在 5039 4793 object = @@root_namespace.find( name ) # root 5040 4794 else 5041 # ç¸å¯¾ãã¹4795 # 相対パス 5042 4796 i = 0 5043 4797 object = @@namespace_stack[@@namespace_sp].find_one( name ) # crrent … … 5072 4826 5073 4827 unless object.kind_of?( Namespace ) then 5074 # ã¯ã©ã¹ã¡ã½ããå 5075 㧠cdl_error ãå¼ã³åºããã¨ã¯ã§ããªã 5076 # ã¾ããåæ¹åç 5077 §å¯¾å¿å¾ãæ£ç¢ºãªè¡çªå·ãåºãªãåé¡ãçãã 4828 # クラスメソッド内で cdl_error を呼び出すことはできない 4829 # また、前方参照対応後、正確な行番号が出ない問題も生じる 5078 4830 # cdl_error( "S1092 \'$1\' not namespace" , name ) 5079 # ãã®ã¡ã½ãããã nil ã帰ã£ãå ´å "not found" ãåºãã®ã§ãããã§ã¯åºããªã4831 # このメソッドから nil が帰った場合 "not found" が出るので、ここでは出さない 5080 4832 return nil 5081 4833 end … … 5093 4845 end 5094 4846 5095 #=== Namespace# namespace ããæ¢ããè¦ã¤ãããªããã°è¦ª namespace ããæ¢ã4847 #=== Namespace# namespace から探す。見つからなければ親 namespace から探す 5096 4848 def self.find_one( name ) 5097 4849 return @@namespace_stack[@@namespace_sp].find_one( name ) … … 5101 4853 5102 4854 object = find( name ) 5103 # ããã¯åºãã4855 # これは出すぎ 5104 4856 # dbgPrint "in '#{@name}' find '#{name}' object #{object ? object.class : "Not found"}\n" 5105 4857 … … 5118 4870 5119 4871 def self.find_tag( name ) 5120 # mikan tag : namespace ã® path ã«å¯¾å¿ããªã5121 # namespace ã®ä¸ã«ãã£ã¦ããroot namespace ã«ãããã®ã¨è¦ãªããã5122 # ãã£ã¦ ã«ã¬ã³ã namespace ããæ ¹ã«åãã£ã¦æ¢ã4872 # mikan tag : namespace の path に対応しない 4873 # namespace の中にあっても、root namespace にあるものと見なされる 4874 # よって カレント namespace から根に向かって探す 5123 4875 i = @@namespace_sp 5124 4876 while i >= 0 … … 5196 4948 end 5197 4949 5198 #=== Namespace# åç 5199 §ããã¦ããããæªå®ç¾©ã®ã»ã«ãæ¢ã 5200 # ãããã¿ã¤ã宣è¨ã ãã§å®ç¾©ããã¦ããªãã±ã¼ã¹ãã¨ã©ã¼ã¨ãã 5201 # ååã®æªçµåã»ã«ã«ã¤ãã¦è¦åãã 4950 #=== Namespace# 参照されているが、未定義のセルを探す 4951 # プロトタイプ宣言だけで定義されていないケースをエラーとする 4952 # 受動の未結合セルについて警告する 5202 4953 def check_ref_but_undef 5203 4954 @cell_list.each { |c| 5204 if ! c.get_f_def then # Namespace ã® @cell_list ã«ã¯ãããã¿ã¤ããå«ã¾ããã±ã¼ã¹ãã4955 if ! c.get_f_def then # Namespace の @cell_list にはプロトタイプが含まれるケースあり 5205 4956 if c.get_f_ref then 5206 4957 c.cdl_error( "S1093 $1 : undefined cell" , c.get_namespace_path.get_path_str ) … … 5225 4976 end 5226 4977 5227 #=== Namespace# ã»ã«ã®åãå£ã®åç 5228 §ã«ã¦ã³ããè¨å®ãã 4978 #=== Namespace# セルの受け口の参照カウントを設定する 5229 4979 def set_port_reference_count 5230 4980 @cell_list.each { |c| … … 5242 4992 5243 4993 def new_structtype( struct ) 5244 # struct.set_owner self # StructType (Namespace) # StructType 㯠BDNode ã§ã¯ãªã4994 # struct.set_owner self # StructType (Namespace) # StructType は BDNode ではない 5245 4995 dup = @struct_tag_list.get_item(struct.get_name) 5246 4996 if dup != nil then 5247 4997 if struct.same? dup then 5248 # åããã®ã typedef ããã4998 # 同じものが typedef された 5249 4999 # p "#{struct.get_name}" 5250 5000 return … … 5270 5020 if typedef_type.get_type_str == dup_type.get_type_str && 5271 5021 typedef_type.get_type_str_post == dup_type.get_type_str_post then 5272 # åããã®ã typedef ããã5273 # ããã¸æ¥ãã®ã¯ C ã§é¢æ°ãã¤ã³ã¿ã typedef ãã¦ããã±ã¼ã¹5274 # 以ä¸ã®ããã«äºéã«å®ç¾©ããã¦ããå ´å㯠type_specifier_qualifier_list ã¨ãã¦æ±ããã5022 # 同じものが typedef された 5023 # ここへ来るのは C で関数ポインタを typedef しているケース 5024 # 以下のように二重に定義されている場合は type_specifier_qualifier_list として扱われる 5275 5025 # typedef long LONG; 5276 5026 # typedef long LONG; 5277 # bnf.y.rb ã§ã¯ declarator ã« TYPE_NAME ã許ããªãã®ã§ãããã¸æ¥ããã¨ã¯ãªã5027 # bnf.y.rb では declarator に TYPE_NAME を許さないので、ここへ来ることはない 5278 5028 # p "#{typedef.get_declarator.get_type.get_type_str} #{typedef.get_name} #{typedef.get_declarator.get_type.get_type_str_post}" 5279 5029 return … … 5316 5066 def new_const_decl( decl ) 5317 5067 decl.set_owner self # Decl (Namespace:const) 5318 if ! decl.is_const? then # const 修飾ãã¦ãããã¨5068 if ! decl.is_const? then # const 修飾さていること 5319 5069 if decl.is_type?( PtrType ) then 5320 5070 cdl_error( "S1094 $1: pointer is not constant. check \'const\'" , decl.get_name ) … … 5324 5074 elsif ! decl.is_type?( IntType ) && ! decl.is_type?( FloatType ) && 5325 5075 ! decl.is_type?( BoolType ) && ! decl.is_type?( PtrType ) then 5326 # IntType, FloatType ã§ãããã¨5076 # IntType, FloatType であること 5327 5077 cdl_error( "S1096 $1: should be int, float, bool or pointer type" , decl.get_name ) 5328 elsif decl.get_initializer == nil then # åæå¤ãæã¤ãã¨5078 elsif decl.get_initializer == nil then # 初期値を持つこと 5329 5079 cdl_error( "S1097 $1: has no initializer" , decl.get_name ) 5330 # elsif decl.get_initializer.eval_const(nil) == nil then #eval_const 㯠check_init ã§å¼åºãããã®ã§äºéãã§ãã¯5331 # # mikan åæå¤ãåã«å¯¾ãé©åã§ãããã¨5080 # elsif decl.get_initializer.eval_const(nil) == nil then #eval_const は check_init で呼出されるので二重チェック 5081 # # mikan 初期値が型に対し適切であること 5332 5082 # cdl_error( "S1098 $1: has unsuitable initializer" , decl.get_name ) 5333 5083 else … … 5351 5101 ### 5352 5102 5353 #=== Namespace# ãã¹ã¦ã®ã»ã«ã® require ãã¼ããè¨å®5103 #=== Namespace# すべてのセルの require ポートを設定 5354 5104 # STAGE: S 5355 5105 def set_require_join … … 5357 5107 ct.set_require_join 5358 5108 } 5359 # ãã¹ã¦ã® namespace ã«ã¤ã㦠require ãã¼ããã»ãã5109 # すべての namespace について require ポートをセット 5360 5110 @namespace_list.each{ |ns| 5361 5111 ns.set_require_join … … 5363 5113 end 5364 5114 5365 #=== Namespace# Join ã¸ã® definition ã®è¨å®ã¨ãã§ãã¯5366 # ã»ã«ã¿ã¤ãã«å±ãããã¹ã¦ã®ã»ã«ã«å¯¾ãã¦å®æ½5115 #=== Namespace# Join への definition の設定とチェック 5116 # セルタイプに属するすべてのセルに対して実施 5367 5117 def set_definition_join 5368 # celltype ã®ã³ã¼ããçæ5118 # celltype のコードを生成 5369 5119 @cell_list.each { |c| 5370 5120 dbgPrint "set_definition_join #{c.get_name}\n" … … 5377 5127 5378 5128 #=== Namespace# set_max_entry_port_inner_cell 5379 # ã»ã«ã¿ã¤ãã«å±ãããã¹ã¦ã®ã»ã«ã«å¯¾ãã¦å®æ½5129 # セルタイプに属するすべてのセルに対して実施 5380 5130 def set_max_entry_port_inner_cell 5381 # celltype ã®ã³ã¼ããçæ5131 # celltype のコードを生成 5382 5132 @cell_list.each { |c| 5383 5133 c.set_max_entry_port_inner_cell … … 5388 5138 end 5389 5139 5390 #=== Namespace# ã»ã«ã®çµåããã§ãã¯ãã5140 #=== Namespace# セルの結合をチェックする 5391 5141 def check_join 5392 5142 @cell_list.each { |c| … … 5400 5150 end 5401 5151 5402 #== Namespace# ã«ã¼ãã?5403 # ã«ã¼ããã¼ã ã¹ãã¼ã¹ 㨠ã«ã¼ããªã¼ã¸ã§ã³ã¯åã5152 #== Namespace# ルートか? 5153 # ルートネームスペース と ルートリージョンは同じ 5404 5154 def is_root? 5405 5155 @name == "::" 5406 5156 end 5407 5157 5408 #== Namespace# ã«ã¼ããå¾ã5409 # ã«ã¼ããªã¼ã¸ã§ã³ã¨ã«ã¼ããã¼ã ã¹ãã¼ã¹ã¯åããªãã¸ã§ã¯ã5158 #== Namespace# ルートを得る 5159 # ルートリージョンとルートネームスペースは同じオブジェクト 5410 5160 def self.get_root 5411 5161 @@root_namespace 5412 5162 end 5413 5163 5414 #== Namespace (Region) ã«å±ããã»ã«ã®ãªã¹ã5164 #== Namespace (Region) に属するセルのリスト 5415 5165 def get_cell_list 5416 5166 @cell_list 5417 5167 end 5418 5168 5419 #== Namespace (Region)# åãªã¼ã¸ã§ã³ã®ãªã¹ã5169 #== Namespace (Region)# 子リージョンのリスト 5420 5170 # 5421 # ãªã¼ã¸ã§ã³ã¯ Namespace ã¯ã©ã¹ã§ namespace ã¨ãã¦è¨æ¶ããã¦ãã5171 # リージョンは Namespace クラスで namespace として記憶されている 5422 5172 def get_region_list 5423 5173 @namespace_list … … 5441 5191 # 5442 5192 # available if definition is Port 5443 # @cell_name:: string : å³è¾ºã®ã»ã«ã®åå5444 # @cell:: Cell : å³è¾ºã®ã»ã«5445 # @celltype:: Celltype : å³è¾ºã®ã»ã«ã¿ã¤ã5446 # @port_name:: string : å³è¾ºã®åãå£å5447 # @port:: Port : å³è¾ºã®åãå£5193 # @cell_name:: string : 右辺のセルの名前 5194 # @cell:: Cell : 右辺のセル 5195 # @celltype:: Celltype : 右辺のセルタイプ 5196 # @port_name:: string : 右辺の受け口名 5197 # @port:: Port : 右辺の受け口 5448 5198 # @array_member:: rhs array : available only for first appear in the same name 5449 5199 # @array_member2:: Join array : available only for first appear in the same name 5450 # @rhs_subscript:: nil : not array, >=0: å³è¾ºã®æ·»æ°5200 # @rhs_subscript:: nil : not array, >=0: 右辺の添数 5451 5201 # 5452 5202 5453 5203 # @through_list:: @cp_through_list + @region_through_list 5454 # 以ä¸ã®æ§é ãæã¤ï¼@cp_through_list ã®æ§é ã¯å 5455 ±éï¼ 5456 # @cp_through_list:: å¼ã³å£ã«æå®ããã through 5204 # 以下の構造を持つ(@cp_through_list の構造は共通) 5205 # @cp_through_list:: 呼び口に指定された through 5457 5206 # [ [plugin_name, cell_name, plugin_arg], [plugin_name2, cell_name2, plugin_arg], ... ] 5458 # @region_through_list:: region ã«æå®ãããthrough5207 # @region_through_list:: region に指定された through 5459 5208 # [ [plugin_name, cell_name, plugin_arg, region], [plugin_name2, cell_name2, plugin_arg, region2], ... ] 5460 5209 # 5461 # @through_generated_list:: [Plugin_class object, ...]: @through_list ã«å¯¾å¿5462 # @region_through_generated_list:: [Plugin_class object, ...]: @region_through_list ã«å¯¾å¿5210 # @through_generated_list:: [Plugin_class object, ...]: @through_list に対応 5211 # @region_through_generated_list:: [Plugin_class object, ...]: @region_through_list に対応 5463 5212 # 5464 5213 5465 5214 include PluginModule 5466 5215 5467 #=== Join# åæå 5468 #name:: string: ååï¼å±æ§åãå¼ã³å£åï¼ 5469 #subscript:: Nil=éé 5470 å, -1="[]", N="[N]" 5471 #rhs:: Expression: å³è¾ºã®å¼ 5216 #=== Join# 初期化 5217 #name:: string: 名前(属性名、呼び口名) 5218 #subscript:: Nil=非配列, -1="[]", N="[N]" 5219 #rhs:: Expression: 右辺の式 5472 5220 def initialize( name, subscript, rhs, locale = nil ) 5473 5221 # dbgPrint "Join#new: #{name}, #{subscript} #{rhs.eval_const(nil)}\n" … … 5481 5229 @name = name 5482 5230 if subscript.instance_of?( Expression ) then 5483 #mikan é 5484 åæ·»æ°ãæ´æ°ã§ãããã¨ãæªãã§ã㯠5231 #mikan 配列添数が整数であることを未チェック 5485 5232 @subscript = subscript.eval_const(nil) 5486 5233 if @subscript == nil then … … 5494 5241 @definition = nil 5495 5242 5496 # é 5497 åè¦ç´ ãè¨å® 5498 # æ¬å½ã¯ãååºã®è¦ç´ ã®ã¿è¨å®ããã®ãé©å½ 5499 # new_join 㧠add_array_member ã®ä¸ã§ååºè¦ç´ ã® array_member ã«å¯¾ãè¨å®ãã 5243 # 配列要素を設定 5244 # 本当は、初出の要素のみ設定するのが適当 5245 # new_join で add_array_member の中で初出要素の array_member に対し設定する 5500 5246 if @subscript == -1 then 5501 5247 @array_member = [self] … … 5515 5261 end 5516 5262 5517 #=== Join# 左辺ã«å¯¾å¿ãã celltype ã®å®ç¾©ãè¨å®ããã¨ã¨ãã«ãã§ãã¯ãã5263 #=== Join# 左辺に対応する celltype の定義を設定するとともにチェックする 5518 5264 # STAGE: S 5519 5265 # 5520 # 代å 5521 ¥å¯è½ããã§ãã¯ãã 5522 #definition:: Decl (attribute,varã®æ) ã¾ã㯠Port (callã®æ) ã¾ã㯠nil (definition ãè¦ã¤ãããªãã£ãæ) 5266 # 代入可能かチェックする 5267 #definition:: Decl (attribute,varの時) または Port (callの時) または nil (definition が見つからなかった時) 5523 5268 5524 5269 def set_definition( definition ) … … 5526 5271 dbgPrint "set_definition: #{@owner.get_name}.#{@name} = #{definition.class}\n" 5527 5272 5528 # äºéãã§ãã¯ã®é²æ¢5273 # 二重チェックの防止 5529 5274 if @definition then 5530 # set_definition ãåå¥ã«è¡ãã±ã¼ã¹ã§ãäºéã«è¡ãããå¯è½æ§ãããï¼ç°å¸¸ã§ã¯ãªãï¼5531 # äºéã« set_definition ãå®è¡ããã㨠through ãäºéã«é©ç¨ããã¦ãã¾ã5275 # set_definition を個別に行うケースで、二重に行われる可能性がある(異常ではない) 5276 # 二重に set_definition が実行されると through が二重に適用されてしまう 5532 5277 # cdl_warning( "W9999 $1, internal error: set_definition duplicate", @name ) 5533 5278 return … … 5536 5281 @definition = definition 5537 5282 5538 # mikan 左辺å¤ãå³è¾ºå¤ã®åãã§ãã¯ãªã©5283 # mikan 左辺値、右辺値の型チェックなど 5539 5284 if @definition.instance_of?( Decl ) then 5540 5285 check_var_init 5541 5286 elsif @definition.instance_of?( Port ) then 5542 5287 check_call_port_init 5543 if @definition.get_port_type == :CALL then # :ENTRY ãªãã¨ã©ã¼ãç¡è¦ããªã5288 if @definition.get_port_type == :CALL then # :ENTRY ならエラー。無視しない 5544 5289 check_and_gen_through 5545 create_allocator_join # through ãã©ã°ã¤ã³çæããå¾ã§ãªãã¨ãæ¿å 5546 ¥åã®ã»ã«ã®ã¢ãã±ã¼ã¿ãçµåãã¦ãã¾ã 5290 create_allocator_join # through プラグイン生成した後でないと、挿入前のセルのアロケータを結合してしまう 5547 5291 end 5548 5292 elsif @definition == nil then … … 5553 5297 end 5554 5298 5555 #=== Join# å¤æ°ã®åæåãã§ãã¯5299 #=== Join# 変数の初期化チェック 5556 5300 def check_var_init 5557 # attribute, var ã®å ´å5301 # attribute, var の場合 5558 5302 if @definition.get_kind == :ATTRIBUTE then 5559 5303 # check_cell_cb_init( definition.get_type, @rhs ) 5560 # å³è¾ºã§åæåå¯è½ããã§ãã¯5304 # 右辺で初期化可能かチェック 5561 5305 @definition.get_type.check_init( @locale, @definition.get_identifier, @rhs, :ATTRIBUTE ) 5562 5306 elsif @definition.get_kind == :VAR then 5563 # var ã¯åæåã§ããªã5307 # var は初期化できない 5564 5308 cdl_error( "S1100 $1: cannot initialize var" , @name ) 5565 5309 else … … 5569 5313 end 5570 5314 5571 #=== Join# å¼ã³å£ã®åæåãã§ãã¯5315 #=== Join# 呼び口の初期化チェック 5572 5316 def check_call_port_init 5573 5317 ### Port 5574 5318 5575 # 左辺ã¯åãå£ãï¼åãå£ãåæåãããã¨ãã¦ããï¼ï¼5319 # 左辺は受け口か(受け口を初期化しようとしている)? 5576 5320 if @definition.get_port_type == :ENTRY then 5577 5321 cdl_error( "S1101 \'$1\' cannot initialize entry port" , @name ) … … 5579 5323 end 5580 5324 5581 # # é 5582 åæ·»æ°ã®æ´åæ§ãã§ã㯠5583 # # å¼ã³å£ã®å®ç¾©ã§ãéé 5584 åãªãæ·»æ°ãªããæ·»æ°ãªãé 5585 åãªãæ·»æ°ãªããæ·»æ°ããé 5586 åãªãæ·»æ°ãã 5325 # # 配列添数の整合性チェック 5326 # # 呼び口の定義で、非配列なら添数なし、添数なし配列なら添数なし、添数あり配列なら添数あり 5587 5327 as = @definition.get_array_size 5588 5328 if ( @subscript == nil && as != nil ) then … … 5607 5347 # end 5608 5348 5609 # mikan Expression ã® get_type ã§åå°åºãããæ¹ãã¹ãã¼ã 5610 # mikan '=' ã®å·¦è¾ºãé 5611 åãã©ããæªãã§ã㯠5612 #(1) '=' ã®å³è¾ºã¯ "Cell.ePort" ã®å½¢å¼ãï¼ 5613 # æ¼ç®å㯠"." ã㤠"." ã®å·¦è¾ºã :IDENTIFIER 5614 # "." ã®å³è¾ºã¯ãã§ãã¯ä¸è¦ (synatax çã« :IDENTIFIER) 5615 #(2) "Cell" ã¯åå¨ãããï¼ï¼ååãä¸è´ãããã®ã¯ãããï¼ 5616 #(3) "Cell" 㯠cell ãï¼ 5617 #(4) "Cell" ã® celltype ã¯æå¹ãï¼ (ç¡å¹ãªãæ¢ã«ã¨ã©ã¼ï¼ 5618 #(5) "ePort" 㯠"Cell" ã® celltype å 5619 ã«åå¨ãããï¼ 5620 #(6) "ePort" 㯠entry port ãï¼ 5621 #(7) signature ã¯ä¸è´ããã 5622 5623 # å³è¾ºããªãï¼ä»¥åã®æ®µéã§ã¨ã©ã¼ï¼ 5349 # mikan Expression の get_type で型導出させる方がスマート 5350 # mikan '=' の左辺が配列かどうか未チェック 5351 #(1) '=' の右辺は "Cell.ePort" の形式か? 5352 # 演算子は "." かつ "." の左辺が :IDENTIFIER 5353 # "." の右辺はチェック不要 (synatax 的に :IDENTIFIER) 5354 #(2) "Cell" は存在するか?(名前が一致するものはあるか) 5355 #(3) "Cell" は cell か? 5356 #(4) "Cell" の celltype は有効か? (無効なら既にエラー) 5357 #(5) "ePort" は "Cell" の celltype 内に存在するか? 5358 #(6) "ePort" は entry port か? 5359 #(7) signature は一致するか 5360 5361 # 右辺がない(以前の段階でエラー) 5624 5362 return unless @rhs 5625 5363 5626 # cCall = composite.cCall; ã®ãã§ãã¯ï¼ãã®å½¢å¼ã¯å±æ§ç¨5627 # å¼ã³å£ã export ããã«ã¯ cCall => composite.cCall; ã®å½¢å¼ãç¨ãã5364 # cCall = composite.cCall; のチェック.この形式は属性用 5365 # 呼び口を export するには cCall => composite.cCall; の形式を用いる 5628 5366 if @rhs.instance_of?( Array ) == true && @rhs[0] == :COMPOSITE then 5629 5367 cdl_error( "S1107 to export port, use \'cCall => composite.cCall\'" ) … … 5633 5371 end 5634 5372 5635 # å³è¾ºã® Expression ã®è¦ç´ ãåãåºã5373 # 右辺の Expression の要素を取り出す 5636 5374 ret = @rhs.analyze_cell_join_expression 5637 5375 if ret == nil then #1 … … 5641 5379 5642 5380 nsp, @rhs_subscript, @port_name = ret[0], ret[1], ret[2] 5643 @cell_name = nsp.get_name # mikan ns::cellname ã®å½¢å¼ã®èæ 5644 ® 5645 5646 # composite ã®å®ç¾©ã®ä¸ãªã object ã¯çµåå 5647 cell ããè¦ã¤ãããªããã° nil ãè¿ã 5648 # composite ã®å®ç¾©å¤ãªã false ãè¿ã 5381 @cell_name = nsp.get_name # mikan ns::cellname の形式の考慮 5382 5383 # composite の定義の中なら object は結合先 cell か、見つからなければ nil が返る 5384 # composite の定義外なら false が返る 5649 5385 object = CompositeCelltype.find( @cell_name ) 5650 5386 if object == false then 5651 # mikan 左辺ã namespace ã«å¯¾å¿ãã¦ããªãããã path ã«ãã¦find5387 # mikan 左辺が namespace に対応していないため。 path にして find 5652 5388 # p nsp.get_path_str, nsp.get_path 5653 5389 object = Namespace.find( nsp ) #1 … … 5668 5404 object.set_f_ref 5669 5405 5670 # å³è¾ºã®ã»ã«ã®ã»ã«ã¿ã¤ã5406 # 右辺のセルのセルタイプ 5671 5407 celltype = object.get_celltype 5672 5408 … … 5681 5417 cdl_error( "S1113 \'$1\' signature mismatch" , @port_name ) 5682 5418 elsif object2.get_array_size then 5683 # åãå£é 5684 å 5419 # 受け口配列 5685 5420 5686 5421 unless @rhs_subscript then 5687 # å³è¾ºã«æ·»æ°æå®ããªãã£ã5422 # 右辺に添数指定がなかった 5688 5423 cdl_error( "S1114 \'$1\' should be array" , @port_name ) 5689 5424 else … … 5691 5426 as = object2.get_array_size 5692 5427 if( as.kind_of?( Integer ) && as <= @rhs_subscript )then 5693 # åãå£é 5694 åã®å¤§ããã«å¯¾ããå³è¾ºã®æ·»æ°ãåãã大ãã 5428 # 受け口配列の大きさに対し、右辺の添数が同じか大きい 5695 5429 cdl_error( "S1115 $1[$2]: subscript out of range (< $3)" , @port_name, @rhs_subscript, as ) 5696 5430 else … … 5699 5433 @celltype = celltype 5700 5434 @port = object2 5701 # å³è¾ºã®ã»ã«ã®åãå£ object2 ãåç 5702 §æ¸ã¿ã«ãã 5435 # 右辺のセルの受け口 object2 を参照済みにする 5703 5436 # object2: Port, @definition: Port 5704 5437 @cell.set_entry_port_max_subscript( @port, @rhs_subscript ) … … 5710 5443 end 5711 5444 elsif @rhs_subscript then 5712 # åãå£é 5713 åã§ãªãã®ã«å³è¾ºã§æ·»æ°æå®ããã¦ãã 5445 # 受け口配列でないのに右辺で添数指定されている 5714 5446 cdl_error( "S1116 \'$1\' entry port is not array" , @port_name ) 5715 5447 else … … 5719 5451 @celltype = celltype 5720 5452 5721 # å³è¾ºã®ã»ã« object ã®åãå£ object2 ãåç 5722 §æ¸ã¿ã«ãã 5453 # 右辺のセル object の受け口 object2 を参照済みにする 5723 5454 # object2: Port, @definition: Port 5724 5455 5725 5456 # debug 5726 5457 # p "rhs: #{@cell} #{@cell.get_name}" 5727 end # end of port (object2) ãã§ãã¯5458 end # end of port (object2) チェック 5728 5459 5729 5460 #else 5730 # celltype == nil ( ãã§ã«ã¨ã©ã¼)5731 end # end of celltyep ãã§ãã¯5461 # celltype == nil (すでにエラー) 5462 end # end of celltyep チェック 5732 5463 5733 5464 5734 5465 check_region( object ) 5735 5466 5736 end # end of cell (object) ãã§ãã¯5737 5738 end 5739 5740 #=== Join# ã¢ãã±ã¼ã¿ã®çµåãçæ5467 end # end of cell (object) チェック 5468 5469 end 5470 5471 #=== Join# アロケータの結合を生成 5741 5472 # STAGE: S 5742 #cell:: å¼ã³å£ã®çµåå 5743 ã®ã»ã« 5473 #cell:: 呼び口の結合先のセル 5744 5474 # 5745 # ããã§ã¯å¼ã³å£å´ã«çæãããã¢ãã±ã¼ã¿å¼ã³å£ã®çµåãçæ 5746 # åãå£å´ã¯ Cell ã® set_specifier_list ã§çæ 5747 # a[*] ã®å 5748 容㯠Cell ã® set_specifier_list ãåç 5749 § 5475 # ここでは呼び口側に生成されるアロケータ呼び口の結合を生成 5476 # 受け口側は Cell の set_specifier_list で生成 5477 # a[*] の内容は Cell の set_specifier_list を参照 5750 5478 def create_allocator_join 5751 5479 5752 cell = get_rhs_cell2 # å³è¾ºã®ã»ã«ãå¾ã5480 cell = get_rhs_cell2 # 右辺のセルを得る 5753 5481 port = get_rhs_port2 5754 5482 5755 if( cell && cell.get_allocator_list ) then # cell == nil ãªãæ¢ã«ã¨ã©ã¼5483 if( cell && cell.get_allocator_list ) then # cell == nil なら既にエラー 5756 5484 5757 5485 dbgPrint "create_allocator_join: #{@owner.get_name}.#{@name}=>#{cell ? cell.get_name : "nil"}\n" … … 5760 5488 5761 5489 if( a[0+1] == port && a[1+1] == @rhs_subscript )then 5762 # ååã®ä¸è´ãããã®ã®çµåãçæãã5763 # éä¸è¶³ã¯ãå¥éãã§ãã¯ããã5490 # 名前の一致するものの結合を生成する 5491 # 過不足は、別途チェックされる 5764 5492 cp_name = :"#{@name}_#{a[2+1]}_#{a[3+1]}" 5765 5493 # p "creating allocator join #{cp_name} #{@subscript} #{a[1+1]}" … … 5776 5504 end 5777 5505 5778 #=== Join# ãªã¼ã¸ã§ã³éã®çµåããã§ã㯠5779 # ãªã¼ã¸ã§ã³éã® through ã«ãã @region_through_list ã®ä½æ 5780 # å®éã®çæ㯠check_and_gen_through ã§è¡ã 5781 # mikan Cell#distance ã¨Region ã¸ãã©ãçãã¾ã§ããã®å¦çã«å 5782 ±éé¨åãå¤ã 5506 #=== Join# リージョン間の結合をチェック 5507 # リージョン間の through による @region_through_list の作成 5508 # 実際の生成は check_and_gen_through で行う 5509 # mikan Cell#distance とRegion へたどり着くまでための処理に共通部分が多い 5783 5510 def check_region( object ) 5784 5511 … … 5787 5514 # print "DOMAIN: check_region #{@owner.get_name}.#{@name} => #{object.get_name}\n" 5788 5515 5789 # ãã©ã°ã¤ã³ã§çæããããªãã§ã¯çæããªã5790 # ãããªãã¨ãã©ã°ã¤ã³çæããããã®ã¨ã®éã§ãç¡éã«çæããã5516 # プラグインで生成されたなかでは生成しない 5517 # さもないとプラグイン生成されたものとの間で、無限に生成される 5791 5518 ## if Generator.get_nest >= 1 then 5792 ## if Generator.get_plugin then # mikan ããã¯å¿ 5793 è¦ï¼ (æå³è§£æ段éã§ã®å®è¡ã«ãªãã®ã§ä¸é©å) 5519 ## if Generator.get_plugin then # mikan これは必要? (意味解析段階での実行になるので不適切) 5794 5520 if @owner.get_plugin.kind_of?( ThroughPlugin ) then 5795 # ãã©ã°ã¤ã³çæãããã»ã«ã®å ´åãçµåãã§ãã¯ã®ã¿5521 # プラグイン生成されたセルの場合、結合チェックのみ 5796 5522 return 5797 5523 end 5798 5524 5799 # region ã®ãã§ãã¯5800 r1 = @owner.get_region # å¼ã³å£ã»ã«ã®region5801 r2 = object.get_region # åãå£ã»ã«ã®region5802 5803 if ! r1.equal? r2 then # åä¸ region ãªãå¼åºãå¯è½5525 # region のチェック 5526 r1 = @owner.get_region # 呼び口セルの region 5527 r2 = object.get_region # 受け口セルの region 5528 5529 if ! r1.equal? r2 then # 同一 region なら呼出し可能 5804 5530 5805 5531 f1 = r1.get_family_line … … 5808 5534 len2 = f2.length 5809 5535 5810 # ä¸ä¸è´ã«ãªãã¨ããï¼å 5811 å¼ï¼ãæ¢ã 5812 i = 1 # i = 0 㯠:RootRegion ãªã®ã§å¿ 5813 ãä¸è´ 5536 # 不一致になるところ(兄弟)を探す 5537 i = 1 # i = 0 は :RootRegion なので必ず一致 5814 5538 while( i < len1 && i < len2 ) 5815 5539 if( f1[i] != f2[i] )then … … 5819 5543 end 5820 5544 5821 sibling_level = i # å 5822 å¼ã¨ãªãã¬ãã«ããããã¯ã©ã¡ããä¸æ¹ãçµãã£ãã¬ãã« 5545 sibling_level = i # 兄弟となるレベル、もしくはどちらか一方が終わったレベル 5823 5546 5824 5547 dbgPrint "sibling_level: #{i}\n" … … 5833 5556 5834 5557 5835 # å¼ã³å´ã«ã¤ãã¦å¼ã³å 5836 ã®ã¬ãã«ããå 5837 å¼ã¬ãã«ã¾ã§ï¼out_through ããã§ãã¯ããã³æ¿å 5838 ¥ï¼ 5558 # 呼び側について呼び元のレベルから兄弟レベルまで(out_through をチェックおよび挿入) 5839 5559 i = len1 -1 5840 5560 if b_to_through then … … 5860 5580 5861 5581 out_through_list.each { |ol| 5862 if ol[0] then # plugin_name ãæå®ããã¦ããªããã°ç»é²ããªã5582 if ol[0] then # plugin_name が指定されていなければ登録しない 5863 5583 plugin_arg = CDLString.remove_dquote ol[1] 5864 5584 through = [ ol[0], :"Join_out_through_", plugin_arg, f1[i], f1[i-1], :OUT_THROUGH, region_count] … … 5873 5593 end 5874 5594 5875 # å 5876 å¼ã¬ãã«ã«ããã¦ï¼to_through ããã§ãã¯ããã³æ¿å 5877 ¥ï¼ 5595 # 兄弟レベルにおいて(to_through をチェックおよび挿入) 5878 5596 if f1[sibling_level] && f2[sibling_level] then 5879 5597 dbgPrint "going from #{f1[sibling_level].get_name} to #{f2[sibling_level].get_name}\n" 5880 5598 found = 0 5881 region_count = f1[i].next_to_through_count( f2[sibling_level].get_name ) # to_through ã® region ã«ã¦ã³ã5599 region_count = f1[i].next_to_through_count( f2[sibling_level].get_name ) # to_through の region カウント 5882 5600 f1[sibling_level].get_to_through_list.each { |t| 5883 if t[0][0] == f2[sibling_level].get_name then # region åãä¸è´ããã?5884 if t[1] then # plugin_name ãæå®ããã¦ããªããã°ç»é²ããªã5601 if t[0][0] == f2[sibling_level].get_name then # region 名が一致するか ? 5602 if t[1] then # plugin_name が指定されていなければ登録しない 5885 5603 plugin_arg = CDLString.remove_dquote t[2] 5886 5604 through = [ t[1], :"Join_to_through__", plugin_arg, f1[sibling_level], f2[sibling_level], :TO_THROUGH, region_count ] … … 5905 5623 end 5906 5624 5907 # åãå´ã«ã¤ãã¦å 5908 å¼ã¬ãã«ããåãå´ã®ã¬ãã«ã¾ã§ï¼in_through ããã§ãã¯ããã³æ¿å 5909 ¥ï¼ 5625 # 受け側について兄弟レベルから受け側のレベルまで(in_through をチェックおよび挿入) 5910 5626 if b_to_through then 5911 i = sibling_level + 1 # to_through ãçµãå ´åãæåã® in_through ã¯é©ç¨ããªã5627 i = sibling_level + 1 # to_through を経た場合、最初の in_through は適用しない 5912 5628 else 5913 5629 i = sibling_level … … 5932 5648 end 5933 5649 in_through_list.each { |il| 5934 if il[0] then # plugin_name ãæå®ããã¦ããªããã°ç»é²ããªã5650 if il[0] then # plugin_name が指定されていなければ登録しない 5935 5651 plugin_arg = CDLString.remove_dquote il[1] 5936 5652 through = [ il[0], :"Join_in_through_", plugin_arg, f2[i-1], f2[i],:IN_THROUGH, region_count ] … … 5945 5661 5946 5662 5947 #=== Join# çæããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯5948 # å³è¾ºã®ã»ã«ããçæãããªããªã¼ã¸ã§ã³ã«ããã°ã¨ã©ã¼5949 # å³è¾ºã¯ããã©ã°ã¤ã³çæãããã»ã«ãããã°ãããã対象ã¨ãã5663 #=== Join# 生成しないリージョンへの結合かチェック 5664 # 右辺のセルが、生成されないリージョンにあればエラー 5665 # 右辺は、プラグイン生成されたセルがあれば、それを対象とする 5950 5666 def check_region2 5951 5667 lhs_cell = @owner 5952 5668 5953 # çæããªããªã¼ã¸ã§ã³ã®ã»ã«ã¸ã®çµåãï¼5669 # 生成しないリージョンのセルへの結合か? 5954 5670 # if join.get_cell && ! join.get_cell.is_generate? then 5955 # if get_rhs_cell && ! get_rhs_cell.is_generate? then # composite ã»ã«ãããã¿ã¤ã宣è¨ã®å ´åä¾å¤5671 # if get_rhs_cell && ! get_rhs_cell.is_generate? then # composite セルがプロタイプ宣言の場合例外 5956 5672 # print "Link root: (caller #{@owner.get_name}) '#{@owner.get_region.get_link_root.get_name}'" 5957 5673 # print " #{@owner.get_region.get_link_root == get_rhs_region.get_link_root ? "==" : "!="} " … … 5966 5682 end 5967 5683 else 5968 # rhs ã®ã»ã«ãåå¨ããªãã£ã (æ¢ã«ã¨ã©ã¼)5684 # rhs のセルが存在しなかった (既にエラー) 5969 5685 end 5970 5686 end … … 5974 5690 end 5975 5691 5976 #=== Join# specifier ãè¨å®5692 #=== Join# specifier を設定 5977 5693 # STAGE: B 5978 # set_specifier_list ã¯ãjoin ã®è§£æã®æå¾ã§å¼ã³åºããã5979 # through æå®åãè¨å®5980 # check_and_gen_through ãå¼åºãã¦ãthrough çæ5694 # set_specifier_list は、join の解析の最後で呼び出される 5695 # through 指定子を設定 5696 # check_and_gen_through を呼出して、through 生成 5981 5697 def set_specifier_list( specifier_list ) 5982 5698 … … 5986 5702 # set plugin_name 5987 5703 plugin_name = s[1].to_s 5988 plugin_name[0] = "#{plugin_name[/^./].upcase}" # å 5989 é æåã大æåã« : ruby ã®ã¯ã©ã¹åã®å¶ç´ 5704 plugin_name[0] = "#{plugin_name[/^./].upcase}" # 先頭文字を大文字に : ruby のクラス名の制約 5990 5705 5991 5706 # set cell_name … … 5994 5709 # set plugin_arg 5995 5710 plugin_arg = CDLString.remove_dquote s[2].to_s 5996 # plugin_arg = s[2].to_s.gsub( /\A"(.*)/, '\1' ) # åå¾ã® "" ãåãé¤ã5711 # plugin_arg = s[2].to_s.gsub( /\A"(.*)/, '\1' ) # 前後の "" を取り除く 5997 5712 # plugin_arg.sub!( /(.*)"\z/, '\1' ) 5998 5713 … … 6003 5718 end 6004 5719 6005 #=== Join# through ã®ãã§ãã¯ã¨çæ6006 # new_join ã®ä¸ã® check_region 㧠region éã® through ã @region_through ã«è¨å®ããã6007 # set_specifier ã§å¼ã³å£ã®çµåã§æå®ããã through ã @cp_through è¨å®ããã6008 # ãã®å¾ããã®ã¡ã½ãããå¼ã°ãã5720 #=== Join# through のチェックと生成 5721 # new_join の中の check_region で region 間の through が @region_through に設定される 5722 # set_specifier で呼び口の結合で指定された through が @cp_through 設定される 5723 # その後、このメソッドが呼ばれる 6009 5724 def check_and_gen_through 6010 5725 … … 6027 5742 6028 5743 @through_list = @cp_through_list + @region_through_list 6029 # å¾ãã @cp_through_list 㨠@region_through_list ã«åããããããã®ãããªå®è£ 6030 ã«ãªã£ã 5744 # 後から @cp_through_list と @region_through_list に分けたため、このような実装になった 6031 5745 6032 5746 if @through_list then # nil when the join is not Port 6033 len = @through_list.length # through ãé£æ¥ãã¦ããæ°5747 len = @through_list.length # through が連接している数 6034 5748 else 6035 5749 len = 0 … … 6042 5756 end 6043 5757 6044 # é£ç¶ãã through ã«ã¤ãã¦ãåãå£å´ããé ã«ã»ã«ãçæã解éãã5758 # 連続した through について、受け口側から順にセルを生成し解釈する 6045 5759 i = len - 1 6046 5760 while i >= 0 … … 6072 5786 6073 5787 else 6074 # æå¾ã®ã»ã«ã®å ´åã次ã®ã»ã«ã®ååããã¼ãå5788 # 最後のセルの場合、次のセルの名前、ポート名 6075 5789 next_cell = @cell 6076 5790 next_port_name = @port_name … … 6078 5792 6079 5793 if next_cell == nil then 6080 # çµåå 6081 ããªã 5794 # 結合先がない 6082 5795 return 6083 5796 end … … 6085 5798 6086 5799 if i >= cp_len then 6087 # region_through_list é¨å6088 # region ãã @cell_name.@port_name ã¸ã® through ããªããæ¢ã5800 # region_through_list 部分 5801 # region から @cell_name.@port_name への through がないか探す 6089 5802 # rp = @through_list[i][3].find_cell_port_through_plugin( @cell_name, @port_name ) #762 6090 5803 rp = @through_list[i][3].find_cell_port_through_plugin( @cell.get_global_name, @port_name, @rhs_subscript ) 6091 # @through_list[i] 㨠@region_through_list[i-cp_len] ã¯åã 6092 # å 6093 ±ç¨ããªãããã«ããã«ã¯ãè¦ã¤ãããªãã£ããã¨ã«ããã°ãã 5804 # @through_list[i] と @region_through_list[i-cp_len] は同じ 5805 # 共用しないようにするには、見つからなかったことにすればよい 6094 5806 # rp = nil 6095 5807 else 6096 # region 以å¤ã®ãã®ã¯å 6097 ±æããªã 6098 # å¼ã³å£å´ã«æå®ããã¦ããããplugin_arg ãç°ãªããããããªã 5808 # region 以外のものは共有しない 5809 # 呼び口側に指定されているし、plugin_arg が異なるかもしれない 6099 5810 rp = nil 6100 5811 end … … 6106 5817 end 6107 5818 else 6108 # è¦ã¤ãã£ããã®ãå 6109 ±ç¨ãã 5819 # 見つかったものを共用する 6110 5820 @through_generated_list[ i ] = rp 6111 5821 end 6112 5822 6113 5823 if i >= cp_len then 6114 # @through_generated_list ã®ãã¡ @region_through_listã«å¯¾å¿ããé¨å5824 # @through_generated_list のうち @region_through_listに対応する部分 6115 5825 @region_through_generated_list[ i - cp_len ] = @through_generated_list[ i ] 6116 5826 if rp == nil then 6117 # çæãããã®ã region(@through_list[i][3]) ã®ãªã¹ãã«è¿½å5827 # 生成したものを region(@through_list[i][3]) のリストに追加 6118 5828 # @through_list[i][3].add_cell_port_through_plugin( @cell_name, @port_name, @through_generated_list[i] ) #762 6119 5829 @through_list[i][3].add_cell_port_through_plugin( @cell.get_global_name, @port_name, @rhs_subscript, @through_generated_list[i] ) … … 6122 5832 6123 5833 if i == 0 then 6124 # æãå¼ã³å£å´ã®ã»ã«ã¯ãCDL ä¸ã®çµåããªããããåç 6125 §ããããã¨ã«ãªããªã 6126 # mikan namespace å¯¾å¿ 5834 # 最も呼び口側のセルは、CDL 上の結合がないため、参照されたことにならない 5835 # mikan namespace 対応 6127 5836 # cell = Namespace.find( [ @through_generated_list[0].get_cell_name] ) #1 6128 5837 if @through_generated_list[0] == nil then 6129 return # plugin_object ã®çæã«å¤±æãã¦ãã5838 return # plugin_object の生成に失敗している 6130 5839 end 6131 5840 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 … … 6151 5860 end 6152 5861 6153 #=== Join# through ãã©ã°ã¤ã³ãå¼ã³åºã㦠CDL çæãããã¨ã¨ãã«ãimport ãã5862 #=== Join# through プラグインを呼び出して CDL 生成させるとともに、import する 6154 5863 def gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name, next_port_subscript, plClass ) 6155 5864 … … 6159 5868 plugin_arg = through[ 2 ] 6160 5869 if through[ 3 ] then 6161 # region éã® through ã®å ´å5870 # region 間の through の場合 6162 5871 @@start_region = through[ 3 ] 6163 5872 if next_cell.get_region.equal? @@start_region then … … 6169 5878 @@region_count = through[ 6 ] 6170 5879 else 6171 # å¼ã³å£ã® through ã®å ´å6172 @@start_region = @owner.get_region # å¼ã³å£å´ã»ã«ã®region6173 @@end_region = next_cell.get_region # 次ã®ã»ã«ã®region6174 @@through_type = :THROUGH # å¼ã³å£ã® through æå®5880 # 呼び口の through の場合 5881 @@start_region = @owner.get_region # 呼び口側セルの region 5882 @@end_region = next_cell.get_region # 次のセルの region 5883 @@through_type = :THROUGH # 呼び口の through 指定 6175 5884 @@region_count = 0 6176 5885 end … … 6194 5903 @through_generated_list[ i ] = plugin_object 6195 5904 6196 # Region ã«é¢ããæ 6197 å ±ãè¨å® 6198 # å¾ãã追å ããã®ã§ãnew ã®å¼æ°å¤ã§è¨å® 5905 # Region に関する情報を設定 5906 # 後から追加したので、new の引数外で設定 6199 5907 # plugin_object.set_through_info( start_region, end_region, through_type ) 6200 5908 … … 6202 5910 end 6203 5911 6204 # ãã©ã°ã¤ã³ã¸ã®å¼æ°ã§æ¸¡ããªããã®ããä¸æçã«è¨æ¶ãã¦ãã6205 # ãã©ã°ã¤ã³ã® initialize ã®ä¸ã§ã³ã¼ã«ããã¯ãã¦è¨å®ãã5912 #プラグインへの引数で渡さないものを、一時的に記憶しておく 5913 # プラグインの initialize の中でコールバックして設定する 6206 5914 @@plugin_creating_join = nil 6207 5915 @@start_region = nil … … 6210 5918 @@region_count = nil 6211 5919 6212 #=== Join# ThroughPlugin ã®è¿½å æ 6213 å ±ãè¨å®ãã 6214 # ãã®ã¡ã½ãã㯠ThroughPlugin#initialize ããå¼ã³åºããã 6215 # plugin_object ãçæããéã®å¼æ°ã§ã¯ä¸è¶³ããæ 6216 å ±ã追å ãã 5920 #=== Join# ThroughPlugin の追加情報を設定する 5921 # このメソッドは ThroughPlugin#initialize から呼び出される 5922 # plugin_object を生成する際の引数では不足する情報を追加する 6217 5923 def self.set_through_info plugin_object 6218 5924 plugin_object.set_through_info( @@start_region, @@end_region, @@through_type, … … 6226 5932 end 6227 5933 6228 #=== Join#é 6229 åæ·»æ°ãå¾ã 6230 # @subscript ã®èª¬æãåç 6231 §ã®ã㨠5934 #=== Join#配列添数を得る 5935 # @subscript の説明を参照のこと 6232 5936 def get_subscript 6233 5937 @subscript 6234 5938 end 6235 5939 6236 def get_cell_name # åãå£ã»ã«å5940 def get_cell_name # 受け口セル名 6237 5941 @cell_name 6238 5942 end … … 6246 5950 end 6247 5951 6248 #=== Join# å³è¾ºã®å®ã»ã«ãå¾ã 6249 # å®ã»ã«ã¨ã¯ through ã§æ¿å 6250 ¥ããããã®ãcomposite ã®å 6251 é¨ãªã©å®éã«çµåãããå 6252 6253 # ãã®ã¡ã½ããã¯ãget_rhs_port ã¨å¯¾ã«ãªã£ã¦ãã 6254 # ãã®ã¡ã½ããã¯ãæå³è§£æ段éã§ã¯å¼ã³åºãã¦ã¯ãªããªã (対象ã»ã«ã®æå³è§£æãæ¸ãåã«ã¯æ£ããçµæãè¿ããªã) 5952 #=== Join# 右辺の実セルを得る 5953 # 実セルとは through で挿入されたもの、composite の内部など実際に結合される先 5954 # このメソッドは get_rhs_port と対になっている 5955 # このメソッドは、意味解析段階では呼び出してはならない (対象セルの意味解析が済む前には正しい結果を返さない) 6255 5956 def get_rhs_cell 6256 # through æå®ããï¼5957 # through 指定あり? 6257 5958 if @through_list[0] then 6258 # mikan through ã§çæãããã®ã root namespace éå®5959 # mikan through で生成したものが root namespace 限定 6259 5960 if @through_generated_list[0] then 6260 5961 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] ) #1 6261 5962 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 6262 # cell ã nil ã«ãªãã®ã¯ãã©ã°ã¤ã³ã® get_cell_namespace_path ãæ£ãããªããã6263 # ãã©ã°ã¤ã³çæã³ã¼ããã¨ã©ã¼ã«ãªã£ã¦ããã6264 # ã§ãã®æªããã©ã°ã¤ã³ãå¤ããã°ãcell == nil ãã¯ãããæ¹ãããã5963 # cell が nil になるのはプラグインの get_cell_namespace_path が正しくないか、 5964 # プラグイン生成コードがエラーになっている。 5965 # できの悪いプラグインが多ければ、cell == nil をはじいた方がよい。 6265 5966 return cell.get_real_cell( @through_generated_list[0].get_through_entry_port_name ) 6266 5967 else 6267 return nil # generate ã«å¤±æãã¦ãã5968 return nil # generate に失敗している 6268 5969 end 6269 5970 elsif @cell then 6270 5971 return @cell.get_real_cell( @port_name ) 6271 5972 else 6272 # å³è¾ºãæªå®ç¾©ã®å ´å @cell 㯠nil (æ¢ã«ã¨ã©ã¼)5973 # 右辺が未定義の場合 @cell は nil (既にエラー) 6273 5974 return nil 6274 5975 end 6275 5976 end 6276 5977 6277 #=== Join# å³è¾ºã®ã»ã«ãå¾ã6278 # å³è¾ºã®ã»ã«ãå¾ãããã ããcomposite å±éããã¦ããªã6279 # composite å±éããããã®ãå¾ãã«ã¯ get_rhs_cell ã使ã6280 # ãããã¿ã¤ã宣è¨ããããã¦ããªãå ´åã«ã¯ããã¡ããã使ããªã6281 # ãã®ã¡ã½ãã㯠get_rhs_port2 ã¨å¯¾ã«ãªã£ã¦ãã5978 #=== Join# 右辺のセルを得る 5979 # 右辺のセルを得る。ただし、composite 展開されていない 5980 # composite 展開されたものを得るには get_rhs_cell を使う 5981 # プロトタイプ宣言しかされていない場合には、こちらしか使えない 5982 # このメソッドは get_rhs_port2 と対になっている 6282 5983 def get_rhs_cell2 6283 # through æå®ããï¼5984 # through 指定あり? 6284 5985 if @through_list[0] then 6285 # mikan through ã§çæãããã®ã root namespace éå®5986 # mikan through で生成したものが root namespace 限定 6286 5987 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name ] ) 6287 5988 if @through_generated_list[0] then … … 6289 5990 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 6290 5991 else 6291 cell = @cell # generate ã«å¤±æãã¦ãã5992 cell = @cell # generate に失敗している 6292 5993 end 6293 5994 else … … 6298 5999 end 6299 6000 6300 #=== Join# å³è¾ºã®ã»ã«ãå¾ã6301 # through ã¯é©ç¨ããªãããcomposite ã¯å±éããå¾ã®ã»ã«6302 # ( æå³è§£æãçµãã£ã¦ããªãã¨ãcomposite å±éãçµãã£ã¦ããªã)6303 # ãã®ã¡ã½ãã㯠get_rhs_port3 ã¨å¯¾ã«ãªã£ã¦ãã6001 #=== Join# 右辺のセルを得る 6002 # through は適用しないが、composite は展開した後のセル 6003 # (意味解析が終わっていないと、composite 展開が終わっていない) 6004 # このメソッドは get_rhs_port3 と対になっている 6304 6005 def get_rhs_cell3 6305 6006 if @cell then … … 6308 6009 end 6309 6010 6310 #=== Join# å³è¾ºã®ã»ã«ã®ãªã¼ã¸ã§ã³ãå¾ã6311 # å³è¾ºãæªå®ç¾©ã®å ´åãnil ãè¿ã6312 # composite ã®å ´åãå®ã»ã«ã§ã¯ãªã composite cell ã® region ãè¿ã(composite ã¯ãã¹ã¦åã region ã«å±ãã)6313 # composite ã® cell ããããã¿ã¤ã宣è¨ããã¦ããã¨ã get_rhs_cell/get_real_cell 㯠ruby ã®ä¾å¤ã¨ãªã6011 #=== Join# 右辺のセルのリージョンを得る 6012 # 右辺が未定義の場合、nil を返す 6013 # composite の場合、実セルではなく composite cell の region を返す(composite はすべて同じ region に属する) 6014 # composite の cell がプロトタイプ宣言されているとき get_rhs_cell/get_real_cell は ruby の例外となる 6314 6015 def get_rhs_region 6315 # through æå®ããï¼6016 # through 指定あり? 6316 6017 if @through_list[0] then 6317 6018 if @through_generated_list[0] then 6318 # mikan through ã§çæãããã®ã root namespace éå®6019 # mikan through で生成したものが root namespace 限定 6319 6020 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] ) #1 6320 6021 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 … … 6323 6024 end 6324 6025 else 6325 return nil # generate ã«å¤±æãã¦ãã6026 return nil # generate に失敗している 6326 6027 end 6327 6028 elsif @cell then 6328 6029 return @cell.get_region 6329 6030 end 6330 # å³è¾ºãæªå®ç¾©ã®å ´å @cell 㯠nil (æ¢ã«ã¨ã©ã¼)6031 # 右辺が未定義の場合 @cell は nil (既にエラー) 6331 6032 return nil 6332 6033 end 6333 6034 6334 def get_cell_global_name # åãå£ã»ã«åï¼ã³ã³ãã¸ãããªãå±éããå 6335 å´ã®ã»ã«ï¼ 6035 def get_cell_global_name # 受け口セル名(コンポジットなら展開した内側のセル) 6336 6036 6337 6037 # debug … … 6347 6047 end 6348 6048 6349 #=== Join# çµåã®å³è¾ºã®åãå£ã®åå 6350 # namespace å + '_' + ã»ã«å + '_' + åãå£å ï¼ãã®ã»ã«ã composite ãªãã°å±éå¾ã®ã»ã«åãåãå£åï¼ 6351 #subscript:: Integer å¼ã³å£é 6352 åã®ææ·»æ° ã¾ã㯠nil å¼ã³å£é 6353 åã§ãªãæ 6354 def get_port_global_name( subscript = nil ) # åãå£åï¼ã³ã³ãã¸ãããªãå±éããå 6355 å´ã®ã»ã«ï¼ 6049 #=== Join# 結合の右辺の受け口の名前 6050 # namespace 名 + '_' + セル名 + '_' + 受け口名 (このセルが composite ならば展開後のセル名、受け口名) 6051 #subscript:: Integer 呼び口配列の時添数 または nil 呼び口配列でない時 6052 def get_port_global_name( subscript = nil ) # 受け口名(コンポジットなら展開した内側のセル) 6356 6053 6357 6054 # debug 6358 6055 dbgPrint "Cell get_port_global_name: #{@cell_name}\n" 6359 6056 6360 # through æå®ããï¼6057 # through 指定あり? 6361 6058 if @through_list[0] then 6362 6059 6363 # mikan through ã§çæãããã®ã root namespace éå®6060 # mikan through で生成したものが root namespace 限定 6364 6061 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] ) #1 6365 6062 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 6366 6063 6367 # through ã§æ¿å 6368 ¥ãããã»ã«ã§ãå®éã«æ¥ç¶ãããã»ã«ï¼compositeã®å ´åå 6369 é¨ã®)ã®åãå£ã® C è¨èªåå 6064 # through で挿入されたセルで、実際に接続されるセル(compositeの場合内部の)の受け口の C 言語名前 6370 6065 return cell.get_real_global_port_name( @through_generated_list[0].get_through_entry_port_name ) 6371 6066 else 6372 6067 6373 # å®éã«æ¥ç¶ãããã»ã«ã®åãå£ã® C è¨èªåå6068 # 実際に接続されるセルの受け口の C 言語名前 6374 6069 if @cell then 6375 6070 return @cell.get_real_global_port_name( @port_name ) … … 6390 6085 end 6391 6086 6392 # æ«å°¾æ°å1 : CDL ã§æå®ããããå³è¾ºã®ã»ã«ãè¿ã6393 def get_rhs_cell1 # get_cell ã¨åã6087 # 末尾数字1 : CDL で指定された、右辺のセルを返す 6088 def get_rhs_cell1 # get_cell と同じ 6394 6089 @cell 6395 6090 end 6396 def get_rhs_port1 # get_port_name åã6091 def get_rhs_port1 # get_port_name 同じ 6397 6092 @port_name 6398 6093 end … … 6401 6096 end 6402 6097 6403 #=== Join# å³è¾ºã®ãã¼ããå¾ã 6404 # å³è¾ºã composite ã®å ´åã¯ãå 6405 é¨ã®ç¹ããã»ã«ã®ãã¼ã, through ã®å ´åã¯æ¿å 6406 ¥ãããã»ã«ã®ãã¼ã 6407 # ãã®ã¡ã½ãã㯠get_rhs_cell ã¨å¯¾ã«ãªã£ã¦ãã 6098 #=== Join# 右辺のポートを得る 6099 # 右辺が composite の場合は、内部の繋がるセルのポート, through の場合は挿入されたセルのポート 6100 # このメソッドは get_rhs_cell と対になっている 6408 6101 def get_rhs_port 6409 # through æå®ããï¼6102 # through 指定あり? 6410 6103 if @through_list[0] then 6411 # through ã§çæãããã»ã«ãæ¢ã6104 # through で生成されたセルを探す 6412 6105 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 6413 # cell ã®ãã©ã°ã¤ã³ã§çæããããã¼ãåã®ãã¼ããæ¢ã (composite ãªãå 6414 é¨ã®ç¹ãããã¼ã) 6106 # cell のプラグインで生成されたポート名のポートを探す (composite なら内部の繋がるポート) 6415 6107 return cell.get_real_port( @through_generated_list[0].get_through_entry_port_name ) 6416 6108 else 6417 # ãã¼ããè¿ã(composite ãªãå 6418 é¨ã®ç¹ãããã¼ããè¿ã) 6109 # ポートを返す(composite なら内部の繋がるポートを返す) 6419 6110 return @cell.get_real_port( @port_name ) 6420 6111 end 6421 6112 end 6422 6113 6423 #=== Join# å³è¾ºã®é 6424 åæ·»æ°ãå¾ã 6425 # å³è¾ºã through ã®å ´åã¯æ¿å 6426 ¥ãããã»ã«ã®æ·»æ° 6427 # å³è¾ºã composite ã®å ´åã¯ãå 6428 é¨ã®ç¹ããã»ã«ã®ãã¼ãã®æ·»æ° (composite ã§ã¯å¤ãããªã) 6429 # ãã®ã¡ã½ãã㯠get_rhs_cell, ã¨å¯¾ã«ãªã£ã¦ãã 6114 #=== Join# 右辺の配列添数を得る 6115 # 右辺が through の場合は挿入されたセルの添数 6116 # 右辺が composite の場合は、内部の繋がるセルのポートの添数 (composite では変わらない) 6117 # このメソッドは get_rhs_cell, と対になっている 6430 6118 def get_rhs_subscript 6431 6119 if @through_list[0] then … … 6436 6124 end 6437 6125 6438 #=== Join# å³è¾ºã®ãã¼ããå¾ã6439 # å³è¾ºã®ãã¼ããå¾ãã6440 # ããã¯ãããã¿ã¤ã宣è¨ããããã¦ããªãå ´åã«ã¯ããã¡ããã使ããªã6126 #=== Join# 右辺のポートを得る 6127 # 右辺のポートを得る。 6128 # これはプロトタイプ宣言しかされていない場合には、こちらしか使えない 6441 6129 def get_rhs_port2 6442 # through æå®ããï¼6130 # through 指定あり? 6443 6131 if @through_list[0] then 6444 6132 if @through_generated_list[0] then 6445 6133 port = @through_generated_list[0].get_through_entry_port_name.to_sym 6446 6134 else 6447 port = @port_name # generate ã«å¤±æãã¦ãã6135 port = @port_name # generate に失敗している 6448 6136 end 6449 6137 else … … 6454 6142 end 6455 6143 6456 #=== Join# å³è¾ºã®ãã¼ããå¾ã6457 # through ã¯é©ç¨ããªãããcomposite ã¯å±éããå¾ã®ã»ã«ã®å¯¾å¿ãããã¼ã6144 #=== Join# 右辺のポートを得る 6145 # through は適用しないが、composite は展開した後のセルの対応するポート 6458 6146 def get_rhs_port3 6459 6147 if @cell then … … 6462 6150 end 6463 6151 6464 #=== Join# å¼ã³å£é 6465 åã®2çªç®ä»¥éã®è¦ç´ ã追å ãã 6466 # ä¸çªæåã«å®ç¾©ãããé 6467 åè¦ç´ ãå 6468 ¨è¦ç´ ã®åæå¤ã®é 6469 åãæ㤠6470 # ãã®ã¡ã½ããã¯éé 6471 åã®å ´åãå¼åºãããï¼join éè¤ã¨ã©ã¼ã®å ´åï¼ 6472 #join2:: Join å¼ã³å£é 6473 åè¦ç´ ã® Join 6152 #=== Join# 呼び口配列の2番目以降の要素を追加する 6153 # 一番最初に定義された配列要素が全要素の初期値の配列を持つ 6154 # このメソッドは非配列の場合も呼出される(join 重複エラーの場合) 6155 #join2:: Join 呼び口配列要素の Join 6474 6156 def add_array_member join2 6475 6157 6476 # subscript2: join2 ã®å·¦è¾ºæ·»æ°6158 # subscript2: join2 の左辺添数 6477 6159 subscript2 = join2.get_subscript 6478 6160 6479 6161 if @subscript == nil then # not array : initialize duplicate 6480 # éé 6481 åã®å ´åãjoin ãéè¤ãã¦ãã 6162 # 非配列の場合、join が重複している 6482 6163 cdl_error( "S1127 \'$1\' duplicate", @name ) 6483 6164 # print "add_array_member2: #{@owner.get_name}\n" 6484 6165 6485 6166 elsif @subscript >= 0 then 6486 # æ·»æ°æå®ããã®å ´å6167 # 添数指定ありの場合 6487 6168 if( subscript2 == nil || subscript2 < 0 ) then 6488 # join2 左辺ã¯éé 6489 åã¾ãã¯æ·»æ°ãªã 6490 # é 6491 åãä¸ä¸è´ 6169 # join2 左辺は非配列または添数なし 6170 # 配列が不一致 6492 6171 cdl_error( "S1128 \'$1\' inconsistent array definition", @name ) 6493 6172 elsif @array_member[subscript2] != nil then 6494 # åãæ·»æ°ãæ¢ã«å®ç¾©æ¸ã¿6173 # 同じ添数が既に定義済み 6495 6174 cdl_error( "S1129 \'$1\' redefinition of subscript $2" ,@name, subscript2 ) 6496 6175 else 6497 # æ·»æ°ã®ä½ç½®ã«è¦ç´ ã追å6176 # 添数の位置に要素を追加 6498 6177 @array_member[subscript2] = join2.get_rhs 6499 6178 @array_member2[subscript2] = join2 … … 6502 6181 6503 6182 else 6504 # æ·»æ°æå®ãªãã®å ´å6183 # 添数指定なしの場合 6505 6184 if( subscript2 == nil || subscript2 >= 0 ) then 6506 # join2 左辺ã¯éé 6507 åã¾ãã¯æ·»æ°æ 6508 # é 6509 åãä¸ä¸è´ 6185 # join2 左辺は非配列または添数有 6186 # 配列が不一致 6510 6187 cdl_error( "S1130 \'R1\' inconsistent array definition", @name ) 6511 6188 end 6512 6189 6513 # æ·»æ°ãªãé 6514 åã®å ´åãé 6515 åè¦ç´ ã追å 6190 # 添数なし配列の場合、配列要素を追加 6516 6191 @array_member << join2.get_rhs 6517 6192 @array_member2 << join2 … … 6537 6212 while i < @array_member2.length 6538 6213 if @array_member2[i] != self && @array_member[i] != nil then 6539 # @array_member2[i] ã nil ã«ãªãã®ã¯ optional ã®æã¨ã 6540 # Join ã® initialize ã§ç¡é§ã« @array_member2 ãè¨å®ããã¦ããå ´å 6541 # ç¡é§ã«è¨å®ããã¦ãããã®ã«ã¤ãã¦ã¯ãå帰çã«å¼ã³åºãå¿ 6542 è¦ã¯ãªãï¼clone_for_composite ã§ã¯å¯¾çãã¦ããï¼ 6214 # @array_member2[i] が nil になるのは optional の時と、 6215 # Join の initialize で無駄に @array_member2 が設定されている場合 6216 # 無駄に設定されているものについては、再帰的に呼び出す必要はない(clone_for_composite では対策している) 6543 6217 @array_member2[i].change_name( name ) 6544 6218 end … … 6548 6222 end 6549 6223 6550 # composite cell ãå±éããã»ã«ã®çµåã clone ããã»ã«ã®ååã«å¤æ´6224 # composite cell を展開したセルの結合を clone したセルの名前に変更 6551 6225 def change_rhs_port( clone_cell_list, celltype ) 6552 6226 dbgPrint "change_rhs_port: name=#{@name}\n" … … 6572 6246 dbgPrint " REWRITE cell_name: #{@owner.get_name} #{@cell_name} => #{c.get_global_name}, #{c.get_name}\n" 6573 6247 6574 # @rhs ã®å 6575 容ã調æ´ãã¦ããï¼ãã®å 6576 容ã¯ãsubscript ãé¤ãã¦ãå¾ãã使ããã¦ããªãï¼ 6248 # @rhs の内容を調整しておく(この内容は、subscript を除いて、後から使われていない) 6577 6249 elements = @rhs.get_elements 6578 if elements[0] == :OP_SUBSC then # å³è¾ºï¼åãå£é 6579 åï¼ 6250 if elements[0] == :OP_SUBSC then # 右辺:受け口配列? 6580 6251 elements = elements[1] 6581 6252 end 6582 6253 6583 # å³è¾ºããcell.ePort ã®å½¢å¼ã§ãªã6254 # 右辺が cell.ePort の形式でない 6584 6255 if elements[0] != :OP_DOT || elements[1][0] != :IDENTIFIER then #1 6585 6256 return 6586 6257 else 6587 # ã»ã«åã composite å 6588 é¨ã®ååãããå¤é¨ã®ååã«å 6589 ¥ãæ¿ãã 6258 # セル名を composite 内部の名前から、外部の名前に入れ替える 6590 6259 # elements[1][1] = Token.new( c.get_name, nil, nil, nil ) 6591 6260 elements[1][1] = NamespacePath.new( c.get_name, false, c.get_namespace ) … … 6594 6263 @cell_name = c.get_name 6595 6264 @cell = c 6596 # @definition = nil # @definition ãæå¹ï¼ ãã§ãã¯æ¸ã¿ï¼ã¨ã¯ãããªãï¼6265 # @definition = nil # @definition が有効: チェック済み(とは、しない) 6597 6266 6598 6267 if @array_member2 then … … 6603 6272 i = 0 6604 6273 while i < @array_member2.length 6605 # @array_member2[i] ã nil ã«ãªãã®ã¯ optional ã®æã¨ã 6606 # Join ã® initialize ã§ç¡é§ã« @array_member2 ãè¨å®ããã¦ããå ´å 6607 # ç¡é§ã«è¨å®ããã¦ãããã®ã«ã¤ãã¦ã¯ãå帰çã«å¼ã³åºãå¿ 6608 è¦ã¯ãªãï¼clone_for_composite ã§ã¯å¯¾çãã¦ããï¼ 6274 # @array_member2[i] が nil になるのは optional の時と、 6275 # Join の initialize で無駄に @array_member2 が設定されている場合 6276 # 無駄に設定されているものについては、再帰的に呼び出す必要はない(clone_for_composite では対策している) 6609 6277 if @array_member2[i] != self && @array_member[i] != nil then 6610 6278 dbgPrint "change_rhs array_member #{i}: #{@name} #{@cell_name}\n" … … 6617 6285 end 6618 6286 6619 #=== Join# composite ã»ã«ç¨ã«ã¯ãã¼ã³ 6620 #cell_global_name:: string : 親ã»ã«ã®ã°ãã¼ãã«å 6621 # å³è¾ºã® C_EXP ã«å«ã¾ãã $id$, $cell$, $ct$ ãç½®æ 6622 # ããã§ç½®æããã®ã¯ composite ã® attribute ã® C_EXP ã composite ã»ã«ã¿ã¤ãããã³ã»ã«åã«ç½®æãããã 6623 # ï¼å 6624 é¨ã»ã«ã® C_EXP ãããã§ç½®æãããï¼ 6625 # @through_list ãªã©ãã³ãã¼ãããã®ã§ããããå¼ã³åºãããåã«ç¢ºå®ããå¿ 6626 è¦ããã 6287 #=== Join# composite セル用にクローン 6288 #cell_global_name:: string : 親セルのグローバル名 6289 # 右辺の C_EXP に含まれる $id$, $cell$, $ct$ を置換 6290 # ここで置換するのは composite の attribute の C_EXP を composite セルタイプおよびセル名に置換するため 6291 # (内部セルの C_EXP もここで置換される) 6292 # @through_list などもコピーされるので、これが呼び出される前に確定する必要がある 6627 6293 def clone_for_composite( ct_name, cell_name, locale, b_need_recursive = true ) 6628 6294 # debug … … 6643 6309 6644 6310 def clone_array_member( ct_name, cell_name, prev, locale ) 6645 # é 6646 åã®ã³ãã¼ãä½ã 6311 # 配列のコピーを作る 6647 6312 am = @array_member.clone 6648 6313 am2 = @array_member2.clone 6649 6314 6650 # é 6651 åè¦ç´ ã®ã³ãã¼ãä½ã 6315 # 配列要素のコピーを作る 6652 6316 i = 0 6653 6317 while i < am2.length 6654 6318 if @array_member2[i] == prev then 6655 # èªåèªèº«ã§ããï¼ã®ã§ãå¼åºãã¨ç¡éå帰å¼åºãã¨ãªãï¼6319 # 自分自身である(ので、呼出すと無限再帰呼出しとなる) 6656 6320 am2[i] = self 6657 6321 am[i] = am2[i].get_rhs … … 6661 6325 am[i] = am2[i].get_rhs 6662 6326 else 6663 # 以åã®ã¨ã©ã¼ã§ array_member2[i] 㯠nil ã«ãªã£ã¦ãã6327 # 以前のエラーで array_member2[i] は nil になっている 6664 6328 end 6665 6329 … … 6670 6334 end 6671 6335 6672 # i = 0 ã¯ãããã§èªåèªèº«ãè¨å®6336 # i = 0 は、ここで自分自身を設定 6673 6337 # am2[0] = self 6674 6338 … … 6678 6342 end 6679 6343 6680 #=== Join# rhs ãå 6681 ¥ãæãã 6344 #=== Join# rhs を入れ換える 6682 6345 #rhs:: Expression | initializer 6683 # å³è¾ºãå 6684 ¥ãæããï¼ 6685 # ãã®ã¡ã½ããã¯ãcomposite 㧠cell ã®å±æ§ã®åæå¤ã attribute ã®å¤ã§ç½®ãæããã®ã«ä½¿ããã 6686 # ãã®ã¡ã½ãã㯠composite å 6687 ã® cell ã®å±æ§ã®åæå¤ãå®æ°ã§ã¯ãªãå¼ã«ãªã£ãå ´åãä¸è¦ã«ãªã 6346 # 右辺を入れ換える. 6347 # このメソッドは、composite で cell の属性の初期値を attribute の値で置き換えるのに使われる 6348 # このメソッドは composite 内の cell の属性の初期値が定数ではなく式になった場合、不要になる 6688 6349 def change_rhs rhs 6689 6350 @rhs = rhs 6690 6351 end 6691 6352 6692 #=== Join# clone ããã join ã® owner ãå¤æ´6353 #=== Join# clone された join の owner を変更 6693 6354 def set_cloned( owner ) 6694 6355 dbgPrint "Join#set_cloned: #{@name} prev owner: #{@owner.get_name} new owner: #{owner.get_name}\n" … … 6784 6445 end 6785 6446 6786 #== éçµå6447 #== 逆結合 6787 6448 class ReverseJoin < BDNode 6788 6449 #@ep_name:: Symbol … … 6809 6470 end 6810 6471 6811 # CLASS: CompositeCelltype ç¨ã®Join6812 # REM: CompositeCelltype ã export ãããã®6472 # CLASS: CompositeCelltype 用の Join 6473 # REM: CompositeCelltype が export するもの 6813 6474 class CompositeCelltypeJoin < BDNode 6814 # @export_name:: string : CompositeCelltype ã export ããååï¼å¼ã³å£ãåãå£ãå±æ§ï¼ 6815 # @internal_cell_name:: string : CompositeCelltype å 6816 é¨ã®ã»ã«ã®åå 6817 # @internal_cell_elem_name:: string : CompositeCelltype å 6818 é¨ã®ã»ã«ã®å¼ã³å£ãåãå£ãå±æ§ã®åå 6819 # @cell : Cell : Cell:: internal cell : CompositeCelltyep å 6820 é¨ã®ã»ã«ï¼in_compositeã»ã«ï¼ 6475 # @export_name:: string : CompositeCelltype が export する名前(呼び口、受け口、属性) 6476 # @internal_cell_name:: string : CompositeCelltype 内部のセルの名前 6477 # @internal_cell_elem_name:: string : CompositeCelltype 内部のセルの呼び口、受け口、属性の名前 6478 # @cell : Cell : Cell:: internal cell : CompositeCelltyep 内部のセル(in_compositeセル) 6821 6479 # @port_decl:: Port | Decl 6822 6480 # @b_pseudo: bool : … … 6833 6491 end 6834 6492 6835 #=== CompositeCelltypeJoin# CompositeCelltypeJoin ã®å¯¾è±¡ã»ã«ãï¼6836 #cell:: Cell 対象ãã©ãããã§ãã¯ããã»ã«6493 #=== CompositeCelltypeJoin# CompositeCelltypeJoin の対象セルか? 6494 #cell:: Cell 対象かどうかチェックするセル 6837 6495 # 6838 # CompositeCelltypeJoin 㨠cell ã®ååãä¸è´ããããã§ãã¯ãã6839 # port_decl ãæå®ãããå ´åã¯ãç¾ç¶ä½¿ããã¦ããªã6496 # CompositeCelltypeJoin と cell の名前が一致するかチェックする 6497 # port_decl が指定された場合は、現状使われていない 6840 6498 def match?( cell, port_decl = nil ) 6841 6499 … … 6853 6511 6854 6512 # if @cell.equal?( cell ) && ( port_decl == nil || @port_decl.equal?( port_decl ) ) then 6855 # ãªã port_decl ãä¸è´ããªããã°ãªããªãã£ããå¿ããã6856 # recursive_composite ã§ååã®ä¸è´ã«å¤æ´0609176513 # なぜ port_decl が一致しなければならなかったか忘れた。 6514 # recursive_composite で名前の一致に変更 060917 6857 6515 if((@cell.get_name == cell.get_name) && (port_decl == nil || @port_decl.get_name == port_decl.get_name))then 6858 6516 true … … 6886 6544 end 6887 6545 6888 # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã6546 # @port_decl が Port の場合のみ呼び出してよい 6889 6547 def get_port_type 6890 6548 if @port_decl then … … 6908 6566 end 6909 6567 6910 # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã6568 # @port_decl が Port の場合のみ呼び出してよい 6911 6569 def is_require? 6912 6570 if @port_decl then … … 6915 6573 end 6916 6574 6917 # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã6575 # @port_decl が Port の場合のみ呼び出してよい 6918 6576 def is_allocator_port? 6919 6577 if @port_decl then … … 6922 6580 end 6923 6581 6924 # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã6582 # @port_decl が Port の場合のみ呼び出してよい 6925 6583 def is_optional? 6926 6584 if @port_decl then … … 6929 6587 end 6930 6588 6931 #=== CompositeCelltypeJoin# å³è¾ºã Decl ãªãã°åæååï¼å¼ï¼ãè¿ã6932 # ãã®ã¡ã½ãã㯠Cell ã® check_join ããåæå¤ãã§ãã¯ã®ããã«å¼ã³åºããã6589 #=== CompositeCelltypeJoin# 右辺が Decl ならば初期化子(式)を返す 6590 # このメソッドは Cell の check_join から初期値チェックのために呼び出される 6933 6591 def get_initializer 6934 6592 if @port_decl.instance_of? Decl then … … 6943 6601 end 6944 6602 6945 #=== CompositeCelltypeJoin# é 6946 åãµã¤ãºãå¾ã 6947 #RETURN:: nil: not array, "[]": 大ããæå®ãªã, Integer: 大ããæå®ãã 6603 #=== CompositeCelltypeJoin# 配列サイズを得る 6604 #RETURN:: nil: not array, "[]": 大きさ指定なし, Integer: 大きさ指定あり 6948 6605 def get_array_size 6949 6606 @port_decl.get_array_size 6950 6607 end 6951 6608 6952 #=== CompositeCelltypeJoin# signature ãå¾ã6953 # @port_decl ã Port ã®æã®ã¿å¼ã³åºãã¦ããã6609 #=== CompositeCelltypeJoin# signature を得る 6610 # @port_decl が Port の時のみ呼び出してもよい 6954 6611 def get_signature 6955 6612 @port_decl.get_signature … … 6994 6651 # @file_name:: string 6995 6652 # @format:: string 6996 # @arg_list:: Expression ã® elements ã¨åãå½¢å¼[ [:IDENTIFIER, String], ... ]6653 # @arg_list:: Expression の elements と同じ形式 [ [:IDENTIFIER, String], ... ] 6997 6654 # @f_celltype:: bool : true: celltype factory, false: cell factory 6998 6655 … … 7005 6662 case name 7006 6663 when :write 7007 # write é¢æ°6664 # write 関数 7008 6665 @name = name 7009 6666 7010 # write é¢æ°ã®ç¬¬ä¸å¼æ°ï¼åºåå 7011 ãã¡ã¤ã«å 7012 # å¼ãè©ä¾¡ããï¼é常åä¸ã®æååã§ãããããåä¸ã®æååãè¿ãããï¼ 6667 # write 関数の第一引数:出力先ファイル名 6668 # 式を評価する(通常単一の文字列であるから、単一の文字列が返される) 7013 6669 @file_name = file_name.eval_const(nil).val # file_name : Expression 7014 6670 if ! @file_name.instance_of?( String ) then 7015 # æååå®æ°ã§ã¯ãªãã£ã6671 # 文字列定数ではなかった 7016 6672 cdl_error( "S1132 $1: 1st parameter is not string(file name)" , @name ) 7017 6673 @file_name = nil 7018 6674 end 7019 6675 7020 # write é¢æ°ã®ç¬¬äºå¼æ°ï¼ãã©ã¼ãããæåå6676 # write 関数の第二引数:フォーマット文字列 7021 6677 @format = format.eval_const(nil).val # format : Expression 7022 # å¼ãè©ä¾¡ããï¼é常åä¸ã®æååã§ãããããåä¸ã®æååãè¿ãããï¼6678 # 式を評価する(通常単一の文字列であるから、単一の文字列が返される) 7023 6679 if ! @format.instance_of?( String ) then 7024 # æååå®æ°ã§ã¯ãªãã£ã6680 # 文字列定数ではなかった 7025 6681 cdl_error( "S1133 $1: 2nd parameter is not string(fromat)" , @name ) 7026 6682 @format = nil 7027 6683 end 7028 6684 7029 # 第ä¸å¼æ°ä»¥éãå¼æ°ãªã¹ãã¨ãã mikan å¼æ°ã®ãã§ãã¯6685 # 第三引数以降を引数リストとする mikan 引数のチェック 7030 6686 @arg_list = arg_list 7031 6687 … … 7104 6760 #== DomainType 7105 6761 # 7106 # region ã® domain ãè¨æ¶ããã¯ã©ã¹6762 # region の domain を記憶するクラス 7107 6763 class DomainType < Node 7108 #@name::Symbol : ãã¡ã¤ã³ã¿ã¤ãã®ååex) HRP26764 #@name::Symbol : ドメインタイプの名前 ex) HRP2 7109 6765 #@region::Region 7110 6766 #@plugin_name::Symbol : ex) HRP2Plugin 7111 6767 #@option::String : ex) "trusted", "nontrusted" 7112 #@plugin::DomainPlugin ã®åã¯ã©ã¹6768 #@plugin::DomainPlugin の子クラス 7113 6769 7114 6770 include PluginModule 7115 6771 7116 # ãã¡ã¤ã³ã«å±ãã region ã®Hash7117 # domain æå®ãä¸åº¦ãè¡ãããªãå ´åããã®ãªã¹ãã¯ç©ºã§ãã7118 # ã«ã¼ããªã¼ã¸ã§ã³ã¯ option = "OutOfDomain" ã§ç»é²ããã (domain æå®ãç¡ããã°ç»é²ãããªã)6772 # ドメインに属する region の Hash 6773 # domain 指定が一度も行われない場合、このリストは空である 6774 # ルートリージョンは option = "OutOfDomain" で登録される (domain 指定が無ければ登録されない) 7119 6775 @@domain_regions = { } # { :domain_type => [ region, ... ] } 7120 6776 … … 7159 6815 end 7160 6816 7161 #== DomainType ãªã¼ã¸ã§ã³ã® Hash ãå¾ã 7162 # @@domain_regions ã®èª¬æåç 7163 § 6817 #== DomainType リージョンの Hash を得る 6818 # @@domain_regions の説明参照 7164 6819 def self.get_domain_regions 7165 6820 return @@domain_regions … … 7174 6829 end 7175 6830 7176 #== DomainType# ãã¡ã¤ã³ç¨®å¥ãå¾ã6831 #== DomainType#ドメイン種別を得る 7177 6832 #return::Symbol :kernel, :user, :OutOfDomain 7178 6833 def get_kind … … 7186 6841 end 7187 6842 7188 #== Region ã¯ã©ã¹6843 #== Region クラス 7189 6844 # 7190 # Region 㯠Namespace ãç¶æ¿ãã¦ãã7191 # root region ã¯ç¹æ®ã§ãroot namespace ã¨åãã§ãã6845 # Region は Namespace を継承している 6846 # root region は特殊で、root namespace と同じである 7192 6847 # 7193 # cell 㯠region ã«å±ãã7194 # region ã«å±ãã cell ã®ãªã¹ã㯠Namespace ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¨ãã¦è¨æ¶ããã6848 # cell は region に属する 6849 # region に属する cell のリストは Namespace クラスのインスタンス変数として記憶される 7195 6850 # 7196 6851 class Region < Namespace 7197 6852 # @name:: string 7198 # @in_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil ã®æ in ç¦æ¢7199 # @out_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil ã®æ out ç¦æ¢6853 # @in_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil の時 in 禁止 6854 # @out_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil の時 out 禁止 7200 6855 # @to_through_list:: [ [ dst_region, plugin_name, plugin_arg ], ... ] 7201 # @cell_port_throug_plugin_list:: { "#{cell_name}.#{port_name}" => through_generated_list ã®è¦ç´}7202 # ãã® region ãã cell_name.port_name ã¸ã® through ãã©ã°ã¤ã³ã§çæããããªãã¸ã§ã¯ã6856 # @cell_port_throug_plugin_list:: { "#{cell_name}.#{port_name}" => through_generated_list の要素 } 6857 # この region から cell_name.port_name への through プラグインで生成されたオブジェクト 7203 6858 # @region_type::Symbol : :NODE, :LINKUNIT, :DOMAIN, :CLASS 7204 # @region_type_param::Symbol : domain, class ã®åå. node, linkunit ã§ã¯nil7205 # @link_root:: Region : linkUnit ã®æ ¹ã£ãã¨ãªã region (node, linkunit ãæå®ãããregion)7206 # @family_line:: [ @region_root, ...,@region_me ] 家系7207 # @in_through_count:: Integer : n çªç®ã® in_through çµå(n>=0)7208 # @out_through_count:: Integer : n çªç®ã® out_through çµå(n>=0)7209 # @to_through_count:: { :RegionName => Integer }: RegionName ã¸ã® n çªç®ã® to_through çµå(n>=0)7210 # @domain_type::DomainType : domain æå®ããã¦ããªãå ´åãnil7211 # @domain_root::Region : domain æå®ããã¦ããªã Region (root ã®å ´ånil)6859 # @region_type_param::Symbol : domain, class の名前. node, linkunit では nil 6860 # @link_root:: Region : linkUnit の根っことなる region (node, linkunit が指定された region) 6861 # @family_line:: [ @region_root, ...,@region_me ] 家系 6862 # @in_through_count:: Integer : n 番目の in_through 結合 (n>=0) 6863 # @out_through_count:: Integer : n 番目の out_through 結合 (n>=0) 6864 # @to_through_count:: { :RegionName => Integer }: RegionName への n 番目の to_through 結合 (n>=0) 6865 # @domain_type::DomainType : domain 指定されていない場合、nil 6866 # @domain_root::Region : domain 指定されていなる Region (root の場合 nil) 7212 6867 7213 6868 @@in_through_list = [] … … 7217 6872 @@region_type_param = nil 7218 6873 @@domain_name = nil 7219 @@domain_option = nil # Token ãå 7220 ¥ã 6874 @@domain_option = nil # Token が入る 7221 6875 7222 6876 @@link_roots = [] 7223 6877 7224 6878 def initialize( name ) 7225 # mikan name ã® Namespace 修飾7226 # object = Namespace.find( [ name ] ) # 親ã¾ã§æãã«ãã6879 # mikan name の Namespace 修飾 6880 # object = Namespace.find( [ name ] ) # 親まで捜しにいく 7227 6881 if name != "::" then 7228 6882 object = Namespace.get_current.find( name ) #1 7229 6883 else 7230 # root ãªã¼ã¸ã§ã³6884 # root リージョン 7231 6885 object = nil 7232 6886 @@region_type = :NODE … … 7265 6919 dbgPrint "Region.new: re-appear #{@name}\n" 7266 6920 7267 # # Region path ãåååºç¾ã¨ä¸è´ãããï¼6921 # # Region path が前回出現と一致するか? 7268 6922 # if @@region_stack[ @@region_stack_sp - 1 ] then 7269 6923 # my_path = @@region_stack[ @@region_stack_sp - 1 ].get_path_string.to_s + "." + @name.to_s … … 7275 6929 # end 7276 6930 7277 # ååºç¾6931 # 再出現 7278 6932 # @@region_stack[@@region_stack_sp] = object 7279 6933 7280 # ååºç¾æã« specifier ãæå®ããã¦ãããï¼6934 # 再出現時に specifier が指定されているか? 7281 6935 if( @in_through_list.length != 0 || @out_through_list.length != 0 || @to_through_list.length != 0 || 7282 6936 @region_type != nil || @domain_type != nil )then … … 7286 6940 7287 6941 else 7288 # ã¨ã©ã¼ç¨ããã¼å®ç¾©7289 7290 # ç°ãªãååã®ãªãã¸ã§ã¯ããå®ç¾©æ¸ã¿6942 # エラー用ダミー定義 6943 6944 # 異なる同名のオブジェクトが定義済み 7291 6945 cdl_error( "S1141 $1 duplication, previous one : $2" , name, object.class ) 7292 # @@region_stack[@@region_stack_sp] = self # ã¨ã©ã¼ææ«å®region7293 end 7294 else 7295 # ååºç¾6946 # @@region_stack[@@region_stack_sp] = self # エラー時暫定 region 6947 end 6948 else 6949 # 初出現 7296 6950 dbgPrint "Region.new: #{@name}\n" 7297 6951 set_region_family_line … … 7346 7000 end 7347 7001 7348 #== Region ã«ã¼ããªã¼ã¸ã§ã³ãå¾ã7349 # ã«ã¼ããªã¼ã¸ã§ã³ã¯ãã«ã¼ããã¼ã ã¹ãã¼ã¹ã¨åãã§ãã7002 #== Region ルートリージョンを得る 7003 # ルートリージョンは、ルートネームスペースと同じである 7350 7004 def self.get_root 7351 7005 Namespace.get_root … … 7355 7009 7356 7010 dbgPrint "set_region_family_line: Region: #{@name} \n" 7357 # root namespace (root region) ã® region type ã¯:NODE7011 # root namespace (root region) の region type は :NODE 7358 7012 if @name == "::" then 7359 7013 @region_type = :NODE … … 7373 7027 7374 7028 if @domain_type then 7375 # ã«ã¼ããªã¼ã¸ã§ã³ãæåãã @domain_type è¨å®ããããã¨ã¯ãªãã® 7376 # 㧠@owner == nil ã調ã¹ãå¿ 7377 è¦ã¯ãªã 7029 # ルートリージョンが最初から @domain_type 設定されることはないの 7030 # で @owner == nil を調べる必要はない 7378 7031 @owner.set_domain_type @domain_type 7379 7032 end … … 7389 7042 @link_root = nil 7390 7043 7391 # @family_line ãä½æãã 7392 # @link_root ãã¿ã¤ãã 7393 # (ä¸ä½ã«ãã©ã£ã¦ãã£ã¦ Region 㧠node ã¾ã㯠linkunit ã®ããããå 7394 ã«è¦ã¤ãã£ããã®ã @link_root ã¨ãªã) 7395 # root namespace 㯠Region ã㤠node ãªã®ã§å¿ 7396 ã @link_root ã¯è¦ã¤ãã 7397 # mikan: self ã node, linkUnit ã®å ´åãããã§æå¾ 7398 ããã¨ããã«è¨å®ãããªããããRegion#initialize ã§åè¨å® 7044 # @family_line を作成する 7045 # @link_root もみつける 7046 # (上位にたどっていって Region で node または linkunit のいずれか先に見つかったものが @link_root となる) 7047 # root namespace は Region かつ node なので必ず @link_root は見つかる 7048 # mikan: self が node, linkUnit の場合、ここで期待したとおりに設定されないため、Region#initialize で再設定 7399 7049 obj = self 7400 7050 while 1 … … 7407 7057 end 7408 7058 else 7409 # ãããªããã°Namespace7410 # namespace ã®ä¸ã« region ãããå ´å7411 end 7412 7413 # root namespace ã«ãã©ãçãã°çµã7059 # さもなければ Namespace 7060 # namespace の下に region がある場合 7061 end 7062 7063 # root namespace にたどり着けば終り 7414 7064 break if obj.get_name == "::" 7415 7065 … … 7422 7072 end 7423 7073 7424 #== Region# ãã¡ã¤ã³ãè¨å®ãã7074 #== Region#ドメインを設定する 7425 7075 def set_domain_type domain_type 7426 7076 if @region_type == :NODE then … … 7466 7116 end 7467 7117 7468 #== Region# domain ã®æ ¹ã£ãã¨ãªã region ãå¾ã7469 # Region ã®ã¤ã³ã¹ã¿ã³ã¹ãè¿ã7470 # domain æå®åãããã°ããã®ãªã¼ã¸ã§ã³ããã¡ã¤ã³ã«ã¼ãã§ãã7471 # ãªããã°ã親ãªã¼ã¸ã§ã³ã®ãã¡ã¤ã³ã«ã¼ãã¨ãã7118 #== Region# domain の根っことなる region を得る 7119 # Region のインスタンスを返す 7120 # domain 指定子があれば、そのリージョンがドメインルートである 7121 # なければ、親リージョンのドメインルートとする 7472 7122 def get_domain_root 7473 7123 @domain_root … … 7493 7143 end 7494 7144 7495 #== Region# ã«ã¼ããªã¼ã¸ã§ã³7496 # ã«ã¼ããªã¼ã¸ã§ã³ã¯ãnamespace ã®ã«ã¼ãã¨åãã¤ã³ã¹ã¿ã³ã¹7145 #== Region# ルートリージョン 7146 # ルートリージョンは、namespace のルートと同じインスタンス 7497 7147 def selfget_root 7498 7148 Namespace.get_root … … 7515 7165 end 7516 7166 7517 #=== Region# æ§æ解æä¸ã® region ãå¾ã 7518 # æ§æ解æä¸ Namespace (ãããã¯åã¯ã©ã¹ã® Region) ã®ä¸ä½ããã©ã£ã¦ Region ãè¦ã¤ãã 7519 # cell ã namespace ä¸ã«ãããã¨ãã§ããªããã°ãã«ã¼ããã¾ããå¿ 7520 è¦ã¯ãªã 7167 #=== Region# 構文解析中の region を得る 7168 # 構文解析中 Namespace (あるいは子クラスの Region) の上位をたどって Region を見つける 7169 # cell が namespace 下におくことができなければ、ループをまわす必要はない 7521 7170 def self.get_current 7522 7171 # @@region_stack[@@region_stack_sp] … … 7531 7180 end 7532 7181 7533 #=== Region# through ãã©ã°ã¤ã³ã§ããã® region ãã cell_name.port_name ã¸ã®ãã©ã°ã¤ã³ãªãã¸ã§ã¯ããç»é²7534 # mikan namesppace 対å¿(cell_name)7182 #=== Region# through プラグインで、この region から cell_name.port_name へのプラグインオブジェクトを登録 7183 # mikan namesppace 対応 (cell_name) 7535 7184 def add_cell_port_through_plugin( cell_name, port_name, subscript, through_plugin_object ) 7536 7185 if subscript then … … 7553 7202 end 7554 7203 7555 #=== Region# to_region ã¸ã®è·é¢ï¼unreachable ãªå ´å nil) 7556 # mikan Cell#check_region ã¨Region ã¸ãã©ãçãã¾ã§ããã®å¦çã«å 7557 ±éæ§ãé«ã 7558 # region#distance 㯠require ã§ç¨ãããã 7204 #=== Region# to_region への距離(unreachable な場合 nil) 7205 # mikan Cell#check_region とRegion へたどり着くまでための処理に共通性が高い 7206 # region#distance は require で用いられる 7559 7207 def distance( to_region ) 7560 7208 7561 r1 = self # åºçºregion7562 r2 = to_region # ç®çregion7209 r1 = self # 出発 region 7210 r2 = to_region # 目的 region 7563 7211 dist = 0 7564 7212 7565 if ! r1.equal? r2 then # åä¸ region ãªãå¼åºãå¯è½7566 7567 # mikan namespace 対å¿7213 if ! r1.equal? r2 then # 同一 region なら呼出し可能 7214 7215 # mikan namespace 対応 7568 7216 f1 = r1.get_family_line 7569 7217 len1 = f1.length … … 7571 7219 len2 = f2.length 7572 7220 7573 # ä¸ä¸è´ã«ãªãã¨ããï¼å 7574 å¼ï¼ãæ¢ã 7575 i = 1 # i = 0 㯠:RootRegion ãªã®ã§å¿ 7576 ãä¸è´ 7221 # 不一致になるところ(兄弟)を探す 7222 i = 1 # i = 0 は :RootRegion なので必ず一致 7577 7223 while( i < len1 && i < len2 ) 7578 7224 if( f1[i] != f2[i] )then … … 7582 7228 end 7583 7229 7584 sibling_level = i # å 7585 å¼ã¨ãªãã¬ãã«ããããã¯ã©ã¡ããä¸æ¹ãçµãã£ãã¬ãã« 7230 sibling_level = i # 兄弟となるレベル、もしくはどちらか一方が終わったレベル 7586 7231 7587 7232 # p "sibling_level: #{i}" … … 7589 7234 # p "to: #{f2[i].get_name}" if f2[i] 7590 7235 7591 # å¼ã³å´ã«ã¤ãã¦å¼ã³å 7592 ã®ã¬ãã«ããå 7593 å¼ã¬ãã«ã¾ã§ï¼out_through ããã§ãã¯ããã³æ¿å 7594 ¥ï¼ 7236 # 呼び側について呼び元のレベルから兄弟レベルまで(out_through をチェックおよび挿入) 7595 7237 i = len1 -1 7596 7238 while i >= sibling_level … … 7615 7257 end 7616 7258 7617 # å 7618 å¼ã¬ãã«ã«ããã¦ï¼to_through ããã§ãã¯ããã³æ¿å 7619 ¥ï¼ 7259 # 兄弟レベルにおいて(to_through をチェックおよび挿入) 7620 7260 if f1[sibling_level] && f2[sibling_level] then 7621 7261 dbgPrint "going from #{f1[sibling_level].get_name} to #{f2[sibling_level].get_name}\n" … … 7632 7272 found = 0 7633 7273 f1[sibling_level].get_to_through_list.each { |t| 7634 if t[0][0] == f2[sibling_level].get_name then # region åãä¸è´ããã?7274 if t[0][0] == f2[sibling_level].get_name then # region 名が一致するか ? 7635 7275 found = 1 7636 7276 end … … 7643 7283 end 7644 7284 7645 # åãå´ã«ã¤ãã¦å 7646 å¼ã¬ãã«ããåãå´ã®ã¬ãã«ã¾ã§ï¼in_through ããã§ãã¯ããã³æ¿å 7647 ¥ï¼ 7285 # 受け側について兄弟レベルから受け側のレベルまで(in_through をチェックおよび挿入) 7648 7286 i = sibling_level 7649 7287 while i < len2 … … 7756 7394 class Import_C < Node 7757 7395 7758 # ãããã®ååæååã®ãªã¹ã7396 # ヘッダの名前文字列のリスト 7759 7397 @@header_list = {} 7760 7398 @@header_list2 = [] … … 7763 7401 include Importable 7764 7402 7765 #=== Import_C# import_C ã®çæï¼ããããã¡ã¤ã«ãåè¾¼ãï¼7766 #header:: Token : import_C ã®ç¬¬ä¸å¼æ°æååãªãã©ã«ãã¼ã¯ã³7767 #define:: Token : import_C ã®ç¬¬äºå¼æ°æååãªãã©ã«ãã¼ã¯ã³7403 #=== Import_C# import_C の生成(ヘッダファイルを取込む) 7404 #header:: Token : import_C の第一引数文字列リテラルトークン 7405 #define:: Token : import_C の第二引数文字列リテラルトークン 7768 7406 def initialize( header, define = nil ) 7769 7407 super() 7770 # ããããã¡ã¤ã«åæååããåå¾ã® "" ãåãé¤ã7408 # ヘッダファイル名文字列から前後の "" を取り除く 7771 7409 # header = header.to_s.gsub( /\A"(.*)"\z/, '\1' ) 7772 7410 header = CDLString.remove_dquote header.to_s 7773 7411 7774 7412 if define then 7775 # åå¾ã® "" ãåãé¤ã7413 # 前後の "" を取り除く 7776 7414 # def_opt = define.to_s.gsub( /\A"(.*)/, '\1' ) 7777 7415 # def_opt.sub!( /(.*)"\z/, '\1' ) 7778 7416 def_opt = CDLString.remove_dquote define.to_s 7779 7417 7780 # "," ã -D ã«ç½®ãæã7418 # "," を -D に置き換え 7781 7419 def_opt = def_opt.gsub( /,/, " -D " ) 7782 7420 7783 # å 7784 é ã« -D ãæ¿å 7785 ¥ # mikan ä¸é©å㪠define å 7786 ¥åããã£ãå ´åãCPP æã«ã¨ã©ã¼ 7421 # 先頭に -D を挿入 # mikan 不適切な define 入力があった場合、CPP 時にエラー 7787 7422 def_opt = def_opt.gsub( /^/, "-D " ) 7788 7423 7789 7424 end 7790 7425 7791 # ã³ãã³ãã©ã¤ã³æå®ãããDEFINE7426 # コマンドライン指定された DEFINE 7792 7427 $define.each{ |define| 7793 7428 if $IN_EXERB then … … 7813 7448 if found == false then 7814 7449 begin 7815 # ãã¡ã¤ã«ã® stat ãåã£ã¦ã¿ã(ãªããã°ä¾å¤çºç)7450 # ファイルの stat を取ってみる(なければ例外発生) 7816 7451 File.stat( "#{path}/#{header}" ) 7817 7452 7818 # cdl ãè¦ã¤ãã£ããã¡ã¤ã«ãã¹ã«åè¨å®7453 # cdl を見つかったファイルパスに再設定 7819 7454 header_path = "#{path}/#{header}" 7820 7455 found = true … … 7843 7478 } 7844 7479 7845 # èªè¾¼ã¿æ¸ã¿ï¼7480 # 読込み済み? 7846 7481 if( @@header_list[ header ] ) then 7847 # 第äºå¼æ° define ã以åã¨ç°ãªã7482 # 第二引数 define が以前と異なる 7848 7483 if @@define_list[ header ].to_s != define.to_s then 7849 7484 cdl_error( "S1143 import_C: arg2: mismatch with previous one" ) 7850 7485 end 7851 # ãããã«ããèªã¿è¾¼ã¾ãªã7486 # いずれにせよ読み込まない 7852 7487 return 7853 7488 end 7854 7489 7855 # ãããã®ãªã¹ããè¨é²7490 # ヘッダのリストを記録 7856 7491 @@header_list[ header ] = header_path 7857 7492 @@header_list2 << header … … 7881 7516 end 7882 7517 7883 # CPP åºåç¨ tmp ãã¡ã¤ã«å7518 # CPP 出力用 tmp ファイル名 7884 7519 tmp_header = header.gsub( /\//, "_" ) 7885 7520 tmp_header = "#{$gen}/tmp_#{tmp_header}" 7886 7521 7887 # CPP ã³ãã³ãã©ã¤ã³ãä½æ7522 # CPP コマンドラインを作成 7888 7523 cmd = "#{$cpp} #{def_opt} #{include_opt} #{tmp_C}" 7889 7524 … … 7893 7528 end 7894 7529 7895 # ããªããã»ããµã³ãã³ãã pipe ã¨ãã¦éã7896 # cmd 㯠cygwin/Linux ã§ã¯ bash(sh) çµç±ã§å®è¡ããã7897 # Exerb çã§ã¯ cmd.exe çµç±ã§å®è¡ããã7898 # ãã®å·®ã¯å¼ãæ°ã® (), $, % ãªã©ã·ã§ã«ã®ç¹å¥ãªæåã®è©ä¾¡ã«ç¾ããã®ã§æ³¨æ7530 # プリプロセッサコマンドを pipe として開く 7531 # cmd は cygwin/Linux では bash(sh) 経由で実行される 7532 # Exerb 版では cmd.exe 経由で実行される 7533 # この差は引き数の (), $, % などシェルの特別な文字の評価に現れるので注意 7899 7534 cpp = IO.popen( cmd, "r:ASCII-8BIT" ) 7900 7535 begin … … 7909 7544 print_exception( evar ) 7910 7545 ensure 7911 tmp_file.close if tmp_file # mikan File.open ã«å¤±æããæ tmp_file == nil ã¯ä¿è¨¼ããã¦ãã?7546 tmp_file.close if tmp_file # mikan File.open に失敗した時 tmp_file == nil は保証されている ? 7912 7547 cpp.close 7913 7548 end … … 7917 7552 end 7918 7553 7919 # C è¨èªã®ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ7554 # C 言語のパーサインスタンスを生成 7920 7555 c_parser = C_parser.new 7921 7556 7922 # tmp_header ããã¼ã¹7557 # tmp_header をパース 7923 7558 c_parser.parse( [tmp_header] ) 7924 7559 7925 # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã7560 # 終期化 パーサスタックを戻す 7926 7561 c_parser.finalize 7927 7562 … … 7984 7619 7985 7620 class Import < Node 7986 # @b_reuse::bool: åå©ç¨ï¼ã»ã«ã¿ã¤ãã® template çæä¸è¦7987 # @b_reuse_real::bool: å®éã«åå©ç¨7988 # @cdl:: string: import ããCDL7989 # @cdl_path:: string: CDL ã®ãã¹7990 # @b_imported:: bool: import ããã(ã³ãã³ãã©ã¤ã³æå®ããã¦ããªã)7621 # @b_reuse::bool: 再利用.セルタイプの template 生成不要 7622 # @b_reuse_real::bool: 実際に再利用 7623 # @cdl:: string: import する CDL 7624 # @cdl_path:: string: CDL のパス 7625 # @b_imported:: bool: import された(コマンドライン指定されていない) 7991 7626 7992 7627 include Importable 7993 7628 7994 # ãããã®ååæååã®ãªã¹ã æ·»åï¼expand ãããã¹ãå¤ï¼Import7629 # ヘッダの名前文字列のリスト 添字:expand したパス、値:Import 7995 7630 @@import_list = {} 7996 7631 … … 8013 7648 end 8014 7649 8015 #=== Import# import ãè¡ã8016 #cdl:: string cdl ã¸ã®ãã¹ï¼"" ã§å²ã¾ãã¦ãããã¨ãä»®å®8017 #b_reuse:: bool true: template ãçæããªã7650 #=== Import# import を行う 7651 #cdl:: string cdl へのパス."" で囲まれていることを仮定 7652 #b_reuse:: bool true: template を生成しない 8018 7653 def initialize( cdl, b_reuse = false, b_imported = true ) 8019 7654 Import.push self … … 8021 7656 super() 8022 7657 @@current_import = self 8023 # ããããã¡ã¤ã«åæååããåå¾ã® "", <> ãåãé¤ãn7658 # ヘッダファイル名文字列から前後の "", <> を取り除くn 8024 7659 @cdl = cdl.to_s.gsub( /\A["<](.*)[">]\z/, '\1' ) 8025 7660 8026 # ãµã¼ããã¹ããæ¢ã7661 # サーチパスから探す 8027 7662 found = false 8028 7663 @cdl_path = "" … … 8047 7682 end 8048 7683 8049 # èªè¾¼ã¿æ¸ã¿ãªããèªè¾¼ã¾ãªã7684 # 読込み済みなら、読込まない 8050 7685 prev = @@import_list[ File.expand_path( @cdl_path ) ] 8051 7686 if( prev ) then … … 8056 7691 end 8057 7692 8058 # import ãªã¹ããè¨é²7693 # import リストを記録 8059 7694 @@import_list[ File.expand_path( @cdl_path ) ] = self 8060 7695 8061 # plugin ãã import ããã¦ããå ´å7696 # plugin から import されている場合 8062 7697 plugin = Generator.get_plugin 8063 7698 8064 # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èªã¿è¾¼ã)7699 # パーサインスタンスを生成(別パーサで読み込む) 8065 7700 parser = Generator.new 8066 7701 8067 # plugin ãã import ããã¦ããå ´åã® plugin è¨å®7702 # plugin から import されている場合の plugin 設定 8068 7703 parser.set_plugin plugin 8069 7704 8070 # reuse ãã©ã°ãè¨å®7705 # reuse フラグを設定 8071 7706 parser.set_reuse @b_reuse_real 8072 7707 8073 # cdl ããã¼ã¹7708 # cdl をパース 8074 7709 parser.parse( [@cdl_path] ) 8075 7710 8076 # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã7711 # 終期化 パーサスタックを戻す 8077 7712 parser.finalize 8078 7713 Import.pop … … 8099 7734 end 8100 7735 8101 #=== cdl ã®ååãè¿ã8102 # å¼æ°ã§æå®ããã¦ãã cdl åãä¸é¨ãã¹ãå«ãå¯è½æ§ããã7736 #=== cdl の名前を返す 7737 # 引数で指定されている cdl 名。一部パスを含む可能性がある 8103 7738 def get_cdl_name 8104 7739 @cdl … … 8106 7741 end 8107 7742 8108 #== generate: signature, celltype, cell ã¸ã®ãã©ã°ã¤ã³ã®ãã¼ãã¨é©ç¨7743 #== generate: signature, celltype, cell へのプラグインのロードと適用 8109 7744 class Generate < Node 8110 7745 #@plugin_name:: Symbol 8111 7746 #@object_nsp:: NamespacePath 8112 #@option:: String '"', '"' ã§å²ã¾ãã¦ãã7747 #@option:: String '"', '"' で囲まれている 8113 7748 #@plugin_object:: Plugin 8114 7749 … … 8119 7754 @plugin_name = plugin_name 8120 7755 @object_nsp = object_nsp 8121 option = option.to_s # option ã¯Token7756 option = option.to_s # option は Token 8122 7757 @option = option 8123 7758 @plugin_object = nil … … 8132 7767 @plugin_object = object.apply_plugin( @plugin_name, @option ) 8133 7768 elsif object then 8134 # V1.5.0 以åã®ä»æ§ã§ã¯ãsignature ã®ã¿å¯è½ã ã£ã7769 # V1.5.0 以前の仕様では、signature のみ可能だった 8135 7770 # cdl_error( "S1149 $1 not signature" , signature_nsp ) 8136 7771 cdl_error( "S9999 generate: '$1' neither signature, celltype nor cell", object_nsp ) … … 8142 7777 end 8143 7778 8144 #== åå空éãã¹7779 #== 名前空間パス 8145 7780 class NamespacePath < Node 8146 7781 #@b_absolute::Bool 8147 7782 #@path::[ Symbol,... ] 8148 #@namespace::Namespace: @b_absolute == false ã®ã¨ããåºç¹ã¨ãªãnamespace7783 #@namespace::Namespace: @b_absolute == false のとき、基点となる namespace 8149 7784 8150 7785 #=== NamespacePath# initialize 8151 #ident::Symbol æåã®åå, ãã ã "::" ã®ã¿ã®å ´å㯠String 8152 #b_absolute:Bool "::" ã§å§ã¾ã£ã¦ããå ´å true 8153 #namespace::Namespace b_absolute = false ãã¤ãæ§æ解é段é以å¤ã§å¼ã³åºãå ´åã¯ãå¿ 8154 ãæå®ããã㨠7786 #ident::Symbol 最初の名前, ただし "::" のみの場合は String 7787 #b_absolute:Bool "::" で始まっている場合 true 7788 #namespace::Namespace b_absolute = false かつ、構文解釈段階以外で呼び出す場合は、必ず指定すること 8155 7789 def initialize( ident, b_absolute, namespace = nil ) 8156 7790 super() … … 8178 7812 end 8179 7813 8180 #=== NamespacePath# append ãã7814 #=== NamespacePath# append する 8181 7815 #RETURN self 8182 # ãã®ã¡ã½ããã¯ãå 8183 ã® NamespacePath ãªãã¸ã§ã¯ããå¤å½¢ãã¦è¿ã 7816 # このメソッドは、元の NamespacePath オブジェクトを変形して返す 8184 7817 def append!( ident ) 8185 7818 @path << ident 8186 7819 return self 8187 7820 end 8188 #=== NamespacePath# append ãã 8189 # ãã®ã¡ã½ããã¯ãå 8190 ã® NamespacePath ãªãã¸ã§ã¯ããå¤å½¢ããªã 8191 #RETURN:: è¤è£½ãã NamespacePath 7821 #=== NamespacePath# append する 7822 # このメソッドは、元の NamespacePath オブジェクトを変形しない 7823 #RETURN:: 複製した NamespacePath 8192 7824 def append( ident ) 8193 7825 cl = self.clone … … 8205 7837 end 8206 7838 8207 #=== NamespacePath# ã¯ãã¼ã³ãä½æãã¦ååãå¤æ´ãã7839 #=== NamespacePath#クローンを作成して名前を変更する 8208 7840 def change_name name 8209 7841 cl = self.clone … … 8214 7846 alias :change_name_clone :change_name 8215 7847 8216 #=== NamespacePath#ååãå¤æ´ãã 8217 # ãã®ã¤ã³ã¹ã¿ã³ã¹ãåç 8218 §ãããã¹ã¦ã«å½±é¿ãä¸ãããã¨ã«æ³¨æ 7848 #=== NamespacePath#名前を変更する 7849 # このインスタンスを参照するすべてに影響を与えることに注意 8219 7850 def change_name_no_clone name 8220 7851 @path[ @path.length - 1 ] = name … … 8222 7853 end 8223 7854 8224 #=== NamespacePath:: path æååãå¾ã8225 # CDL ç¨ã® path æååãçæ7855 #=== NamespacePath:: path 文字列を得る 7856 # CDL 用の path 文字列を生成 8226 7857 def to_s 8227 7858 get_path_str … … 8252 7883 end 8253 7884 8254 #=== NamespacePath:: ãã¹ã®é 8255 åãè¿ã 8256 # is_absolute? true ã®å ´åãã«ã¼ãããã®ãã¹ 8257 # false ã®å ´åãbase_namespace ããã®ç¸å¯¾ 8258 # ã«ã¼ã namespace ã®å ´åãé·ãï¼ã®é 8259 åãè¿ã 7885 #=== NamespacePath:: パスの配列を返す 7886 # is_absolute? true の場合、ルートからのパス 7887 # false の場合、base_namespace からの相対 7888 # ルート namespace の場合、長さ0の配列を返す 8260 7889 # 8261 7890 def get_path … … 8263 7892 end 8264 7893 8265 #=== NamespacePath#ãã«ãã¹ã®é 8266 åãè¿ã 8267 # è¿ãããé 8268 åãæ¸ãæãã¦ã¯ãªããªã 7894 #=== NamespacePath#フルパスの配列を返す 7895 # 返された配列を書き換えてはならない 8269 7896 def get_full_path 8270 7897 if @b_absolute then … … 8275 7902 end 8276 7903 8277 #=== NamespacePath:: ç¸å¯¾ãã¹ã®ãã¼ã¹ã¨ãªãnamespace8278 # is_absolute? == false ã®æã®ã¿æå¹ãªå¤ãè¿ã (true ãªãnil)7904 #=== NamespacePath:: 相対パスのベースとなる namespace 7905 # is_absolute? == false の時のみ有効な値を返す (true なら nil) 8279 7906 def get_base_namespace 8280 7907 @namespace 8281 7908 end 8282 7909 8283 #=== NamespacePath:: C è¨èªã°ãã¼ãã«åãå¾ã7910 #=== NamespacePath:: C 言語グローバル名を得る 8284 7911 def get_global_name 8285 7912 if @b_absolute then … … 8299 7926 end 8300 7927 8301 #=== NamespacePath:: å解ã㦠NamespacePath ã¤ã³ã¹ã¿ã³ã¹ãçæãã8302 #path_str:: String : namespace ã¾ã㯠region ã®ãã¹ex) "::path::A" , "::", "ident"8303 #b_force_absolute:: Bool : "::" ã§å§ã¾ã£ã¦ããªãå ´åã§ã絶対ãã¹ã«æ±ã7928 #=== NamespacePath:: 分解して NamespacePath インスタンスを生成する 7929 #path_str:: String : namespace または region のパス ex) "::path::A" , "::", "ident" 7930 #b_force_absolute:: Bool : "::" で始まっていない場合でも絶対パスに扱う 8304 7931 # 8305 # NamespacePath ã¯é常æ§æ解æããã¦ä½æããã8306 # ãã®ã¡ã½ããã¯ããªãã·ã§ã³ãªã©ã§æå®ãããæååãå解ã㦠NamespacePath ãçæããã®ã«ç¨ãã8307 # ãã§ãã¯ã¯ããããä¸é©åãªãã¹æå®ã¯ãä¸é©å㪠NamespacePath ãçæããã7932 # NamespacePath は通常構文解析されて作成される 7933 # このメソッドは、オプションなどで指定される文字列を分解して NamespacePath を生成するのに用いる 7934 # チェックはゆるい。不適切なパス指定は、不適切な NamespacePath が生成される 8308 7935 def self.analyze( path_str, b_force_absolute = false ) 8309 7936 … … 8344 7971 end 8345 7972 8346 # 以ä¸åä½ãã¹ãã³ã¼ã7973 # 以下単体テストコード 8347 7974 if $unit_test then 8348 7975 root_namespace = Namespace.new("::") -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/ctypes.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ 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 elsif self.instance_of?( CFloatType ) then 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 ) … … 145 130 end 146 131 147 #=== qualifier ãè¨å®ãã 148 # å 149 ã® Type ã¯ã©ã¹ã§ã¯çç¾ãã§ãã¯ããªãï¼TECSã®æ¬æ¥ã®ææ³ã§ã¯éè¤æå®ã§ããªãããï¼ 132 #=== qualifier を設定する 133 # 元の Type クラスでは矛盾チェックしない(TECSの本来の文法では重複指定できないため) 150 134 def set_qualifier( qual ) 151 135 … … 184 168 185 169 def initialize( bit_size ) 186 #p super.class mikan super.class ã Symbol ã ããªãï¼170 #p super.class mikan super.class が Symbol だ、なぜ? 187 171 super( bit_size ) 188 172 end -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/expression.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 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 … … 247 230 end 248 231 249 #=== Expression# éãã¼ã©ã³ãæååå250 #param_list:: ParamlList é¢æ°ã®å¼æ°ãªã¹ã232 #=== Expression# 逆ポーランド文字列化 233 #param_list:: ParamlList 関数の引数リスト 251 234 def get_rpn( param_list = nil, name_list2 = nil ) 252 235 return elements_rpn( @elements, param_list, name_list2 ) 253 236 end 254 237 255 #=== Expression# éãã¼ã©ã³ãæååå(private)256 #name_list:: ParamlList é¢æ°ã®å¼æ°ãªã¹ã238 #=== Expression# 逆ポーランド文字列化 (private) 239 #name_list:: ParamlList 関数の引数リスト 257 240 def elements_rpn( elements, name_list = nil, name_list2 = nil ) 258 241 if elements.instance_of? Token then 259 242 print "rpn: #{elements.to_s}\n" 260 return elements.to_s # OP_DOT, OP_REF ã®å³è¾º243 return elements.to_s # OP_DOT, OP_REF の右辺 261 244 end 262 245 … … 354 337 end 355 338 356 # å®æ°å¼(elements)ãè©ä¾¡ãã339 # 定数式(elements)を評価する 357 340 # 358 # ãã®ã¡ã½ãã㯠Expression ã¯ã©ã¹ã®ã¡ã½ããã§ããå¿ 359 è¦ã¯ãªãï¼é¢æ°åã§ããï¼ 341 # このメソッドは Expression クラスのメソッドである必要はない(関数化できる) 360 342 # 361 # elements ã¯å¼ã®è¦ç´343 # elements は式の要素 362 344 # 363 # name_list, name_list2 㯠eval_const ãåç 364 § 345 # name_list, name_list2 は eval_const を参照 365 346 # 366 # RETURN: è©ä¾¡ããå®æ°ãè©ä¾¡ã§ããªãã£ãå ´å㯠nil ãè¿ã 367 368 MAX_NEST_LEVEL = 64 # ç°¡æã®ã«ã¼ãæ¤åºï¼åç 369 §ã®ãã¹ãã 64 ã¾ã§è¨±å¯ããï¼ 347 # RETURN: 評価した定数、評価できなかった場合は nil を返す 348 349 MAX_NEST_LEVEL = 64 # 簡易のループ検出(参照のネストを 64 まで許可する) 370 350 def elements_eval_const( elements, name_list, name_list2 = nil, nest = nil ) 371 351 … … 374 354 nsp = elements[1] 375 355 376 # #809 ã®ä¿®æ£ããã (å¥ã®åé¡ã解決ãããã¦ããªã) 377 # nest += 1 # åç 378 §ãã«ã¼ãã«ãªã£ã¦ããªããã®ãã§ã㯠379 # # mikan æ¬å½ã«ã«ã¼ããã¦ãããã©ããã§ã¯ãªããåç´ã«å¤æ°ã®åç 380 §ãç¹°ãè¿ãã¦ãããã¨ã§å¤å®ãã¦ãã 356 # #809 の修正しかけ (別の問題が解決しきれていない) 357 # nest += 1 # 参照がループになっていないかのチェック 358 # # mikan 本当にループしているかどうかではなく、単純に多数の参照を繰り返していることで判定している 381 359 # if nest > MAX_NEST_LEVEL then 382 360 # cdl_error( "E9999: '$1' too many reference (maybe loop) max=$1" , nsp.to_s, MAX_NEST_LEVEL ) … … 393 371 end 394 372 395 # è¦ã¤ãããªããã°å®æ°å®ç¾©ããæ¢ã373 # 見つからなければ定数定義から探す 396 374 if object == nil then 397 object = Namespace.find( nsp )# mikan namespace ã®å¯¾å¿ #1 398 end 399 400 # ãã®å®è£ 401 ã¯ãããå°ãæ´çãããã¹ã 402 # ãããå¼åºãããã®ã¯ã以ä¸ã®å ´å 403 # ã»attribute, var ã®å³è¾ºå¼ã®è©ä¾¡ 404 # ã»size_is å¼æ°ã®è©ä¾¡ï¼é¢æ°ãã©ã¡ã¼ã¿ã®å ´åã¨attribute, var ã®å ´åããã 405 # 以ä¸ã®ã¨ã©ã¼ãã§ãã¯ã§ã¯ããããããã£ã¡ãã«ãªã£ã¦èª¤ããæ¤åºãããã¨ãã¦ãã 406 407 # IDENTIFIER ã¯è¦ã¤ãããªãã£ãï¼ 375 object = Namespace.find( nsp )# mikan namespace の対応 #1 376 end 377 378 # この実装は、もう少し整理されるべき 379 # これが呼出されるのは、以下の場合 380 # ・attribute, var の右辺式の評価 381 # ・size_is 引数の評価:関数パラメータの場合とattribute, var の場合がある 382 # 以下のエラーチェックでは、これらがごっちゃになって誤りを検出しようとしている 383 384 # IDENTIFIER は見つからなかった? 408 385 if object == nil then 409 386 cdl_error( "E1001 $1: not found" , nsp.get_path_str ) … … 411 388 return nil 412 389 elsif object.instance_of?( Join ) then 413 # Join ã®å ´åï¼ cell ã®ä¸ã® attribute, var, call ã®ã©ãããè¦ã¤ãã£ã414 # Decl (attribute, var) ã§ãªãï¼390 # Join の場合: cell の中の attribute, var, call のどれかが見つかった 391 # Decl (attribute, var) でない? 415 392 if ! object.get_definition.instance_of?( Decl ) then 416 393 cdl_error( "E1002 $1: not constant (port)" , nsp.get_path_str ) … … 419 396 return object.get_rhs.eval_const2( name_list, name_list2, nest ) 420 397 elsif ! object.instance_of?( Decl ) then 421 # Decl ã§ãªãå ´åï¼ å®æ°ã§ããªã398 # Decl でない場合: 定数でもない 422 399 if ( ! object.instance_of?( ParamDecl ) ) then 423 # mikan paramdecl ã¯ç¡è¦ãã424 # ParamList ããå¼ã°ããã¨ã400 # mikan paramdecl は無視する 401 # ParamList から呼ばれたとき 425 402 cdl_error( "E1003 $1: not constant" , nsp.get_path_str ) 426 403 else … … 432 409 object.referenced 433 410 if object.get_initializer == nil then 434 # åæååã®åå¨ããªãå¤æ° # mikan ããã¸ããã®ã¯ãé常ããããªãã¯ãï¼æªæ¤è¨¼ï¼411 # 初期化子の存在しない変数 # mikan ここへくるのは、通常ありえないはず(未検証) 435 412 return IntegerVal.new( 0 ) 436 413 else 437 # Decl ã®å³è¾ºã®è©ä¾¡438 # mikan size_is å¼æ°ã«ç¾ããå¤æ°ã®åãé©åãã®ãã§ãã¯ãã414 # Decl の右辺の評価 415 # mikan size_is 引数に現れる変数の型が適切かのチェックする 439 416 if object.get_initializer.instance_of?( Expression ) || object.get_initializer.instance_of?( C_EXP ) then 440 417 return object.get_initializer.eval_const2( name_list, name_list2, nest ) 441 418 else 442 # Array ã®å ´å419 # Array の場合 443 420 return object.get_initializer 444 421 end … … 556 533 # p "val.respond_to?( \"-@\" )=#{val.respond_to?( "-@" )} #{val.class}" 557 534 # p "val.respond_to?( \"~@\" )=#{val.respond_to?( "~@" )}" 558 #2.0 if val.respond_to?( "~@" ) then # Ruby 1.9, 2.0 preview çã§ã¯ä¾å¤ãçºçãã¦ãã¾ã535 #2.0 if val.respond_to?( "~@" ) then # Ruby 1.9, 2.0 preview 版では例外が発生してしまう 559 536 if val.kind_of? IntegerVal then 560 537 return ~ val … … 702 679 def elements_get_type( elements, namedList ) 703 680 type = elements_get_type_sub( elements, namedList ) 704 # è¿ãããæ¹ã DefinedType ã®å ´å å 705 ã®åãè¿ã 681 # 返された方が DefinedType の場合 元の型を返す 706 682 if type.kind_of?( DefinedType ) then 707 683 type = type.get_type … … 742 718 unless type.kind_of?( PtrType ) then 743 719 cdl_error( "E1013 \'*\': operand is not pointer value" ) 744 return IntType.new( 8 ) # IntType ãè¿ãã¦ãã720 return IntType.new( 8 ) # IntType を返しておく 745 721 end 746 722 return type.get_referto 747 723 748 724 when :OP_U_PLUS, :OP_U_MINUS 749 # mikan operand ãé©åãªåããã§ãã¯ãã¦ããªã725 # mikan operand が適切な型かチェックしていない 750 726 return elements_get_type( elements[1], namedList ) 751 727 752 728 when :OP_ADD, :OP_SUB, :OP_MULT, :OP_DIV, :OP_REMAIN 753 # mikan operand ãé©åãªåããã§ãã¯ãã¦ããªãï¼å·¦è¾ºã®åãæ¡ç¨ãã¦ãã729 # mikan operand が適切な型かチェックしていない&左辺の型を採用している 754 730 return elements_get_type( elements[1], namedList ) 755 731 756 732 when :OP_U_TILDE 757 # mikan operand ãæ´æ°ããã§ãã¯ãã¦ããªã733 # mikan operand が整数かチェックしていない 758 734 return elements_get_type( elements[1], namedList ) 759 735 when :OP_AND, :OP_EOR, :OP_OR, :OP_LSFT, :OP_RSFT 760 # mikan operand ãæ´æ°ããã§ãã¯ãã¦ããªã736 # mikan operand が整数かチェックしていない 761 737 return BoolType.new 762 738 when :OP_U_EXCLAM 763 # mikan operand ãæ´æ°ããã§ãã¯ãã¦ããªã739 # mikan operand が整数かチェックしていない 764 740 return BoolType.new 765 741 … … 771 747 end 772 748 773 # å¼ã size_is, count_is, string ã®å¼æ°ã§ããå ´åã®æ¹åã®ãã§ãã¯749 # 式が size_is, count_is, string の引数である場合の方向のチェック 774 750 def elements_check_dir_for_param( elements, namedList, dir, spec ) 775 # dir ï¼ å 776 ã®å¼æ°ã®æ¹å 777 # direct: size_is ãªã©ã®å¼æ°ã®å¤æ°ã®æ¹å 751 # dir : 元の引数の方向 752 # direct: size_is などの引数の変数の方向 778 753 779 754 case elements[0] … … 806 781 judge = true if ( direct == :IN || direct == :INOUT ) 807 782 req_direct = "in or inout" 808 when :OUT, :RECEIVE # mikan out 㧠count_is ã®ã¿æå®ããã¦ããå ´å in ã§ãªãã¦ã¯ãªããªã783 when :OUT, :RECEIVE # mikan out で count_is のみ指定されている場合 in でなくてはならない 809 784 judge = true if ( direct == :OUT || direct == :INOUT ) 810 785 req_direct = "out or inout" … … 822 797 return true 823 798 824 # åé 825 æ¼ç®å 799 # 単項演算子 826 800 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, 827 801 elements_check_dir_for_param( elements[1], namedList, dir, spec ) 828 802 829 # 2é 830 æ¼ç®å 803 # 2項演算子 831 804 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 832 805 return elements_check_dir_for_param( elements[1], namedList, dir, spec ) && elements_check_dir_for_param( elements[2], namedList, dir, spec ) 833 806 834 # 3é 835 æ¼ç®å 807 # 3項演算子 836 808 when :OP_CEX 837 809 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 ) … … 845 817 #Express# get_allocator_rhs_elem 846 818 #alloc_type::Symbol :NORMAL_ALLOC|:INTERNAL_ALLOC|:RELAY_ALLOC 847 # å¼ãã¢ãã±ã¼ã¿æå®åã®å³è¾ºã¨ãã¦å¦¥å½ããã§ãã¯ããæ£ãããã°å解ããå¤ãè¿ã819 #式がアロケータ指定子の右辺として妥当かチェックし、正しければ分解した値を返す 848 820 #return: 849 821 # :NORMAL_ALLOC [ cell_nsp, ep_name ] # rhs = cell_nsp.ep_name ex) Alloc.eAlloc … … 883 855 end 884 856 885 #Expression#Expression ã®ã¯ãã¼ã³ãä½æãã857 #Expression#Expression のクローンを作成する 886 858 def clone_for_composite 887 859 cl = self.clone … … 891 863 end 892 864 893 #Expression#elements ã®ã¯ãã¼ã³ãä½æ865 #Expression#elements のクローンを作成 894 866 #elements::Array 895 # ãã®ã¡ã½ããã¯ãArray ã®ãã£ã¼ãã³ãã¼ãè¡ã867 # このメソッドは、Array のディープコピーを行う 896 868 def clone_elements elements 897 869 elements = elements.clone … … 910 882 end 911 883 912 #=== Expression# ã»ã«çµåã®å¼ã解æãã884 #=== Expression#セル結合の式を解析する 913 885 # Cell.eEntry => [ :OP_DOT, [ :IDENTIFIER, token ], token ] 914 886 # Cell.eEntry[expression] => [ :OP_SUBSC, [ :OP_DOT, [ :IDENTIFIER, token ], token ], expression ] 915 887 # Return: [ NamespacePath(cell_name), Integer(subscript) or nil, Token(port_name)] 916 888 def analyze_cell_join_expression 917 # å³è¾ºã® Expression ã®è¦ç´ ãåãåºã889 # 右辺の Expression の要素を取り出す 918 890 elements = @elements 919 if elements[0] == :OP_SUBSC then # å³è¾ºï¼åãå£é 920 åï¼ 891 if elements[0] == :OP_SUBSC then # 右辺:受け口配列? 921 892 # elements = [ :OP_SUBSC, [ :OP_DOT, [ :IDENTIFIER, token ], token ], expression ] 922 subscript = elements[2].eval_const(nil) # åãå£é 923 åã®æ·»æ° 924 elements = elements[1] # mikan é 925 åã ã£ãå ´å 893 subscript = elements[2].eval_const(nil) # 受け口配列の添数 894 elements = elements[1] # mikan 配列だった場合 926 895 else 927 896 subscript = nil … … 939 908 end 940 909 941 #=== Expression# ã»ã«ã¸ã®çµåã®å¼ãçæãã910 #=== Expression# セルへの結合の式を生成する 942 911 #nsp:: NamespacePath 943 912 #subscript:: Integer 944 913 #port_name:: Symbol 945 # analyze_cell_join_expression ã¨å¯¾ã«ãªã£ã¦ãã914 # analyze_cell_join_expression と対になっている 946 915 def self.create_cell_join_expression( nsp, subscript, port_name, locale = nil ) 947 916 if ! port_name.instance_of?( Symbol ) then … … 959 928 end 960 929 961 #=== Expression# æ´æ°å®æ°ã®å¼ãçæãã962 #val:: Integer : å¤ï¼ æ´æ°930 #=== Expression#整数定数の式を生成する 931 #val:: Integer : 値: 整数 963 932 def self.create_integer_constant( val, locale = nil ) 964 933 if val != Integer( val ) || val < 0 then … … 968 937 end 969 938 970 #=== Expression# åä¸ã®èå¥åã®å¼ã解æãã939 #=== Expression#単一の識別子の式を解析する 971 940 # Identifier => [ :IDENTIFIER, token ] 972 941 # Return: NamespacePath(Identifier) 973 942 def analyze_single_identifier 974 # å³è¾ºã® Expression ã®è¦ç´ ãåãåºã943 # 右辺の Expression の要素を取り出す 975 944 elements = @elements 976 945 if elements[0] == :IDENTIFIER … … 982 951 983 952 #=== Expression# 984 #nsp:: NamespacePath : åç 985 §ãããã®èå¥å 953 #nsp:: NamespacePath : 参照するもの識別子 986 954 def self.create_single_identifier( nsp, locale ) 987 955 if ! nsp.instance_of?( NamespacePath ) then … … 991 959 end 992 960 993 #=== è©ä¾¡å¯è½ããã§ãã¯ãã994 #*v:: å¯å¤åå¼æ°ï¼ä»»æã®åï¼995 # ãã¹ã¦ã BaseVal ã®åã¯ã©ã¹ï¼å¤ï¼ã§ããã°ãè©ä¾¡å¯è½ã¨å¤æãã961 #=== 評価可能かチェックする 962 #*v:: 可変個引数(任意の型) 963 # すべてが BaseVal の子クラス(値)であれば、評価可能と判断する 996 964 def evaluable?( *v ) 997 965 v.each{ |val| … … 1012 980 1013 981 #c_exp_string::String 1014 #b_renew::Bool : true ãªã C_EXP ã® clone ä½æï¼ã¨ã¹ã±ã¼ãå¦ççãããªãï¼982 #b_renew::Bool : true なら C_EXP の clone 作成(エスケープ処理等をしない) 1015 983 def initialize( c_exp_string, b_renew = false ) 1016 984 if b_renew then 1017 985 @c_exp_string = c_exp_string 1018 986 else 1019 # åå¾ã® " ãåãé¤ã987 # 前後の " を取り除く 1020 988 # str = c_exp_string.to_s.sub( /^\"(.*)\"$/, "\\1" ) 1021 989 str = CDLString.remove_dquote c_exp_string.to_s … … 1024 992 end 1025 993 1026 #=== composite ç¨ã« C_EXP ã clone ãã994 #=== composite 用に C_EXP を clone する 1027 995 #ct_name:: 1028 996 #cell_name:: 1029 # composite ã® attribute ã«ç¾ãã C_EXP ãæååç½®æãã¦çæããªããï¼1030 # ãã®æååç½®æã¯ãæå³è§£é段éã§è¡ãï¼1031 # ä»ã® C_EXP ã®æååç½®æã¯ãã³ã¼ãçæ段éã§è¡ãï¼997 # composite の attribute に現れる C_EXP を文字列置換して生成しなおす. 998 # この文字列置換は、意味解釈段階で行う. 999 # 他の C_EXP の文字列置換は、コード生成段階で行う. 1032 1000 def clone_for_composite( ct_name, cell_name, locale ) 1033 1001 dbgPrint "C_EXP: #{ct_name} #{cell_name} #{@c_exp_string}\n" … … 1044 1012 end 1045 1013 1046 #=== C_EXP ãè©ä¾¡ãã1047 # C_EXP ã®å¼ãæ°æååãè¿ã1048 # æ¬æ¥ C_EXP 㯠eval_const ãã対象ã§ã¯ãªããã便å®ä¸ eval_const ã§å¯¾å¿1014 #=== C_EXP を評価する 1015 # C_EXP の引き数文字列を返す 1016 # 本来 C_EXP は eval_const する対象ではないが、便宜上 eval_const で対応 1049 1017 def eval_const( name_list, name_list2 = nil ) 1050 1018 return self -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/gen_xml.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 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 37 # $Id$ … … 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
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/generate.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2019 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 134 119 end 135 120 136 # celltype_private.h ãçæ121 # celltype_private.h を生成 137 122 138 123 class Namespace … … 141 126 142 127 begin 143 # root namespace ãªãã° makefile ãåºåãã(å 144 ¨ã»ã«ã¿ã¤ãã«é¢ãããã®ã ã) 145 # å 146 ã«åºåãã 128 # root namespace ならば makefile を出力する(全セルタイプに関わるものだけ) 129 # 先に出力する 147 130 if @name == "::" then 148 131 … … 159 142 160 143 dbgPrint "generating region: #{$generating_region.get_name} namespace=#{@name} gen_dir=#{$gen}\n" 161 # global_tecsgen.h (typedef, struct, const) ã®çæ144 # global_tecsgen.h (typedef, struct, const) の生成 162 145 gen_global_header 163 146 … … 171 154 end 172 155 173 # signature ã®ã³ã¼ããçæ156 # signature のコードを生成 174 157 @signature_list.each { |s| 175 158 s.generate 176 159 } 177 160 178 # celltype ã®ã³ã¼ããçæ161 # celltype のコードを生成 179 162 @celltype_list.each { |t| 180 163 t.generate 181 164 } 182 165 183 # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ166 # サブネームスペースのコードを生成 184 167 @namespace_list.each { |n| 185 168 n.generate … … 187 170 188 171 rescue => evar 189 # ããã¹ã¿ãã¯ãã¬ã¼ã¹ãåºãã¾ã§ãæéãããããããªãã°ã次ãã³ã¡ã³ãã¢ã¦ããã¦ã¿ãã¹ã172 # もしスタックトレースが出るまでい時間がかかるようならば、次をコメントアウトしてみるべし 190 173 cdl_error( "H1001 tecsgen: fatal internal error during code generation" ) 191 174 print_exception( evar ) … … 200 183 201 184 begin 202 # global_tecsgen.h (typedef, struct, const) ã®çµããã®ã¬ã¼ãã³ã¼ãçæ185 # global_tecsgen.h (typedef, struct, const) の終わりのガードコード生成 203 186 gen_global_header_post 204 187 205 # signature ã®ã³ã¼ããçæ188 # signature のコードを生成 206 189 @signature_list.each { |s| 207 190 s.generate_post 208 191 } 209 192 210 # celltype ã®ã³ã¼ããçæ193 # celltype のコードを生成 211 194 @celltype_list.each { |t| 212 195 t.generate_post 213 196 } 214 197 215 # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ198 # サブネームスペースのコードを生成 216 199 @namespace_list.each { |n| 217 200 n.generate_post … … 227 210 def gen_global_header 228 211 229 # global_tecs.h ã®çæ212 # global_tecs.h の生成 230 213 f = AppFile.open( "#{$gen}/global_tecsgen.#{$h_suffix}" ) 231 214 … … 233 216 print_note f 234 217 235 # ã¬ã¼ãã³ã¼ããåºå218 # ガードコードを出力 236 219 f.print <<EOT 237 220 #ifndef GLOBAL_TECSGEN_H … … 240 223 EOT 241 224 242 # import_C ã§æå®ãããããããã¡ã¤ã«ã® #include ãåºå225 # import_C で指定されたヘッダファイルの #include を出力 243 226 if Import_C.get_header_list2.length > 0 then 244 # ããã include ã®åºå227 # ヘッダ include の出力 245 228 f.printf TECSMsg.get( :IMP_comment ), "#_IMP_#" 246 229 Import_C.get_header_list2.each{ |h| … … 253 236 end 254 237 255 # typedef, struct, enum ãçæ238 # typedef, struct, enum を生成 256 239 @decl_list.each { |d| 257 240 258 # d 㯠Typedef, StructType, EnumType ã®ãããã241 # d は Typedef, StructType, EnumType のいずれか 259 242 if d.instance_of?( Typedef ) then 260 243 261 # Typedef ã®å ´åãdeclarator ã® @type ããCType ã§ãªãã244 # Typedef の場合、declarator の @type が CType でないか 262 245 if ! d.get_declarator.get_type.kind_of?( CType ) then 263 246 d.gen_gh f … … 265 248 elsif ! d.kind_of?( CType ) then 266 249 267 # CType ã§ã¯ãªã (StructType ã¾ãã¯EnumType)250 # CType ではない (StructType または EnumType) 268 251 d.gen_gh f 269 252 # else 270 # ããã«è©²å½ããã®ã¯CStructType, CEnumType253 # ここに該当するのは CStructType, CEnumType 271 254 end 272 255 } … … 297 280 end 298 281 299 # const ãçæmikan282 # const を生成 mikan 300 283 @const_decl_list.each { |d| 301 284 f.printf( "#define %-14s ((%s%s)%s)\n", d.get_global_name, … … 310 293 def gen_global_header_post 311 294 312 # global_tecs.h ãéã295 # global_tecs.h を開く 313 296 f = AppFile.open( "#{$gen}/global_tecsgen.#{$h_suffix}" ) 314 297 … … 324 307 end 325 308 326 #=== Makefile.tecsgen, Makefile.templ ã®åºå 327 # å 328 ¨ã»ã«ã¿ã¤ãåãåºåããé¨åãåºå 329 # ï¼æ¬ã¡ã½ãã㯠root namespace ã«å¯¾ãã¦å¼åºãï¼ 330 # åã 331 ã®ã»ã«ã¿ã¤ãã®ã¡ã¼ã¯ã«ã¼ã«ã¯ Celltype ã¯ã©ã¹ã§åºå 309 #=== Makefile.tecsgen, Makefile.templ の出力 310 # 全セルタイプ名を出力する部分を出力 311 # (本メソッドは root namespace に対して呼出す) 312 # 個々のセルタイプのメークルールは Celltype クラスで出力 332 313 def gen_makefile 333 314 gen_makefile_template … … 339 320 return if $generate_no_template 340 321 341 ### Makefile.templ ã®çæ322 ### Makefile.templ の生成 342 323 f = AppFile.open( "#{$gen}/Makefile.templ" ) 343 324 344 325 print_Makefile_note f 345 326 346 # Makefile ã®å¤æ°ã®åºå327 # Makefile の変数の出力 347 328 f.printf TECSMsg.get( :MVAR_comment ), "#_MVAR_#" 348 329 f.printf "# fixed variable (unchangeable by config or plugin)\n" 349 330 350 # TARGET ã®åºå (第ä¸å¼æ° $target ã« region åããã³ .exe ãä»å)331 # TARGET の出力 (第一引数 $target に region 名および .exe を付加) 351 332 target = $target 352 333 if $generating_region != @@root_namespace then 353 # å region ã®ãªã³ã¯ã¿ã¼ã²ããã®å ´å334 # 子 region のリンクターゲットの場合 354 335 target += "-#{$generating_region.get_global_name}" 355 336 end … … 433 414 EOT 434 415 435 # make ã«ã¼ã«ã®åºå416 # make ルールの出力 436 417 f.printf( TECSMsg.get( :MRUL_comment), "#_MRUL_#" ) 437 418 … … 461 442 f.print "-include $(GEN_DIR)/Makefile.tecsgen\n" 462 443 if $generating_region.get_n_cells != 0 then 463 # Makefile.depend ã®include444 # Makefile.depend の include 464 445 f.print "-include $(GEN_DIR)/Makefile.depend\n\n" 465 446 … … 471 452 f.print "\nsub_regions:$(TIMESTAMP)\n" 472 453 Region.get_link_roots.each {|region| 473 if region.get_global_name != "" then # Root region: ãã® Makefile èªèº«454 if region.get_global_name != "" then # Root region: この Makefile 自身 474 455 f.print "\tcd #{region.get_global_name}; make all\n" 475 456 end … … 478 459 end 479 460 480 # clean: ã¿ã¼ã²ãã461 # clean: ターゲット 481 462 f.print "clean :\n" 482 463 if $generating_region == @@root_namespace then 483 464 Region.get_link_roots.each {|region| 484 if region.get_global_name != "" then # Root region: ãã® Makefile èªèº«465 if region.get_global_name != "" then # Root region: この Makefile 自身 485 466 f.print "\tcd #{region.get_global_name}; make clean\n" 486 467 end … … 493 474 f.print "\n" 494 475 495 # tecs: ã¿ã¼ã²ãã476 # tecs: ターゲット 496 477 if $generating_region == @@root_namespace then 497 478 f.print "tecs : $(PRE_TECSGEN_TARGET) $(TIMESTAMP) $(POST_TECSGEN_TARGET)\n\n" … … 504 485 end 505 486 506 # tecsflow:, tcflow ã¿ã¼ã²ãã487 # tecsflow:, tcflow ターゲット 507 488 if $generating_region.get_n_cells != 0 || $generating_region == @@root_namespace then 508 489 f.print "##### TECSFlow targets #####\n" … … 561 542 562 543 def gen_makefile_tecsgen 563 ### Makefile.tecsgen ã®çæ544 ### Makefile.tecsgen の生成 564 545 f = AppFile.open( "#{$gen}/Makefile.tecsgen" ) 565 546 … … 658 639 domain_regions = nil 659 640 DomainType.get_domain_regions.each{ |dt, regions| 660 # domain_type ã¯ä¸ã¤ã®ãã¼ãã«ã¯ãä¸ã¤ãããªãã®ã§ããã®ã«ã¼ãã¯ãå¿ 661 ãä¸åããåããªã 662 ### mikan è¤æ°ã®ãã¼ãããããç°ãªã domain_type ãæå®ãããå¯è½æ§ã¯ãã 641 # domain_type は一つのノードには、一つしかないので、このループは、必ず一回しか回らない 642 ### mikan 複数のノードがあり、異なる domain_type が指定される可能性はある 663 643 domain_regions = regions 664 644 domain_type = dt … … 836 816 end 837 817 838 #=== ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå 839 #f:: FILE: åºåå 840 ãã¡ã¤ã« 841 #prepend:: string: åç½®æåå 842 #append:: string: å¾ç½®æåå 843 #b_plguin:: bool: plugin ã«ããçæãããã»ã«ã¿ã¤ããåºå 844 ##b_inline_only:: bool: true ãªãã° inline ã® entry port ã®ã¿ã®ã»ã«ã¿ã¤ããå«ãã 845 #b_inline_only_or_proc:: bool|Proc: true ãªãã° inline ã® entry port ã®ã¿ããã¤ã¤ã³ã¢ã¯ãã£ããªã»ã«ã¿ã¤ããå«ãã 846 # Proc ãªãã° Proc ãå®è¡ããçµæ true ãªãã°å«ãã 847 # namespace "::" ããå¼åºããã 818 #=== すべてのセルタイプの名前を出力 819 #f:: FILE: 出力先ファイル 820 #prepend:: string: 前置文字列 821 #append:: string: 後置文字列 822 #b_plguin:: bool: plugin により生成されたセルタイプを出力 823 ##b_inline_only:: bool: true ならば inline の entry port のみのセルタイプを含める 824 #b_inline_only_or_proc:: bool|Proc: true ならば inline の entry port のみ、かつインアクティブなセルタイプを含める 825 # Proc ならば Proc を実行した結果 true ならば含める 826 # namespace "::" から呼出される 848 827 def gen_celltype_names( f, prepend, append, b_plugin, b_inline_only_or_proc = true ) 849 828 dbgPrint "gen_celltype_names #{@name}\n" … … 865 844 end 866 845 867 #=== ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå846 #=== すべてのセルタイプの名前を出力 868 847 #region:: Region: 869 # gen_celltype_names ã¨gen_celltype_names_domain ã®ç¸éï¼ 870 # region ã domain_roots ã«å«ãå ´åãåºåããï¼ 871 # ã¾ãã¯ãregion ãå«ã¾ãªãããdomain_roots ãè¤æ°ãã¤ã«ã¼ããªã¼ã¸ã§ã³ã®å ´åãåºåããï¼ 872 # ãã以å¤ã¯ãgen_celltype_names ã®èª¬æãåç 873 § 848 # gen_celltype_names とgen_celltype_names_domain の相違: 849 # region を domain_roots に含む場合、出力する. 850 # または、region を含まないが、domain_roots が複数かつルートリージョンの場合、出力する. 851 # それ以外は、gen_celltype_names の説明を参照 874 852 def gen_celltype_names_domain( f, prepend, append, domain_type, region, b_plugin, b_inline_only = true ) 875 853 dbgPrint "gen_celltype_names #{@name}\n" … … 901 879 } 902 880 end 903 #== Namespace# ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå904 # ã»ã«ã¿ã¤ãã³ã¼ãã®ããã®åååºå905 # gen_celltype_names_domain 㨠gen_celltype_names_domain2 ã®ç¸é906 # ã»ã©ããä¸ã¤ã®ãªã¼ã¸ã§ã³ã«ããåºããªã907 # domain_roots ã1ã¤ã ãã§ãæå®ãªã¼ã¸ã§ã³ãå«ã908 # domain_roots ã2ã¤ä»¥ä¸ã§ãæå®ãªã¼ã¸ã§ã³ãã«ã¼ããªã¼ã¸ã§ã³909 # ã»ãã¡ã¤ã³åãä»å ããªã881 #== Namespace#すべてのセルタイプの名前を出力 882 # セルタイプコードのための名前出力 883 # gen_celltype_names_domain と gen_celltype_names_domain2 の相違 884 # ・どれか一つのリージョンにしか出さない 885 # domain_roots が1つだけで、指定リージョンを含む 886 # domain_roots が2つ以上で、指定リージョンがルートリージョン 887 # ・ドメイン名を付加しない 910 888 def gen_celltype_names_domain2( f, prepend, append, domain_type, region, b_plugin, b_inline_only = true ) 911 889 dbgPrint "gen_celltype_names #{@name}\n" … … 933 911 end 934 912 935 #=== Namespace# ãã¹ã¦ã®ã·ã°ããã£ããã©ã936 def travers_all_signature # ãããã¯å¼æ°{ |signature| }937 proc = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°913 #=== Namespace#すべてのシグニチャをたどる 914 def travers_all_signature # ブロック引数 { |signature| } 915 proc = Proc.new # このメソッドのブロック引数 938 916 @signature_list.each{ |sig| 939 917 proc.call sig … … 952 930 end 953 931 954 #=== Namespace# ãã¹ã¦ã®ã»ã«ã¿ã¤ãããã©ã955 def travers_all_celltype # ãããã¯å¼æ°{ |celltype| }956 proc = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°932 #=== Namespace#すべてのセルタイプをたどる 933 def travers_all_celltype # ブロック引数 { |celltype| } 934 proc = Proc.new # このメソッドのブロック引数 957 935 @celltype_list.each{ |ct| 958 936 proc.call ct … … 1078 1056 def gen_sh_func_tab f 1079 1057 1080 # ã·ã°ããã£ãã£ã¹ã¯ãªãã¿ã®åºå1058 # シグニチャディスクリプタの出力 1081 1059 f.printf TECSMsg.get(:SD_comment), "#_SD_#" 1082 1060 f.print "struct tag_#{@global_name}_VDES {\n" … … 1084 1062 f.print "};\n\n" 1085 1063 1086 # ã·ã°ããã£é¢æ°ãã¼ãã«ã®åºå1064 # シグニチャ関数テーブルの出力 1087 1065 f.printf TECSMsg.get(:SFT_comment), "#_SFT_#" 1088 1066 f.print( "struct tag_#{@global_name}_VMT {\n" ) … … 1099 1077 len = items.length 1100 1078 else 1101 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å1079 # ここで nil になるのは、引数なしの時に void がなかった場合 1102 1080 items = [] 1103 1081 len = 0 … … 1129 1107 end 1130 1108 1131 #=== Signature# é¢æ°ã® ID ã® define ãåºå1109 #=== Signature# 関数の ID の define を出力 1132 1110 def gen_sh_func_id f 1133 1111 f.print "/* function id */\n" … … 1148 1126 def generate 1149 1127 1150 if need_generate? # ã»ã«ã®ãªãã»ã«ã¿ã¤ãã¯çæããªã1128 if need_generate? # セルのないセルタイプは生成しない 1151 1129 1152 1130 generate_private_header … … 1159 1137 generate_makefile 1160 1138 1161 elsif $generate_all_template # ãã³ãã¬ã¼ãã³ã¼ãçæãªãã·ã§ã³1139 elsif $generate_all_template # テンプレートコード生成オプション 1162 1140 1163 1141 generate_template_code 1164 1142 generate_inline_template_code 1165 1143 1166 # generate_makefile_template 㯠Makefile ã«è¿½è¨ãããã®ã ãããå¼ã³åºããªã1144 # generate_makefile_template は Makefile に追記するものだから、呼び出さない 1167 1145 1168 1146 end … … 1171 1149 1172 1150 def generate_post 1173 return if ! need_generate? # ã»ã«ã®ãªãã»ã«ã¿ã¤ãã¯çæããªã1151 return if ! need_generate? # セルのないセルタイプは生成しない 1174 1152 1175 1153 generate_private_header_post … … 1191 1169 gen_ph_cell_cb_type f 1192 1170 gen_ph_INIB_as_CB f 1193 gen_ph_extern_cell f # ã»ã«ã¿ã¤ãã°ã«ã³ã¼ã以å¤ã¯åç 1194 §ããªã 1195 gen_ph_typedef_idx f # mikan åç 1196 §ãããã®ãã§ãã¦ããªã 1171 gen_ph_extern_cell f # セルタイプグルコード以外は参照しない 1172 gen_ph_typedef_idx f # mikan 参照するものができていない 1197 1173 gen_ph_ep_fun_prototype f 1198 1174 end_extern_C f … … 1202 1178 1203 1179 if @n_entry_port_inline == 0 then 1204 # inline ããªããã° CB_TYPE_ONLY ã¨ãã1205 # inline ããã®å ´åããã£ãã define ãã¦ããã¦ãå¾ã§ãã¹ã¦ undef ãã1180 # inline がなければ CB_TYPE_ONLY とする 1181 # inline ありの場合、いったん define しておいて、後ですべて undef する 1206 1182 ifndef_cb_type_only f 1207 1183 end … … 1229 1205 # gen_ph_cell_cb_type f 1230 1206 # gen_ph_INIB_as_CB f 1231 # gen_ph_extern_cell f # ã»ã«ã¿ã¤ãã°ã«ã³ã¼ã以å¤ã¯åç 1232 §ããªã 1233 # gen_ph_typedef_idx f # mikan åç 1234 §ãããã®ãã§ãã¦ããªã 1207 # gen_ph_extern_cell f # セルタイプグルコード以外は参照しない 1208 # gen_ph_typedef_idx f # mikan 参照するものができていない 1235 1209 # gen_ph_ep_fun_prototype f 1236 1210 gen_ph_ep_skel_prototype f 1237 1211 1238 #--- CB_TYPE_ONLY ã®å ´åãref_desc, set_desc é¢æ°ã¯å«ããªã (ãã¯ãåç 1239 §ãããã) 1212 #--- CB_TYPE_ONLY の場合、ref_desc, set_desc 関数は含めない (マクロ参照するため) 1240 1213 if @n_entry_port_inline == 0 then 1241 1214 ifndef_cb_type_only f … … 1249 1222 endif_macro_only f 1250 1223 1251 # ç縮形ãªã©ã®ãã¯ãåºå1224 # 短縮形などのマクロ出力 1252 1225 if @n_entry_port_inline == 0 then 1253 1226 ifndef_cb_type_only f … … 1261 1234 gen_ph_test_optional_call_port_abbrev f 1262 1235 gen_ph_ep_fun_macro f if @n_entry_port > 0 1263 gen_ph_foreach_cell f # FOREACH ãã¯ãã®åºå1264 gen_ph_cb_initialize_macro f # CB åæåãã¯ãã®åºåï¼æ¶è²»ããªãã®ã§ ram_initializer ãã©ã°ã«é¢ãããåºå1236 gen_ph_foreach_cell f # FOREACH マクロの出力 1237 gen_ph_cb_initialize_macro f # CB 初期化マクロの出力.消費しないので ram_initializer フラグに関わらず出力 1265 1238 gen_ph_dealloc_code f, "" 1266 1239 gen_ph_dealloc_code f, "_RESET" … … 1309 1282 next if p.get_port_type != :CALL 1310 1283 1311 # is_...joined 㯠omit ããã±ã¼ã¹ã§ãåºåããããããomit ãæ¤æ»ããåã«åºå1284 # is_...joined は omit するケースでも出力されるため、omit を検査する前に出力 1312 1285 if p.is_optional? then 1313 1286 f.print( "#undef is_#{p.get_name}_joined\n" ) … … 1353 1326 end 1354 1327 1355 #=== CELLTYPE_tecsgen.c ãçæ1328 #=== CELLTYPE_tecsgen.c を生成 1356 1329 def generate_cell_code 1357 1330 fs = { } … … 1388 1361 end 1389 1362 1390 # ãã¹ã¦ã® _tecsgen.c ã«åºå1363 # すべての _tecsgen.c に出力 1391 1364 print_note f 1392 1365 gen_cell_private_header f … … 1394 1367 gen_cell_ep_des_type f 1395 1368 1396 # ãã¹ã¦ã® _tecsgen.c ã«åºå1369 # すべての _tecsgen.c に出力 1397 1370 fs.each{ |r,f2| 1398 1371 if f == f2 then … … 1405 1378 } 1406 1379 1407 # ä¸ã¤ã® _tecsgen.c ã«åºå1380 # 一つの _tecsgen.c に出力 1408 1381 gen_cell_skel_fun f 1409 1382 gen_cell_fun_table f 1410 1383 gen_cell_var_init f 1411 1384 1412 # ã»ã«ãã¨ã« _tecsgen.c ã«åºå1385 # セルごとに _tecsgen.c に出力 1413 1386 gen_cell_ep_vdes fs 1414 1387 gen_cell_ep_vdes_array fs 1415 gen_cell_cb_out_init fs # INITIALIZE_CB ã§åç 1416 §ããããã ram_initializer=false ã§ãæ¶ããªã 1388 gen_cell_cb_out_init fs # INITIALIZE_CB で参照されるため ram_initializer=false でも消せない 1417 1389 gen_cell_cb fs 1418 1390 gen_cell_extern_mt fs 1419 1391 gen_cell_ep_des fs 1420 1392 1421 # ä¸ã¤ã® _tecsgen.c ã«åºå1393 # 一つの _tecsgen.c に出力 1422 1394 gen_cell_cb_tab f 1423 1395 if $ram_initializer then … … 1481 1453 1482 1454 def gen_ph_include f 1483 # ã©ã³ã¿ã¤ã ãããã®include1455 # ランタイムヘッダの include 1484 1456 # f.printf TECSMsg.get( :IRTH_comment), "#_IRTH_#" 1485 1457 # f.print "#include \"tecs.#{$h_suffix}\"\n\n" 1486 1458 1487 # ã°ãã¼ãã«ãããã®include1459 # グローバルヘッダの include 1488 1460 f.printf TECSMsg.get( :IGH_comment ), "#_IGH_#" 1489 1461 f.print "#include \"global_tecsgen.#{$h_suffix}\"\n\n" 1490 1462 1491 # ã·ã°ããã£ãããã®include1463 # シグニチャヘッダの include 1492 1464 f.printf TECSMsg.get( :ISH_comment ), "#_ISH_#" 1493 1465 @port.each { |p| … … 1507 1479 end 1508 1480 1509 # æé©åã®ããåç 1510 §ããã»ã«ã¿ã¤ãã® CB åã®å®ç¾©ãåè¾¼ã 1511 # _CB_TYPE_ONLY ãå®ç¾©ããä¸ã§ include ãã 1481 # 最適化のため参照するセルタイプの CB 型の定義を取込む 1482 # _CB_TYPE_ONLY を定義した上で include する 1512 1483 f.printf( TECSMsg.get( :ICT_comment ), "#_ICT_#" ) 1513 1484 … … 1522 1493 1523 1494 if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then 1524 # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©1495 # 最適化コード (optimize) # スケルトン不要など 1525 1496 p2 = p.get_real_callee_port 1526 1497 if p2 then … … 1531 1502 end 1532 1503 # else 1533 # optional ã§æªçµå1504 # optional で未結合 1534 1505 end 1535 1506 end … … 1543 1514 # next if p.get_port_type != :CALL 1544 1515 # if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then 1545 # # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©1516 # # 最適化コード (optimize) # スケルトン不要など 1546 1517 # p2 = p.get_real_callee_port 1547 1518 # ct = p2.get_celltype … … 1559 1530 return if @singleton 1560 1531 1561 # ID ã®åºæ°ããã³åæ°ã® define ãåºå1532 # ID の基数および個数の define を出力 1562 1533 f.printf("#define %-20s %10s /* %s #_NIDB_# */\n", "#{@global_name}_ID_BASE", "(#{@id_base})", TECSMsg.get(:NIDB_comment)) 1563 1534 f.printf("#define %-20s %10s /* %s #_NCEL_# */\n\n", "#{@global_name}_N_CELL", "(#{@n_cell_gen})", TECSMsg.get(:NCEL_comment)) … … 1567 1538 return if @singleton 1568 1539 1569 # mikan æé©å1570 # IDX æ£å½æ§ãã§ãã¯ãã¯ãã®åºå1540 # mikan 最適化 1541 # IDX 正当性チェックマクロの出力 1571 1542 f.printf( TECSMsg.get( :CVI_comment ), "#_CVI_#" ) 1572 1543 if @idx_is_id_act then … … 1581 1552 return if @singleton 1582 1553 1583 # IDX æ£å½æ§ãã§ãã¯ãã¯ãï¼ç縮形ï¼ã®åºå1554 # IDX 正当性チェックマクロ(短縮形)の出力 1584 1555 f.printf( TECSMsg.get( :CVIA_comment ), "#_CVIA_#") 1585 1556 f.print("#define VALID_IDX(IDX) #{@global_name}_VALID_IDX(IDX)\n\n") … … 1587 1558 end 1588 1559 1589 #=== å¼ã³å£é 1590 åã®å¤§ãããå¾ããã¯ãã®åºå 1560 #=== 呼び口配列の大きさを得るマクロの出力 1591 1561 # 1592 # ã»ã«ã¿ã¤ããããã¸å¼ã³å£ã®åæ°ãåºå1562 #セルタイプヘッダへ呼び口の個数を出力 1593 1563 def gen_ph_n_cp f 1594 1564 … … 1604 1574 end 1605 1575 1606 if p.get_array_size != "[]" then # åºå®é·é 1607 å 1576 if p.get_array_size != "[]" then # 固定長配列 1608 1577 f.print( "#define N_CP_#{p.get_name} (#{p.get_array_size})\n" ) 1609 1578 f.print( "#define NCP_#{p.get_name} (#{p.get_array_size})\n" ) 1610 else # å¯å¤é·é 1611 å 1579 else # 可変長配列 1612 1580 if @singleton then 1613 1581 if has_INIB? then … … 1618 1586 f.print( "#define N_CP_#{p.get_name} (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" ) 1619 1587 f.print( "#define NCP_#{p.get_name} (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" ) 1620 # mikan singleton ãªãã°ãåºå®é·åã§ãã1588 # mikan singleton ならば、固定長化できる 1621 1589 else 1622 1590 if has_CB? && has_INIB? then … … 1632 1600 end 1633 1601 1634 #=== åãå£é 1635 åã®å¤§ãããå¾ããã¯ãã®åºå 1602 #=== 受け口配列の大きさを得るマクロの出力 1636 1603 # 1637 # ã»ã«ã¿ã¤ããããã¸åãå£ã®åæ°ãåºå1604 #セルタイプヘッダへ受け口の個数を出力 1638 1605 def gen_ph_n_ep f 1639 1606 … … 1641 1608 @port.each { |p| 1642 1609 next if p.get_port_type != :ENTRY 1643 # next if p.is_omit? # åãå£é 1644 åã®åæ°ã¯çç¥ããªã 1610 # next if p.is_omit? # 受け口配列の個数は省略しない 1645 1611 next if p.get_array_size == nil 1646 1612 … … 1650 1616 end 1651 1617 1652 if p.get_array_size != "[]" then # åºå®é·é 1653 å 1618 if p.get_array_size != "[]" then # 固定長配列 1654 1619 f.print( "#define NEP_#{p.get_name} (#{p.get_array_size})\n" ) 1655 else # å¯å¤é·é 1656 å 1620 else # 可変長配列 1657 1621 if @singleton then 1658 1622 if has_INIB? then … … 1662 1626 end 1663 1627 f.print( "#define NEP_#{p.get_name} (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" ) 1664 # mikan singleton ãªãã°ãåºå®é·åã§ãã1628 # mikan singleton ならば、固定長化できる 1665 1629 else 1666 1630 if has_CB? && has_INIB? then … … 1675 1639 end 1676 1640 1677 #=== optional ãªå¼ã³å£ãçµåããã¦ããããã¹ãããã³ã¼ãã®çæ1641 #=== optional な呼び口が結合されているかテストするコードの生成 1678 1642 def gen_ph_test_optional_call_port f 1679 1643 b_comment = false … … 1696 1660 next if p.get_port_type != :CALL 1697 1661 next if ! p.is_optional? 1698 # next if p.is_omit? # omit ã§ã test ã³ã¼ãã¯çæãã1662 # next if p.is_omit? # omit でも test コードは生成する 1699 1663 1700 1664 if b_comment == false then … … 1720 1684 end 1721 1685 1722 # é¢æ°åã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãã VMT ã®é¢æ°åãæé©åï¼åãå£é¢æ° or åãå£ãã£ã¹ã¯ãªãã¿) 1723 # mikan å 1724 ¨é¨ã¤ãªãã£ã¦ãããã©ãã㧠(1) ãå¤å®ãã 1686 # 関数名の出力(標準:受け口ディスクリプタから VMT の関数名、最適化:受け口関数 or 受け口ディスクリプタ) 1687 # mikan 全部つながっているかどうかで (1) を判定する 1725 1688 if ! p.is_VMT_useless? then 1726 1689 if p.is_dynamic? then … … 1734 1697 end 1735 1698 1736 # æ¨æºã³ã¼ã1699 # 標準コード 1737 1700 if p.get_array_size == nil then 1738 1701 if @singleton then … … 1742 1705 end 1743 1706 else 1744 # é 1745 åã®å ´å 1707 # 配列の場合 1746 1708 if @singleton then 1747 1709 f.print( "\t ((#{@global_name}_SINGLE_CELL_#{inib_tmp}.#{p.get_name}!=0) \\\n" ) … … 1753 1715 end 1754 1716 else 1755 # æé©åã³ã¼ã (optimize) # VMT ä¸è¦ï¼é 1756 åè¦ç´ ãã¹ã¦åãï¼ 1717 # 最適化コード (optimize) # VMT 不要(配列要素すべて同じ) 1757 1718 p2 = p.get_real_callee_port 1758 1719 if p2 then 1759 1720 ct = p2.get_celltype 1760 1721 if p.is_skelton_useless? then 1761 # åãå£é¢æ°ãç´æ¥å¼åºã1722 # 受け口関数を直接呼出す 1762 1723 f.print( "\t (1)\n" ) 1763 1724 else 1764 # åãå£ã¹ã±ã«ãã³é¢æ°ãç´æ¥å¼åºã1725 # 受け口スケルトン関数を直接呼出す 1765 1726 f.print( "\t (1)\n" ) 1766 1727 end 1767 1728 else 1768 # optional ã§æªçµå1729 # optional で未結合 1769 1730 f.print( "\t (0) /* not joined */\n" ) 1770 1731 end … … 1773 1734 end 1774 1735 1775 #=== optional ãªå¼ã³å£ãçµåããã¦ããããã¹ãããã³ã¼ãã®çæï¼ç縮形ï¼1736 #=== optional な呼び口が結合されているかテストするコードの生成(短縮形) 1776 1737 def gen_ph_test_optional_call_port_abbrev f 1777 1738 b_comment = false … … 1780 1741 next if p.get_port_type != :CALL 1781 1742 next if ! p.is_optional? 1782 # next if p.is_omit? # omit ã§ã test ã³ã¼ãã¯çæãã1743 # next if p.is_omit? # omit でも test コードは生成する 1783 1744 1784 1745 if b_comment == false then … … 1805 1766 end 1806 1767 1807 #=== CELLCB ã¸ã®ãã¤ã³ã¿ãå¾ããã¯ããåºå1808 # ã»ã«ã¿ã¤ããããã¸åºå1768 #=== CELLCB へのポインタを得るマクロを出力 1769 # セルタイプヘッダへ出力 1809 1770 def gen_ph_get_cellcb f 1810 1771 f.printf( TECSMsg.get( :GCB_comment ), "#_GCB_#" ) 1811 1772 if ( ! has_CB? && ! has_INIB? ) || @singleton then 1812 1773 f.print( "#define #{@global_name}_GET_CELLCB(idx) ((void *)0)\n" ) 1813 elsif @idx_is_id_act then # mikan åä¸ã®ã»ã«ã®å ´åã®æé©å, idx_is_id ã§ãªãå ´å1774 elsif @idx_is_id_act then # mikan 単一のセルの場合の最適化, idx_is_id でない場合 1814 1775 f.print( "#define #{@global_name}_GET_CELLCB(idx) (#{@global_name}_CB_ptab[(idx) - #{@global_name}_ID_BASE])\n" ) 1815 1776 else … … 1818 1779 end 1819 1780 1820 #=== CELLCB ã¸ã®ãã¤ã³ã¿ãå¾ããã¯ãï¼ç縮形ï¼ãåºå1821 # ã»ã«ã¿ã¤ããããã¸åºå1781 #=== CELLCB へのポインタを得るマクロ(短縮形)を出力 1782 # セルタイプヘッダへ出力 1822 1783 def gen_ph_get_cellcb_abbrev f 1823 1784 f.printf( TECSMsg.get( :GCBA_comment ), "#_GCBA_#" ) … … 1835 1796 end 1836 1797 1837 #=== attribute, var ãã¢ã¯ã»ã¹ãããã¯ããåºå1838 # ã»ã«ã¿ã¤ããããã¸åºå1798 #=== attribute, var をアクセスするマクロを出力 1799 # セルタイプヘッダへ出力 1839 1800 def gen_ph_attr_access f 1840 1801 if @n_attribute_rw > 0 || @n_attribute_ro > 0 then … … 1846 1807 next if a.is_omit? 1847 1808 1848 # mikan const_value ã®å ´å1809 # mikan const_value の場合 1849 1810 f.print( "#define " ) 1850 1811 if @singleton then … … 1856 1817 f.printf( "%-20s", "#{@global_name}_ATTR_#{a.get_name}" ) 1857 1818 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name})\n" ) 1858 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1819 # mikan ここでは cell ではなく celltype の名前 1859 1820 else 1860 1821 if ! a.is_rw? && has_CB? && has_INIB? then … … 1887 1848 end 1888 1849 1889 # mikan const_value ã®å ´å1850 # mikan const_value の場合 1890 1851 f.print( "#define " ) 1891 1852 if @singleton then 1892 1853 f.printf( "%-20s", "#{@global_name}_GET_#{a.get_name}()" ) 1893 1854 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name})\n" ) 1894 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1855 # mikan ここでは cell ではなく celltype の名前 1895 1856 else 1896 1857 f.printf( "%-20s", "#{@global_name}_GET_#{a.get_name}(p_that)" ) … … 1903 1864 f.printf( "%-20s", "#{@global_name}_SET_#{a.get_name}(val)" ) 1904 1865 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name} = (val))\n" ) 1905 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1866 # mikan ここでは cell ではなく celltype の名前 1906 1867 else 1907 1868 f.printf( "%-20s", "#{@global_name}_SET_#{a.get_name}(p_that,val)" ) … … 1935 1896 end 1936 1897 1937 # mikan const_value ã®å ´å1898 # mikan const_value の場合 1938 1899 f.print( "#define " ) 1939 1900 if @singleton then 1940 1901 f.printf( "%-20s", "#{@global_name}_VAR_#{v.get_name}" ) 1941 1902 f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{v.get_name})\n" ) 1942 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1903 # mikan ここでは cell ではなく celltype の名前 1943 1904 else 1944 1905 f.printf( "%-20s", "#{@global_name}_VAR_#{v.get_name}(p_that)" ) … … 1951 1912 next if v.is_omit? 1952 1913 1953 # mikan const_value ã®å ´å1914 # mikan const_value の場合 1954 1915 f.print( "#define " ) 1955 1916 if @singleton then 1956 1917 f.printf( "%-20s", "#{@global_name}_GET_#{v.get_name}()" ) 1957 1918 f.print( "\t(#{@global_name}_SINGLE_CELL_CB.#{v.get_name})\n" ) 1958 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1919 # mikan ここでは cell ではなく celltype の名前 1959 1920 else 1960 1921 f.printf( "%-20s", "#{@global_name}_GET_#{v.get_name}(p_that)" ) … … 1966 1927 f.printf( "%-20s", "#{@global_name}_SET_#{v.get_name}(val)" ) 1967 1928 f.print( "\t(#{@global_name}_SINGLE_CELL_CB.#{v.get_name}=(val))\n" ) 1968 # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå1929 # mikan ここでは cell ではなく celltype の名前 1969 1930 else 1970 1931 f.printf( "%-20s", "#{@global_name}_SET_#{v.get_name}(p_that,val)" ) … … 1976 1937 end 1977 1938 1978 #=== attribute/var ã¢ã¯ã»ã¹ãã¯ãï¼ç縮形ï¼ã³ã¼ãã®çæ1939 #=== attribute/var アクセスマクロ(短縮形)コードの生成 1979 1940 def gen_ph_attr_access_abbrev f 1980 1941 if @n_attribute_rw > 0 || @n_attribute_ro > 0 then … … 1985 1946 next if a.is_omit? 1986 1947 1987 # mikan const_value ã®å ´å1948 # mikan const_value の場合 1988 1949 f.print( "#define " ) 1989 1950 f.printf( "%-20s", "ATTR_#{a.get_name}" ) … … 2003 1964 next if v.is_omit? 2004 1965 2005 # mikan const_value ã®å ´å1966 # mikan const_value の場合 2006 1967 f.print( "#define " ) 2007 1968 f.printf( "%-20s", "VAR_#{v.get_name}" ) … … 2072 2033 delim = "" 2073 2034 2074 # é¢æ°åã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãã VMT ã®é¢æ°åãæé©åï¼åãå£é¢æ° or åãå£ãã£ã¹ã¯ãªãã¿)2035 # 関数名の出力(標準:受け口ディスクリプタから VMT の関数名、最適化:受け口関数 or 受け口ディスクリプタ) 2075 2036 if b_flow then 2076 2037 f.print( "\t (p_that)->#{p.get_name}#{subsc}.#{fun.get_name}__T( \\\n" ) 2077 2038 elsif ! p.is_VMT_useless? then 2078 # æ¨æºã³ã¼ã2039 # 標準コード 2079 2040 if @singleton then 2080 2041 f.print( "\t #{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}" ) … … 2084 2045 f.print( "#{subsc}->VMT->#{fun.get_name}__T( \\\n" ) 2085 2046 else 2086 # æé©åã³ã¼ã (optimize) # VMT ä¸è¦2047 # 最適化コード (optimize) # VMT 不要 2087 2048 p2 = p.get_real_callee_port 2088 2049 if p2 then 2089 2050 ct = p2.get_celltype 2090 2051 if p.is_skelton_useless? then 2091 # åãå£é¢æ°ãç´æ¥å¼åºã2052 # 受け口関数を直接呼出す 2092 2053 f.print( "\t #{ct.get_global_name}_#{p2.get_name}_#{fun.get_name}( \\\n" ) 2093 2054 else 2094 # åãå£ã¹ã±ã«ãã³é¢æ°ãç´æ¥å¼åºã2055 # 受け口スケルトン関数を直接呼出す 2095 2056 f.print( "\t #{ct.get_global_name}_#{p2.get_name}_#{fun.get_name}_skel( \\\n" ) 2096 2057 # print "skelton: #{@name} #{ct.get_global_name}_#{p2.get_name}\n" 2097 2058 end 2098 2059 else 2099 # optional ã§æªçµå2060 # optional で未結合 2100 2061 f.print( "\t ((#{fun.get_declarator.get_type.get_type.get_type_str} (*)()" ) 2101 2062 f.print( "#{fun.get_declarator.get_type.get_type.get_type_str_post})0)()\n" ) … … 2107 2068 end 2108 2069 2109 b_join = true # optional ã§çµåãã¦ããªãå ´å false 2110 2111 # åãå£æ 2112 å ±ã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãæé©åï¼IDX ãªã©) 2070 b_join = true # optional で結合していない場合 false 2071 2072 # 受け口情報の出力(標準:受け口ディスクリプタ、最適化:IDX など) 2113 2073 if b_flow then 2114 2074 elsif ! p.is_skelton_useless? && ! p.is_cell_unique? then 2115 # æ¨æºã³ã¼ã2075 # 標準コード 2116 2076 if @singleton then 2117 2077 f.print( "\t #{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}#{subsc}" ) … … 2122 2082 end 2123 2083 else 2124 # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦2125 c2 = p.get_real_callee_cell # å¯ä¸ã®ã»ã«(ã§ãªãå ´åããããè¤æ°ã»ã«ãããå ´å)2126 p2 = p.get_real_callee_port # å¯ä¸ã®ãã¼ã(ã§ãªãå ´åã¯ããªã)2084 # 最適化コード (optimize) # スケルトン不要 2085 c2 = p.get_real_callee_cell # 唯一のセル(でない場合もある、複数セルがある場合) 2086 p2 = p.get_real_callee_port # 唯一のポート(でない場合は、ない) 2127 2087 if p2 then 2128 ct = p2.get_celltype # å¼ã³å 2129 ã®ã»ã«ã¿ã¤ã 2088 ct = p2.get_celltype # 呼び先のセルタイプ 2130 2089 if ! ct.is_singleton? then 2131 2090 if ct.has_CB? || ct.has_INIB? then … … 2134 2093 f.print( "\t #{name_array[7]}" ) 2135 2094 else 2136 # CELLCB IDX ã渡ã (æ¨æºã³ã¼ãã¨åãã ããæ±ãåã¯ç°ãªã)2137 # p.is_skelton_useless? == true/false ã¨ãã«åã2095 # CELLCB IDX を渡す (標準コードと同じだが、扱う型は異なる) 2096 # p.is_skelton_useless? == true/false ともに同じ 2138 2097 f.print( "\t (p_that)#{inib}->#{p.get_name}#{subsc}" ) 2139 2098 end … … 2146 2105 end 2147 2106 else 2148 # optional ã§æªçµå2107 # optional で未結合 2149 2108 b_join = false 2150 2109 end … … 2163 2122 end 2164 2123 2165 #=== ref_desc æå®ãããå¼ã³å£ã«å¯¾ãããã£ã¹ã¯ãªãã¿åç 2166 §é¢æ°ã®çæ 2124 #=== ref_desc 指定された呼び口に対するディスクリプタ参照関数の生成 2167 2125 def gen_ph_ref_desc_func f 2168 2126 if @n_call_port_ref_desc >0 then … … 2219 2177 end 2220 2178 2221 #=== dynamic æå®ãããå¼ã³å£ã«å¯¾ãããã£ã¹ã¯ãªãã¿è¨å®é¢æ°ã®çæ2179 #=== dynamic 指定された呼び口に対するディスクリプタ設定関数の生成 2222 2180 def gen_ph_set_desc_func f 2223 2181 if @n_call_port_dynamic >0 then … … 2291 2249 end 2292 2250 2293 #=== send/receive ã§åãåã£ãã¡ã¢ãªé åã dealloc ãããã¯ãã³ã¼ã2251 #=== send/receive で受け取ったメモリ領域を dealloc するマクロコード 2294 2252 #f:: File 2295 #b_undef:: bool : true = #undef ã³ã¼ãã®çæ, false = #define ã³ã¼ãã®çæ2253 #b_undef:: bool : true = #undef コードの生成, false = #define コードの生成 2296 2254 def gen_ph_dealloc_code( f, append_name, b_undef = false ) 2297 2255 b_msg = false … … 2300 2258 2301 2259 p.each_param{ |port, fd, par| 2302 case par.get_direction # å¼æ°ã®æ¹åæå®å(in, out, inout, send, receive )2260 case par.get_direction # 引数の方向指定子 (in, out, inout, send, receive ) 2303 2261 when :SEND 2304 2262 # next if port.get_port_type == :CALL … … 2317 2275 end 2318 2276 2319 # ãã¼ãå é¢æ°å ãã©ã¡ã¼ã¿å2277 # ポート名 関数名 パラメータ名 2320 2278 dealloc_func_name = "#{port.get_name}_#{fd.get_name}_#{par.get_name}_dealloc" 2321 2279 dealloc_macro_name = dealloc_func_name.upcase … … 2356 2314 @port.each { |p| 2357 2315 next if p.get_port_type != :CALL 2358 # next if p.is_omit? å¼ã³åºãã¨ã¨ã©ã¼ãèµ·ããã³ã¼ããçæ2316 # next if p.is_omit? 呼び出すとエラーを起こすコードを生成 2359 2317 2360 2318 p.get_signature.get_function_head_array.each{ |fun| … … 2531 2489 f.print( "struct tag_#{@global_name}_CB *" ) 2532 2490 elsif has_INIB? then 2533 # f.print( "struct tag_#{@global_name}_INIB *" ) # const ãåºåãã¦ããªã2491 # f.print( "struct tag_#{@global_name}_INIB *" ) # const を出力していない 2534 2492 f.print( "const struct tag_#{@global_name}_INIB *" ) 2535 2493 else … … 2567 2525 2568 2526 if p.get_array_size then 2569 f.print( "#{delim} int_t subscript" ) # mikan singleton æã® ',' ã®å§æ«2527 f.print( "#{delim} int_t subscript" ) # mikan singleton 時の ',' の始末 2570 2528 delim = "," 2571 2529 end … … 2575 2533 len = items.length 2576 2534 else 2577 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å2535 # ここで nil になるのは、引数なしの時に void がなかった場合 2578 2536 items = [] 2579 2537 len = 0 … … 2596 2554 2597 2555 def gen_ph_ep_skel_prototype f 2598 # åãå£ã¹ã±ã«ãã³é¢æ°ã®ãããã¿ã¤ã宣è¨ãåºå2556 # 受け口スケルトン関数のプロトタイプ宣言を出力 2599 2557 if @n_entry_port >0 then 2600 2558 f.printf( TECSMsg.get( :EPSP_comment ), "#_EPSP_#" ) … … 2603 2561 next if p.get_port_type != :ENTRY 2604 2562 next if p.is_omit? 2605 # if p.is_skelton_useless? || ! p.is_VMT_useless? then # åãå£æé©å2606 if p.is_skelton_useless? then # åãå£æé©å2563 # if p.is_skelton_useless? || ! p.is_VMT_useless? then # 受け口最適化 2564 if p.is_skelton_useless? then # 受け口最適化 2607 2565 # f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" ) 2608 2566 next … … 2623 2581 len = items.length 2624 2582 else 2625 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å2583 # ここで nil になるのは、引数なしの時に void がなかった場合 2626 2584 items = [] 2627 2585 len = 0 … … 2646 2604 2647 2605 if ( $rom )then 2648 # å®æ°é¨ã¯ ROM, å¤æ°é¨ã¯RAM2606 # 定数部は ROM, 変数部は RAM 2649 2607 2650 2608 if has_INIB? then … … 2680 2638 2681 2639 else 2682 # å 2683 ¨ã¦ RAM 2640 # 全て RAM 2684 2641 f.printf( TECSMsg.get( :CCTPO_comment ), "#_CCTPO_#" ) 2685 2642 … … 2695 2652 2696 2653 2697 #=== attribute ã®å宣è¨åºå2698 #inib_cb:: :INIB ã¾ãã¯:CB2654 #=== attribute の型宣言出力 2655 #inib_cb:: :INIB または :CB 2699 2656 def gen_cell_cb_type_attribute( f, inib_cb ) 2700 2657 if inib_cb == :INIB && @n_attribute_ro > 0 then … … 2729 2686 next if v.is_omit? 2730 2687 next if v.get_size_is == nil 2731 next if $rom && inib_cb == :CB # size_is æå®ããããã®ã¯ INIB ã«ã®ã¿åºåãã2688 next if $rom && inib_cb == :CB # size_is 指定されたものは INIB にのみ出力する 2732 2689 2733 2690 f.print " " … … 2738 2695 2739 2696 def gen_cell_cb_type_var f 2740 # å¤æ°ã®åºå2697 # 変数の出力 2741 2698 if @n_var > 0 then 2742 2699 f.print " /* var #_VA_# */ \n" … … 2746 2703 2747 2704 next if v.is_omit? 2748 next if v.get_size_is != nil # size_is æå®ããã var 㯠attribute ã¸åºåãã2705 next if v.get_size_is != nil # size_is 指定された var は attribute へ出力する 2749 2706 2750 2707 f.print " " … … 2760 2717 2761 2718 def gen_cell_cb_type_call_port( f, inib_cb ) 2762 # å¼ã³å£2719 # 呼び口 2763 2720 if @n_call_port >0 then 2764 2721 f.print " /* call port #_TCP_# */\n" … … 2785 2742 2786 2743 if ! p.is_skelton_useless? then 2787 # æ¨æºå½¢2744 # 標準形 2788 2745 if inib_cb == :INIB && p.is_dynamic? && p.get_array_size != nil && $ram_initializer then 2789 2746 f.print( " struct tag_#{p.get_signature.get_global_name}_VDES #{ptr}#{const2}*#{p.get_name;}_init_;\n" ) … … 2795 2752 end 2796 2753 else 2797 # æé©å skelton é¢æ°ãå¼åºããªã(åãå£é¢æ°ãç´æ¥å¼åºã) 2798 # å¼ã³å 2799 ã»ã«ã¿ã¤ãã® CB ã® IDX å 2754 # 最適化 skelton 関数を呼出さない(受け口関数を直接呼出す) 2755 # 呼び先セルタイプの CB の IDX 型 2800 2756 if p.get_real_callee_cell then 2801 2757 f.print( " " ) 2802 2758 p.get_real_callee_cell.get_celltype.gen_ph_idx_type f 2803 2759 f.print( " #{ptr}#{p.get_name;};\n" ) 2804 # ç¸äºåç 2805 §ã«åãã¦ãtypedef ããåã使ããªã 2760 # 相互参照に備えて、typedef した型を使わない 2806 2761 # f.print( " #{p.get_real_callee_cell.get_celltype.get_global_name}_IDX #{ptr}#{p.get_name;};\n" ) 2807 2762 if p.get_array_size == "[]" then … … 2809 2764 end 2810 2765 #else 2811 # optional ã§æªçµå2766 # optional で未結合 2812 2767 end 2813 2768 end 2814 2769 # else 2815 # æé©å ä¸ã¤ããã»ã«ããªãå ´åãåãå£ãã£ã¹ã¯ãªãã¿ã¾ãã¯åãå´ã® IDX ã¯å¼ã³å£é¢æ°ãã¯ãã«åãè¾¼ã¾ãã 2816 end 2817 } 2818 end 2819 2820 #=== Celltype#åãå£é 2821 åæ·»æ°ãè¨æ¶ããå¤æ°ã®å®ç¾© 2770 # 最適化 一つしかセルがない場合、受け口ディスクリプタまたは受け側の IDX は呼び口関数マクロに埋め込まれる 2771 end 2772 } 2773 end 2774 2775 #=== Celltype#受け口配列添数を記憶する変数の定義 2822 2776 def gen_cell_cb_type_entry_port( f, inib_cb ) 2823 # å¼ã³å£2777 # 呼び口 2824 2778 if @n_entry_port >0 then 2825 2779 f.print " /* call port #_NEP_# */ \n" … … 2827 2781 2828 2782 @port.each{ |p| 2829 # next if p.is_omit? # åãå£é 2830 åã®åæ°ã¯çç¥ããªã 2783 # next if p.is_omit? # 受け口配列の個数は省略しない 2831 2784 if p.get_port_type == :ENTRY && p.get_array_size == "[]" 2832 2785 f.print( " int_t n_#{p.get_name};\n" ) … … 2850 2803 f.print "extern #{@global_name}_CB *const #{@global_name}_CB_ptab[];\n" 2851 2804 @ordered_cell_list.each{ |c| 2852 if c.is_generate? then # çæ対象ãï¼2805 if c.is_generate? then # 生成対象か? 2853 2806 name_array = get_name_array c 2854 2807 f.print "extern #{@global_name}_CB #{name_array[4]};\n" … … 2858 2811 f.print "extern #{@global_name}_INIB *const #{@global_name}_INIB_ptab[];\n" 2859 2812 @ordered_cell_list.each{ |c| 2860 if c.is_generate? then # çæ対象ãï¼2813 if c.is_generate? then # 生成対象か? 2861 2814 name_array = get_name_array c 2862 2815 f.print "extern #{@global_name}_INIB #{name_array[11]};\n" … … 2875 2828 2876 2829 def gen_ph_INIB_as_CB f 2877 # ããã¯ãææãã§ãããæ¬æ¥ãªã INIB ãåºåãã¹ã2830 # ここは、手抜きである。本来なら INIB を出力すべき 2878 2831 if ! has_CB? && has_INIB? then 2879 2832 f.printf( TECSMsg.get( :DCI_comment ), "#_DCI_#" ) … … 2892 2845 end 2893 2846 2894 #=== ã¤ãã¬ã¼ã¿ã³ã¼ã (FOREACH_CELL)ã®çæ2895 # singleton ã§ã¯åºåããªã2847 #=== イテレータコード (FOREACH_CELL)の生成 2848 # singleton では出力しない 2896 2849 def gen_ph_foreach_cell f 2897 2850 … … 2936 2889 2937 2890 2938 #=== å¤æ°varåæåã³ã¼ã2891 #=== 変数var初期化コード 2939 2892 # 2940 2893 def gen_ph_cb_initialize_macro f … … 2947 2900 type = v.get_type 2948 2901 if( type.kind_of? PtrType )then 2949 # PtrType 㯠ArrayType ã«ããæ¿ãã2950 2951 # åæååã®è¦ç´ æ°ã¨ãã (å¾ã¯ 0 ã§ãã)2902 # PtrType は ArrayType にすり替える 2903 2904 # 初期化子の要素数とする (後は 0 である) 2952 2905 t2 = ArrayType.new( Expression.create_integer_constant( init.length, nil ) ) 2953 2906 t2.set_type( type.get_type ) … … 3005 2958 } 3006 2959 3007 # dynamic call port ã®åæåã³ã¼ã2960 # dynamic call port の初期化コード 3008 2961 b_dyn_port = false 3009 2962 @port.each{ |p| … … 3061 3014 3062 3015 # else 3063 # ã»ã«ãä¸ã¤ããªããã°åºåããªã3016 # セルが一つもなければ出力しない 3064 3017 end 3065 3018 … … 3068 3021 3069 3022 def gen_ph_inline f 3070 # inline ãã¼ããä¸ã¤ã§ãããã°ãinline.h ã®include3023 # inline ポートが一つでもあれば、inline.h の include 3071 3024 if @n_entry_port_inline > 0 then 3072 3025 f.printf( TECSMsg.get( :INL_comment ), "#_INL_#" ) … … 3120 3073 next if p.get_port_type != :ENTRY 3121 3074 next if p.is_omit? 3122 if p.is_skelton_useless? # åãå£æé©å3075 if p.is_skelton_useless? # 受け口最適化 3123 3076 f.print( "/* #{p.get_name} : omitted by entry port optimize */\n\n" ) 3124 3077 next … … 3131 3084 f.print( " #{@name}_IDX idx;\n" ) 3132 3085 else 3133 # CB ã INIB ãåå¨ããªã (ã®ã§ãidx ã¨ãã¦æ´æ°ã§åæåãã¦ãã)3086 # CB も INIB も存在しない (ので、idx として整数で初期化しておく) 3134 3087 f.print( " int idx;\n" ) 3135 3088 end … … 3149 3102 next if p.get_port_type != :ENTRY 3150 3103 next if p.is_omit? 3151 if p.is_skelton_useless? then # åãå£æé©å3104 if p.is_skelton_useless? then # 受け口最適化 3152 3105 f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" ) 3153 3106 next … … 3168 3121 len = items.length 3169 3122 else 3170 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å3123 # ここで nil になるのは、引数なしの時に void がなかった場合 3171 3124 items = [] 3172 3125 len = 0 … … 3190 3143 end 3191 3144 3192 if functype.get_type_str == "void" then # mikan "void" ã® typedef ã«æªå¯¾å¿3145 if functype.get_type_str == "void" then # mikan "void" の typedef に未対応 3193 3146 f.print " " 3194 3147 else … … 3233 3186 next if p.get_port_type != :ENTRY 3234 3187 next if p.is_omit? 3235 if p.is_VMT_useless? then # åãå£æé©å3188 if p.is_VMT_useless? then # 受け口最適化 3236 3189 f.print "/* #{p.get_name} : omitted by entry port optimize */\n" 3237 3190 next … … 3259 3212 end 3260 3213 3261 # ãã®ã»ã«ã¿ã¤ãã®ãã¹ã¦ã®ã»ã«ã«ã¤ãã¦3214 # このセルタイプのすべてのセルについて 3262 3215 @ordered_cell_list.each{ |c| 3263 if c.is_generate? then # çæ対象ãï¼3216 if c.is_generate? then # 生成対象か? 3264 3217 3265 3218 f = fs[ c.get_region.get_domain_root ] 3266 3219 3267 # çµåã®ãªã¹ã(NamedList)3220 # 結合のリスト (NamedList) 3268 3221 jl = c.get_join_list 3269 3222 3270 # å 3271 ¨ã¦ã®çµåãªã¹ãã«ã¤ã㦠3223 # 全ての結合リストについて 3272 3224 jl.get_items.each{ |j| 3273 3225 3274 # 左辺ã®å®ç¾©ãå¾ã3226 # 左辺の定義を得る 3275 3227 definition = j.get_definition 3276 3228 3277 # å¼ã³å£ã§ã¯ãªãï¼ãï¼å±æ§ï¼3229 # 呼び口ではない? (属性) 3278 3230 next unless definition.instance_of? Port 3279 3231 3280 port = find j.get_name # celltype ã® Port (ãã¡ãã«æé©åæ 3281 å ±ããã) 3282 # port = definition # definition 㯠composite ã® Port ãå¾ããããã¨ããã 3232 port = find j.get_name # celltype の Port (こちらに最適化情報がある) 3233 # port = definition # definition は composite の Port が得られることがある 3283 3234 next if port.is_cell_unique? 3284 3235 next if port.is_omit? 3285 3236 3286 # é 3287 åè¦ç´ ãå¾ãï¼åãå£é 3288 åã§ãªããã° nil ãè¿ãï¼ 3237 # 配列要素を得る(受け口配列でなければ nil が返る) 3289 3238 am = j.get_array_member2 3290 3239 3291 # å¼ã³å£é 3292 åã? 3240 # 呼び口配列か? 3293 3241 if am then 3294 3242 i = 0 … … 3297 3245 if j then 3298 3246 if am[i].get_rhs_cell.get_celltype == self then 3299 # åãã»ã«ã¿ã¤ãã¸çµåãã¦ããå ´å(VDES ã§ã¯ type conflict ã«ãªã)3247 # 同じセルタイプへ結合している場合(VDES では type conflict になる) 3300 3248 p = am[i].get_rhs_port 3301 3249 des_type = "const struct tag_#{@global_name}_#{p.get_name}_DES" … … 3304 3252 end 3305 3253 3306 # å³è¾ºã¯åãå£é 3307 åãï¼ 3254 # 右辺は受け口配列か? 3308 3255 if j.get_rhs_subscript then 3309 3256 3310 # åãå£ã®é 3311 åæ·»æ° 3257 # 受け口の配列添数 3312 3258 subscript = j.get_rhs_subscript 3313 3259 … … 3322 3268 end 3323 3269 #else if j == nil 3324 # optioanl ã§é 3325 åè¦ç´ ãåæåããã¦ããªã 3270 # optioanl で配列要素が初期化されていない 3326 3271 end 3327 3272 i += 1 … … 3330 3275 dbgPrint "me=#{@name} callee=#{j.get_rhs_cell.get_celltype.get_name} #{j.get_cell.get_celltype.get_name} \n" 3331 3276 if j.get_rhs_cell.get_celltype == self then 3332 # åãã»ã«ã¿ã¤ãã¸çµåãã¦ããå ´å(VDES ã§ã¯ type conflict ã«ãªã)3277 # 同じセルタイプへ結合している場合(VDES では type conflict になる) 3333 3278 p = j.get_rhs_port 3334 3279 des_type = "const struct tag_#{@global_name}_#{p.get_name}_DES" … … 3338 3283 3339 3284 if j.get_rhs_subscript then 3340 # åãå£é 3341 å 3285 # 受け口配列 3342 3286 subscript = j.get_rhs_subscript 3343 3287 f.printf( "extern %s %s%d;\n", … … 3351 3295 end 3352 3296 end 3353 # mikan cell ã® namespace æªå¯¾å¿ãJoin 㧠Cell ãªãã¸ã§ã¯ããå¼å½ã¦ããå¿ 3354 è¦ãã 3297 # mikan cell の namespace 未対応、Join で Cell オブジェクトを引当ておく必要あり 3355 3298 } 3356 3299 … … 3362 3305 def gen_cell_ep_vdes_array fs 3363 3306 if @n_cell_gen >0 then 3364 fs.each{ |r, f| f.printf( TECSMsg.get( :CPA_comment ), "#_CPA_#" ) } # mikan å¼ã³å£é 3365 åãç¡ãå ´åãåºã¦ãã¾ã 3307 fs.each{ |r, f| f.printf( TECSMsg.get( :CPA_comment ), "#_CPA_#" ) } # mikan 呼び口配列が無い場合も出てしまう 3366 3308 end 3367 3309 … … 3371 3313 3372 3314 jl = c.get_join_list 3373 # ã«ã¼ããåãå¤æ°ã jl ãã @port ã«å¤æ´3315 # ループを回す変数を jl から @port に変更 3374 3316 # dynamic, optional 3375 3317 # jl.get_items.each{ |j| … … 3382 3324 j = jl.get_item( port.get_name ) 3383 3325 3384 # port = definition # definition 㯠composite ã® Port ãå¾ããããã¨ããã 3385 # port = find j.get_name # celltype ã® Port (ãã¡ãã«æé©åæ 3386 å ±ããã) 3326 # port = definition # definition は composite の Port が得られることがある 3327 # port = find j.get_name # celltype の Port (こちらに最適化情報がある) 3387 3328 next if port.is_cell_unique? 3388 3329 next if port.is_omit? … … 3405 3346 if b_array then 3406 3347 # if am then 3407 # 左辺ã¯é 3408 å 3348 # 左辺は配列 3409 3349 const = ( port.is_dynamic? && ! $ram_initializer ) ? '' : 'const ' 3410 3350 init = ( port.is_dynamic? && $ram_initializer ) ? '_init_' : '' … … 3417 3357 else 3418 3358 3419 # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©åã®å ´åããã®é 3420 åã¯åç 3421 §ãããªã 3422 # mikan ãã®ã±ã¼ã¹ããã¹ãããã¦ããªã 3359 # スケルトン関数不要最適化の場合、この配列は参照されない 3360 # mikan このケースがテストされていない 3423 3361 f.printf( "#{const}%s_IDX %s_%s[] = {\n", 3424 # "#{j.get_celltype.get_global_name}", # å³è¾º composite ã«å¯¾å¿ã§ããªã3362 # "#{j.get_celltype.get_global_name}", # 右辺 composite に対応できない 3425 3363 "#{j.get_rhs_cell.get_celltype.get_global_name}", 3426 3364 "#{c.get_global_name}", … … 3444 3382 3445 3383 if j then 3446 # åä¸ã»ã«ã¿ã¤ãã®çµåã®å ´åãVDES åã¸ã®ãã£ã¹ããå¿ 3447 è¦ 3384 # 同一セルタイプの結合の場合、VDES 型へのキャストが必要 3448 3385 if j.get_rhs_cell.get_celltype == self then 3449 3386 definition = j.get_definition … … 3455 3392 3456 3393 if j.get_rhs_subscript then 3457 # å³è¾ºé 3458 åã®å ´å(æé©åã¯ãªã) 3394 # 右辺配列の場合(最適化はない) 3459 3395 subscript = j.get_rhs_subscript 3460 3396 f.printf( " %s%d,\n", … … 3465 3401 3466 3402 else 3467 # å³è¾ºéé 3468 åã®å ´å */ 3403 # 右辺非配列の場合 */ 3469 3404 if ! port.is_skelton_useless? then 3470 3405 f.printf( " %s,\n", … … 3477 3412 end 3478 3413 else 3479 # optional ã§å¼ã³å£é 3480 åè¦ç´ ãåæåããã¦ããªã 3414 # optional で呼び口配列要素が初期化されていない 3481 3415 f.printf( " 0,\n" ) 3482 3416 end 3483 3417 # } 3484 3418 end 3485 # mikan cell ã® namespace æªå¯¾å¿ãJoin 㧠Cell ãªãã¸ã§ã¯ããå¼å½ã¦ããå¿ 3486 è¦ãã 3419 # mikan cell の namespace 未対応、Join で Cell オブジェクトを引当ておく必要あり 3487 3420 f.print "};\n" 3488 # dynamic ã®å¼ã³å£é 3489 å 3421 # dynamic の呼び口配列 3490 3422 if port.is_dynamic? && $ram_initializer then 3491 3423 f.printf( "struct %s * %s_%s[ #{length} ];\n", … … 3502 3434 end 3503 3435 3504 #=== CB ãåæåããããã°ã©ã ã®çæ3436 #=== CB を初期化するプログラムの生成 3505 3437 def gen_cell_cb_initialize_code f 3506 3438 if ! need_CB_initializer? … … 3534 3466 end 3535 3467 3536 # === CB/INIB ã®å¤ã§åæåãããå¤æ°ã®åºå3468 # === CB/INIB の外で初期化される変数の出力 3537 3469 def gen_cell_cb_out_init fs 3538 3470 3539 # ã»ã«ããªããã°ãåºåããªã3471 # セルがなければ、出力しない 3540 3472 if @n_cell_gen == 0 then 3541 3473 return … … 3544 3476 fs.each{ |r, f| f.printf( TECSMsg.get( :AVAI_comment ), "#_AVAI_#" ) } 3545 3477 3546 # attribute, var ã®ãã¤ã³ã¿åã®åç 3547 §ããé 3548 åãçæ 3478 # attribute, var のポインタ型の参照する配列を生成 3549 3479 @ordered_cell_list.each{ |c| 3550 3480 next if ! c.is_generate? … … 3556 3486 jl = c.get_join_list 3557 3487 3558 # attribute, var ã®ãã¤ã³ã¿å¤æ°ãé 3559 åã«ããåæåãããå ´åã®ãé 3560 åãåºå 3488 # attribute, var のポインタ変数が配列により初期化される場合の、配列を出力 3561 3489 av_list = ct.get_attribute_list + ct.get_var_list 3562 3490 if av_list.length != 0 then … … 3574 3502 3575 3503 if size then 3576 # å¼ãè©ä¾¡ãã(attribute, var ã«å«ã¾ããå¤æ°ãåç 3577 §å¯è½) 3504 # 式を評価する(attribute, var に含まれる変数を参照可能) 3578 3505 sz = size.eval_const( c.get_join_list, c.get_celltype.get_name_list ) 3579 # å¼ãçæããªãã (å¤æ°ãå«ã¾ãªãå½¢ã«ãã) ä¸å®å 3580 ¨ãªå½¢ã§ Token ãçæ (ã¨ã©ã¼çºçããªããã) 3506 # 式を生成しなおす (変数を含まない形にする) 不完全な形で Token を生成 (エラー発生しないから) 3581 3507 size = Expression.new( [:INTEGER_CONSTANT, Token.new(sz, nil, 0, 0)] ) 3582 3508 array_type = ArrayType.new( size ) … … 3592 3518 # name_array[3]: cell_CB_INIT 3593 3519 if !( $ram_initializer && a.get_kind == :VAR ) then 3594 # -R (ram initializer 使ç¨) ã®å ´å var ã¯åæåã³ã¼ããåºåããªã3520 # -R (ram initializer 使用) の場合 var は初期化コードを出力しない 3595 3521 if( init )then 3596 3522 str = " = #{gen_cell_cb_init( f, c, name_array, array_type, init, a.get_identifier, 1, true )}" … … 3610 3536 end 3611 3537 3612 #=== var ã®åæå¤ã® ROM é¨ã¸ã®3538 #=== var の初期値の ROM 部への 3613 3539 def gen_cell_var_init f 3614 # var ã®{ }ã§å²ã¾ããåæå¤æå®ãããã調ã¹ã3540 # var の{ }で囲まれた初期値指定があるか調べる 3615 3541 n_init = 0 3616 3542 @var.each { |v| … … 3630 3556 3631 3557 if( org_type.kind_of? PtrType )then 3632 # PtrType 㯠ArrayType ã«ããæ¿ãã3633 3634 # åæååã®è¦ç´ æ°ã ãã¨ããï¼å¾ã¯0)3558 # PtrType は ArrayType にすり替える 3559 3560 # 初期化子の要素数だけとする(後は 0) 3635 3561 t2 = ArrayType.new( Expression.create_integer_constant( init.length, nil ) ) 3636 3562 t2.set_type( type.get_type ) … … 3639 3565 end 3640 3566 3641 c = @ordered_cell_list[0] # 仮㮠cell (å®éã«ã¯ä½¿ãããªã)3567 c = @ordered_cell_list[0] # 仮の cell (実際には使われない) 3642 3568 name_array = get_name_array( c ) 3643 3569 # f.print "const #{type0.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type0.get_type_str_post} = " 3644 3570 f.print "const #{type.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type.get_type_str_post} = " 3645 3571 if org_type.kind_of? StructType then 3646 # celltype ã® default ã®åæå¤ãã3572 # celltype の default の初期値あり 3647 3573 str = gen_cell_cb_init( f, c, name_array, type, init, v.get_identifier, 1, true ) 3648 3574 elsif( org_type.kind_of?( PtrType ) || org_type.kind_of?( ArrayType ) ) then 3649 3575 str = "{ " 3650 3576 type = org_type.get_type 3651 # mikan ãã¤ã³ã¿ã§ã¯ãªããé 3652 ååã¨ããªãã¨ããã¤ã³ã¿å¤æ°ã®é åã®åãæãã 3577 # mikan ポインタではなく、配列型としないと、ポインタ変数の領域の分、損する 3653 3578 init.each { |i| 3654 3579 str += gen_cell_cb_init( f, c, name_array, type, i, v.get_identifier, 1, true ) … … 3707 3632 3708 3633 unless @singleton then 3709 # 1 ã¤ã® cell INIB ã®çµãã3634 # 1 つの cell INIB の終わり 3710 3635 if @b_need_ptab then 3711 3636 f.print( "};\n\n" ) … … 3725 3650 end 3726 3651 3727 # RAM initializer ã使ç¨ããªããã¾ã㯠ROM åããªã3652 # RAM initializer を使用しない、または ROM 化しない 3728 3653 if $ram_initializer == false || $rom == false then 3729 3654 if @singleton then … … 3772 3697 3773 3698 unless @singleton then 3774 # 1 ã¤ã® cell CB ã®çµãã3699 # 1 つの cell CB の終わり 3775 3700 if @b_need_ptab then 3776 3701 f.print( "};\n\n" ) … … 3810 3735 f.print "/* ID to INIB table #_INTAB_# */\n" 3811 3736 @ordered_cell_list.each{ |c| 3812 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # çæ対象ãã¤ãã«ã¼ã以å¤ã3737 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # 生成対象かつ、ルート以外か 3813 3738 name_array = get_name_array( c ) 3814 3739 print_indent( f, indent + 1 ) … … 3819 3744 f.print "#{@global_name}_INIB *const #{@global_name}_INIB_ptab[] ={\n" 3820 3745 @ordered_cell_list.each{ |c| 3821 if c.is_generate? then # çæ対象ãï¼3746 if c.is_generate? then # 生成対象か? 3822 3747 name_array = get_name_array( c ) 3823 3748 print_indent( f, indent + 1 ) … … 3830 3755 f.print "/* ID to CB table #_CBTAB_# */\n" 3831 3756 @ordered_cell_list.each{ |c| 3832 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # çæ対象ãã¤ãã«ã¼ã以å¤ã3757 if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # 生成対象かつ、ルート以外か 3833 3758 name_array = get_name_array( c ) 3834 3759 print_indent( f, indent + 1 ) … … 3839 3764 f.print "#{@global_name}_CB *const #{@global_name}_CB_ptab[] ={\n" 3840 3765 @ordered_cell_list.each{ |c| 3841 if c.is_generate? then # çæ対象ãï¼3766 if c.is_generate? then # 生成対象か? 3842 3767 name_array = get_name_array( c ) 3843 3768 print_indent( f, indent + 1 ) … … 3851 3776 3852 3777 3853 #=== name_array ãçæ3778 #=== name_array を生成 3854 3779 # IN: cell : Cell 3855 # index : CB, INIB é 3856 åã®æ·»æ° 3780 # index : CB, INIB 配列の添数 3857 3781 # RETURN: name_array 3858 3782 # name_array[0] = @name # celltype name 3859 3783 # name_array[1] = cell.get_name # cell name 3860 3784 # name_array[2] = cell_CB_name # cell_CB_name 3861 # name_array[3] = cell_CB_INIT # cell_CB_INIT # CB ã®å¤å´ã§åæåãå¿ 3862 è¦ãªé 3863 åã®åå 3785 # name_array[3] = cell_CB_INIT # cell_CB_INIT # CB の外側で初期化が必要な配列の名前 3864 3786 # name_array[4] = cell_CB_proto # CB name for prototype 3865 3787 # name_array[5] = cell_INIB # INIB name … … 3903 3825 cell_CBP = "&#{cell_INIB_name}" 3904 3826 else 3905 cell_CBP = "NULL" # CB ã INIB ããªããã° NULL ã«ç½®æ3827 cell_CBP = "NULL" # CB も INIB もなければ NULL に置換 3906 3828 end 3907 3829 … … 3929 3851 end 3930 3852 3931 #=== attribute 㨠size_is æå®ããã var (ãã¤ã³ã¿)ã®åæåãã¼ã¿ãåºå3853 #=== attribute と size_is 指定された var (ポインタ)の初期化データを出力 3932 3854 # 3933 # ROM åãµãã¼ãã®æç¡ãããã³åºå対象ã CB ã INIB ãã«ããåºåãããå 3934 容ãç°ãªã 3855 # ROM 化サポートの有無、および出力対象が CB か INIB かにより出力される内容が異なる 3935 3856 def gen_cell_cb_attribute( cell, indent, f, name_array, cb_inib ) 3936 3857 ct = self … … 3942 3863 f.print "/* attribute(RO) */ \n" 3943 3864 elsif $rom then # && cb_inib == CB 3944 # CB 㧠rw ã¨var3865 # CB で rw と var 3945 3866 return if @n_attribute_rw == 0 3946 3867 print_indent( f, indent + 1 ) 3947 3868 f.print "/* attribute(RW) */ \n" 3948 3869 else # cb_inib == CB && $rom == false 3949 # CB ã«å 3950 ¨é¨ 3870 # CB に全部 3951 3871 return if @n_attribute_rw == 0 && @n_attribute_ro == 0 && @n_var_size_is == 0 3952 3872 print_indent( f, indent + 1 ) … … 3958 3878 next if a.is_omit? 3959 3879 if cb_inib == :INIB && a.is_rw? == true then 3960 # $rom == true ã§ãããããã¸æ¥ãªã3880 # $rom == true でしか、ここへ来ない 3961 3881 next 3962 3882 elsif cb_inib == :CB && $rom && ! a.is_rw? then … … 3966 3886 j = jl.get_item( a.get_identifier ) 3967 3887 if j then 3968 # cell ã®åæå¤æå®ãã3888 # cell の初期値指定あり 3969 3889 gen_cell_cb_init( f, cell, name_array, a.get_type, j.get_rhs, a.get_identifier, indent + 1 ) 3970 3890 elsif a.get_initializer then 3971 # celltype ã® default ã®åæå¤ãã3891 # celltype の default の初期値あり 3972 3892 gen_cell_cb_init( f, cell, name_array, a.get_type, a.get_initializer, a.get_identifier, indent + 1 ) 3973 3893 else 3974 # åæå¤æªæå®3894 # 初期値未指定 3975 3895 gen_cell_cb_init( f, cell, name_array, a.get_type, nil, a.get_identifier, indent + 1 ) 3976 3896 end … … 3978 3898 @var.each{ |v| 3979 3899 next if v.is_omit? 3980 next if v.get_size_is == nil # size_is æå®ãããå ´å attribute ã®ä¸é¨ã¨ãã¦åºå3900 next if v.get_size_is == nil # size_is 指定がある場合 attribute の一部として出力 3981 3901 3982 3902 if v.get_initializer && $ram_initializer == false then 3983 3903 gen_cell_cb_init( f, cell, name_array, v.get_type, v.get_initializer, v.get_identifier, indent + 1 ) 3984 3904 else 3985 # åæå¤æªæå® ã¾ã㯠RAM initializer 使ç¨3905 # 初期値未指定 または RAM initializer 使用 3986 3906 gen_cell_cb_init( f, cell, name_array, v.get_type, nil, v.get_identifier, indent + 1 ) 3987 3907 end … … 3989 3909 end 3990 3910 3991 #=== var ã®åæåãã¼ã¿ãåºå3911 #=== var の初期化データを出力 3992 3912 def gen_cell_cb_var( cell, indent, f, name_array ) 3993 3913 jl = cell.get_join_list … … 3999 3919 4000 3920 next if v.is_omit? 4001 next if v.get_size_is # size_is æå®ãããå ´å attribute ã®ä¸é¨ã¨ãã¦åºå3921 next if v.get_size_is # size_is 指定がある場合 attribute の一部として出力 4002 3922 4003 3923 if v.get_initializer && $ram_initializer == false then 4004 3924 gen_cell_cb_init( f, cell, name_array, v.get_type, v.get_initializer, v.get_identifier, indent + 1 ) 4005 3925 else 4006 # åæå¤æªæå® ã¾ã㯠RAM initializer 使ç¨3926 # 初期値未指定 または RAM initializer 使用 4007 3927 gen_cell_cb_init( f, cell, name_array, v.get_type, nil, v.get_identifier, indent + 1 ) 4008 3928 end … … 4017 3937 end 4018 3938 4019 #=== å¼ã³å£ã®åæåã³ã¼ãã®çæ3939 #=== 呼び口の初期化コードの生成 4020 3940 def gen_cell_cb_call_port( cell, indent, f, name_array, inib_cb ) 4021 3941 jl = cell.get_join_list … … 4031 3951 next if p.get_port_type != :CALL 4032 3952 next if p.is_omit? 4033 next if p.is_cell_unique? # æé©åï¼åä¸ã»ã«ã§å¼ã³å£ãã¯ãã«åãè¾¼ã¾ããï¼3953 next if p.is_cell_unique? # 最適化(単一セルで呼び口マクロに埋め込まれる) 4034 3954 next if inib_cb == :INIB && p.is_dynamic? && p.get_array_size == nil && ! $ram_initializer 4035 3955 next if inib_cb == :CB_DYNAMIC && ( ! p.is_dynamic? || p.get_array_size != nil ) … … 4041 3961 if j == nil then 4042 3962 dbgPrint "cell_cb_call_port: #{p.get_name} array size=#{p.get_array_size}\n" 4043 # optional å¼ã³å£3963 # optional 呼び口 4044 3964 # cdl_error( "H1003 internal error: cell \'$1\' port \'$2\': initializer not found\n" , cell.get_name, p.get_name ) 4045 3965 # exit( 1 ) … … 4059 3979 end 4060 3980 if p.get_array_size == "[]" then 4061 # æ·»æ°çç¥ã®å¼ã³å£é 4062 å 3981 # 添数省略の呼び口配列 4063 3982 print_indent( f, indent + 1 ) 4064 3983 f.printf( "%-40s /* %s #_CCP6_# */\n", "0,", "length of #{p.get_name} (n_#{p.get_name})" ) … … 4072 3991 am = j.get_array_member2 4073 3992 if am then 4074 # å¼ã³å£é 4075 åã®å ´å 3993 # 呼び口配列の場合 4076 3994 if inib_cb == :INIB && p.is_dynamic? && p.get_array_size != nil && $ram_initializer then 4077 3995 f.printf( "%-40s /* #_CCP3_# _init_ */\n", "#{cell.get_global_name}_#{j.get_name}_init_," ) … … 4080 3998 f.printf( "%-40s /* #_CCP3B_# */\n", "#{cell.get_global_name}_#{j.get_name}," ) 4081 3999 if p.get_array_size == "[]" then 4082 # æ·»æ°çç¥ã®å¼ã³å£é 4083 å 4000 # 添数省略の呼び口配列 4084 4001 print_indent( f, indent + 1 ) 4085 4002 f.printf( "%-40s /* %s #_CCP4_# */\n", "#{am.length},", "length of #{p.get_name} (n_#{p.get_name})" ) 4086 4003 end 4087 4004 else 4088 # åä¸ã»ã«ã¿ã¤ãã®çµåã®å ´åãVDES åã¸ã®ãã£ã¹ããå¿ 4089 è¦ 4005 # 同一セルタイプの結合の場合、VDES 型へのキャストが必要 4090 4006 #print "CCP0/CCP1 #{p.get_name}, #{j.get_rhs_cell.get_celltype.get_name}, #{@name}\n" 4091 4007 if j.get_rhs_cell.get_celltype == self then … … 4099 4015 4100 4016 if j.get_rhs_subscript then 4101 # åãå£é 4102 åã®å ´å 4017 # 受け口配列の場合 4103 4018 subscript = j.get_rhs_subscript 4104 4019 f.printf( "%-40s /* %s #_CCP0_# */\n", … … 4107 4022 p.get_name.to_s + init ) 4108 4023 else 4109 # å¼ã³å£é 4110 åã§ããåãå£é 4111 åã§ããªã 4024 # 呼び口配列でも、受け口配列でもない 4112 4025 if ! p.is_skelton_useless? then 4113 4026 f.printf( "%-40s /* %s #_CCP1_# */\n", … … 4115 4028 p.get_name.to_s + init ) 4116 4029 else 4117 # ã¹ã±ã«ãã³ä¸è¦æé©åï¼CB (INIB) ã¸ã®ãã¤ã³ã¿ãåãè¾¼ãï¼ 4118 c = j.get_rhs_cell # å¼ã³å 4119 ã»ã« 4120 ct = c.get_celltype # å¼ã³å 4121 ã»ã«ã¿ã¤ã 4122 name_array = ct.get_name_array( c ) # å¼ã³å 4123 ã»ã«ã¿ã¤ã㧠name_array ãå¾ã 4030 # スケルトン不要最適化(CB (INIB) へのポインタを埋め込む) 4031 c = j.get_rhs_cell # 呼び先セル 4032 ct = c.get_celltype # 呼び先セルタイプ 4033 name_array = ct.get_name_array( c ) # 呼び先セルタイプで name_array を得る 4124 4034 if ct.has_INIB? || ct.has_CB? then 4125 4035 f.printf( "%-40s /* %s #_CCP2_# */\n", "#{name_array[7]},", p.get_name ) 4126 4036 else 4127 # å¼ã³å 4128 㯠CB ã INIB ãæããªãï¼NULL ã«åæåï¼ 4037 # 呼び先は CB も INIB も持たない(NULL に初期化) 4129 4038 f.printf( "%-40s /* %s #_CCP2B_# */\n", "0,", p.get_name ) 4130 4039 end … … 4137 4046 end 4138 4047 4139 #=== åãå£ã®åæåã³ã¼ãã®çæ4048 #=== 受け口の初期化コードの生成 4140 4049 def gen_cell_cb_entry_port( cell, indent, f, name_array ) 4141 4050 jl = cell.get_join_list … … 4146 4055 f.print "/* entry port #_EP_# */ \n" 4147 4056 @port.each{ |p| 4148 # next if p.is_omit? # åãå£é 4149 åã®åæ°ã¯çç¥ããªã 4057 # next if p.is_omit? # 受け口配列の個数は省略しない 4150 4058 if p.get_port_type == :ENTRY && p.get_array_size == "[]" 4151 4059 print_indent( f, indent + 1 ) … … 4156 4064 end 4157 4065 4158 #=== ã»ã«ã® attribute ã®åæå¤ãåºå4066 #=== セルの attribute の初期値を出力 4159 4067 # 4160 #f_get_str:: true ã®å ´åãæååãè¿ããfalse ã®å ´åããã¡ã¤ã« f ã«åºåããï¼ 4161 # æååãè¿ãã¨ããæ«å°¾ã« ',' ã¯å«ã¾ããªãï¼ 4162 # ãã¡ã¤ã«ã¸åºåããã¨ããæ«å°¾ã« ',' ãåºåãããï¼æ§é ä½è¦ç´ ãé 4163 åè¦ç´ ã®åæå¤ãåºåãã㨠',' ãäºéã«åºåãããï¼ 4164 # ãã ãç¾ç¶ã§ã¯ããã¡ã¤ã«ã¸åºåãããã¨ã¯ãªã 4068 #f_get_str:: true の場合、文字列を返す、false の場合、ファイル f に出力する. 4069 # 文字列を返すとき、末尾に ',' は含まれない. 4070 # ファイルへ出力するとき、末尾に ',' が出力される.構造体要素、配列要素の初期値を出力すると ',' が二重に出力される. 4071 # ただし現状では、ファイルへ出力することはない 4165 4072 # 4166 4073 def gen_cell_cb_init( f, cell, name_array, type, init, identifier, indent, f_get_str = false ) … … 4176 4083 4177 4084 if f_get_str then 4178 # åæå¤æªæå®4085 # 初期値未指定 4179 4086 if type.kind_of?( BoolType ) then 4180 4087 str = "false" # formerly tecs_false … … 4200 4107 return str 4201 4108 else 4202 # åæå¤æªæå®4109 # 初期値未指定 4203 4110 if type.kind_of?( BoolType ) then 4204 4111 f.print " " * indent … … 4234 4141 end 4235 4142 4236 # ãã®ã¡ã½ãã㯠Celltype ã®ãã®ã§ããå¿ 4237 è¦ã¯ç¡ãï¼ä¸ã«ç¶ãã®ã§ããã«ç½®ãï¼ 4238 # åæå¤æå®ãã 4143 # このメソッドは Celltype のものである必要は無い(上に続くのでここに置く) 4144 # 初期値指定あり 4239 4145 if type.kind_of?( BoolType ) then 4240 4146 if init.instance_of?( C_EXP ) then … … 4302 4208 4303 4209 len.times { 4304 next if ! init[i] # mikan ãã®å¦ç½®ã¯é©åï¼4210 next if ! init[i] # mikan この処置は適切? 4305 4211 if f_get_str then 4306 4212 str += gen_cell_cb_init( f, cell, name_array, at, init[i], "#{identifier}[#{i}]", indent + 1, f_get_str ) … … 4384 4290 end 4385 4291 4386 #== é¢æ°ãã¼ãã«ã®å¤é¨åç 4387 § 4292 #== 関数テーブルの外部参照 4388 4293 def gen_cell_extern_mt fs 4389 4294 fs.each{ |r, f| … … 4400 4305 end 4401 4306 4402 #=== åãå£ãã£ã¹ã¯ãªãã¿ã®å®ç¾©ãçæ4307 #=== 受け口ディスクリプタの定義を生成 4403 4308 def gen_cell_ep_des fs 4404 4309 if @n_cell_gen >0 then … … 4413 4318 f = fs[ c.get_region.get_domain_root ] 4414 4319 4415 ct = c.get_celltype # ct = self ã§ãåã4320 ct = c.get_celltype # ct = self でも同じ 4416 4321 jl = c.get_join_list 4417 4322 name_array = get_name_array( c ) … … 4422 4327 next if p.get_port_type != :ENTRY 4423 4328 next if p.is_omit? 4424 if p.is_skelton_useless? # åãå£æé©ån ep_opt4329 if p.is_skelton_useless? # 受け口最適化n ep_opt 4425 4330 f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" ) 4426 4331 next … … 4433 4338 4434 4339 if len != nil then 4435 # åãå£é 4436 åã®å ´å 4340 # 受け口配列の場合 4437 4341 i = 0 4438 4342 while i < len … … 4519 4423 return if @b_reuse && ! $generate_all_template 4520 4424 if ! ( @plugin && @plugin.gen_ep_func? ) then 4521 return if $generate_no_template # $generate_all_template ããåªå 4522 ããã 4523 4524 # åèã¨ãã¦åºåãããã³ãã¬ã¼ããã¡ã¤ã«ã§ãããã¨ã示ãããã« "_templ" ãä»å ãã 4425 return if $generate_no_template # $generate_all_template より優先される 4426 4427 # 参考として出力するテンプレートファイルであることを示すために "_templ" を付加する 4525 4428 fname = "#{$gen}/#{@global_name}_templ.#{$c_suffix}" 4526 4429 else 4527 # Plugin ã«ããçæãããã»ã«ã¿ã¤ãã«ã¤ãã¦ã¯ãååçã«ãã³ãã¬ã¼ãã§ã¯ãªãã 4528 # ä¿®æ£ä¸è¦ãªã»ã«ã¿ã¤ãã®å®è£ 4529 ã³ã¼ããçæããï¼ 4530 # ãã®ããããã¡ã¤ã«åã« _temp ãä»å ããªã 4430 # Plugin により生成されたセルタイプについては、原則的にテンプレートではなく、 4431 # 修正不要なセルタイプの実装コードを生成する. 4432 # このため、ファイル名に _temp を付加しない 4531 4433 fname = "#{$gen}/#{@global_name}.#{$c_suffix}" 4532 4434 end … … 4543 4445 gen_template_attr_access f 4544 4446 gen_template_cp_fun f 4545 # gen_template_types f # 0805503 追å ãã¦ã¿ããããã£ã±ãããã4447 # gen_template_types f # 0805503 追加してみたが、やっぱりやめる 4546 4448 f.print( " *\n * #[</PREAMBLE>]# */\n\n" ) 4547 4449 f.printf TECSMsg.get( :PAC_comment ), "#_PAC_#" … … 4549 4451 gen_template_private_header f 4550 4452 if ( @plugin ) then 4551 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4453 # このメソッドの引数は plugin.rb の説明を見よ 4552 4454 @plugin.gen_preamble( f, @singleton, @name, @global_name ) 4553 4455 end … … 4558 4460 4559 4461 if ( @plugin ) then 4560 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4462 # このメソッドの引数は plugin.rb の説明を見よ 4561 4463 @plugin.gen_postamble( f, @singleton, @name, @global_name ) 4562 4464 end … … 4740 4642 next if p.get_port_type != :ENTRY 4741 4643 next if p.is_omit? 4742 next if b_inline && ! p.is_inline? # inline ãã¼ã4743 next if ! b_inline && p.is_inline? # é inline ãã¼ã4644 next if b_inline && ! p.is_inline? # inline ポート 4645 next if ! b_inline && p.is_inline? # 非 inline ポート 4744 4646 4745 4647 inline_prefix = "" … … 4798 4700 len = items.length 4799 4701 else 4800 # ãã㧠nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å4702 # ここで nil になるのは、引数なしの時に void がなかった場合 4801 4703 items = [] 4802 4704 len = 0 … … 4819 4721 4820 4722 if ( @plugin && @plugin.gen_ep_func? ) then 4821 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4723 # このメソッドの引数は plugin.rb の説明を見よ 4822 4724 @plugin.gen_ep_func_body( f, @singleton, @name, @global_name, p.get_signature.get_global_name, p.get_name, fun.get_name, "#{@global_name}_#{p.get_name}_#{fun.get_name}", functype, items ) 4823 4725 … … 4867 4769 if ! ( @plugin && @plugin.gen_ep_func? ) then 4868 4770 return if @b_reuse && ! $generate_all_template 4869 return if $generate_no_template # $generate_all_template ããåªå 4870 ããã 4871 4872 # åèã¨ãã¦åºåãããã³ãã¬ã¼ããã¡ã¤ã«ã§ãããã¨ã示ãããã« "_templ" ãä»å ãã 4771 return if $generate_no_template # $generate_all_template より優先される 4772 4773 # 参考として出力するテンプレートファイルであることを示すために "_templ" を付加する 4873 4774 fname = "#{$gen}/#{@global_name}_inline_templ.#{$h_suffix}" 4874 4775 else 4875 # Plugin ã«ããçæãããã»ã«ã¿ã¤ãã«ã¤ãã¦ã¯ãååçã«ãã³ãã¬ã¼ãã§ã¯ãªãã 4876 # ä¿®æ£ä¸è¦ãªã»ã«ã¿ã¤ãã®å®è£ 4877 ã³ã¼ããçæããï¼ 4878 # ãã®ããããã¡ã¤ã«åã« _temp ãä»å ããªã 4776 # Plugin により生成されたセルタイプについては、原則的にテンプレートではなく、 4777 # 修正不要なセルタイプの実装コードを生成する. 4778 # このため、ファイル名に _temp を付加しない 4879 4779 fname = "#{$gen}/#{@global_name}_inline.#{$h_suffix}" 4880 4780 end … … 4899 4799 4900 4800 if ( @plugin ) then 4901 # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã4801 # このメソッドの引数は plugin.rb の説明を見よ 4902 4802 @plugin.gen_postamble( f, @singleton, @name, @global_name ) 4903 4803 end … … 4916 4816 if fa.get_name == :write then 4917 4817 4918 # åå¾ã® " ãåãé¤ã4818 # 前後の " を取り除く 4919 4819 # file_name = fa.get_file_name.sub( /^\"(.*)\"$/, "\\1" ) 4920 4820 file_name = CDLString.remove_dquote fa.get_file_name 4921 4821 format = CDLString.remove_dquote fa.get_format 4922 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # åã® " ãåãé¤ã4923 # format = format.sub( /(.*)\"\z/, "\\1" ) # å¾ã® " ãåãé¤ã4822 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # 前の " を取り除く 4823 # format = format.sub( /(.*)\"\z/, "\\1" ) # 後の " を取り除く 4924 4824 format = format.gsub( /\\\n/, "\n" ) # \\\n => \n 4925 4825 4926 4826 4927 # mikan 以ä¸ã¯ subst_name ã§ç½®æããããã«å¤æ´ãã¹ã4928 file_name = file_name.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4929 file_name = file_name.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4930 format = format.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4931 format = format.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ4932 format = format.gsub( /\$\$/, "\$" ) # $$ ã $ ã«ç½®æ4827 # mikan 以下は subst_name で置換するように変更すべき 4828 file_name = file_name.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ をセルタイプ名に置換 4829 file_name = file_name.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ をセルタイプ名に置換 4830 format = format.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" ) # $ct$ をセルタイプ名に置換 4831 format = format.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" ) # $ct$ をセルタイプ名に置換 4832 format = format.gsub( /\$\$/, "\$" ) # $$ を $ に置換 4933 4833 4934 4834 if file_name[0] != ?/ then … … 4942 4842 puts( format ) 4943 4843 end 4944 # format ä¸ã® \n, \r, \t, \f 㨠\" ãªã©ãç½®æ4844 # format 中の \n, \r, \t, \f と \" などを置換 4945 4845 fmt = CDLString.escape format 4946 4846 cfg_file.print( fmt ) … … 4959 4859 @ordered_cell_list.each{ |c| 4960 4860 4961 # cell ã®ãããã¿ã¤ã宣è¨ãªãç¡è¦4861 # cell のプロトタイプ宣言なら無視 4962 4862 next if ! c.is_generate? 4963 4863 … … 4968 4868 if fa.get_name == :write then 4969 4869 4970 # åå¾ã® " ãåãé¤ã4870 # 前後の " を取り除く 4971 4871 # file_name = fa.get_file_name.sub( /^\"(.*)\"$/, "\\1" ) 4972 4872 file_name = CDLString.remove_dquote fa.get_file_name 4973 4873 file_name = subst_name( file_name, name_array ) 4974 # format = fa.get_format.sub( /^\"(.*)\"$/, "\\1" ) # åå¾ã® "" ãåãé¤ã4874 # format = fa.get_format.sub( /^\"(.*)\"$/, "\\1" ) # 前後の "" を取り除く 4975 4875 format = CDLString.remove_dquote fa.get_format 4976 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # åã® " ãåãé¤ã4977 # format = format.sub( /(.*)\"\z/, "\\1" ) # å¾ã® " ãåãé¤ã4876 # format = fa.get_format.sub( /^\"(.*)/, "\\1" ) # 前の " を取り除く 4877 # format = format.sub( /(.*)\"\z/, "\\1" ) # 後の " を取り除く 4978 4878 format = format.gsub( /\\\n/, "\n" ) # \\\n => \n 4979 4879 … … 4986 4886 end 4987 4887 4988 na = [] # ã·ã³ãã«ã attribute ã®å¤ã«ç½®ãæããå¾ã®å¼æ°4888 na = [] # シンボルを attribute の値に置き換えた後の引数 4989 4889 if arg_list then 4990 4890 arg_list.each { |a| 4991 4891 case a[0] 4992 when :STRING_LITERAL # æååå®æ°4993 # s = a[1].sub( /^\"(.*)\"$/, "\\1" ) # åå¾ã® "" ãåãé¤ã4892 when :STRING_LITERAL # 文字列定数 4893 # s = a[1].sub( /^\"(.*)\"$/, "\\1" ) # 前後の "" を取り除く 4994 4894 s = CDLString.remove_dquote a[1] 4995 4895 s = subst_name( s, name_array ) … … 4998 4898 na << s 4999 4899 when :IDENTIFIER 5000 param_name = a[1] # èå¥åï¼å±æ§ã®ååï¼4900 param_name = a[1] # 識別子(属性の名前) 5001 4901 attr = self.find( param_name ) 5002 init = attr.get_initializer # celltype ã§æå®ãããåæå¤5003 5004 # cell ã® join ã®ãªã¹ãããååãæ¢ã4902 init = attr.get_initializer # celltype で指定された初期値 4903 4904 # cell の join のリストから名前を探す 5005 4905 j = c.get_join_list.get_item( param_name ) 5006 if j then # param_name ã® cell ã®ã¸ã§ã¤ã³ãããã 5007 init = j.get_rhs # cell ã§æå®ãããåæå¤ãåªå 5008 4906 if j then # param_name の cell のジョインがあるか 4907 init = j.get_rhs # cell で指定された初期値を優先 5009 4908 end 5010 4909 … … 5012 4911 # file,cell, name_array, type, init, identifier, indent, f_get_str 5013 4912 5014 # str = str.sub( /^\"(.*)\"$/, "\\1" ) # åå¾ã® "" ãåãé¤ã mikan ããã§ç½®æã§ããï¼4913 # str = str.sub( /^\"(.*)\"$/, "\\1" ) # 前後の "" を取り除く mikan ここで置換でよい? 5015 4914 str = CDLString.remove_dquote str 5016 4915 na << str … … 5030 4929 end 5031 4930 5032 # format ä¸ã® \n, \r, \t, \f 㨠\" ãªã©ãç½®æ4931 # format 中の \n, \r, \t, \f と \" などを置換 5033 4932 fmt = CDLString.escape format 5034 4933 cfg_file.printf( fmt, *na ) … … 5054 4953 return if $generate_no_template 5055 4954 5056 # Makefile.templ ã®çæï¼è¿½è¨ï¼4955 # Makefile.templ の生成(追記) 5057 4956 5058 4957 f = AppFile.open( "#{$gen}/Makefile.templ" ) … … 5062 4961 5063 4962 EOT 5064 # ãã®çæè¦åã¯2ç¹ã§æå³ããªã5065 # ã»$(GEN_DIR) ã« .o ãçæããã«ã¼ã«ããªã5066 # ã»ãã³ãã¬ã¼ãã³ã¼ãããã®ã¾ã¾ãã«ãããã®ã¯ç´ãããã4963 # この生成規則は2点で意味がない 4964 # ・$(GEN_DIR) に .o を生成するルールがない 4965 # ・テンプレートコードをそのままビルドするのは紛らわしい 5067 4966 # # Celltype: #{@name} 5068 4967 # $(GEN_DIR)/#{@global_name}_tecsgen.o : $(GEN_DIR)/#{@global_name}_tecsgen.#{$c_suffix} … … 5081 4980 headers = [ "$(GEN_DIR)/#{@global_name}_tecsgen.#{$h_suffix}", "$(GEN_DIR)/#{@global_name}_factory.#{$h_suffix}", "$(GEN_DIR)/global_tecsgen.#{$h_suffix}" ] 5082 4981 5083 # inline åãå£ãæã¤ãï¼4982 # inline 受け口を持つか? 5084 4983 if @n_entry_port_inline > 0 then 5085 4984 headers << "#{@global_name}_inline.#{$h_suffix}" 5086 4985 end 5087 4986 5088 # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®ããã4987 # 呼び口または受け口のシグニチャのヘッダ 5089 4988 @port.each { |p| 5090 4989 next if p.is_omit? … … 5111 5010 end 5112 5011 5113 #=== decl ç¨ã® dealloc ã³ã¼ããçæ 5114 #b_reset:: Bool: ãªã»ããç¨ã® dealloc ã³ã¼ãã®çæ (NULL ãã¤ã³ã¿ã®å ´å dealloc ããªã) 5115 # mikan string 修飾ããããã¤ã³ã¿ã®å 5116 ã«ãã¤ã³ã¿ãæ¥ãªãã¨ä»®å®ããã¤ã³ã¿åãæã¤æ§é ä½ã®å¯è½æ§ãæé¤ãã¦ããªã 5117 # ãã®ã¡ã½ããã§ã¯ãè¡ãåºåããç´åã« " \\\n" ãåºåããè¡æ«ã§æ¹è¡æåãåºåããªã 5012 #=== decl 用の dealloc コードを生成 5013 #b_reset:: Bool: リセット用の dealloc コードの生成 (NULL ポインタの場合 dealloc しない) 5014 # mikan string 修飾されたポインタの先にポインタが来ないと仮定。ポインタ型を持つ構造体の可能性を排除していない 5015 # このメソッドでは、行を出力する直前に " \\\n" を出力し、行末で改行文字を出力しない 5118 5016 def gen_dealloc_code_for_type( f, type, dealloc_func_name, pre, name, post, level, b_reset, count_str = nil ) 5119 5017 type = type.get_original_type … … 5144 5042 post2 = "" 5145 5043 type2 = md.get_type.get_original_type 5146 if type2.kind_of? PtrType then # mikan typedef ãããå5044 if type2.kind_of? PtrType then # mikan typedef された型 5147 5045 if type2.get_count then 5148 5046 count_str = type2.get_count.to_str( members_decl, pre2, post2 ) … … 5217 5115 end 5218 5116 5219 # å¼ã³å£ã®çµåå 5220 ã®ã»ã«ã¿ã¤ãã®ãããï¼æé©åã®å ´åã®ã¿ï¼ 5221 # çµåå 5222 ã®åãå£ã inline ã®å ´åãinline ãããã 5117 # 呼び口の結合先のセルタイプのヘッダ(最適化の場合のみ) 5118 # 結合先の受け口が inline の場合、inline ヘッダも 5223 5119 @port.each { |p| 5224 5120 next if p.get_port_type != :CALL … … 5226 5122 5227 5123 if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then 5228 # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©5124 # 最適化コード (optimize) # スケルトン不要など 5229 5125 p2 = p.get_real_callee_port 5230 5126 if p2 then … … 5236 5132 headers += ct.get_depend_header_list_( celltype_list ) 5237 5133 #else 5238 # optional ã§æªçµå5134 # optional で未結合 5239 5135 end 5240 5136 end … … 5244 5140 5245 5141 5246 #=== $id$, $ct$, $cb$, $idx$ ç½®æ5142 #=== $id$, $ct$, $cb$, $idx$ 置換 5247 5143 # 5248 # str ã«ä»¥ä¸ã®ç½®æãè¡ã5249 #- $ct$ â ã»ã«ã¿ã¤ãå(ct)5250 #- $cell$ â ã»ã«å(cell) cell ã nil ãªãã°ä»¥ä¸ã®ç½®æã¯è¡ãããªã5251 #- $cb$ â CB ã® C è¨èªå(cb)5252 #- $cbp$ â CB ã¸ã®ãã¤ã³ã¿(cbp)5253 #- $cb_proto$ â CB ã® C è¨èªåãããã¿ã¤ã宣è¨ç¨(cb_proto)5254 #- $id$ â$ct$_$cell_global$ # ct_cell before or same V1.5.25255 #- $idx$ âidx5256 #- $ID$ â id (æ´æ°ã®çªå·)5257 #- $ct_global$ â ã»ã«ã¿ã¤ãå(ct)5258 #- $cell_global$ â ã»ã«å(cell)5259 #- $$ â$5144 # str に以下の置換を行う 5145 #- $ct$ ⇒ セルタイプ名(ct) 5146 #- $cell$ ⇒ セル名(cell) cell が nil ならば以下の置換は行われない 5147 #- $cb$ ⇒ CB の C 言語名(cb) 5148 #- $cbp$ ⇒ CB へのポインタ(cbp) 5149 #- $cb_proto$ ⇒ CB の C 言語名プロトタイプ宣言用(cb_proto) 5150 #- $id$ ⇒ $ct$_$cell_global$ # ct_cell before or same V1.5.2 5151 #- $idx$ ⇒ idx 5152 #- $ID$ ⇒ id (整数の番号) 5153 #- $ct_global$ ⇒ セルタイプ名(ct) 5154 #- $cell_global$ ⇒ セル名(cell) 5155 #- $$ ⇒ $ 5260 5156 def subst_name( str, name_array ) 5261 5157 ct = name_array[0] # celltype name 5262 5158 cell = name_array[1] # cell name 5263 5159 cb = name_array[2] # cell CB name 5264 cb_init = name_array[3] # cell CB INIT, ããã¯ç½®æã«ä½¿ãããªã5160 cb_init = name_array[3] # cell CB INIT, これは置換に使われない 5265 5161 cb_proto = name_array[4] # cell CB name for prototype 5266 5162 id = name_array[6] # cell ID … … 5283 5179 str = str.gsub( /(^|[^\$])\$cell_global\$/, "\\1#{cell_global}" ) 5284 5180 end 5285 str = str.gsub( /\$\$/, "\$" ) # $$ ã $ ã«ç½®æ5181 str = str.gsub( /\$\$/, "\$" ) # $$ を $ に置換 5286 5182 5287 5183 return str … … 5290 5186 end 5291 5187 5292 # Appendable File ï¼è¿½è¨å¯è½ãã¡ã¤ã«ï¼5188 # Appendable File(追記可能ファイル) 5293 5189 class AppFile 5294 # éãããã¡ã¤ã«ã®ãªã¹ã5190 # 開いたファイルのリスト 5295 5191 @@file_name_list = {} 5296 5192 … … 5309 5205 end 5310 5206 5311 # æ¢ã«éãã¦ãããï¼5207 # 既に開いているか? 5312 5208 if @@file_name_list[ name ] then 5313 5209 #2.0 5314 5210 mode = "a" + mode 5315 # 追è¨ã¢ã¼ãã§éã5211 # 追記モードで開く 5316 5212 file = File.open( real_name, mode ) 5317 5213 else 5318 5214 #2.0 5319 5215 mode = "w" + mode 5320 # æ°è¦ã¢ã¼ãã§éãï¼æ¢ã«ããã°ããµã¤ãºãï¼ã«ããï¼5216 # 新規モードで開く(既にあれば、サイズを0にする) 5321 5217 file = File.open( real_name, mode ) 5322 5218 @@file_name_list[ name ] = true 5323 5219 end 5324 # File ã¯ã©ã¹ã®ãªãã¸ã§ã¯ããè¿ã5220 # File クラスのオブジェクトを返す 5325 5221 return file 5326 5222 end -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/location.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 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
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/messages.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ 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 ] … … 105 89 end 106 90 107 #=== TECSMsg#ãã¼ã«ã©ã¤ãºãããæ 108 å ±ã¡ãã»ã¼ã¸ãå¾ã 109 # Generator.info2 ããå¼ã³åºããã 91 #=== TECSMsg#ローカライズされた情報メッセージを得る 92 # Generator.info2 から呼び出される 110 93 def self.get_info_message( body ) 111 body =~ /^[A-Z0-9]+/ # æ 112 å ±çªå·ãåãåºã 94 body =~ /^[A-Z0-9]+/ # 情報番号を取り出す 113 95 num = $& 114 96 msg = @@info_message[ num.to_sym ] -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/optimize.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2018 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 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| … … 243 227 244 228 @domain_roots.each{ |dn, regions| 245 # domain_type ã¯ä¸ã¤ã®ãã¼ãã«ä¸ã¤ãããªãã®ã§ãä¸ã¤ã®è¦ç´ ãç¡æ¡ä»¶ã§åãåºã229 # domain_type は一つのノードに一つしかないので、一つの要素を無条件で取り出す 246 230 if regions.length > 1 then 247 231 if $verbose then … … 259 243 def optimize 260 244 261 # port ã®åç 262 §ããã»ã«ã¿ã¤ãã®æ°ãã»ã«ã®æ°ãæ±ãã 245 # port の参照するセルタイプの数、セルの数を求める 263 246 if $verbose then 264 247 print "=== optimizing celltype #{get_namespace_path.to_s} ===\n" … … 271 254 end 272 255 273 #=== Celltype# å¼ã³å£æé©å256 #=== Celltype#呼び口最適化 274 257 def optimize_call 275 258 @port.each{ |port| 276 259 next if port.get_port_type != :CALL 277 260 if port.is_omit? then 278 # å¼ã³å£æé©åå®æ½261 # 呼び口最適化実施 279 262 @b_cp_optimized = true 280 @n_call_port_omitted_in_CB += 1 # CB ã§çç¥ããå¼ã³å£281 port.set_skelton_useless # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©å282 port.set_VMT_useless # VMT ä¸è¦æé©å (ç´æ¥åãå£é¢æ°ãå¼åºã)263 @n_call_port_omitted_in_CB += 1 # CB で省略する呼び口 264 port.set_skelton_useless # スケルトン関数不要最適化 265 port.set_VMT_useless # VMT 不要最適化 (直接受け口関数を呼出す) 283 266 if $verbose then 284 267 print "optimized by omit: port: #{port.get_name} : o\n" … … 301 284 end 302 285 303 port_cells = [] # å¼ã³å 304 ã»ã« 305 port_ports = [] # å¼ã³å 306 ã®ãã¼ã 307 308 # ã»ã«ã®åç 309 §ããã»ã«ãéããï¼ãã¼ããä¸ç·ã«éããï¼ 286 port_cells = [] # 呼び先セル 287 port_ports = [] # 呼び先のポート 288 289 # セルの参照するセルを集める(ポートも一緒に集める) 310 290 @cell_list.each{ |cell| 311 291 … … 319 299 if j then 320 300 if j.get_array_member2 then 321 # å¼ã³å£é 322 åã®å ´åãå 323 ¨é¨ã®çµåå 324 ãéãã 301 # 呼び口配列の場合、全部の結合先を集める 325 302 j.get_array_member2.each { |j2| 326 303 if j2 then 327 304 port_cells << j2.get_rhs_cell 328 port_ports << j2.get_rhs_port # å³è¾ºã®ãã¼ã305 port_ports << j2.get_rhs_port # 右辺のポート 329 306 else 330 # optional ã§ãããæ·»æ°ã®ã¿åæåããã¦ããªãï¼ãã¹ã¦åæåãããªãå ´åã¯ãä¸ï¼307 # optional で、ある添数のみ初期化されていない(すべて初期化されない場合は、下) 331 308 port_cells << nil 332 309 port_ports << nil … … 334 311 } 335 312 else 336 # å 337 ¨ã¦ã®çµåå 338 ãéãã 313 # 全ての結合先を集める 339 314 port_cells << j.get_rhs_cell 340 port_ports << j.get_rhs_port # å³è¾ºã®ãã¼ã315 port_ports << j.get_rhs_port # 右辺のポート 341 316 end 342 317 else 343 # optional ã§åæåããã¦ããªãï¼nil ãè¦ç´ ã«å ãã¦ããï¼318 # optional で初期化されていない(nil を要素に加えておく) 344 319 port_cells << nil 345 port_ports << nil # å³è¾ºã®ãã¼ã320 port_ports << nil # 右辺のポート 346 321 end 347 322 } 348 323 349 # éè¤è¦ç´ ãåãé¤ã324 # 重複要素を取り除く 350 325 port_cells.uniq! 351 326 port_ports.uniq! 352 327 353 # å¼ã³å£ã®å¼ã³å 354 ãä¸ã¤ã®ãã¼ãã ããï¼ 328 # 呼び口の呼び先が一つのポートだけか? 355 329 if port_ports.length == 1 then 356 330 357 # å¼ã³å£é 358 åãå¯å¤é·ã®å ´åãæé©åããªã 359 # mikan å¼ã³å£é 360 åè¦ç´ æ°ãã¯ãä¸å 361 ·åæ«å®å¯¾ç 362 # ããæã¾ããä¿®æ£ã¯ãåãå£ã¸ã®ãã¤ã³ã¿ã¯çç¥ããããé 363 ååæ°ã¯åºåãã(#_CP_#, #_TCP_#) 364 # ããã«é 365 ååæ°ãå®æ°åã§ããã®ã§ããã°ãå®æ°ãã¯ããåºå (#_NCPA_#) 331 # 呼び口配列が可変長の場合、最適化しない 332 # mikan 呼び口配列要素数マクロ不具合暫定対策 333 # より望ましい修正は、受け口へのポインタは省略するが、配列個数は出力する(#_CP_#, #_TCP_#) 334 # さらに配列個数が定数化できるのであれば、定数マクロを出力 (#_NCPA_#) 366 335 next if port.get_array_size == "[]" 367 336 368 # å¼ã³å£æé©åå®æ½337 # 呼び口最適化実施 369 338 @b_cp_optimized = true 370 339 371 # å¼ã³å 372 ãä¸ã¤ã®ã»ã«ã ããï¼ 340 # 呼び先が一つのセルだけか? 373 341 if port_cells.length == 1 then 374 342 375 # å¼ã³å£ã¯ optional ã§åæåããã¦ããªããã¾ãã¯åãå£ã¯é 376 åã§ã¯ãªããï¼ 343 # 呼び口は optional で初期化されていない、または受け口は配列ではないか? 377 344 if port_ports[0] == nil || port_ports[0].get_array_size == nil then 378 345 379 @n_call_port_omitted_in_CB += 1 # CB ã§çç¥ããå¼ã³å£380 port.set_cell_unique # ã»ã«ä¸ã¤ã ãæé©å381 port.set_skelton_useless # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©å382 port.set_VMT_useless # VMT ä¸è¦æé©å (ç´æ¥åãå£é¢æ°ãå¼åºã)346 @n_call_port_omitted_in_CB += 1 # CB で省略する呼び口 347 port.set_cell_unique # セル一つだけ最適化 348 port.set_skelton_useless # スケルトン関数不要最適化 349 port.set_VMT_useless # VMT 不要最適化 (直接受け口関数を呼出す) 383 350 384 351 if $verbose then … … 386 353 end 387 354 else 388 port.set_VMT_useless # VMT ä¸è¦æé©å (ã¹ã±ã«ãã³é¢æ°ãå¼åºã)355 port.set_VMT_useless # VMT 不要最適化 (スケルトン関数を呼出す) 389 356 390 357 if $verbose then … … 393 360 end 394 361 395 else # å¼ã³å 396 ãè¤æ°ã®ã»ã«ï¼åä¸ã®ãã¼ãï¼ 397 398 # å¼ã³å£ã¯ optional ã§åæåããã¦ããªããã¾ãã¯åãå£ã¯é 399 åã§ã¯ãªããï¼ 362 else # 呼び先が複数のセル(単一のポート) 363 364 # 呼び口は optional で初期化されていない、または受け口は配列ではないか? 400 365 if port_ports[0] == nil || port_ports[0].get_array_size == nil then 401 366 if ! @singleton then 402 port.set_skelton_useless # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©å403 port.set_VMT_useless # VMT ä¸è¦æé©å (ã¹ã±ã«ãã³é¢æ° or åãå£é¢æ°ãå¼åºã)367 port.set_skelton_useless # スケルトン関数不要最適化 368 port.set_VMT_useless # VMT 不要最適化 (スケルトン関数 or 受け口関数を呼出す) 404 369 405 370 if $verbose then … … 407 372 end 408 373 else 409 port.set_VMT_useless # VMT ä¸è¦æé©å (ã¹ã±ã«ãã³é¢æ° or åãå£é¢æ°ãå¼åºã)374 port.set_VMT_useless # VMT 不要最適化 (スケルトン関数 or 受け口関数を呼出す) 410 375 411 376 if $verbose then … … 417 382 418 383 port.set_only_callee( port_ports[0], port_cells[0] ) 419 # set_cell_unique ã§ãªãå ´å cell ã¯æå³ããªã384 # set_cell_unique でない場合 cell は意味がない 420 385 421 386 end … … 426 391 end 427 392 428 #=== Celltype# åãå£æé©å429 # optimize_entry ã¯ãå¼ã³å£æé©åã®çµæã使ç¨ãã¦ãã393 #=== Celltype#受け口最適化 394 # optimize_entry は、呼び口最適化の結果を使用している 430 395 def optimize_entry 431 # åãå£æé©åã®è¨å®396 # 受け口最適化の設定 432 397 @port.each{ |port| 433 398 next if port.get_port_type != :CALL 434 399 435 # å¼ã³å£å´ã®æé©åç¶æ 436 400 # 呼び口側の最適化状態 437 401 b_VMT_useless = port.is_VMT_useless? 438 402 b_skelton_useless = port.is_skelton_useless? 439 403 440 # ã»ã«ã®åç 441 §ããã»ã«ãéããï¼ãã¼ããä¸ç·ã«éããï¼ 404 # セルの参照するセルを集める(ポートも一緒に集める) 442 405 @cell_list.each{ |cell| 443 406 … … 449 412 j = jl.get_item( port.get_name ) 450 413 451 if j then # optional ã§çµåããã¦ããªãå ´ånil414 if j then # optional で結合されていない場合 nil 452 415 if j.get_array_member2 then 453 # å¼ã³å£é 454 å 416 # 呼び口配列 455 417 j.get_array_member2.each { |j2| 456 418 if j2 then 457 port2 = j2.get_rhs_port # å³è¾ºã®ãã¼ã458 # åãå£å´ã®æé©åå¯è½æ§ãè¨å®419 port2 = j2.get_rhs_port # 右辺のポート 420 # 受け口側の最適化可能性を設定 459 421 port2.set_entry_VMT_skelton_useless( b_VMT_useless, b_skelton_useless ) 460 422 #else 461 # optional ã§å¼ã³å£é 462 åè¦ç´ ãåæåããã¦ããªã 423 # optional で呼び口配列要素が初期化されていない 463 424 end 464 425 } 465 426 else 466 port2 = j.get_rhs_port # å³è¾ºã®ãã¼ã467 # åãå£å´ã®æé©åå¯è½æ§ãè¨å®427 port2 = j.get_rhs_port # 右辺のポート 428 # 受け口側の最適化可能性を設定 468 429 port2.set_entry_VMT_skelton_useless( b_VMT_useless, b_skelton_useless ) 469 430 end … … 473 434 end 474 435 475 #Celltype# ãªã»ãããã436 #Celltype# リセットする 476 437 def reset_optimize 477 @@ID_BASE = ID_BASE # æ¬å½ã¯ä¸åã ãã§ãã478 @id_base = 1 # set_cell_id ã§ãªã»ãããããã®ã§ä¸è¦479 480 @b_cp_optimized = false # å¼ã³å£æé©å481 @n_call_port_omitted_in_CB = 0 # å¼ã³å£æé©åã«ããä¸çæã¨ãªã£ããã¼ãã®æ°482 @n_cell_gen = 0 # çæã»ã«åæ°438 @@ID_BASE = ID_BASE # 本当は一回だけでよい 439 @id_base = 1 # set_cell_id でリセットされるので不要 440 441 @b_cp_optimized = false # 呼び口最適化 442 @n_call_port_omitted_in_CB = 0 # 呼び口最適化により不生成となったポートの数 443 @n_cell_gen = 0 # 生成セル個数 483 444 @port.each{ |p| 484 445 p.reset_optimize … … 488 449 end 489 450 490 #Celltype# ããã㯠include ããã¦ããã491 #hname::Symbol : ãããå492 #RETURN:: bool_t: false ã¤ã³ã¯ã«ã¼ãããã¦ããªããtrue ã¤ã³ã¯ã«ã¼ãããã¦ãã493 # #_ISH_#, #_ICT_# ã§ããããåãè¾¼ã¾ãã¦ããããã§ãã¯ãã494 # false ãè¿ã£ãå ´åãhname ã¯ç»é²ããã¦ã次åã®å¼ã³åºãã§ã¯ true ãè¿ã451 #Celltype# ヘッダは include されているか 452 #hname::Symbol : ヘッダ名 453 #RETURN:: bool_t: false インクルードされていない、true インクルードされている 454 # #_ISH_#, #_ICT_# でヘッダが取り込まれているかチェックする 455 # false が返った場合、hname は登録されて、次回の呼び出しでは true が返る 495 456 def header_included?( hname ) 496 457 if @included_header[ hname ] == nil then -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/plugin.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ 53 38 #++ 54 39 55 #== Plugin ã¯ã©ã¹56 # ThroughPlugin, SignaturePlugin, CelltypePlugin ã« include ãã40 #== Plugin クラス 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 # generate æå®åã®å ´åãæ§æ解é次第(end_of_parseã§)å¼ã³åºããã94 # generate æã®å ´åãåºç¾æ¬¡ç¬¬å¼ã³åºããã95 ### æå³è§£æ段éã§å¼ã³åºãããã¡ã½ãã ### <<< ã³ã¡ã³ã誤ã(V1.4.2)96 #=== CDL ãã¡ã¤ã«ã®çæ97 # typedef, signature, celltype, cell ã®ã³ã¼ããçæ98 # éè¤ãã¦çæãã¦ã¯ãªããªã99 # ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã100 # ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã101 #file:: FILE çæãããã¡ã¤ã«77 ### 構文解釈 または 意味解析段階で呼び出されるメソッド ### 78 # generate 指定子の場合、構文解釈次第(end_of_parseで)呼び出される 79 # generate 文の場合、出現次第呼び出される 80 ### 意味解析段階で呼び出されるメソッド ### <<< コメント誤り (V1.4.2) 81 #=== CDL ファイルの生成 82 # typedef, signature, celltype, cell のコードを生成 83 # 重複して生成してはならない 84 # すでに生成されている場合は出力しないこと。 85 # もしくは同名の import により、重複を避けること。 86 #file:: FILE 生成するファイル 102 87 def gen_cdl_file file 103 88 end 104 89 105 90 106 ### ã³ã¼ãç段éã§å¼ã³åºãããã¡ã½ãã###107 #=== ãã©ã°ã¤ã³ã¯ gen_ep_func ãæä¾ããã108 # gen_ep_func å®ç¾© â ãã³ãã¬ã¼ãã§ã¯ãªããã»ã«ã¿ã¤ãã³ã¼ã(tCelltype.c)ãçæ109 # gen_ep_func æªå®ç¾© â ãã³ãã¬ã¼ã(tCelltype_templ.c)ãçæ91 ### コード生段階で呼び出されるメソッド ### 92 #=== プラグインは gen_ep_func を提供するか 93 # gen_ep_func 定義 ⇒ テンプレートではない、セルタイプコード(tCelltype.c)を生成 94 # gen_ep_func 未定義 ⇒ テンプレート(tCelltype_templ.c)を生成 110 95 def gen_ep_func? 111 96 self.class.method_defined?( :gen_ep_func_body ) 112 97 end 113 98 114 #=== åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã 115 # ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿ 116 è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã 117 # ãã®ã¡ã½ãããæªå®ç¾©ã§ããã°ããã©ã°ã¤ã³ã¯ã»ã«ã¿ã¤ãã³ã¼ããçæããªã (é常éããã³ãã¬ã¼ããçæãã) 118 # gen_cdl_file ã®ä¸ã§çæãããã»ã«ã¿ã¤ãã«å¯¾ãã¦å¼ã³åºããã 119 #file:: FILE åºåå 120 ãã¡ã¤ã« (tCelltype.c) 99 #=== 受け口関数の本体(C言語)を生成する 100 # プラグインの場合、変更する必要のないセルタイプコードを生成する 101 # このメソッドが未定義であれば、プラグインはセルタイプコードを生成しない (通常通りテンプレートを生成する) 102 # gen_cdl_file の中で生成されたセルタイプに対して呼び出される 103 #file:: FILE 出力先ファイル (tCelltype.c) 121 104 #b_singleton:: bool true if singleton 122 105 #ct_name:: Symbol … … 130 113 # end 131 114 132 #=== åãå£é¢æ°ã® preamble (Cè¨èª)ãçæãã 133 # å¿ 134 è¦ãªã preamble é¨ã«åºåãã 135 # gen_cdl_file ã®ä¸ã§ã§çæãããã»ã«ã¿ã¤ãã«å¯¾ãã¦å¼ã³åºããã 136 #file:: FILE åºåå 137 ãã¡ã¤ã« 115 #=== 受け口関数の preamble (C言語)を生成する 116 # 必要なら preamble 部に出力する 117 # gen_cdl_file の中でで生成されたセルタイプに対して呼び出される 118 #file:: FILE 出力先ファイル 138 119 #b_singleton:: bool true if singleton 139 120 #ct_name:: Symbol 140 121 #global_ct_name:: string 141 122 def gen_preamble( file, b_singleton, ct_name, global_ct_name ) 142 # ããã©ã«ãã§ã¯ä½ãåºåããªã 143 end 144 145 #=== åãå£é¢æ°ã® postamble (Cè¨èª)ãçæãã 146 # å¿ 147 è¦ãªã postamble é¨ã«åºåãã 148 # gen_cdl_file ã®ä¸ã§çæãããã»ã«ã¿ã¤ãã«å¯¾ãã¦å¼ã³åºããã 149 #file:: FILE åºåå 150 ãã¡ã¤ã« 123 # デフォルトでは何も出力しない 124 end 125 126 #=== 受け口関数の postamble (C言語)を生成する 127 # 必要なら postamble 部に出力する 128 # gen_cdl_file の中で生成されたセルタイプに対して呼び出される 129 #file:: FILE 出力先ファイル 151 130 #b_singleton:: bool true if singleton 152 131 #ct_name:: Symbol 153 132 #global_ct_name:: string 154 133 def gen_postamble( file, b_singleton, ct_name, global_ct_name ) 155 # ããã©ã«ãã§ã¯ä½ãåºåããªã156 end 157 158 #=== gen_cdl_file ã®ä¸ã§çæãããã»ã«ã¿ã¤ãã«æ°ããã»ã«ãçæããã159 # ã©ã®ã»ã«ã¿ã¤ãã㯠cell.get_celltype ã§åãã134 # デフォルトでは何も出力しない 135 end 136 137 #=== gen_cdl_file の中で生成されたセルタイプに新しいセルが生成された 138 # どのセルタイプかは cell.get_celltype で分かる 160 139 # 161 #file:: FILE åºåå 162 ãã¡ã¤ã« 140 #file:: FILE 出力先ファイル 163 141 #b_singleton:: bool true if singleton 164 142 #ct_name:: Symbol 165 143 #global_ct_name:: string 166 144 def new_cell cell 167 # ããã©ã«ãã§ã¯ä½ãããªã168 end 169 170 ### ãã©ã°ã¤ã³å¼æ°ã®è§£é###145 # デフォルトでは何もしない 146 end 147 148 ### プラグイン引数の解釈 ### 171 149 def parse_plugin_arg 172 150 arg = @plugin_arg_str.dup 173 151 174 # æ¹è¡ãæ¶ã152 # 改行を消す 175 153 arg.gsub!( /\\\n/, "" ) 176 154 177 155 while arg != "" 178 156 179 # åã®ç©ºç½èªã¿é£ã°ã157 # 前の空白読み飛ばす 180 158 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') 181 159 182 # èå¥ååå¾160 # 識別子取得 183 161 if arg =~ /\A[a-zA-Z_]\w*/ then 184 162 ident = $~.to_s # … … 189 167 end 190 168 191 # åã®ç©ºç½èªã¿é£ã°ã169 # 前の空白読み飛ばす 192 170 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') 193 171 … … 199 177 end 200 178 201 # åã®ç©ºç½èªã¿é£ã°ã179 # 前の空白読み飛ばす 202 180 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') 203 181 204 # å³è¾ºæåå205 if 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 # $ $ ã§å²ã¾ãã¦ããå ´å215 rhs = $1 216 remain = $' 217 elsif arg =~ /\A\\"(.*?)\\"\s*,/ then # || ã«ã [,$] ã«ãã§ããªãã£ã182 # 右辺文字列 183 if 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 # $ $ で囲まれている場合 193 rhs = $1 194 remain = $' 195 elsif arg =~ /\A\\"(.*?)\\"\s*,/ then # || にも [,$] にもできなかった 218 196 rhs = $1 219 197 remain = $' 220 198 # elsif arg =~ /\A(.*?)\s*$/ then 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 # $ $ ã§å²ã¾ãã¦ããå ´å231 rhs = $1 232 remain = $' 233 elsif arg =~ /\A\\"(.*?)\\"\s*\z/ then # || ã«ã [,$] ã«ãã§ããªãã£ã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 # $ $ で囲まれている場合 209 rhs = $1 210 remain = $' 211 elsif arg =~ /\A\\"(.*?)\\"\s*\z/ then # || にも [,$] にもできなかった 234 212 rhs = $1 235 213 remain = $' … … 237 215 rhs = $1 238 216 remain = $' 239 # åã®ç©ºç½èªã¿é£ã°ã217 # 前の空白読み飛ばす 240 218 rhs.sub!( /\A\s*(.*)\s*\z/, '\1') 241 219 elsif arg =~ /\A(.*?)\s*\z/ then … … 247 225 end 248 226 249 # 0 æåã®æååã to_sym ããã¨ä¾å¤çºçããã®ã§ç©ºç½æåã¨ãã227 # 0文字の文字列を to_sym すると例外発生するので空白文字とする 250 228 if rhs == "" then 251 229 rhs = " " 252 230 end 253 231 254 arg = remain # arg ã®æ®ãã®é¨å255 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') # åã®ç©ºç½èªã¿é£ã°ã256 257 # \ ãå¤ã258 rhs = rhs.gsub( /\\(.)/, "\\1" ) # ãã㧠$' ãå¤ãããã¨ã«æ³¨æï¼232 arg = remain # arg の残りの部分 233 arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1') # 前の空白読み飛ばす 234 235 # \ を外す 236 rhs = rhs.gsub( /\\(.)/, "\\1" ) # ここで $' が変わることに注意! 259 237 # print "parse_plugin_arg: #{ident} #{rhs}\n" 260 238 @plugin_arg_list[ ident ] = rhs … … 265 243 end 266 244 267 #=== ãã©ã°ã¤ã³å¼æ°ããã§ãã¯ãã268 # @plugin_arg_check_proc_tab ã«å¾ã£ã¦ãã©ã°ã¤ã³å¼æ°ããã§ãã¯ããã269 # å¤ãç¨æ³ï¼åã¯ã©ã¹ã§ãªã¼ãã¼ã©ã¤ãããå¼æ°èå¥åãæ£ããããã§ãã¯ãã270 #ident:: string: å¼æ°èå¥å271 #rhs:: string: å³è¾ºæåå245 #=== プラグイン引数をチェックする 246 # @plugin_arg_check_proc_tab に従ってプラグイン引数をチェックすする 247 # 古い用法:子クラスでオーバーライドし、引数識別子が正しいかチェックする 248 #ident:: string: 引数識別子 249 #rhs:: string: 右辺文字列 272 250 def check_plugin_arg( ident, rhs ) 273 251 … … 294 272 end 295 273 296 #=== ãã©ã°ã¤ã³ã®ã¡ãã»ã¼ã¸åºå274 #=== プラグインのメッセージ出力 297 275 def print_msg( msg ) 298 276 if @b_silent == true then … … 302 280 end 303 281 304 #=== ãã©ã°ã¤ã³å¼æ°silent282 #=== プラグイン引数 silent 305 283 def set_silent rhs 306 284 if rhs == "true" || rhs == nil then … … 310 288 end 311 289 312 #== åºåæååã utf-8 ããåºåãã¡ã¤ã«ã« convert ãã313 # tecsgen ã®ã½ã¼ã¹ã³ã¼ã㯠utf-8 ã§è¨è¿°ããã¦ãã314 # ããããåºåãã¡ã¤ã«ã®æåã³ã¼ãã«å¤æãã¦åºåãã290 #== 出力文字列を utf-8 から出力ファイルに convert する 291 # tecsgen のソースコードは utf-8 で記述されている 292 # これを、出力ファイルの文字コードに変換して出力する 315 293 # 316 # generate.rb ã§åºåãããã®ã¯ message.rb ã§å¤æãã¦ãã317 # generate.rb ã§åºåãããã®ã¯ APPFile ã¯ã©ã¹ã使ç¨ãã¦ãã318 # mikan: CFile ã§åºåãããã®ã« factory ã§è¿½è¨ã§ããªã (cdl ãã¡ã¤ã«ã®å ´åã追è¨ã§ãã¦ãæå³ããªã)294 # generate.rb で出力するものは message.rb で変換している 295 # generate.rb で出力するものは APPFile クラスを使用している 296 # mikan: CFile で出力したものに factory で追記できない (cdl ファイルの場合、追記できても意味がない) 319 297 class CFile 320 298 def self.open( path, mode ) -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/pluginModule.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ 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 #=== ãã©ã°ã¤ã³ããã¼ããã46 #=== プラグインをロードする 62 47 # return:: PluginClass 63 # V1.4.1 ã¾ã§ return:: true : æåã false : 失æ48 # V1.4.1 まで return:: true : 成功、 false : 失敗 64 49 # 65 # #{plugin_name}.rb ããã¼ãããplugin_name ã¯ã©ã¹ã®ãªãã¸ã§ã¯ããçæããï¼66 # plugin_name ã MultiPlugin ã®å ´åãget_plugin ã«ãããsuperClass ã®ãã©ã°ã¤ã³ãªãã¸ã§ã¯ãããã¼ãããï¼50 # #{plugin_name}.rb をロードし、plugin_name クラスのオブジェクトを生成する. 51 # plugin_name が MultiPlugin の場合、get_plugin により、superClass のプラグインオブジェクトをロードする. 67 52 # 68 # ãã§ã«ãã¼ãããã¦ãããã®ã¯ãéè¤ãã¦ãã¼ãããªã69 # load æã®ä¾å¤ã¯ãã®ã¡ã½ããã®ä¸ã§ãã£ãããã㦠false ãè¿ããã53 # すでにロードされているものは、重複してロードしない 54 # load 時の例外はこのメソッドの中でキャッチされて false が返される 70 55 def load_plugin( plugin_name, superClass ) 71 56 … … 77 62 print( "load '#{plugin_name}.rb'\n" ) 78 63 end 79 # "#{plugin_name}.rb" ããã¼ãï¼ã·ã¹ãã ç¨ã§ã¯ãªãã®ã§ãfatal ã¨ã©ã¼ã«ããªãï¼64 # "#{plugin_name}.rb" をロード(システム用ではないので、fatal エラーにしない) 80 65 if require_tecsgen_lib( "#{plugin_name}.rb", false ) == false then 81 66 cdl_error( "P2001 $1.rb : fail to load plugin" , plugin_name ) … … 108 93 return nil 109 94 end 110 # ããã¸ã¯æ¥ãªã95 # ここへは来ない 111 96 return nil 112 97 end 113 98 114 #=== ãã©ã°ã¤ã³ã® gen_cdl_file ãå¼ã³ã㦠cdl ãã¡ã¤ã«ãçæããã解éãè¡ã99 #=== プラグインの gen_cdl_file を呼びして cdl ファイルを生成させ、解釈を行う 115 100 def generate_and_parse plugin_object 116 if plugin_object == nil # ãã©ã°ã¤ã³ã®ãã¼ãã«å¤±æãã¦ããï¼æ¢ã«ã¨ã©ã¼ï¼101 if plugin_object == nil # プラグインのロードに失敗している(既にエラー) 117 102 return 118 103 end … … 123 108 elsif @@loaded_plugin_list[ plugin_name ] == nil then 124 109 #raise "#{plugin_name} might have different name " 125 ## ãã©ã°ã¤ã³ã®ãã¡ã¤ã«åã¨ããã©ã°ã¤ã³ã®ã¯ã©ã¹åãç¸éããå ´å126 #MultiPlugin ã® get_plugin ã§è¿ãããã±ã¼ã¹ã§ã¯ nil ã«ãªã£ã¦ãã110 ## プラグインのファイル名と、プラグインのクラス名が相違する場合 111 #MultiPlugin の get_plugin で返されたケースでは nil になっている 127 112 @@loaded_plugin_list[ plugin_name ] = 0 128 113 end … … 157 142 end 158 143 159 #=== ãã©ã°ã¤ã³ã CDL ã® POST ã³ã¼ããçæ160 # tmp_plugin_post_code.cdl ã¸ã®åºå144 #=== プラグインが CDL の POST コードを生成 145 # tmp_plugin_post_code.cdl への出力 161 146 def self.gen_plugin_post_code file 162 147 dbgPrint "PluginModule #{@@loaded_plugin_list}\n" -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/syntaxobj.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ 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, *arg ) 108 89 Generator.info2( @locale, message, *arg ) 109 90 end 110 91 111 #=== æ 112 å ±ã表示ãã 92 #=== 情報を表示する 113 93 def cdl_info2( locale, message, *arg ) 114 94 Generator.info2( locale, message, *arg ) … … 128 108 end 129 109 130 #== åæ¹åNode (Bi Direction Node)110 #== 双方向 Node (Bi Direction Node) 131 111 # 132 # Node ã®åã¯ã©ã¹ 133 # owner Node ããåç 134 §ããã¦ãããã® (owner ã¸ã®ãªã³ã¯ãåãåºãã) 112 # Node の子クラス 113 # owner Node から参照されているもの (owner へのリンクも取り出せる) 135 114 # 136 # get_owner ã§å¾ããããã®115 # get_owner で得られるもの 137 116 # FuncHead => Signature 138 117 # Decl => Namespace(const), Typedef(typedef), … … 140 119 # Struct(member), ParamDecl(parameter), FuncHead(funchead) 141 120 # Signature, Celltype, CompositeCelltype, Typedef => Namespace 142 #, Namespace => Namespace, Generator.class (root Namespace ã®å ´å)121 #, Namespace => Namespace, Generator.class (root Namespace の場合) 143 122 # Cell => Region, CompositeCelltype(in_composite) 144 123 # Port => Celltype, Composite … … 150 129 # ParamList => FuncHead 151 130 # Expression => Namespace 152 # 大åã®ãã®ã¯ new_* ã¡ã½ãã㧠owner Node ã«ä¼éããã153 # ãã®ã¡ã½ãããå¼ã³åºãããã¨ãã« owner Node ãè¨é²ããã154 # new_* ããªããã®ï¼131 # 大半のものは new_* メソッドで owner Node に伝達される 132 # そのメソッドが呼び出されたときに owner Node が記録される 133 # new_* がないもの: 155 134 # Decl(parameter), ParamDecl, ParamList, FuncHead, Expression 156 135 # 157 # Expression ã¯ãowner Node ã¨ãªããã®ãå¤ãããããæ¹é ãå°é£ã§ãããã158 # Expression ãå®ç¾©ãããã¨ãã® Namespace ã owner Node ã¨ãã159 # StructType 㯠Type ã®ä¸ç¨®ãªã®ã§ owner ãæããªã136 # Expression は、owner Node となるものが多くあるが、改造が困難であるため 137 # Expression が定義されたときの Namespace を owner Node とする 138 # StructType は Type の一種なので owner を持たない 160 139 # 161 140 class BDNode < Node … … 173 152 end 174 153 175 #=== owner ãè¨å®ãã154 #=== owner を設定する 176 155 def set_owner owner 177 156 dbgPrint "set_owner: #{owner.class.name}\n" … … 179 158 end 180 159 181 #=== owner ãå¾ã 182 # class ã®èª¬æãåç 183 § 160 #=== owner を得る 161 # class の説明を参照 184 162 def get_owner 185 163 if @owner == nil … … 190 168 end 191 169 192 #== Namespace åãæã¤BDNode170 #== Namespace 名を持つ BDNode 193 171 # Namespace(Region), Signature, Celltype, CompositeCelltype, Cell 194 172 class NSBDNode < BDNode … … 198 176 end 199 177 200 #=== å±ãã namespace ãå¾ã201 # owner ã namespace ã«ãã©ãçãã¾ã§ä¸ã«ãã©ã178 #=== 属する namespace を得る 179 # owner を namespace にたどり着くまで上にたどる 202 180 def get_namespace 203 181 if @owner.kind_of? Namespace … … 206 184 return @owner.get_namespace 207 185 else 208 # @owner == nil ãªã"::"186 # @owner == nil なら "::" 209 187 if @name != "::" then 210 188 raise "non-root namespace has no owner #{self.class.name}##{@name} #{self}" … … 223 201 end 224 202 225 #=== NamespacePath ãå¾ã203 #=== NamespacePath を得る 226 204 def get_namespace_path 227 205 return @NamespacePath … … 232 210 return @import.is_imported? 233 211 else 234 return false # mikan: ä»® @import ã nil ã«ãªãã±ã¼ã¹ã追æ±ã§ãã¦ããªã212 return false # mikan: 仮 @import が nil になるケースが追求できていない 235 213 end 236 214 end … … 239 217 class NamedList 240 218 # @names:: {} of items 241 # @items:: [] of items : item ã® CLASS 㯠get_name ã¡ã½ãããæã¤ã㨠get_name ã®æ»ãå¤ã¯ Symbol ã§ãªãã¦ã¯ãªããªã 242 # NamedList ã clone_for_composite ããå ´åã¯ãitem ã«ãã¡ã½ãããå¿ 243 è¦ 244 # @type:: string ã¨ã©ã¼ã¡ãã»ã¼ã¸ 219 # @items:: [] of items : item の CLASS は get_name メソッドを持つこと get_name の戻り値は Symbol でなくてはならない 220 # NamedList を clone_for_composite する場合は、item にもメソッドが必要 221 # @type:: string エラーメッセージ 245 222 246 223 def initialize( item, type ) … … 251 228 end 252 229 253 #=== è¦ç´ ãå ãã254 # parse ããæç¹ã§å ãããã¨(å ´æãè¨æ¶ãã)230 #=== 要素を加える 231 # parse した時点で加えること(場所を記憶する) 255 232 def add_item( item ) 256 233 … … 311 288 end 312 289 313 #=== composite cell ã clone ããæã«è¦ç´ (JOIN) ã® clone ãã290 #=== composite cell を clone した時に要素(JOIN) の clone する 314 291 # 315 # mikan ãã®ã¡ã½ãã㯠Join ã«ç¹åããã¦ããã®ã§ NamedList ããåé¢ãã¹ã292 # mikan このメソッドは Join に特化されているので NamedList から分離すべき 316 293 def clone_for_composite( ct_name, cell_name, locale ) 317 294 cl = self.clone … … 320 297 end 321 298 322 #=== clone ããã NamedList ã¤ã³ã¹ã¿ã³ã¹ã®åç 323 §ãããã®(item)ã clone 299 #=== clone された NamedList インスタンスの参照するもの(item)を clone 324 300 # 325 # mikan ãã®ã¡ã½ãã㯠Join ã«ç¹åããã¦ããã®ã§ NamedList ããåé¢ãã¹ã301 # mikan このメソッドは Join に特化されているので NamedList から分離すべき 326 302 def set_cloned( ct_name, cell_name, locale ) 327 303 items = [] … … 385 361 end 386 362 387 #== é¢æ°é é¨388 # signature ã«ç»é²ãããé¢æ°363 #== 関数頭部 364 # signature に登録される関数 389 365 class FuncHead <BDNode 390 366 # @declarator:: Decl … … 431 407 end 432 408 433 #=== FuncHead# é¢æ°ã®ååãè¿ã409 #=== FuncHead# 関数の名前を返す 434 410 def get_name 435 411 return @declarator.get_name 436 412 end 437 413 438 #=== FuncHead# é¢æ°ã®æ»ãå¤ã®åãè¿ã 439 # types.rb ã«å®ç¾©ããã¦ããå 440 # é¢æ°ãããã®å®ç¾©ã¨ãã¦ä¸å®å 441 ¨ãªå ´å nil ãè¿ã 414 #=== FuncHead# 関数の戻り値の型を返す 415 # types.rb に定義されている型 416 # 関数ヘッダの定義として不完全な場合 nil を返す 442 417 def get_return_type 443 418 if is_function? then … … 446 421 end 447 422 448 #=== FuncHead# é¢æ°ã®å¼æ°ã®ãªã¹ããè¿ã 449 # ParamList ãè¿ã 450 # é¢æ°ãããã®å®ç¾©ã¨ãã¦ä¸å®å 451 ¨ãªå ´å nil ãè¿ã 423 #=== FuncHead# 関数の引数のリストを返す 424 # ParamList を返す 425 # 関数ヘッダの定義として不完全な場合 nil を返す 452 426 def get_paramlist 453 427 if is_function? then … … 463 437 end 464 438 465 #=== 宣è¨466 # @kind ã§ç¤ºãããå種ã®å®£è¨439 #=== 宣言 440 # @kind で示される各種の宣言 467 441 class Decl < BDNode 468 442 469 443 # @identifer:: String 470 # @global_name:: String | nil : String(@kind=TYPEDEF||:CONSTANT), nil(@kind= ãã®ä»)471 # set_kind ã«ã¦è¨å®ããã444 # @global_name:: String | nil : String(@kind=TYPEDEF||:CONSTANT), nil(@kind=その他) 445 # set_kind にて設定される 472 446 # @type:: ArrayType, FuncType, PtrType, IntType, StructType 473 447 # VoidType, FloatType, DefinedType, BoolType 474 448 # @initializer:: constant_expression, mikan { initlist } 475 # @kind:: :VAR, :ATTRIBUTE, :PARAMETER, :TYPEDEF, :CONSTANT, :MEMBER, :FUNCHEAD(signature ã®é¢æ°å®ç¾©)449 # @kind:: :VAR, :ATTRIBUTE, :PARAMETER, :TYPEDEF, :CONSTANT, :MEMBER, :FUNCHEAD(signatureの関数定義) 476 450 # @b_referenced:: bool 477 451 # 478 # 以ä¸ã¯ã@kind ã :VAR, :ATTRIBUTE ã®ã¨ãã«æå¹ 479 # @rw:: bool # å¤ãææ³ã§ã¯ attr ã«æå®å¯è½ã ã£ãï¼æ¶ãã«ã¯ generate ã®ä¿®æ£ãå¿ 480 è¦ï¼ 452 # 以下は、@kind が :VAR, :ATTRIBUTE のときに有効 453 # @rw:: bool # 古い文法では attr に指定可能だった(消すには generate の修正も必要) 481 454 # @omit:: bool 482 # @choice_list:: [String] attr åæå¤ã®é¸æè¢483 # 以ä¸ã¯ã@kind ã :VAR, :ATTRIBUTE, :MEMBER ã®ã¨ãã«æå¹455 # @choice_list:: [String] attr 初期値の選択肢 456 # 以下は、@kind が :VAR, :ATTRIBUTE, :MEMBER のときに有効 484 457 # @size_is:: Expression or nil unless specified 485 # 以ä¸ã¯ã@kind ã :MEMBER ã®ã¨ãã«æå¹458 # 以下は、@kind が :MEMBER のときに有効 486 459 # @count_is:: Expression or nil unless specified 487 # attr, var ã®å ´åãcount_is ã¯æå®ã§ããªã460 # attr, var の場合、count_is は指定できない 488 461 # @string:: Expression, -1 (length not specified) or nil (not specified) 489 462 # 490 # mikan ParamDecl ã ãå¥ã«è¨ããããMemberDecl, AttrDecl ãªã©ãåããã¹ãã(ï¼)463 # mikan ParamDecl だけ別に設けたが、MemberDecl, AttrDecl なども分けるべきか(?) 491 464 492 465 def initialize( identifier ) … … 518 491 end 519 492 520 #== Decl ã®æå³ç誤ãããã§ãã¯ãã493 #== Decl の意味的誤りをチェックする 521 494 def check 522 495 # return nil if @type == nil 523 496 524 # æ§é ä½ã¿ã°ãã§ãã¯ï¼ãã¤ã³ã¿åããæ§é ä½ãåç 525 §ããã¦ããå ´åã¯ãã¿ã°ã®åå¨ããã§ãã¯ããªãï¼ 497 # 構造体タグチェック(ポインタ型から構造体が参照されている場合は、タグの存在をチェックしない) 526 498 @type.check_struct_tag @kind 527 499 528 # åã®ãã§ãã¯ãè¡ã500 # 型のチェックを行う 529 501 res = @type.check 530 502 if res then … … 532 504 end 533 505 534 # ä¸è¦ã®åæååããã§ãã¯ãã506 # 不要の初期化子をチェックする 535 507 if @initializer then 536 508 case @kind … … 538 510 cdl_error( "S2003 $1: $2 cannot have initializer" , @identifier, @kind.to_s.downcase ) 539 511 when :VAR, :ATTRIBUTE, :CONSTANT 540 # p @initializer ããã§ã¯ä»£å 541 ¥å¯è½ãã©ããããã§ãã¯ããªã 542 # :VAR, :ATTRIBUTE, :CONSTANT ã¯ããããã§ãã§ãã¯ãã 512 # p @initializer ここでは代入可能かどうか、チェックしない 513 # :VAR, :ATTRIBUTE, :CONSTANT はそれぞれでチェックする 543 514 # return @type.check_init( @identifier, @initializer, @kind ) 544 515 else … … 558 529 end 559 530 560 #== ãã¤ã³ã¿ã¬ãã«ãå¾ã561 # æ»ãå¤ï¼562 # éãã¤ã³ã¿å¤æ°= 0563 # ãã¤ã³ã¿å¤æ°= 1564 # äºéãã¤ã³ã¿å¤æ°= 2531 #== ポインタレベルを得る 532 # 戻り値: 533 # 非ポインタ変数 = 0 534 # ポインタ変数 = 1 535 # 二重ポインタ変数 = 2 565 536 def get_ptr_level 566 537 level = 0 … … 570 541 level += 1 571 542 type = type.get_referto 572 # elsif type.kind_of?( ArrayType ) then # æ·»æ°ãªãé 573 åã¯ãã¤ã³ã¿ã¨ã¿ãªã 543 # elsif type.kind_of?( ArrayType ) then # 添数なし配列はポインタとみなす 574 544 # if type.get_subscript == nil then 575 545 # level += 1 … … 578 548 # break 579 549 # end 580 # mikan ãã¤ã³ã¿ã®æ·»æ°ããé 581 åã®ãã¤ã³ã¿ã¬ãã«ã¯ï¼ã§ããï¼ 550 # mikan ポインタの添数あり配列のポインタレベルは0でよい? 582 551 elsif type.kind_of?( DefinedType ) then 583 552 type = type.get_type … … 602 571 @type = type 603 572 else 604 @type.set_type( type ) # èã«è¨å®573 @type.set_type( type ) # 葉に設定 605 574 end 606 575 end … … 744 713 end 745 714 746 # é¢æ°ãã©ã¡ã¼ã¿ã®å®£è¨715 # 関数パラメータの宣言 747 716 class ParamDecl < BDNode 748 717 749 718 # @declarator:: Decl: Token, ArrayType, FuncType, PtrType 750 719 # @direction:: :IN, :OUT, :INOUT, :SEND, :RECEIVE 751 # @size:: Expr (size_is å¼æ°)752 # @count:: Expr (count_is å¼æ°)753 # @max:: Expr (size_is ã®ç¬¬äºå¼æ°)720 # @size:: Expr (size_is 引数) 721 # @count:: Expr (count_is 引数) 722 # @max:: Expr (size_is の第二引数) 754 723 # @b_nullable:: Bool : nullable 755 # @string:: Expr or -1(if size not specified) ï¼string å¼æ°ï¼724 # @string:: Expr or -1(if size not specified) (string 引数) 756 725 # @allocator:: Signature of allocator 757 # @b_ref:: bool : size_is, count_is, string_is å¼æ°ã¨ãã¦åç 758 §ããã¦ãã 726 # @b_ref:: bool : size_is, count_is, string_is 引数として参照されている 759 727 # 760 # 1. é¢æ°åã§ãªãã㨠761 # 2. ï¼æ¬¡å 762 以ä¸ã®é 763 åã§ãã£ã¦æãå 764 å´ä»¥å¤ã®æ·»æ°ãããã㨠765 # 3. in, out, ..., size_is, count_is, ... ã®éè¤æå®ããªãã㨠766 # 4. ãã¤ã³ã¿ã¬ãã«ãé©åãªã㨠728 # 1. 関数型でないこと 729 # 2. 2次元以上の配列であって最も内側以外の添数があること 730 # 3. in, out, ..., size_is, count_is, ... の重複指定がないこと 731 # 4. ポインタレベルが適切なこと 767 732 768 733 def initialize( declarator, specifier, param_specifier ) … … 831 796 end 832 797 when :MAX_IS 833 # max_is ã¯ãå 834 é¨çãªãã® bnf.y.rb åç 835 § 836 # size_is ã§éè¤ãã§ãã¯ããã 798 # max_is は、内部的なもの bnf.y.rb 参照 799 # size_is で重複チェックされる 837 800 @max = i[1] 838 801 when :NULLABLE … … 854 817 end 855 818 856 # mikan ãã¤ã³ã¿ã®é 857 åï¼æ·»æ°æï¼ã®ã¬ãã«ãï¼ 819 # mikan ポインタの配列(添数有)のレベルが0 858 820 ptr_level = @declarator.get_ptr_level 859 821 … … 898 860 cdl_error( "S2014 $1 need pointer or more pointer" , @declarator.get_identifier ) 899 861 elsif ptr_level > max_level then 900 # note: æ§æ解æ段éã§å®è¡ã®ãã get_current å¯862 # note: 構文解析段階で実行のため get_current 可 901 863 if Signature.get_current == nil || Signature.get_current.is_deviate? == false then 902 864 cdl_warning( "W3003 $1 pointer level mismatch" , @declarator.get_identifier ) … … 910 872 911 873 if ptr_level > 0 then 912 # size_is, count_is, string ãã»ãã874 # size_is, count_is, string をセット 913 875 if @direction == :RECEIVE && ptr_level > 1 then 914 876 type.get_type.set_scs( @size, @count, @string, @max, @b_nullable ) … … 920 882 #type.show_tree 1 921 883 922 # ãã¤ã³ã¿ãæãã¦ããå 923 ã®ãã¼ã¿åãå¾ã 884 # ポインタが指している先のデータ型を得る 924 885 i = 0 925 886 t2 = type … … 936 897 # p t2.is_const? 937 898 938 # const 修飾ãé©åããã§ãã¯899 # const 修飾が適切かチェック 939 900 if @direction == :IN then 940 901 if ! t2.is_const? then … … 947 908 end 948 909 else 949 # éãã¤ã³ã¿ã¿ã¤ã910 # 非ポインタタイプ 950 911 if @size != nil || @count != nil || @string != nil || @max != nil || @b_nullable then 951 912 type.set_scs( @size, @count, @string, @max, @b_nullable ) … … 1019 980 end 1020 981 1021 #=== PPAllocator ãå¿ 1022 è¦ã 1023 # Transparent RPC ã®å ´å in 㧠size_is, count_is, string ã®ãããããæå®ããã¦ããå ´å oneway ã§ã¯ PPAllocator ãå¿ 1024 è¦ 1025 # Transparent PC 㧠oneway ãã©ããã¯ãããã§ã¯å¤æããªãã®ã§å¥éå¤æãå¿ 1026 è¦ 1027 # Opaque RPC ã®å ´å size_is, count_is, string ã®ãããããæå®ããã¦ããå ´åãPPAllocator ãå¿ 1028 è¦ 982 #=== PPAllocator が必要か 983 # Transparent RPC の場合 in で size_is, count_is, string のいずれかが指定されている場合 oneway では PPAllocator が必要 984 # Transparent PC で oneway かどうかは、ここでは判断しないので別途判断が必要 985 # Opaque RPC の場合 size_is, count_is, string のいずれかが指定されている場合、PPAllocator が必要 1029 986 def need_PPAllocator?( b_opaque = false ) 1030 987 if ! b_opaque then … … 1073 1030 end 1074 1031 1075 # é¢æ°ãã©ã¡ã¼ã¿ãªã¹ã1032 # 関数パラメータリスト 1076 1033 class ParamList < BDNode 1077 1034 # @param_list:: NamedList : item: ParamDecl … … 1086 1043 1087 1044 def add_param( paramdecl ) 1088 return if paramdecl == nil # æ¢ã«ã¨ã©ã¼1045 return if paramdecl == nil # 既にエラー 1089 1046 1090 1047 @param_list.add_item( paramdecl ) … … 1096 1053 end 1097 1054 1098 #=== size_is, count_is, string ã®å¼æ°ã®å¼ããã§ã㯠1099 # å¤æ°ã¯åæ¹åç 1100 §å¯è½ãªãããé¢æ°é é¨ã®æ§æ解éãçµãã£ãå¾ã«ãã§ãã¯ãã 1055 #=== size_is, count_is, string の引数の式をチェック 1056 # 変数は前方参照可能なため、関数頭部の構文解釈が終わった後にチェックする 1101 1057 def check_param 1102 1058 @param_list.get_items.each { |i| 1103 next if i == nil # i == nil : ã¨ã©ã¼æ1059 next if i == nil # i == nil : エラー時 1104 1060 1105 1061 if i.get_type.class == VoidType then 1106 # åä¸ã® void åã¯ããã«ã¯ããªã1062 # 単一の void 型はここにはこない 1107 1063 cdl_error( "S2027 '$1' parameter cannot be void type", i.get_name ) 1108 1064 end … … 1111 1067 if size then 1112 1068 val = size.eval_const( @param_list ) 1113 if val == nil then # å®æ°å¼ã§ãªããï¼1114 # mikan å¤æ°ãå«ãå¼ï¼åä¸ã®å¤æ°ã®ã¿OK1069 if val == nil then # 定数式でないか? 1070 # mikan 変数を含む式:単一の変数のみ OK 1115 1071 type = size.get_type( @param_list ) 1116 1072 unless type.kind_of?( IntType ) then … … 1150 1106 if count then 1151 1107 val = count.eval_const( @param_list ) 1152 if val == nil then # å®æ°å¼ã§ãªããï¼1153 # mikan å¤æ°ãå«ãå¼ï¼åä¸ã®å¤æ°ã®ã¿OK1108 if val == nil then # 定数式でないか? 1109 # mikan 変数を含む式:単一の変数のみ OK 1154 1110 type = count.get_type( @param_list ) 1155 1111 unless type.kind_of?( IntType ) then … … 1170 1126 if string != -1 && string then 1171 1127 val = string.eval_const( @param_list ) 1172 if val == nil then # å®æ°å¼ã§ãªããï¼1173 # mikan å¤æ°ãå«ãå¼ï¼åä¸ã®å¤æ°ã®ã¿OK1128 if val == nil then # 定数式でないか? 1129 # mikan 変数を含む式:単一の変数のみ OK 1174 1130 type = string.get_type( @param_list ) 1175 1131 unless type.kind_of?( IntType ) then … … 1195 1151 end 1196 1152 1197 #=== Push Pop Allocator ãå¿ 1198 è¦ãï¼ 1199 # Transparent RPC ã®å ´å (oneway ãã¤) in ã®é 1200 å(size_is, count_is, string ã®ããããã§ä¿®é£¾ï¼ããã 1153 #=== Push Pop Allocator が必要か? 1154 # Transparent RPC の場合 (oneway かつ) in の配列(size_is, count_is, string のいずれかで修飾)がある 1201 1155 def need_PPAllocator?( b_opaque = false ) 1202 1156 @param_list.get_items.each { |i| … … 1212 1166 end 1213 1167 1214 #== ParamList# æååå1215 #b_name:: Bool: ãã©ã¡ã¼ã¿åãå«ãã1168 #== ParamList# 文字列化 1169 #b_name:: Bool: パラメータ名を含める 1216 1170 def to_str( b_name ) 1217 1171 str = "(" … … 1236 1190 end 1237 1191 1238 #== CDL ã®æååãªãã©ã«ãæ±ãããã®ã¯ã©ã¹1239 # CDL ã®æååãªãã©ã«ãã®ãã®ã§ã¯ãªã1192 #== CDL の文字列リテラルを扱うためのクラス 1193 # CDL の文字列リテラルそのものではない 1240 1194 class CDLString 1241 # ã¨ã¹ã±ã¼ãæåãå¤æ1195 # エスケープ文字を変換 1242 1196 def self.escape str 1243 1197 str = str.dup … … 1251 1205 str.gsub!( /(\\[Xx][0-9A-Fa-f]{1,2})/, '{printf \"\\1\"}' ) 1252 1206 str.gsub!( /(\\[0-7]{1,3})/, '{printf \"\\1\"}' ) 1253 str.gsub!( /\\(.)/, "\\1" ) # mikan æªå®ç¾©ã®ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãå¤æãã¦ãã¾ã (gcc V3.4.4 ã§ã¯è¦åãåºããã)1207 str.gsub!( /\\(.)/, "\\1" ) # mikan 未定義のエスケープシーケンスを変換してしまう (gcc V3.4.4 では警告が出される) 1254 1208 return str 1255 1209 end 1256 1210 1257 #=== CDLString# åå¾ã® " ãåãé¤ã1211 #=== CDLString#前後の " を取り除く 1258 1212 def self.remove_dquote str 1259 1213 s = str.sub( /\A"/, "" ) … … 1263 1217 end 1264 1218 1265 #== CDL ã®åæååãæ±ãããã®ã¯ã©ã¹1266 # CDL ã®åæååãã®ãã®ã§ã¯ãªã1219 #== CDL の初期化子を扱うためのクラス 1220 # CDL の初期化子そのものではない 1267 1221 class CDLInitializer 1268 #=== åæååã®ã¯ãã¼ã³1269 # åæåå㯠Expression, C_EXP, Array ã®ãããã1222 #=== 初期化子のクローン 1223 # 初期化子は Expression, C_EXP, Array のいずれか 1270 1224 def self.clone_for_composite( rhs, ct_name, cell_name, locale ) 1271 1225 if rhs.instance_of? C_EXP then 1272 # C_EXP ã® clone ãä½ãã¨ã¨ãã«ç½®æ1226 # C_EXP の clone を作るとともに置換 1273 1227 rhs = rhs.clone_for_composite( ct_name, cell_name, locale ) 1274 1228 elsif rhs.instance_of? Expression then … … 1282 1236 end 1283 1237 1284 #=== åæååï¼é 1285 åï¼ã®ã¯ãã¼ã³ 1286 # è¦ç´ 㯠clone_for_composite ãæã¤ãã®ã ã 1238 #=== 初期化子(配列)のクローン 1239 # 要素は clone_for_composite を持つものだけ 1287 1240 def self.clone_for_compoiste_array( array, ct_name, cell_name, locale ) 1288 # "compoiste.identifier" ã®å ´å (CDL ã¨ãã¦ã¯èª¤ã)1241 # "compoiste.identifier" の場合 (CDL としては誤り) 1289 1242 if array[0] == :COMPOSITE then 1290 1243 return array.clone -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/tecs_lang.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 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 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
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/tecsgen.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 56 41 class TECSGEN 57 42 58 @@b_post_coded = false # ãã¹ãã³ã¼ãçæéå§å¾true59 60 #=== import ãã¹ (-I) ãæ«å°¾ã«è¿½å61 # æ¢ã«ç»é²æ¸ã¿ã§ããã°ã追å ããªã43 @@b_post_coded = false # ポストコード生成開始後 true 44 45 #=== import パス (-I) を末尾に追加 46 # 既に登録済みであれば、追加しない 62 47 def self.add_import_path path 63 48 if $import_path.index( path ) == nil then … … 67 52 end 68 53 69 #=== EXEB çã®ãã¹ã®èª¿æ´70 # ç°å¢å¤æ° TECSPATH ã cygwin ã¹ã¿ã¤ã«ã ã¨ãexerb çã§ã¯æ±ããªã71 # $import_path 㨠$TECSPATH ã調æ´ãã54 #=== EXEB 版のパスの調整 55 # 環境変数 TECSPATH が cygwin スタイルだと、exerb 版では扱えない 56 # $import_path と $TECSPATH を調整する 72 57 def self.adjust_exerb_path 73 58 if $IN_EXERB then … … 76 61 paths = [] 77 62 $import_path.each{ |path| 78 # cygpath 㯠'..' ãç°¡ç´ãã¦ãã¾ãã®ã§ãnew_tecspath ã§ç½®æãã63 # cygpath は '..' を簡約してしまうので、new_tecspath で置換する 79 64 # paths << cygpath( path, path ) 80 65 paths << path.sub( pattern, new_tecspath ) … … 87 72 end 88 73 89 #=== $(TECSPATH) ã¸ã®ç½®æ90 #path::String : ENV[ 'TECSPATH' ] ã«ä¸è´ããé¨åãããã°ã "$(TECSPATH)" ã«ç½®æ91 #b_global::Bool : true ãªã gsub ã§ç½®æãfalse ãªã sub ã§ç½®æ74 #=== $(TECSPATH) への置換 75 #path::String : ENV[ 'TECSPATH' ] に一致する部分があれば、 "$(TECSPATH)" に置換 76 #b_global::Bool : true なら gsub で置換。false なら sub で置換 92 77 def self.subst_tecspath( path, b_global = false ) 93 78 tp = $tecspath.dup … … 104 89 end 105 90 106 #=== path ã¯çµ¶å¯¾ãã¹ã?91 #=== path は絶対パスか? 107 92 #path:: String : 108 # '/' ã¾ã㯠'$' ã§å§ã¾ãå ´åã絶対ãã¹ã¨å¤å®ãã93 # '/' または '$' で始まる場合、絶対パスと判定する 109 94 def self.is_absolute_path?( path ) 110 95 pa = path[0..0]; pa2 = path[0..1] … … 118 103 end 119 104 120 #=== tecsgen ã®ããã©ã«ããè¨å®105 #=== tecsgen のデフォルトを設定 121 106 def self.set_default_config 122 107 Makefile::set_default_config … … 124 109 125 110 ### 126 #== Makefile.templ ã®åºåå 127 容ã追å ãå¤æ´ããããã®æä½ 111 #== Makefile.templ の出力内容を追加、変更するための操作 128 112 module Makefile 129 # åºå®ããã¦ããå¤æ°(add_var ã§å¤æ´ã§ããªã)113 # 固定されている変数(add_var で変更できない) 130 114 @@fixed_vars = { :INCLUDES => nil, :DEFINES => nil, :TARGET_BASE => nil, :BASE_DIR => nil } 131 115 @@config_mode = false … … 142 126 @@lines = [] 143 127 144 #=== OTHER_OBJS ã«è¿½å ãã128 #=== OTHER_OBJS に追加する 145 129 def self.add_obj obj 146 130 @@objs << obj 147 131 end 148 #=== 追å ããå¤æ°149 # ãã©ã°ã¤ã³ããã¯ãããã©ã«ãå¤ãå¤æ´ã§ãã150 # config ã«ãã132 #=== 追加する変数 133 # プラグインからは、デフォルト値を変更できる 134 # config により 151 135 def self.add_var( var, val, comment = nil ) 152 136 if @@fixed_vars[ var ] … … 161 145 end 162 146 end 163 #=== LDFLAGS ã«è¿½å ãã147 #=== LDFLAGS に追加する 164 148 def self.add_ldflag ldflag 165 149 @@ldflags += " " + ldflag 166 150 end 167 #=== ãµã¼ããã¹ã追å ãã168 # CFLAGS, vpath ã«è¿½å ãã151 #=== サーチパスを追加する 152 # CFLAGS, vpath に追加する 169 153 def self.add_search_path path 170 154 @@search_path << path 171 155 end 172 #=== PRE_TECSGEN_TARGET ã«è¿½å ãã173 # PRE_TECSGEN_TARGET ã« target ã追å ãã156 #=== PRE_TECSGEN_TARGET に追加する 157 # PRE_TECSGEN_TARGET に target を追加する 174 158 def self.add_pre_tecsgen_target target 175 159 @@pre_tecsgen_target << pre_tecsgen_target 176 160 end 177 #=== POST_TECSGEN_TARGET ã«è¿½å ãã178 # POST_TECSGEN_TARGET ã« target ã追å ãã161 #=== POST_TECSGEN_TARGET に追加する 162 # POST_TECSGEN_TARGET に target を追加する 179 163 def self.add_post_tecsgen_target target 180 164 @@post_tecsgen_target << pre_tecsgen_target 181 165 end 182 #=== 追å ããå¤æ°166 #=== 追加する変数 183 167 def self.add_line( line ) 184 168 @@lines << line.to_s + "\n" 185 169 end 186 170 187 def self.get_objs # Array ãè¿ã171 def self.get_objs # Array を返す 188 172 return @@objs.uniq 189 173 end 190 def self.get_vars # Array ãè¿ã174 def self.get_vars # Array を返す 191 175 if RUBY_VERSION >= '1.9' then 192 176 return (@@vars.keys + @@vars_default.keys).sort.uniq 193 177 else 194 # V1.8 ã§ã¯ãSymbol ã® sort ãã§ããªãã®ã§ãä¸æ¦ String ã«ç½®æãã178 # V1.8 では、Symbol の sort ができないので、一旦 String に置換する 195 179 return (@@vars.keys + @@vars_default.keys).map{|s| s.to_s }.sort.uniq.map!{|s| s.to_sym } 196 180 end … … 202 186 return @@var_comments[ var ] 203 187 end 204 def self.get_ldflags # String ãè¿ã188 def self.get_ldflags # String を返す 205 189 return @@ldflags 206 190 end 207 def self.get_search_path # Array ãè¿ã191 def self.get_search_path # Array を返す 208 192 return @@search_path.uniq 209 193 end 210 def self.get_pre_tecsgen_target # Array ãè¿ã194 def self.get_pre_tecsgen_target # Array を返す 211 195 return @@pre_tecsgen_target.uniq 212 196 end 213 def self.get_post_tecsgen_target # Array ãè¿ã197 def self.get_post_tecsgen_target # Array を返す 214 198 return @@post_tecsgen_target.uniq 215 199 end 216 def self.get_lines # ä»å ããè¡ãå¾ã200 def self.get_lines # 付加する行を得る 217 201 return @@lines.uniq 218 202 end 219 203 220 #=== TECSGEN ã®ããã©ã«ãè¨å®ãè¡ã204 #=== TECSGEN のデフォルト設定を行う 221 205 # Makefile 222 # @@fixed_vars ã§å®ç¾©ããã¦ããå¤æ°ã¯ãå¤æ´ã§ãããå®æ°å®ç¾©ããã¦ãã206 # @@fixed_vars で定義されている変数は、変更できず、定数定義されている 223 207 def self.set_default_config 224 208 add_var( "TARGET", "$(TARGET_BASE).exe", "default target name" ) … … 241 225 242 226 def syntax_analisys argv 243 # ã«ã¼ã namespace (region) ãçæ227 # ルート namespace (region) を生成 244 228 @root_namespace = Region.new("::") 245 229 246 #### æ§æ解æ (post ã³ã¼ããé¤ã) ####247 # ãã¹ã¦ã® cdl ã import ãã230 #### 構文解析 (post コードを除く) #### 231 # すべての cdl を import する 248 232 argv.each{ |f| 249 233 dbgPrint( "## Import: #{f}\n") … … 251 235 } 252 236 253 # ãã¹ã¦ã®æ§æ解éãå®äºãããã¨ã®å ±å254 # å®éã«ã¯ãå¾ãããã©ã°ã¤ã³ã®çæãã CDL ã®ãã¼ã¹ãè¡ããã255 # ã¨ã©ã¼è¡æ°ã®æ±ºå®æ¹æ³ã®å¤æ´ã®ããã«è¡ã237 # すべての構文解釈が完了したことの報告 238 # 実際には、後からプラグインの生成する CDL のパースが行われる 239 # エラー行数の決定方法の変更のために行う 256 240 Generator.end_all_parse 257 241 dbgPrint( "## End all parse (except Post Code)\n") … … 262 246 # other objects (signature, celltype, typedef, etc ) are checked while syntax analisys 263 247 def semantics_analisys_1 264 #### æå³è§£æï¼ (post ã³ã¼ããé¤ã) ####248 #### 意味解析1 (post コードを除く) #### 265 249 dbgPrint( "## Creating reverse join \n") 266 250 Cell.create_reverse_join … … 270 254 Celltype.check_dynamic_join 271 255 272 #0 set_definition_join ã¯2åå¼ã³åºãããï¼1åç®ï¼256 #0 set_definition_join は2回呼び出される(1回目) 273 257 dbgPrint( "## Checking all join\n") 274 258 @root_namespace.set_definition_join 275 # @root_namespace.set_require_join ### ãã£ããè¦åãããéè¤ã¨ã©ã¼ãè¦éã276 # through ãã©ã°ã¤ã³ã§çæãããã»ã«ã«ã require ãçæã§ãã (set_definition_join ã®å¾ãã§å®æ½)277 278 #### post ã³ã¼ãã®çæã¨æ§æ解æ####279 @@b_post_coded = true # ãã¹ãã³ã¼ãçæéå§å¾true280 # å¼æ°ããªããã°ããã©ã°ã¤ã³ã®ãã¹ãã³ã¼ããåºåããªã259 # @root_namespace.set_require_join ### いったん見合わせ。重複エラーを見逃す 260 # through プラグインで生成されたセルにも require も生成できる (set_definition_join の後ろで実施) 261 262 #### post コードの生成と構文解析 #### 263 @@b_post_coded = true # ポストコード生成開始後 true 264 # 引数がなければ、プラグインのポストコードを出力しない 281 265 if ARGV.length > 0 then 282 266 dbgPrint( "## Generating Post Code\n") 283 # ãã©ã°ã¤ã³ã®ãã¹ãã³ã¼ãã®åºåã¨import267 # プラグインのポストコードの出力と import 284 268 tmp_file_name = "#{$gen}/tmp_plugin_post_code.cdl" 285 269 file = nil … … 291 275 292 276 if file then 293 # through ãã©ã°ã¤ã³ã®ãã¹ãã³ã¼ãçæ277 # through プラグインのポストコード生成 294 278 PluginModule.gen_plugin_post_code file 295 279 … … 304 288 end 305 289 306 #### æå³è§£æï¼ (post ã³ã¼ã) ####290 #### 意味解析1 (post コード) #### 307 291 dbgPrint( "## Creating reverse join (for post code) \n") 308 292 Cell.create_reverse_join 309 293 310 # Join ã®å®ç¾©ã®è¨å®ã¨ãã§ã㯠311 #0 # åæ¹åç 312 §å¯¾å¿ 313 #0 set_definition_join ã¯2åå¼ã³åºãããï¼2åç®ï¼ post_code ã§çæããã 294 # Join の定義の設定とチェック 295 #0 # 前方参照対応 296 #0 set_definition_join は2回呼び出される(2回目) post_code で生成された 314 297 dbgPrint( "## Checking all join (for cells generated by Post Code\n") 315 298 @root_namespace.set_definition_join … … 317 300 318 301 dbgPrint( "## Set require join\n") 319 @root_namespace.set_require_join # mikan post ã®åã«ã 320 # ãã¹ãã³ã¼ãã§çæãããã»ã«ã® require ã®join ãçæ 321 # mikan require 㧠through ãé©ç¨ããã¦ããã¹ãã³ã¼ããå¿ 322 è¦ã¨ãªã£ã¦ãåºåãããªã 302 @root_namespace.set_require_join # mikan post の前にも 303 # ポストコードで生成されたセルの require のjoin を生成 304 # mikan require で through が適用されて、ポストコードが必要となっても出力されない 323 305 end # semantics_analisys_1 324 306 325 307 def semantics_analisys_2 326 #### æå³è§£æï¼####308 #### 意味解析2 #### 327 309 Cell.make_cell_list2 328 310 dbgPrint( "## Set fixed join\n") 329 311 Cell.create_reverse_require_join 330 # create_reverse_require_join 㯠set_detinition_join ã«åãè¾¼ããã¨ãã§ããªã 331 # namespace ã«ä¾åããªãåºç¾é ã§è¡ã 332 # mikan through ãã©ã°ã¤ã³ãé©ç¨ãããã¹ãã³ã¼ãã«å½±é¿ãä¸ããå ´åãèæ 333 ®ã§ãã¦ããªã 334 # mikan post code ã«å½±é¿ã®ãããã®ã§ããã°ãæ©ãã« reverse_require_join ã®çµåãå¿ 335 è¦ 312 # create_reverse_require_join は set_detinition_join に埋め込むことができない 313 # namespace に依存しない出現順で行う 314 # mikan through プラグインが適用されポストコードに影響を与える場合が考慮できていない 315 # mikan post code に影響のあるものであれば、早くに reverse_require_join の結合が必要 336 316 dbgPrint( "## Setting port reference count\n") 337 317 @root_namespace.set_port_reference_count … … 340 320 @root_namespace.check_join 341 321 342 # mikan ãã©ã°ã¤ã³ã§çæãããã³ã³ãã¼ãã³ãã®set_def_and_check_join322 # mikan プラグインで生成されたコンポーネントの set_def_and_check_join 343 323 344 324 dbgPrint( "## Checking referenced but undefined cell\n") … … 347 327 348 328 def optimize_and_generate 349 #### Region link root ãã¨ã«ãªããã£ãã¤ãºããã³çæ####329 #### Region link root ごとにオプティマイズおよび生成 #### 350 330 Region.get_link_roots.each { |region| 351 331 … … 369 349 end 370 350 371 # ã»ã«ãä¸ã¤ããªããã°çæããªã372 # ã»ã«ã®çæããªãå ´å351 # セルが一つもなければ生成しない 352 # セルの生成がない場合 373 353 if region.get_n_cells == 0 then 374 354 if $region_list.length > 0 then … … 400 380 401 381 dbgPrint( "## Unset optimize variables\n") 402 @root_namespace.reset_optimize # æé©åããªã»ãããã382 @root_namespace.reset_optimize # 最適化をリセットする 403 383 404 384 if Generator.get_n_error == 0 then 405 # ã¨ã©ã¼ãçºçãã¦ããããè¨å®ããªã385 # エラーが発生していたら、設定しない 406 386 dbgPrint( "## Set cell id\n") 407 @root_namespace.set_cell_id_and_domain # ã»ã«ã® ID ã¨ãã¡ã¤ã³æ 408 å ±ãè¨å®ï¼linkunit æ¯ã«0ããã¤ããï¼ 409 410 # ã¨ã©ã¼ãçºçãã¦ããããæé©åã¯å®æ½ããªã 387 @root_namespace.set_cell_id_and_domain # セルの ID とドメイン情報を設定(linkunit 毎に0からつける) 388 389 # エラーが発生していたら、最適化は実施しない 411 390 if ! $unopt then 412 391 dbgPrint( "## Optimizing: Link Region=#{@root_namespace.get_name}\n") … … 416 395 417 396 if $show_tree then 418 # ã¨ã©ã¼ãçºçãã¦ãã¦ã表示ï¼ã¨ã©ã¼çºçæã¯æé©åããã¦ããªãã®ã§æ³¨æï¼397 # エラーが発生していても表示(エラー発生時は最適化されていないので注意) 419 398 print "##### show_tree LinkRegion=#{region.get_name} #####\n" 420 399 @root_namespace.show_tree(0) … … 422 401 end 423 402 424 # æ§æ解éãæå³è§£æã§ã¨ã©ã¼çºçãã¦ããããã³ã¼ãçæãããªã403 # 構文解釈、意味解析でエラー発生していたら、コード生成をしない 425 404 if Generator.get_n_error != 0 then 426 405 print_report … … 428 407 end 429 408 430 #### ã³ã¼ãçæ####409 #### コード生成 #### 431 410 begin 432 411 dbgPrint( "## Generating: Link Region=#{@root_namespace.get_name}\n") … … 435 414 @root_namespace.generate_post 436 415 rescue 437 # é常ããã¸ã¯æ¥ãªã (generate, generate_post ã§å¦ç½®ããã)416 # 通常ここへは来ない (generate, generate_post で処置される) 438 417 Generator.error( "G9999 fail to generate" ) 439 418 end … … 453 432 } 454 433 455 # update ãã456 # APPFile ã§çæããããã¡ã¤ã«ã¯ãããå¤åãããã°ãããã§æ´æ°ãã457 # ã³ã¼ãçæ段éã§ã¨ã©ã¼ãçºçããã°ãæ´æ°ããªã458 # CFile ã§çæããããã®ã¯ãæ´æ°ããã¦ãã434 # update する 435 # APPFile で生成されたファイルは、もし変化があれば、ここで更新する 436 # コード生成段階でエラーが発生すれば、更新しない 437 # CFile で生成されたものは、更新されている 459 438 if Generator.get_n_error == 0 then 460 439 begin … … 477 456 def dump_tecsgen_rbdmp 478 457 dbgPrint "dump_tecsgen_rbdmp 0:\n" 479 #### unjoin_plugin å¾ã«è¡ãå¿ 480 è¦ããããããã³ã¼ãçæå¾ã«ãã³ããè¡ã 481 #### Region link root ãã¨ã«ãªããã£ãã¤ãºãã¦ãã³ã #### 458 #### unjoin_plugin 後に行う必要があるため、コード生成後にダンプを行う 459 #### Region link root ごとにオプティマイズしてダンプ #### 482 460 Namespace.get_root.unjoin_plugin 483 461 Namespace.get_root.find_plugin 0, [] … … 497 475 498 476 dbgPrint "dump_tecsgen_rbdmp 2: Region.path_str: #{region.get_namespace_path.get_path_str}\n" 499 # ã»ã«ãä¸ã¤ããªããã°çæããªã500 # ã»ã«ã®çæããªãå ´å477 # セルが一つもなければ生成しない 478 # セルの生成がない場合 501 479 if region.get_n_cells == 0 then 502 480 # if $region_list.length > 0 then … … 522 500 dbgPrint "dump_tecsgen_rbdmp 4: Region.path_str: #{region.get_namespace_path.get_path_str}\n" 523 501 dbgPrint( "## Unset optimize variables\n") 524 @root_namespace.reset_optimize # æé©åããªã»ãããã502 @root_namespace.reset_optimize # 最適化をリセットする 525 503 526 504 # if Generator.get_n_error == 0 then 527 # # ã¨ã©ã¼ãçºçãã¦ããããããã¸ã¯æ¥ãªã505 # # エラーが発生していたら、ここへは来ない 528 506 dbgPrint( "## Set cell id\n") 529 @root_namespace.set_cell_id_and_domain # ã»ã«ã® ID ã¨ãã¡ã¤ã³æ 530 å ±ãè¨å®ï¼linkunit æ¯ã«0ããã¤ããï¼ 531 532 # ã¨ã©ã¼ãçºçãã¦ããããæé©åã¯å®æ½ããªã 507 @root_namespace.set_cell_id_and_domain # セルの ID とドメイン情報を設定(linkunit 毎に0からつける) 508 509 # エラーが発生していたら、最適化は実施しない 533 510 if ! $unopt then 534 511 dbgPrint( "## Optimizing: Link Region=#{@root_namespace.get_name}\n") -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/tecsinfo.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2017-2018 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ 53 38 #++ 54 39 55 # TECS æ 56 å ±ã»ã«ã®çæ 40 # TECS 情報セルの生成 57 41 module TECSInfo 58 # region 㯠Link root ã®ãã¨42 # region は Link root のこと 59 43 def self.print_info f, region 60 44 # p "region: "+ region.get_name.to_s … … 67 51 Type.reset_print_info 68 52 69 # mikan å 70 ¨é¨çæããã®ã§ã¯ãªããregion ä¸ã®ã»ã«ã®ã»ã«ã¿ã¤ãã¨ãããããåç 71 §ãããã·ã°ããã£ãã»ã«ã¿ã¤ãã«éå®ãã¦åºåãã¹ã 72 # ããããæå³è§£æå¾ã«åºåãããããããã¯å®¹æã§ã¯ãªãï¼æé©åã¨ã³ã¼ãçæã¯ããªã³ã¯ã«ã¼ããã¨ã«è¡ãããï¼ 53 # mikan 全部生成するのではなく、region 下のセルのセルタイプと、そこから参照されるシグニチャ、セルタイプに限定して出力すべき 54 # しかし、意味解析後に出力するため、これは容易ではない.最適化とコード生成は、リンクルートごとに行われる. 73 55 Namespace.print_info f, indent 74 56 region.get_link_root.print_info f, indent … … 90 72 91 73 class Namespace 92 # RootRegion 㨠LinkRegion ã¯åã Region ã¯ã©ã¹ã®ãªãã¸ã§ã¯ãã§ãã 93 # åãã¼ã ã¹ãã¼ã¹ã¯ Namespace ã¯ã©ã¹ã®ãåãªã¼ã¸ã§ã³ã¯ Region ã¯ã©ã¹ã®ãªãã¸ã§ã¯ãã§ãã 94 # ããã¯ãæå³è§£æ段éã§å¼ã³åºãããããããªã³ã¯ã¦ããããã¨ã«åºãããããã¨ãã§ããªã 95 # åºããããã«ã¯ã2ãã¹ã«ããå¿ 96 è¦ããã 74 # RootRegion と LinkRegion は同じ Region クラスのオブジェクトである 75 # 子ネームスペースは Namespace クラスの、子リージョンは Region クラスのオブジェクトである 76 # これは、意味解析段階で呼び出されるため、リンクユニットごとに出しわけることができない 77 # 出しわけるには、2パスにする必要がある 97 78 def print_info_ns_sub f, indent 98 79 if @name == "::" then … … 151 132 } 152 133 @namespace_list.each { |ns| 153 if ns.instance_of? Namespace then # region ãå«ããªã134 if ns.instance_of? Namespace then # region を含めない 154 135 ns.print_info_ns f, indent 155 136 end … … 161 142 end 162 143 163 #=== Namespace# æ§é ä½ã¡ã³ãã¼ã®ãªãã»ããå®ç¾©144 #=== Namespace# 構造体メンバーのオフセット定義 164 145 def print_struct_define f 165 146 f.print "\n/***** Offset of members of structures *****/\n" … … 184 165 } 185 166 @namespace_list.each { |ns| 186 if ns.instance_of? Namespace then # region ãå«ããªã167 if ns.instance_of? Namespace then # region を含めない 187 168 ns.print_celltype_define_offset f 188 169 end … … 197 178 } 198 179 @namespace_list.each { |ns| 199 if ns.instance_of? Namespace then # region ãå«ããªã180 if ns.instance_of? Namespace then # region を含めない 200 181 ns.print_celltype_define f 201 182 end … … 210 191 } 211 192 @namespace_list.each { |ns| 212 if ns.instance_of? Namespace then # region ãå«ããªã193 if ns.instance_of? Namespace then # region を含めない 213 194 ns.print_call_define f 214 195 end … … 223 204 } 224 205 @namespace_list.each { |ns| 225 if ns.instance_of? Namespace then # region ãå«ããªã206 if ns.instance_of? Namespace then # region を含めない 226 207 ns.print_entry_define f 227 208 end … … 415 396 416 397 def print_define_offset f 417 # intptr_t ã«ä¸åãã£ã¹ãããã®ã¯ 64bit çãèéãã¦ã®ãã¨ï¼ããã 32bit ã¨ãã¦ããã®ã§ 4GB ãè¶ 418 ããæ§é ä½çã¯æ±ããªã 398 # intptr_t に一回キャストするのは 64bit 版を考量してのこと.しかし 32bit としているので 4GB を超える構造体等は扱えない 419 399 if @n_cell_gen > 0 then 420 400 f.print <<EOT … … 453 433 // #include "#{@global_name}_tecsgen.h" // no cell exist 454 434 EOT 455 # çæãããªãã»ã«ã¿ã¤ã435 # 生成されないセルタイプ 456 436 @attribute.each{ |decl| 457 437 f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff" … … 641 621 red = "(void *)0" 642 622 end 643 # mikan åãå£é 644 å 623 # mikan 受け口配列 645 624 f.print <<EOT 646 625 #{indent}cell nTECSInfo::tRawEntryDescriptorInfo #{@global_name}_#{port.get_name}RawEntryDescriptorInfo { … … 795 774 796 775 def print_info f, indent 797 # Type ã® info ã¯ãæå¾ã«ã¾ã¨ãã¦åºåããã®ã§ãããã§ã¯è¨é²ããã ã776 # Type の info は、最後にまとめて出力するので、ここでは記録するだけ 798 777 if @@typeinfo_printed[ get_ID_str ] then 799 778 return … … 821 800 822 801 def print_info_post f, indent 823 if self.class.superclass == Type then # 親ã¯ã©ã¹ã Type ã®å ´å types.rb ã®ã¯ã©ã¹802 if self.class.superclass == Type then # 親クラスが Type の場合 types.rb のクラス 824 803 type_name = self.class.name 825 804 else 826 type_name = self.class.superclass.name # ctypes.rb ã®ã¯ã©ã¹ (親ã¯ã©ã¹ã types.rb ã®ã¯ã©ã¹)805 type_name = self.class.superclass.name # ctypes.rb のクラス (親クラスが types.rb のクラス) 827 806 end 828 807 # p "type: #{type_name}, #{self.class.name}" … … 856 835 end 857 836 858 #=== Type# åæååã®èå¥åå859 # åæååã«å«ã¾ããèå¥åã¨ãã¦ç¨ãããã¨ã®ã§ããªãæåãç¨ãããã¨ã®ã§ããæååã«ç½®ãæãã860 # 空ç½=> __837 #=== Type# 型文字列の識別子化 838 #型文字列に含まれる識別子として用いることのできない文字を用いることのできる文字列に置き換える 839 # 空白 => __ 861 840 # * => _Ptr_ 862 841 # [] => _Array_ -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/tool_info.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ … … 307 292 308 293 #== Cell_location 309 # tecscde ã®ä½ç½®æ 310 å ± 294 # tecscde の位置情報 311 295 class Cell_location 312 296 … … 335 319 336 320 #== Join_location 337 # tecscde ã®ä½ç½®æ 338 å ± 321 # tecscde の位置情報 339 322 class Join_location 340 323 @@join_location_list = [] -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/types.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ 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 … … 774 733 # @members_decl:: NamedList 775 734 # @definition:: StructType 776 # @b_has_pointer_member:: bool : ã¡ã³ãã«ãã¤ã³ã¿åããã777 # @b_has_sized_pointer_member:: bool : ã¡ã³ãã«ãã¤ã³ã¿åããã778 # @b_has_unsized_string_member:: bool : ã¡ã³ãã«ãã¤ã³ã¿åããã779 # @b_hasTag:: bool : ã¿ã°ããã780 # @member_types_symbol:: Symbol : tag ãç¡ãæã®ã¿è¨å® (ãã以å¤ã§ã¯nil)735 # @b_has_pointer_member:: bool : メンバにポインタ型がある 736 # @b_has_sized_pointer_member:: bool : メンバにポインタ型がある 737 # @b_has_unsized_string_member:: bool : メンバにポインタ型がある 738 # @b_hasTag:: bool : タグがある 739 # @member_types_symbol:: Symbol : tag が無い時のみ設定 (それ以外では nil) 781 740 782 741 @@structtype_current_stack = [] 783 742 @@structtype_current_sp = -1 784 743 785 # tag ãªãstruct744 # tag なし struct 786 745 @@no_struct_tag_num = 0 787 746 @@no_tag_struct_list = {} … … 811 770 if @b_define then 812 771 @members_decl = NamedList.new( nil, "in struct #{@tag}" ) 813 # if @tag then ç»é²ã¿ã¤ãã³ã°ãçµããã«å¤æ´V1.0.2.19772 # if @tag then 登録タイミングを終わりに変更 V1.0.2.19 814 773 # Namespace.new_structtype( self ) 815 774 # end 816 775 else 817 776 @definition = Namespace.find_tag( @tag ) 818 # check_struct_tag ã«ç§»ãV1.0.2.19777 # check_struct_tag に移す V1.0.2.19 819 778 # if @definition == nil then 820 779 # cdl_error( "T1021 \'$1\': struct not defined" , @tag ) … … 841 800 end 842 801 843 def check # æå³ç誤ããããã°ãæååãè¿ã802 def check # 意味的誤りがあれば、文字列を返す 844 803 nil 845 804 end 846 805 847 #=== æ§é ä½ã®ã¿ã°ããã§ã㯠848 # declarator ã®æç¹ã§ãã§ãã¯ãã 849 #kind:: Decl ã® @kind ãåç 850 § 806 #=== 構造体のタグをチェック 807 # declarator の時点でチェックする 808 #kind:: Decl の @kind を参照 851 809 def check_struct_tag kind 852 810 if @tag == nil … … 860 818 end 861 819 862 # mikan Float åã® C_EXP å¯¾å¿ (generate.rb ã«ãå¤æ´å¿ 863 è¦) 820 # mikan Float 型の C_EXP 対応 (generate.rb にも変更必要) 864 821 def check_init( locale, ident, initializer, kind, attribute = nil ) 865 822 … … 870 827 end 871 828 872 # åæååãå¼ã®å ´åãåï¼ã¿ã°ï¼ãä¸è´ããããã§ãã¯829 # 初期化子が式の場合、型(タグ)が一致するかチェック 873 830 if initializer.instance_of?( Expression ) then 874 831 t = initializer.get_type( attribute ) … … 906 863 907 864 def end_of_parse() 908 if @members_decl == nil # @b_define = false ã¾ãã¯ã¡ã³ãã¼ã®ãªãæ§é ä½ï¼ã¨ã©ã¼ï¼865 if @members_decl == nil # @b_define = false またはメンバーのない構造体(エラー) 909 866 return 910 867 end … … 932 889 string = md.get_string 933 890 if string == -1 then 934 # é·ãæå®ãªã891 # 長さ指定なし 935 892 elsif string then 936 893 val = string.eval_const( @members_decl ) … … 970 927 971 928 if @b_hasTag then 972 # typedef struct tag StructType; ã®å½¢å¼ã®å ´å973 # struct ã®æ¬ä½ã¯ãå¥ã«çæããã929 # typedef struct tag StructType; の形式の場合 930 # struct の本体は、別に生成される 974 931 return "#{str}struct #{@tag}" 975 932 976 933 else 977 # typedef struct { int a; } StructType; ã®å½¢å¼ã®å ´å934 # typedef struct { int a; } StructType; の形式の場合 978 935 str += "struct {" 979 936 @members_decl.get_items.each{ |i| … … 1026 983 end 1027 984 1028 #=== åãæ§é ä½ãã©ãããã§ãã¯ãã1029 # tag ã®ãã§ãã¯ã¯è¡ããªã1030 # ãã¹ã¦ã®ã¡ã³ãã®ååã¨åãä¸è´ãããã¨ã確èªãã985 #=== 同じ構造体かどうかチェックする 986 # tag のチェックは行わない 987 # すべてのメンバの名前と型が一致することを確認する 1031 988 def same? another 1032 989 md = another.get_members_decl … … 1118 1075 end 1119 1076 1120 def check # æå³ç誤ããããã°ãæååãè¿ã 1121 if @type.class == ArrayType then # é 1122 åãè¿ãé¢æ° 1077 def check # 意味的誤りがあれば、文字列を返す 1078 if @type.class == ArrayType then # 配列を返す関数 1123 1079 return "function returning array" 1124 elsif @type.class == FuncType then # é¢æ°ãè¿ãé¢æ°1080 elsif @type.class == FuncType then # 関数を返す関数 1125 1081 return "function returning function" 1126 1082 end 1127 return @type.check # é¢æ°ã® return ããåã®ãã§ãã¯1128 1129 # ãã©ã¡ã¼ã¿ã®åã®ãã§ãã¯ã¯ ParamList#check_param ã§è¡ã1083 return @type.check # 関数の return する型のチェック 1084 1085 # パラメータの型のチェックは ParamList#check_param で行う 1130 1086 end 1131 1087 1132 1088 def check_struct_tag kind 1133 1089 @type.check_struct_tag kind 1134 # ParamDecl ã§ããã§ãã¯ãããã®ã§ãããã§ã¯ãã§ãã¯ããªã1090 # ParamDecl でもチェックされるので、ここではチェックしない 1135 1091 # @paramlist.check_struct_tag kind 1136 1092 end … … 1149 1105 end 1150 1106 1151 #=== return type ãè¿ã1107 #=== return type を返す 1152 1108 # 1153 # return type ãè¿ã1154 # get_return_type ã¨ãã¹ãã ã£ã1109 # return type を返す 1110 # get_return_type とすべきだった 1155 1111 def get_type 1156 1112 @type … … 1162 1118 1163 1119 def get_type_str_post 1164 # åã ããè¿ã (ä»®å¼æ°ã®ååãå«ããªã)1120 # 型だけを返す (仮引数の名前を含めない) 1165 1121 @paramlist.to_str( false ) 1166 1122 end … … 1190 1146 end 1191 1147 1192 #=== Push Pop Allocator ãå¿ 1193 è¦ãï¼ 1194 # Transparent RPC ã®å ´å oneway ã㤠in ã®é 1195 å(size_is, count_is, string ã®ããããã§ä¿®é£¾ï¼ããã 1148 #=== Push Pop Allocator が必要か? 1149 # Transparent RPC の場合 oneway かつ in の配列(size_is, count_is, string のいずれかで修飾)がある 1196 1150 def need_PPAllocator?( b_opaque = false ) 1197 1151 if @b_oneway || b_opaque then … … 1202 1156 end 1203 1157 1204 #=== ãã©ã¡ã¼ã¿ã in, inout, out, send, receive ãæã¤ã1158 #=== パラメータが in, inout, out, send, receive を持つか 1205 1159 def has_in? 1206 1160 @has_in … … 1219 1173 end 1220 1174 1221 #=== å 1222 ¥åæ¹åã®ãã©ã¡ã¼ã¿ãæã¤ã 1175 #=== 入力方向のパラメータを持つか 1223 1176 def has_inward? 1224 1177 @has_in || @has_inout || @has_send 1225 1178 end 1226 #=== åºåæ¹åã®ãã©ã¡ã¼ã¿ãæã¤ã1179 #=== 出力方向のパラメータを持つか 1227 1180 def has_outward? 1228 1181 @has_inout || @has_out || @has_receive … … 1266 1219 end 1267 1220 1268 #=== Array#qualifier(const, volatile) ã®è¨å®1221 #=== Array#qualifier(const, volatile) の設定 1269 1222 def set_qualifier( qualifier ) 1270 1223 clone_type … … 1273 1226 end 1274 1227 1275 # é 1276 åè¦ç´ ã const ãªã const 1228 # 配列要素が const なら const 1277 1229 def is_const? 1278 1230 @type.is_const? 1279 1231 end 1280 1232 1281 # é 1282 åè¦ç´ ã volatile ãªã volatile 1233 # 配列要素が volatile なら volatile 1283 1234 def is_volatile? 1284 1235 @type.is_volatile? … … 1306 1257 end 1307 1258 1308 def check # æå³ç誤ããããã°ãæååãè¿ã 1309 if @type.class == FuncType then # é¢æ°ã®é 1310 å 1259 def check # 意味的誤りがあれば、文字列を返す 1260 if @type.class == FuncType then # 関数の配列 1311 1261 return "array of function" 1312 elsif @type.class == ArrayType then # æ·»æ°ãªãé 1313 åã®é 1314 å 1262 elsif @type.class == ArrayType then # 添数なし配列の配列 1315 1263 unless @type.get_subscript then 1316 1264 return "subscript not specified" … … 1318 1266 end 1319 1267 1320 return @type.check # é 1321 åè¦ç´ ã®åããã§ã㯠1268 return @type.check # 配列要素の型をチェック 1322 1269 end 1323 1270 … … 1328 1275 def check_init( locale, ident, initializer, kind, attribute = nil ) 1329 1276 if ( initializer.instance_of?( Array ) ) then 1330 # è¦ç´ æ°ãæå®ããã¦ããå ´åãåæåè¦ç´ æ°ããã§ãã¯1277 # 要素数が指定されている場合、初期化要素数をチェック 1331 1278 if @subscript then 1332 1279 n_sub = @subscript.eval_const( nil ) … … 1381 1328 # @size:: Expr, or nil if not specified 1382 1329 # @count:: Expr, or nil if not specified 1383 # @string:: Expr or -1(if size not specified) ï¼string å¼æ°ï¼, or nil if not specified1330 # @string:: Expr or -1(if size not specified) (string 引数), or nil if not specified 1384 1331 1385 1332 include HasType … … 1398 1345 @type = type 1399 1346 else 1400 @type.set_type( type ) # æå 1401 ã® type ãè¨å® 1347 @type.set_type( type ) # 枝先の type を設定 1402 1348 end 1403 1349 end … … 1421 1367 end 1422 1368 1423 def check # æå³ç誤ããããã°ãæååãè¿ã1369 def check # 意味的誤りがあれば、文字列を返す 1424 1370 return nil if @type == nil 1425 1371 @type.check … … 1427 1373 1428 1374 def check_struct_tag kind 1429 if kind != :MEMBER # æ§é ä½ã¡ã³ãã¼ã®å ´åããã¤ã³ã¿ã®å 1430 ã®æ§é ä½ã¿ã°ããã§ãã¯ããªã 1375 if kind != :MEMBER # 構造体メンバーの場合、ポインタの先の構造体タグをチェックしない 1431 1376 @type.check_struct_tag kind 1432 1377 end … … 1445 1390 if ( t1.class == t2.class ) && ( t1.get_bit_size == t2.get_bit_size ) then 1446 1391 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 1447 # int8_t ãªã©ããä¸æ¹ã¯ .h ã«å®ç¾©ããã¦ããã±ã¼ã¹1392 # int8_t などが、一方は .h に定義されているケース 1448 1393 else 1449 1394 cdl_error2( locale, "T1032 $1: incompatible pointer type" , ident ) … … 1456 1401 end 1457 1402 elsif val.kind_of? StringVal then 1458 # æååå®æ°1403 # 文字列定数 1459 1404 # mikan L"wide string" 1460 1405 if @type.get_bit_size != -1 && @type.get_bit_size != -11 then # -1: char_t … … 1500 1445 @b_nullable = b_nullable 1501 1446 1502 # string ã¯æãå·¦å´ã® ptr ã«ä½ç¨ãã1447 # string は最も左側の ptr に作用する 1503 1448 if @type.kind_of?( PtrType ) then 1504 # ptr_level ã 2 以ä¸ã§ãããã¨ã¯ ParamDecl#initializer ã§ãã§ãã¯ããã1449 # ptr_level が 2 以上であることは ParamDecl#initializer でチェックされる 1505 1450 clone_type 1506 1451 @type.set_scs( nil, nil, string, nil, false ) … … 1549 1494 end 1550 1495 1551 #=== PtrType# size_is ã®æ大å¤1496 #=== PtrType# size_is の最大値 1552 1497 def get_max 1553 1498 @max … … 1612 1557 end 1613 1558 1614 #== DescriptorType ã¯ã©ã¹1615 # åççµåã§æ¸¡ããã¹ã¯ãªãã¿å1559 #== DescriptorType クラス 1560 # 動的結合で渡すデスクリプタ型 1616 1561 class DescriptorType < Type 1617 1562 # @sinagure_nsp::NamespacePath … … 1643 1588 case kind 1644 1589 when :PARAMETER 1645 # å¼æ°ã¯åæåã§ããªã1590 # 引数は初期化できない 1646 1591 else 1647 1592 cdl_error2( locale, "T9999 Descriptor cannot be used for $1", kind) … … 1677 1622 end 1678 1623 1679 # 以ä¸åä½ãã¹ãã³ã¼ã1624 # 以下単体テストコード 1680 1625 if $unit_test then 1681 1626 puts( "===== Unit Test: IntType ===== (types.rb)") -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/unjoin_plugin.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2019 by TOPPERS Project 7 7 #-- 8 # ä¸è¨èä½æ¨©è 9 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ 10 # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹ 11 # å¤ã»åé 12 å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼ 13 # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½ 14 # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ 15 # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼ 16 # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 17 # ç¨ã§ããå½¢ã§åé 18 å¸ããå ´åã«ã¯ï¼åé 19 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨ 20 # è 21 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ 22 # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 23 # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ 24 # ç¨ã§ããªãå½¢ã§åé 25 å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã 26 # ã¨ï¼ 27 # (a) åé 28 å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è 29 ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è 30 # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼ 31 # (b) åé 32 å¸ã®å½¢æ 33 ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã« 34 # å ±åãããã¨ï¼ 35 # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ 36 # 害ãããï¼ä¸è¨èä½æ¨©è 37 ããã³TOPPERSããã¸ã§ã¯ããå 38 責ãããã¨ï¼ 39 # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç 40 # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è 41 ããã³TOPPERSããã¸ã§ã¯ãã 42 # å 43 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 37 # $Id$ 53 38 #++ 54 39 55 # Marshal.dump ã§ä¸é½åãªäºé 56 ã¸ã®å¯¾ç 57 # Proc 㯠_dump_data ãå®ç¾©ããã¦ããªããããå®ç¾©ããï¼ 58 # plugin é¢ä¿ã¯ãtecsflow ã« Plugin ã¯ã©ã¹ãåå¨ããªããããæ¶ãã¦ããï¼ 59 60 # Proc ã¯ãMarshal.dump ãããã¨ãã§ããªããã _dump_data ãå®ç¾© 40 # Marshal.dump で不都合な事項への対策 41 # Proc は _dump_data が定義されていないため、定義する. 42 # plugin 関係は、tecsflow に Plugin クラスが存在しないため、消しておく. 43 44 # Proc は、Marshal.dump することができないため _dump_data を定義 61 45 class Proc 62 46 def _dump_data … … 86 70 87 71 if kind_of? Expression then 88 # print # Expression ã§ã¯ print ãå¥ã«å®ç¾©ããã¦ãã72 # print # Expression では print が別に定義されている 89 73 get_elements.each{|ele| 90 74 ele.find_plugin_1 level+1, object_list … … 103 87 end 104 88 105 object_list.push self ##### ãããã return ä¸å¯89 object_list.push self ##### ここから return 不可 106 90 107 91 if (kind_of? Plugin) || (kind_of? HRPSVCPlugin) then … … 136 120 } 137 121 end 138 object_list.pop ##### ããã¾ã§ return ä¸å¯122 object_list.pop ##### ここまで return 不可 139 123 end 140 124 end -
Property svn:mime-type
changed from
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/value.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 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 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.