- Timestamp:
- May 22, 2019, 10:03:37 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/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
Note:
See TracChangeset
for help on using the changeset viewer.