- Timestamp:
- Jul 3, 2020, 7:19:17 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/componentobj.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 6by TOPPERS Project6 # Copyright (C) 2008-2019 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 79 79 # @b_checked_as_allocator_signature:: bool: アロケータシグニチャとしてチェック済み 80 80 # @b_empty:: Bool: 空(関数が一つもない状態) 81 # @descriptor_list:: nil | { Signature => ParamDecl } 最後の ParamDecl しか記憶しないことに注意 82 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 83 84 include PluginModule 81 85 82 86 @@nest_stack_index = -1 … … 123 127 @b_empty = false 124 128 @b_checked_as_allocator_signature = false 129 @descriptor_list = nil 130 @generate = nil 125 131 @@current_object = self 126 132 set_specifier_list( Generator.get_statement_specifier ) … … 136 142 function_head_list.get_items.each{ |f| 137 143 @func_name_to_id[ f.get_name ] = id 144 f.set_owner self 138 145 id += 1 139 146 } … … 142 149 end 143 150 151 # set_descriptor_list ## 152 153 if @generate then 154 signature_plugin 155 end 156 144 157 @@current_object = nil 158 145 159 return self 146 160 end … … 170 184 when :DEVIATE 171 185 @b_deviate = true 186 when :GENERATE 187 if @generate then 188 cdl_error( "S9999 generate specifier duplicate" ) 189 end 190 @generate = [ s[1], s[2] ] # [ PluginName, "option" ] 172 191 else 173 192 cdl_error( "S1002 \'$1\': unknown specifier for signature" , s[0] ) … … 309 328 end 310 329 311 #== Signature# 引数で参照されている Descriptor 型のリストを作成する 330 #=== Signature# シグニチャプラグイン (generate 指定子) 331 def signature_plugin 332 plugin_name = @generate[0] 333 option = @generate[1] 334 apply_plugin( plugin_name, option ) 335 end 336 337 #== Signature#apply_plugin 338 def apply_plugin plugin_name, option 339 if is_empty? then 340 cdl_warning( "S9999 $1 is empty. cannot apply signature plugin. ignored" , @name ) 341 return 342 end 343 344 plClass = load_plugin( plugin_name, SignaturePlugin ) 345 return if plClass == nil 346 if $verbose then 347 print "new through: plugin_object = #{plClass.class.name}.new( #{@name}, #{option} )\n" 348 end 349 350 begin 351 plugin_object = plClass.new( self, option ) 352 plugin_object.set_locale @locale 353 rescue Exception => evar 354 cdl_error( "S1150 $1: fail to new" , plugin_name ) 355 print_exception( evar ) 356 end 357 generate_and_parse plugin_object 358 end 359 360 #== Signature# 引数で参照されている Descriptor 型のリストを 312 361 #RETURN:: Hash { Signature => ParamDecl }: 複数の ParamDecl から参照されている場合、最後のものしか返さない 313 362 def get_descriptor_list 363 @descriptor_list 364 end 365 366 @@set_descriptor_list = {} 367 def self.set_descriptor_list 368 Namespace.get_root.travers_all_signature{ |sig| 369 if @@set_descriptor_list[ sig ] == nil then 370 @@set_descriptor_list[ sig ] = true 371 sig.set_descriptor_list 372 end 373 } 374 end 375 376 #== Signature# 引数で参照されている Descriptor 型のリストを作成する 377 def set_descriptor_list 314 378 desc_list = { } 315 379 # p "has_desc #{@name}" 316 380 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 317 381 if fha == nil then # nil の場合、自己参照によるケースと仮定 382 @descriptor_list = desc_list 318 383 return desc_list 319 384 end … … 330 395 # p "has_desc #{param.get_name} #{t}" 331 396 if t.kind_of? DescriptorType then 332 desc_list[t] = param 397 desc_list[ t.get_signature ] = param 398 # p self.get_name, t.get_signature.get_name 399 if t.get_signature == self then 400 # cdl_error( "S9999 Descriptor argument '$1' is the same signature as this parameter '$2' included", @name, param.get_name ) 401 end 402 dir = param.get_direction 403 if dir != :IN && dir != :OUT && dir != :INOUT then 404 cdl_error( "S9999 Descriptor argument '$1' cannot be specified for $2 parameter", param.get_name, dir.to_s.downcase ) 405 end 333 406 end 334 407 } … … 336 409 end 337 410 } 338 returndesc_list411 @descriptor_list = desc_list 339 412 end 340 413 341 414 #=== Signature# 引数に Descriptor があるか? 342 415 def has_descriptor? 343 # p "has_desc #{@name}" 344 fha = get_function_head_array # 呼び口または受け口のシグニチャの関数配列 345 if fha == nil then # nil の場合、自己参照によるケースと仮定 416 if get_descriptor_list == nil then 417 # end_of_parse が呼び出される前に has_descriptor? が呼び出された 418 # 呼び出し元は DescriptorType#initialize 419 # この場合、同じシグニチャ内の引数が Descriptor 型である 346 420 return true 347 end 348 fha.each{ |fh| 349 fd = fh.get_declarator # fd: Decl (関数頭部からDeclarotorを得る) 350 if fd.is_function? then # fd が関数でなければ、すでにエラー 351 params = fd.get_type.get_paramlist.get_items 352 if params then 353 params.each{ |param| 354 t = param.get_type.get_original_type 355 while( t.kind_of? PtrType ) 356 t = t.get_referto 357 end 358 # p "has_desc #{param.get_name} #{t}" 359 if t.kind_of? DescriptorType then 360 return true 361 end 362 } 363 end 364 end 365 } 366 return false 421 elsif get_descriptor_list.length > 0 then 422 return true 423 else 424 return false 425 end 367 426 end 368 427 … … 411 470 412 471 end 472 473 module CelltypePluginModule 474 #=== Celltype# セルタイププラグイン (generate 指定子) 475 def celltype_plugin 476 plugin_name = @generate[0] 477 option = @generate[1] 478 @generate[2] = apply_plugin( plugin_name, option ) 479 end 480 481 #=== Celltype# セルタイププラグインをこのセルタイプに適用 482 def apply_plugin( plugin_name, option ) 483 484 # plClass = load_plugin( plugin_name, CelltypePlugin ) 485 if kind_of? Celltype then 486 plugin_class = CelltypePlugin 487 elsif kind_of? CompositeCelltype then 488 plugin_class = CompositePlugin 489 else 490 raise "unknown class #{self.class.name}" 491 end 492 493 plClass = load_plugin( plugin_name, plugin_class ) 494 return if plClass == nil 495 if $verbose then 496 print "new celltype plugin: plugin_object = #{plClass.class.name}.new( #{@name}, #{option} )\n" 497 end 498 499 begin 500 plugin_object = plClass.new( self, option ) 501 @generate_list << [ plugin_name, option, plugin_object ] 502 plugin_object.set_locale @locale 503 generate_and_parse plugin_object 504 rescue Exception => evar 505 cdl_error( "S1023 $1: fail to new" , plugin_name ) 506 print_exception( evar ) 507 end 508 509 # 既に存在するセルに new_cell を適用 510 @cell_list.each{ |cell| 511 apply_plugin_cell plugin_object, cell 512 } 513 514 return plugin_object 515 end 516 517 def apply_plugin_cell plugin, cell 518 begin 519 plugin.new_cell cell 520 rescue Exception => evar 521 cdl_error( "S1037 $1: celltype plugin fail to new_cell" , plugin.class.name ) 522 print_exception( evar ) 523 end 524 end 525 526 def celltype_plugin_new_cell cell 527 @generate_list.each{ |generate| 528 celltype_plugin = generate[2] 529 begin 530 celltype_plugin.new_cell cell 531 rescue Exception => evar 532 cdl_error( "S1037 $1: celltype plugin fail to new_cell" , celltype_plugin.class.name ) 533 print_exception( evar ) 534 end 535 } 536 end 537 end #CelltypePluginModule 413 538 414 539 class Celltype < NSBDNode # < Nestable … … 423 548 # @ct_factory_list:: Factory[] : celltype factory 424 549 # @cell_list:: Cell[] : 定義のみ (V1.0.0.2 以降) 550 # @ordered_cell_list:: Cell[] : ID 順に順序付けされたセルリスト、最適化以降有効 (リンク単位ごとに生成されなおす) 425 551 # @singleton:: bool 426 552 # @idx_is_id:: bool 427 553 # @idx_is_id_act:: bool: actual value 554 # @b_need_ptab:: bool: true if having cells in multi-domain 428 555 # @active:: bool 429 556 # @b_reuse:: bool : reuse 指定されて import された(template 不要) 430 557 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 558 # @generate_list:: [ [ Symbol, String, Plugin ], ... ] generate 文で追加された generate 431 559 # 432 560 # @n_attribute_ro:: int >= 0 none specified … … 437 565 # @n_var_omit:: int >= 0 # of [omit] specified vars # mikan var の omit は有? 438 566 # @n_var_init:: int >= 0 # of vars with initializer 439 # @n_call_port:: int >= 0 440 # @n_call_port_array:: int >= 0 567 # @n_call_port:: int >= 0 # dynamic ports are included 568 # @n_call_port_array:: int >= 0 # dynamic ports are included 441 569 # @n_call_port_omitted_in_CB:: int >= 0 最適化で省略される呼び口 570 # @n_call_port_dynamic:: int >= 0 # 571 # @n_call_port_array_dynamic:: int >= 0 572 # @n_call_port_ref_desc:: int >= 0 # 573 # @n_call_port_array_ref_desc:: int >= 0 442 574 # @n_entry_port:: int >= 0 443 575 # @n_entry_port_array:: int >= 0 … … 455 587 456 588 include PluginModule 457 589 include CelltypePluginModule 590 458 591 @@nest_stack_index = -1 459 592 @@nest_stack = [] … … 496 629 @active = false 497 630 @generate = nil 631 @generate_list = [] 498 632 499 633 @n_attribute_ro = 0 … … 507 641 @n_call_port_array = 0 508 642 @n_call_port_omitted_in_CB = 0 643 @n_call_port_dynamic = 0 644 @n_call_port_array_dynamic = 0 645 @n_call_port_ref_desc = 0 646 @n_call_port_array_ref_desc = 0 509 647 @n_entry_port = 0 510 648 @n_entry_port_array = 0 … … 528 666 if $idx_is_id then 529 667 @idx_is_id = true 668 @idx_is_id_act = true 669 @b_need_ptab = true 530 670 else 531 671 @idx_is_id = false 532 end 533 @idx_is_id_act = @idx_is_id 672 @idx_is_id_act = false 673 @b_need_ptab = false 674 end 534 675 535 676 Namespace.new_celltype( self ) 536 677 set_namespace_path # @NamespacePath の設定 537 678 set_specifier_list( Generator.get_statement_specifier ) 538 539 if @singleton then540 @idx_is_id_act = false541 end542 679 543 680 @included_header = {} … … 577 714 celltype_plugin 578 715 end 716 717 # check_dynamic_join ## 579 718 580 719 @@current_object = nil … … 592 731 @n_call_port += 1 593 732 @n_call_port_array += 1 if port.get_array_size != nil 733 if port.is_dynamic? then 734 @n_call_port_dynamic += 1 735 @n_call_port_array_dynamic += 1 if port.get_array_size != nil 736 end 737 if port.is_ref_desc? then 738 @n_call_port_ref_desc += 1 739 @n_call_port_array_ref_desc += 1 if port.get_array_size != nil 740 end 594 741 else 595 742 @n_entry_port += 1 … … 753 900 when :IDX_IS_ID 754 901 @idx_is_id = true 902 @idx_is_id_act = true 903 @b_need_ptab = true 755 904 when :ACTIVE 756 905 @active = true … … 764 913 end 765 914 } 915 if @singleton then 916 @idx_is_id_act = false 917 @b_need_ptab = false 918 end 766 919 end 767 920 … … 863 1016 end 864 1017 865 #=== Celltype# セルタイププラグイン (generate 指定子) 866 def celltype_plugin 867 868 load_plugin( @generate[0], CelltypePlugin ) 869 870 plugin_name = @generate[0] 871 option = @generate[1] 872 plugin_object = nil 873 eval_str = "plugin_object = #{plugin_name}.new( self, option )" 874 if $verbose then 875 print "new celltype : #{eval_str}\n" 876 end 877 878 begin 879 eval( eval_str ) # plugin を生成 880 plugin_object.set_locale @locale 881 @generate[ 2 ] = plugin_object 882 generate_and_parse plugin_object 883 rescue Exception => evar 884 cdl_error( "S1023 $1: fail to new" , plugin_name ) 885 print "eval( #{eval_str} )\n" 886 887 print_exception( evar ) 888 end 1018 @@dynamic_join_checked_list = {} 1019 def self.check_dynamic_join 1020 Namespace.get_root.travers_all_celltype{ |ct| 1021 if @@dynamic_join_checked_list[ ct ] == nil then 1022 @@dynamic_join_checked_list[ ct ] = true 1023 ct.check_dynamic_join 1024 end 1025 } 1026 end 1027 1028 #=== Celltype#dynamic の適合性チェック 1029 def check_dynamic_join 1030 return if ! $verbose 1031 @port.each{ |port| 1032 signature = port.get_signature 1033 next if signature == nil # すでにエラー 1034 if port.is_dynamic? then 1035 dbgPrint( "[DYNAMIC] checking dynamic port: #{@global_name}.#{port.get_name}\n" ) 1036 # print( "[DYNAMIC] checking dynamic port: #{@global_name}.#{port.get_name}\n" ) 1037 next if find_ref_desc_port signature 1038 next if find_descriptor_param signature, :DYNAMIC 1039 cdl_warning( 'W9999 $1 cannot get information for dynamic port $2', @name, port.get_name ) 1040 elsif port.is_ref_desc? then 1041 dbgPrint( "[DYNAMIC] checking ref_desc port: #{@global_name}.#{port.get_name}\n" ) 1042 # print( "[DYNAMIC] checking ref_desc port: #{@global_name}.#{port.get_name}\n" ) 1043 next if find_dynamic_port signature 1044 next if find_descriptor_param signature, :REF_DESC 1045 cdl_warning( 'W9999 $1 cannot put information from ref_desc port $2', @name, port.get_name ) 1046 elsif port.get_signature then 1047 if port.get_signature.has_descriptor? then 1048 port.get_signature.get_descriptor_list.each{ |signature, param| 1049 dbgPrint( "[DYNAMIC] checking Descriptor parameter: #{@global_name}.#{port.get_name} ... #{param.get_name}\n" ) 1050 # print( "[DYNAMIC] checking Descriptor parameter: #{@global_name}.#{port.get_name} ... #{param.get_name}\n" ) 1051 if port.get_port_type == :CALL then 1052 if param.get_direction == :IN 1053 next if find_ref_desc_port signature 1054 next if find_descriptor_param signature, :DYNAMIC 1055 elsif param.get_direction == :OUT 1056 next if find_dynamic_port signature 1057 next if find_descriptor_param signature, :REF_DESC 1058 end 1059 else # :ENTRY 1060 if param.get_direction == :IN 1061 next if find_dynamic_port signature 1062 next if find_descriptor_param signature, :REF_DESC 1063 elsif param.get_direction == :OUT 1064 next if find_ref_desc_port signature 1065 next if find_descriptor_param signature, :DYNAMIC 1066 end 1067 end 1068 cdl_warning( 'W9999 "$1" cannot handle Descriptor "$2" information for port "$3"', @name, param.get_name, port.get_name ) 1069 } 1070 end 1071 end 1072 } 1073 end 1074 1075 def find_dynamic_port signature 1076 dbgPrint "[DYNAMIC] find_dynamic_port signature=#{signature.get_name}" 1077 @port.each{ |port| 1078 dbgPrint "[DYNAMIC] port=#{port.get_name} signature=#{port.get_signature.get_name} dynamic=#{port.is_dynamic?}" 1079 return port if port.is_dynamic? && port.get_signature == signature 1080 } 1081 return nil 1082 end 1083 def find_ref_desc_port signature 1084 if signature == nil then # すでにエラー 1085 return nil 1086 end 1087 dbgPrint "[DYNAMIC] find_ref_desc_port signature=#{signature.get_name}" 1088 @port.each{ |port| 1089 dbgPrint "[DYNAMIC] port=#{port.get_name} signature=#{port.get_signature.get_name} ref_desc=#{port.is_ref_desc?}" 1090 return port if port.is_ref_desc? && port.get_signature == signature 1091 } 1092 return nil 1093 end 1094 #=== Celltype#ディスクリプタ型でシグニチャが一致し dyn_ref に対応づく引数を探す 1095 #dyn_ref::Symbol: :DYNAMIC=ディスクリプタを得る手段となる引数を探す.:REF_DESC=渡す手段となる引数を探す 1096 def find_descriptor_param signature, dyn_ref 1097 param_list = [] 1098 @port.each{ |port| 1099 port.each_param{ |port, func, param| 1100 type = param.get_type 1101 while type.kind_of? PtrType 1102 type = type.get_type 1103 end 1104 dbgPrint( "[DYNAMIC] dyn_ref=#{dyn_ref} port_type=#{port.get_port_type} dir=#{param.get_direction} paramName=#{param.get_name} paramType=#{type.class}\n" ) 1105 # print( "[DYNAMIC] dyn_ref=#{dyn_ref} port_type=#{port.get_port_type} dir=#{param.get_direction} paramName=#{param.get_name} paramType=#{type.class}\n" ) 1106 if type.kind_of? DescriptorType then 1107 if type.get_signature == signature then 1108 dir = param.get_direction 1109 if dir == :INOUT then 1110 dbgPrint( "[DYNAMIC] found INOUT Descriptor parameter: #{@global_name}.#{port.get_name} ... #{param.get_name}\n" ) 1111 # print( "[DYNAMIC] found INOUT Descriptor parameter: #{@global_name}.#{port.get_name} ... #{param.get_name}\n" ) 1112 return param 1113 elsif dyn_ref == :DYNAMIC then 1114 if dir == :IN && port.get_port_type == :ENTRY || 1115 dir == :OUT && port.get_port_type == :CALL then 1116 dbgPrint( "[DYNAMIC] found INBOUND Descriptor parameter: #{@global_name}.#{port.get_name} ... #{param.get_name}\n" ) 1117 # print( "[DYNAMIC] found INBOUND Descriptor parameter: #{@global_name}.#{port.get_name} ... #{param.get_name}\n" ) 1118 return param 1119 end 1120 elsif dyn_ref == :REF_DESC 1121 if dir == :IN && port.get_port_type == :CALL || 1122 dir == :OUT && port.get_port_type == :ENTRY then 1123 dbgPrint( "[DYNAMIC] found OUTBOUND Descriptor parameter: #{@global_name}.#{port.get_name} ... #{param.get_name}\n" ) 1124 # print( "[DYNAMIC] found OUTBOUND Descriptor parameter: #{@global_name}.#{port.get_name} ... #{param.get_name}\n" ) 1125 return param 1126 end 1127 else 1128 raise "unknown ref_desc" 1129 end 1130 end 1131 end 1132 } 1133 } 1134 return nil 889 1135 end 890 1136 … … 895 1141 # シングルトンセルが同じ linkunit に複数ないかチェック 896 1142 def new_cell( cell ) 1143 dbgPrint "Celltype#new_cell( #{cell.get_name} )\n" 897 1144 # Celltype では Cell の set_owner しない 898 1145 # シングルトンで、プロトタイプ宣言でない場合、コード生成対象リージョンの場合 … … 905 1152 end 906 1153 @cell_list << cell 1154 1155 # プラグインにより生成されたセルタイプか ? 907 1156 if @plugin then 908 1157 @plugin.new_cell cell 909 1158 end 1159 1160 # セルタイププラグインの適用 1161 celltype_plugin_new_cell cell 910 1162 end 911 1163 … … 919 1171 # 呼び口(ただし、最適化で不要となるものは除く) 920 1172 def has_INIB? 921 # print "name=#{@name} @n_attribute_ro=#{@n_attribute_ro} @n_var_size_is=#{@n_var_size_is} @n_call_port=#{@n_call_port} @n_call_port_omitted_in_CB=#{@n_call_port_omitted_in_CB} @n_entry_port_array_ns=#{@n_entry_port_array_ns}\n" 922 return $rom && (@n_attribute_ro > 0 || @n_var_size_is > 0 || ( @n_call_port - @n_call_port_omitted_in_CB ) > 0 || @n_entry_port_array_ns > 0) 923 # return $rom && (@n_attribute_ro > 0 || ( @n_call_port - @n_call_port_omitted_in_CB ) > 0) 1173 1174 result = $rom && 1175 (@n_attribute_ro > 0 || 1176 @n_var_size_is > 0 || 1177 ( @n_call_port - @n_call_port_omitted_in_CB - (@n_call_port_dynamic-@n_call_port_array_dynamic) ) > 0 || 1178 $ram_initializer && @n_call_port_dynamic > 0 || 1179 @n_entry_port_array_ns > 0) 1180 # print "name=#{@name} n_attribute_ro=#{@n_attribute_ro} n_var_size_is=#{@n_var_size_is} n_call_port=#{@n_call_port} n_call_port_omitted_in_CB=#{@n_call_port_omitted_in_CB} n_call_port_dynamic=#{@n_call_port_dynamic} n_call_port_array_dynamic=#{@n_call_port_array_dynamic} n_entry_port_array_ns=#{@n_entry_port_array_ns} has_INIB?=#{result}\n" 1181 1182 return result 924 1183 end 925 1184 … … 934 1193 def has_CB? 935 1194 if $rom then 936 return @n_attribute_rw > 0 || (@n_var-@n_var_size_is) > 0 1195 return @n_attribute_rw > 0 || (@n_var-@n_var_size_is) > 0 || (@n_call_port_dynamic - @n_call_port_array_dynamic) > 0 937 1196 # return @n_attribute_rw > 0 || @n_var > 0 938 1197 else … … 943 1202 #=== Celltype# SET_CB_INIB_POINTER, INITIALIZE_CB が必要か 944 1203 def need_CB_initializer? 945 @n_var_init > 0 || has_CB? 1204 @n_var_init > 0 || has_CB? || ( @n_call_port_dynamic && $ram_initializer ) 946 1205 end 947 1206 … … 998 1257 def is_active? 999 1258 @active 1259 end 1260 1261 def idx_is_id_act? 1262 @idx_is_id_act 1263 end 1264 1265 def multi_domain? 1266 @b_need_ptab 1000 1267 end 1001 1268 … … 1120 1387 # 逆require ポートに対して複数の結合がないかチェックする 1121 1388 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 1389 # @b_post_code_generated:: Bool: true if generated in tmp_plugin_post_code.cdl 1122 1390 # 1123 1391 # composite のためインスタンス変数 … … 1142 1410 # @id:: Integer : コード生成直前に設定 (プロトタイプ宣言の場合は -1 のまま放置) 1143 1411 # @id_specified::Integer : 指定された id 1144 # @restrict_list::{ entry_name => { func_name, [ region_name, ... ] } } 1412 # @restrict_list::{ entry_name => { func_name, [ region_path_str, ... ] } } 1413 # @restrict_list2::{ entry_name => { func_name, [ domain_root_region, ... ] } } 1414 # @b_restrict_referenced::Bool: restrict_list が参照れた 1145 1415 1146 1416 =begin … … 1187 1457 end 1188 1458 1189 1190 # composite で clone されたもの(子孫まで含む)1191 # Join.change_rhs_port にて CompoisteCelltype 内の Join の結合先を変更する際に使用1192 @@cloned_cell_list = {}1193 ### mikan BUG @@cloned_cell_list は composite の階層ごとに記憶していないため、同じ名前が内部に現れると、うまく動作しない1194 # change_rhs_port の実装は、こんな回りくどいことをする必要はなかった。右辺に現れるセル名には、composite のセル名を前につなげるだけでよかった1195 1196 1459 def initialize( ct_path, in_composite = false ) 1197 1460 super() … … 1233 1496 @referenced_port_list = {} 1234 1497 @restrict_list = {} 1498 @restrict_list2 = {} 1499 @b_restrict_referenced = false 1500 @b_post_code_generated = false 1235 1501 1236 1502 @cell_list = {} … … 1258 1524 cell_prev = CompositeCelltype.find( name ) 1259 1525 if cell_prev == nil then 1260 CompositeCelltype.new_cell ( self )1526 CompositeCelltype.new_cell_in_composite( self ) 1261 1527 end 1262 1528 else … … 1437 1703 1438 1704 else 1705 dbgPrint "new_join: cell=#{@name} add_item=#{join.get_name}\n" 1439 1706 # join 1440 1707 @join_list.add_item( join ) … … 1500 1767 1501 1768 # 呼び口側のセルと、そのセルタイプ 1502 cell = Namespace.find cp_cell_nsp 1769 if ! @in_composite then 1770 cell = Namespace.find cp_cell_nsp 1771 else 1772 cell = CompositeCelltype.find cp_cell_nsp.to_s.to_sym 1773 end 1774 1503 1775 if ! cell.instance_of? Cell then 1504 1776 cdl_error( "S9999 '$1': not cell for reverse join", cp_cell_nsp.get_path_str ) … … 1510 1782 end 1511 1783 1512 ep_cell_nsp = get_namespace_path 1784 if ! @in_composite then 1785 ep_cell_nsp = get_namespace_path 1786 ep_cell_nsp_str = ep_cell_nsp.get_path_str 1787 else 1788 ep_cell_nsp = NamespacePath.new @name, false 1789 ep_cell_nsp_str = @name 1790 end 1513 1791 ep_subscript_val = ep_subscript ? ep_subscript.eval_const( nil ) : nil 1514 1792 rhs = Expression.create_cell_join_expression( ep_cell_nsp, ep_subscript_val, ep_name, rj.get_locale ) … … 1521 1799 ss_str = "" 1522 1800 end 1523 dbgPrint "create_reverse_join: #{cell.get_name}.#{cp_name}#{ss_str} => #{ep_cell_nsp .get_path_str}.ep_name\n"1801 dbgPrint "create_reverse_join: #{cell.get_name}.#{cp_name}#{ss_str} => #{ep_cell_nsp_str}.#{ep_name}\n" 1524 1802 } 1525 1803 end … … 1565 1843 set_specifier_list( Generator.get_statement_specifier ) 1566 1844 end 1845 if TECSGEN.post_coded? 1846 @b_post_code_generated = true 1847 end 1567 1848 set_f_def f_def 1568 1849 … … 1581 1862 1582 1863 if ! @in_composite then 1583 if @celltype.instance_of? Celltype then 1864 # if @celltype.instance_of? Celltype then 1865 if @celltype then # composite でも呼びだす, エラー時 nil 1584 1866 @celltype.new_cell self 1585 1867 end … … 1702 1984 end 1703 1985 1704 #=== Cell# セル タイププラグイン (generate 指定子)1986 #=== Cell# セルプラグイン (generate 指定子) 1705 1987 def cell_plugin 1706 1707 load_plugin( @generate[0], CellPlugin )1708 1709 1988 plugin_name = @generate[0] 1710 1989 option = @generate[1] 1711 plugin_object = nil 1712 eval_str = "plugin_object = #{plugin_name}.new( self, option )" 1990 @generate[2] = apply_plugin plugin_name, option 1991 end 1992 1993 def apply_plugin plugin_name, option 1994 if ! @b_defined then 1995 cdl_error( "S9999 plugin cannot apply to prototype cell '$1'", @name ) 1996 end 1997 1998 plClass = load_plugin( plugin_name, CellPlugin ) 1999 # return if plClass == nil # 従来と仕様が変わるので、継続する 1713 2000 if $verbose then 1714 print "new cell : #{eval_str}\n"2001 print "new cell plugin: plugin_object = #{plClass.class.name}.new( #{@name}, #{option} )\n" 1715 2002 end 1716 2003 1717 2004 begin 1718 eval( eval_str ) # plugin を生成2005 plugin_object = plClass.new( self, option ) 1719 2006 plugin_object.set_locale @locale 1720 @generate[ 2 ] = plugin_object1721 2007 generate_and_parse plugin_object 1722 2008 rescue Exception => evar 1723 2009 cdl_error( "S1166 $1: fail to new", plugin_name ) 1724 print "eval( #{eval_str} )\n"1725 1726 2010 print_exception( evar ) 1727 2011 end 2012 return plugin_object 1728 2013 end 1729 2014 … … 1742 2027 1743 2028 # debug 1744 dbgPrint "Cell#clone_for_composite : cloning: #{@name} #{global_name} b_defined=#{@b_defined}\n" 2029 dbgPrint " CLONING Cell#clone_for_composite : cloning: #{@name} #{global_name} b_defined=#{@b_defined} #{self}=>#{@my_clone} \n" 2030 dbgPrint " my_name=#{@name} name=#{name} owner class=#{@owner.class.name}\n" 1745 2031 1746 2032 @my_clone = self.clone 1747 @@cloned_cell_list[ self ] = @my_clone1748 2033 1749 2034 # clone したセルの内部に持つ名前情報を調整する 1750 1751 2035 @my_clone.set_cloned( name, global_name, namespacePath, join_array, ct_name, region, plugin, locale ) 1752 2036 … … 1772 2056 # debug 1773 2057 dbgPrint "cell.set_cloned : global_name: #{global_name} name: #{name} @name: #{@name}\n" 1774 2058 dbgPrint "set_cloned: entry_array_max_subscript.len=#{@entry_array_max_subscript.length}\n" 1775 2059 @global_name = :"#{global_name}_#{@name}" 1776 2060 @name = :"#{name}_#{@name}" … … 1796 2080 @alloc_list = [] 1797 2081 @require_joined_list = {} 1798 @entry_array_max_subscript = {}2082 @entry_array_max_subscript = @entry_array_max_subscript.dup 1799 2083 @cell_list = {} 1800 2084 @cell_list2 = [] … … 1805 2089 @join_list.change_item j 1806 2090 } 2091 end 2092 2093 #=== clone されたセルが composite の場合、内部セルを展開する 2094 #self:: clone されたセルでなければならない 2095 def expand_inner 2096 if ! @f_cloned then 2097 raise "expnad_inner: not cloned cell" 2098 end 1807 2099 1808 2100 # clone しようとするセルが composit セルタイプ? … … 1811 2103 @cell_list, @cell_list2 = @celltype.expand( @name, @global_name, @NamespacePath, @join_list, @region, @plugin, @locale ) 1812 2104 end 1813 1814 2105 end 1815 2106 1816 2107 #=== Cell# clone された cell の join_list の右辺の変更 1817 2108 # 呼び口の右辺の cell を他の clone された cell に置換え 1818 def change_rhs_port 2109 def change_rhs_port cloned_cell_list 1819 2110 1820 2111 # debug 1821 dbgPrint " Cell change_rhs_port: global_name: #{@global_name}\n"2112 dbgPrint "===== Cell#change_rhs_port: name=#{@name} =====\n" 1822 2113 1823 2114 @join_list.get_items.each { |j| 1824 j.change_rhs_port( @@cloned_cell_list, @celltype ) 1825 } 1826 1827 if @celltype.instance_of?( CompositeCelltype ) then 1828 1829 # 入れ子のセルについても変更 1830 @cell_list.each{ |name,c| 1831 c.change_rhs_port 1832 } 1833 end 2115 j.change_rhs_port( cloned_cell_list, @celltype ) 2116 } 1834 2117 end 1835 2118 … … 1891 2174 def is_in_composite? 1892 2175 @in_composite 2176 end 2177 2178 #=== Cell# composite のセルか? 2179 def is_of_composite? 2180 if @celltype.kind_of? CompositeCelltype 2181 return true 2182 else 2183 return false 2184 end 2185 end 2186 2187 #=== Cell# tmp_plugin_post_code.cdl で生成されたセルか? 2188 def post_code_generated? 2189 @b_post_code_generated 1893 2190 end 1894 2191 … … 1980 2277 1981 2278 # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる) 2279 # print "get_real_cell: cell=#{@name} port=#{port_name}\n" 2280 # pp @cell_list 1982 2281 cj = @celltype.find_export( port_name ) 1983 2282 … … 1991 2290 end 1992 2291 2292 #=== Cell#get_real_celltype 2293 # 2294 def get_real_celltype( port_name ) 2295 if @celltype.instance_of?( CompositeCelltype ) then 2296 return @celltype.get_real_celltype port_name 2297 else 2298 return @celltype 2299 end 2300 end 1993 2301 1994 2302 #=== Cell# 受け口のport の参照カウントをアップする … … 2033 2341 end 2034 2342 2343 #Cell#属性の初期値を得る 2344 #attr_name::Symbol 必ず初期化されていないと Ruby 例外となる 2345 def get_attr_initializer attr_name 2346 val = @join_list.get_item( attr_name ) 2347 if val == nil then 2348 val = (@celltype.find attr_name).get_initializer 2349 else 2350 val = val.get_rhs 2351 end 2352 return val 2353 end 2354 2035 2355 def get_celltype 2036 2356 @celltype … … 2075 2395 #=== Cell# composite の内側セルの受け口配列の添数の最大値を設定 2076 2396 def set_entry_inner_port_max_subscript( port, num ) 2077 if @cell_list == nil then # mikan これって問題ない?2078 return # プロトタイプ宣言しかされていなくて、内側セルが展開されていない 2397 if @cell_list == nil then 2398 return # プロトタイプ宣言しかされていなくて、内側セルが展開されていない or composite 展開前 2079 2399 end 2080 2400 2081 2401 # composite の内側のセルに伝播 2082 2402 if @celltype.instance_of? CompositeCelltype then 2403 dbgPrint "set_entry_inner_port_max_subscript #{@name} #{@port} #{num} cell_list.len=#{@cell_list.length}\n" 2404 # @cell_list.each{ |c, p| print c, p, '\n' } 2405 2083 2406 cj = @celltype.find_export port.get_name 2084 2407 if cj && @cell_list[ cj.get_cell_name.to_s ] then … … 2278 2601 else 2279 2602 cell = j.get_rhs_cell2 2280 next if cell == nil # 右辺が見つからなかった.既にエラー2603 next if cell == nil || cell.get_celltype == nil # 右辺が見つからなかった.既にエラー 2281 2604 port = cell.get_celltype.find( j.get_rhs_port2 ) 2605 if port == nil then 2606 dbgPrint "set_port_ref: #{@name}.#{j.get_name} = #{cell.get_name}.#{j.get_rhs_port2}\n" 2607 # through プラグインで生成されたセルの受け口が見つからないケース (のハズ) 2608 cdl_error( "entry '$1' not found in '$2' refered from $3.$4", j.get_rhs_port2, cell.get_name, @name, j.get_name ) 2609 next 2610 end 2282 2611 dbgPrint( "set_port_reference_count: #{@name}.#{j.get_name} => #{cell.get_name}.#{port.get_name}\n") 2283 2612 cell.port_referenced port … … 2672 3001 } 2673 3002 else 3003 dbgPrint "set_definition_join: #{@name}.#{join.get_name} celltype=#{@celltype.get_name}\n" 2674 3004 join.set_definition( @celltype.find(join.get_name) ) 2675 3005 end … … 2687 3017 expand 2688 3018 end 2689 2690 # celltype に generate が指定されされているか2691 celltype_plugin = @celltype.get_celltype_plugin2692 if celltype_plugin then2693 begin2694 celltype_plugin.new_cell self2695 rescue Exception => evar2696 cdl_error( "S1037 $1: celltype plugin fail to new_cell" , celltype_plugin.class.name )2697 print_exception( evar )2698 end2699 end2700 3019 end 2701 3020 … … 2705 3024 2706 3025 #debug 2707 dbgPrint "expanding #{@name} #{@celltype.get_name}\n" 2708 2709 # 展開されたセルのリスト 2710 @@cloned_cell_list = {} 3026 dbgPrint "===== expanding #{@name} =====\n" 2711 3027 2712 3028 # composite celltype の cell を展開 … … 2718 3034 set_f_ref 2719 3035 end 2720 2721 # 呼び口の右辺のセルを clone したものに変更 2722 self.change_rhs_port 3036 end 3037 3038 #=== Cell#内部セルの受け口添数最大値を設定 3039 def set_max_entry_port_inner_cell 3040 if @cell_list == nil then 3041 return 3042 end 3043 3044 dbgPrint "set_max_entry_port_inner_cell name=#{@name} entry_array_max_subscript.len=#{@entry_array_max_subscript.length}\n" 2723 3045 2724 3046 # プロトタイプ宣言で設定されていたものを反映する 2725 3047 @entry_array_max_subscript.each{ |port,name| 3048 dbgPrint "set_entry_inner_port_max_subscript( #{port}, #{name} )\n" 2726 3049 set_entry_inner_port_max_subscript( port, name ) 2727 3050 } … … 2730 3053 #=== Cell#restrict を追加 2731 3054 def add_restrict( entry_name, func_name, region_name_list ) 2732 if @restrict_list[ entry_name ] then 2733 if @restrict_list[ entry_name ][ func_name ] then 2734 @restrict_list[ entry_name ][ func_name ].each{ |rn| 2735 if region_name_list.include? rn then 2736 # p func_name 2737 name = func_name ? entry_name : entry_name+"."+func_name 2738 cdl_warning( "W9999 $1 restrict region duplicate $2", name, rn ) 3055 if @restrict_list[ entry_name ] == nil then 3056 @restrict_list[ entry_name ] = {} 3057 @restrict_list2[ entry_name ] = {} 3058 end 3059 if @restrict_list[ entry_name ][ func_name ] == nil then 3060 @restrict_list[ entry_name ][ func_name ] = [] 3061 @restrict_list2[ entry_name ][ func_name ] = [] 3062 end 3063 region_name_list.each { |rp| 3064 @restrict_list[ entry_name ][ func_name ] << rp 3065 # p "Class: " + rp.to_s 3066 obj = Namespace.find rp 3067 if ( obj.kind_of? Region ) then 3068 @restrict_list2[ entry_name ][ func_name ] << obj.get_domain_root 3069 else 3070 cdl_error( "S9999 $1 not found or not region", rp.to_s ) 3071 end 3072 } 3073 end 3074 3075 #=== Cell#check_restrict_list 3076 def check_restrict_list 3077 # p "check_restrict_list" 3078 @restrict_list.each{ |entry_name, func_hash| 3079 func_hash.each{ |func_name, region_list| 3080 region_list.each{ |rp| 3081 obj = Namespace.find rp 3082 if ( obj.kind_of? Region ) then 3083 if obj.get_domain_root != @region.get_domain_root then 3084 else 3085 cdl_info( "I9999 $1: restrict calling domain to $2, which is same domain as the cell locates", @name, rp.to_s ) 3086 # restrict を同じドメインを指定してもよいこととする (HRP3) 3087 # KernelDoamin 内のセルに対し、KernelDomain に restrict している場合、 3088 # 無所属経由で結合されているが、KernelDomain から呼出すことを想定した許可 3089 end 3090 else 3091 cdl_error( "S9999 $1 not region", rp.to_s ) 3092 end 3093 } 3094 } 3095 } 3096 end 3097 3098 #=== Cell#callable? 3099 def callable?( callee_cell, entry_name, func_name ) 3100 # p "callable? #{@name}" 3101 res = callee_cell.callable_from?( entry_name, func_name, self ) 3102 dbgPrint "callable? #{callee_cell.get_namespace_path}.#{entry_name}.#{func_name} from #{@NamespacePath} is #{res}\n" 3103 return res 3104 end 3105 3106 #=== Cell#callable_from? (private) 3107 def callable_from?( entry_name, func_name, caller_cell ) 3108 @b_restrict_referenced = true 3109 if @restrict_list.length == 0 then 3110 return true 3111 end 3112 3113 dr = caller_cell.get_region.get_domain_root 3114 if @restrict_list[entry_name] then 3115 if @restrict_list[entry_name][func_name] then 3116 @restrict_list2[entry_name][func_name].each{ |region| 3117 if dr == region then 3118 return true 3119 end 3120 } 3121 elsif @restrict_list[entry_name][nil] then 3122 @restrict_list2[entry_name][nil].each{ |region| 3123 if dr == region then 3124 return true 2739 3125 end 2740 3126 } 2741 3127 else 2742 @restrict_list[ entry_name ][ func_name ] = region_name_list 2743 end 2744 else 2745 func_list = { } 2746 func_list[ func_name ] = region_name_list 2747 @restrict_list[ entry_name ] = func_list 2748 end 2749 # pp @restrict_list 2750 end 2751 2752 #=== Cell#check_restrict_list 2753 def check_restrict_list 2754 @restrict_list.each{ |entry_name, func_hash| 2755 func_hash.each{ |func_name, region_list| 2756 region_list.each{ |rn| 2757 obj = Namespace.find [ rn ] 2758 if ( obj.kind_of? Region ) then 2759 if obj.get_domain_root != @region.get_domain_root then 2760 else 2761 cdl_warning( "W9999 $1 in same domain", rn ) 2762 end 2763 else 2764 cdl_error( "S9999 $1 not region", region ) 2765 end 2766 } 2767 } 2768 } 2769 end 2770 2771 #=== Cell#callable? 2772 def callable?( callee_cell, entry_name, func_name ) 2773 res = callee_cell.callable_from?( entry_name, func_name, self ) 2774 dbgPrint "callable? #{callee_cell.get_namespace_path}.#{entry_name}.#{func_name} from #{@NamespacePath} is #{res}\n" 2775 return res 2776 end 2777 2778 #=== Cell#callable_from? (private) 2779 def callable_from?( entry_name, func_name, caller_cell ) 2780 if @restrict_list.length == 0 then 3128 return false 3129 end 3130 else 3131 return false 3132 end 3133 end 3134 3135 #=== Cell#get_callable_regions( entry_name, func_name ) 3136 # func_name=nil の場合、entry_name の可否をチェック数る 3137 # nil が返る場合、制限されていないことを意味する 3138 def get_restricted_regions( entry_name, func_name ) 3139 # p "get_restricted_regions #{@name}" 3140 @b_restrict_referenced = true 3141 if @restrict_list[entry_name] then 3142 if @restrict_list[entry_name][func_name] then 3143 return @restrict_list2[entry_name][func_name] 3144 else 3145 return @restrict_list2[entry_name][nil] 3146 end 3147 end 3148 return nil 3149 end 3150 3151 #=== Cell#has_ineffective_restrict_specifier 3152 # restrict 指定子が指定されていて、参照されていない場合 true 3153 # 参照は、HRPSVCPlugin のみ 3154 def has_ineffective_restrict_specifier 3155 if @restrict_list.length != 0 && @b_restrict_referenced == false then 2781 3156 return true 2782 end 2783 2784 if @restrict_list[entry_name] then 2785 if @restrict_list[entry_name][nil] && 2786 @restrict_list[entry_name][nil].include?( caller_cell.get_region.get_domain_root.get_name )then 2787 return true 2788 end 2789 if @restrict_list[entry_name][func_name] && 2790 @restrict_list[entry_name][func_name].include?( caller_cell.get_region.get_domain_root.get_name )then 2791 return true 2792 else 2793 return false 2794 end 2795 else 2796 return true 2797 end 2798 end 2799 3157 else 3158 return false 3159 end 3160 end 3161 2800 3162 def show_tree( indent ) 2801 3163 indent.times { print " " } … … 2857 3219 # @name:: str 2858 3220 # @global_name:: str 2859 # @cell_list:: NamedList Cell 3221 # @cell_list_in_composite:: NamedList Cell 3222 # @cell_list::Array :: [ Cell ] : cell of CompositeCelltype's cell 2860 3223 # @export_name_list:: NamedList : CompositeCelltypeJoin 2861 3224 # @port_list:: CompositeCelltypeJoin[] … … 2867 3230 # @name_list:: NamedList item: Decl (attribute), Port エクスポート定義 2868 3231 # @internal_allocator_list:: [ [cell, internal_cp_name, port_name, func_name, param_name, ext_alloc_ent], ... ] 3232 # @generate:: [ Symbol, String, Plugin ] = [ PluginName, option, Plugin ] Plugin は生成後に追加される 3233 # @generate_list:: [ [ Symbol, String, Plugin ], ... ] generate 文で追加された generate 2869 3234 2870 3235 @@nest_stack_index = -1 2871 3236 @@nest_stack = [] 2872 3237 @@current_object = nil 3238 3239 include CelltypePluginModule 3240 include PluginModule 2873 3241 2874 3242 def self.push … … 2889 3257 super() 2890 3258 @name = name 2891 @cell_list = NamedList.new( nil, "in composite celltype #{name}" ) 3259 @cell_list_in_composite = NamedList.new( nil, "in composite celltype #{name}" ) 3260 @cell_list = [] 2892 3261 @export_name_list = NamedList.new( nil, "export in composite celltype #{name}" ) 2893 3262 @name_list = NamedList.new( nil, "in composite celltype #{name}" ) … … 2910 3279 @attr_list = [] 2911 3280 @internal_allocator_list = [] 3281 @generate_list = [] 2912 3282 set_specifier_list( Generator.get_statement_specifier ) 2913 3283 end … … 2920 3290 # CompositeCelltype#end_of_parse 2921 3291 def end_of_parse 2922 2923 3292 # singleton に関するチェック 2924 3293 if @b_singleton && @real_singleton == nil then … … 2960 3329 # mikan relay が正しく抜けているかチェックされていない 2961 3330 3331 # callback 結合 3332 @cell_list_in_composite.get_items.each{ |c| 3333 ct = c.get_celltype 3334 if ct then 3335 c.create_reverse_join 3336 end 3337 } 3338 2962 3339 # 意味解析 2963 @cell_list .get_items.each{ |c|3340 @cell_list_in_composite.get_items.each{ |c| 2964 3341 c.set_definition_join 2965 3342 } 2966 3343 2967 3344 # cell の未結合の呼び口がないかチェック 2968 @cell_list .get_items.each{ |c|3345 @cell_list_in_composite.get_items.each{ |c| 2969 3346 c.check_join 2970 3347 c.check_reverse_require … … 3004 3381 } 3005 3382 } 3006 end 3007 3008 ### cell (CompositeCelltype) 3009 def self.new_cell( cell ) 3010 @@current_object.new_cell( cell ) 3011 3012 end 3013 3014 def new_cell( cell ) 3383 3384 # composite プラグイン 3385 if @generate then 3386 celltype_plugin 3387 end 3388 end 3389 3390 ### CompositeCelltype#new_cell_in_composite 3391 def self.new_cell_in_composite( cell ) 3392 @@current_object.new_cell_in_composite( cell ) 3393 3394 end 3395 3396 def new_cell_in_composite( cell ) 3015 3397 cell.set_owner self # Cell (in_omposite) 3016 @cell_list .add_item( cell )3398 @cell_list_in_composite.add_item( cell ) 3017 3399 if cell.get_celltype then # nil ならば、すでにセルタイプなしエラー 3018 3400 if cell.get_celltype.is_singleton? then … … 3031 3413 internal_cell_elem_name, type ) 3032 3414 3415 end 3416 3417 ### CompositeCelltype#new_cell 3418 def new_cell cell 3419 @cell_list << cell 3420 3421 # セルタイププラグインの適用 3422 celltype_plugin_new_cell cell 3033 3423 end 3034 3424 … … 3050 3440 dbgPrint "new_join: #{export_name} #{internal_cell_name} #{internal_cell_elem_name}\n" 3051 3441 3052 cell = @cell_list .get_item( internal_cell_name )3442 cell = @cell_list_in_composite.get_item( internal_cell_name ) 3053 3443 if cell == nil then 3054 3444 cdl_error( "S1057 $1 not found in $2" , internal_cell_name, @name ) … … 3107 3497 elsif obj.is_omit? != obj2.is_omit? then 3108 3498 cdl_error( "S9999 $1 : omit specifier mismatch with previous definition" , export_name ) 3499 elsif obj.is_dynamic? != obj2.is_dynamic? then 3500 cdl_error( "S9999 $1 : dynamic specifier mismatch with previous definition" , export_name ) 3501 elsif obj.is_ref_desc? != obj2.is_ref_desc? then 3502 cdl_error( "S9999 $1 : ref_desc specifier mismatch with previous definition" , export_name ) 3109 3503 end 3110 3504 else … … 3292 3686 def find name 3293 3687 dbgPrint "CompositeCelltype: find in composite: #{name}\n" 3294 cell = @cell_list .get_item( name )3688 cell = @cell_list_in_composite.get_item( name ) 3295 3689 return cell if cell 3296 3690 … … 3333 3727 clone_cell_list = {} 3334 3728 clone_cell_list2 = [] 3729 clone_cell_list3 = {} 3335 3730 3336 3731 # composite 内部のすべての cell について 3337 @cell_list .get_items.each { |c|3732 @cell_list_in_composite.get_items.each { |c| 3338 3733 3339 3734 # debug … … 3359 3754 # debug 3360 3755 if j then 3361 dbgPrint " expand : parent cell: #{name} child cell: #{c.get_name}: parent's export port: #{cj.get_name} join: #{j.get_name} #{j}\n"3756 dbgPrint " REWRITE_EX parent cell: #{name} child cell: #{c.get_name}: parent's export port: #{cj.get_name} join: #{j.get_name}=>#{j.get_rhs.to_s}\n" 3362 3757 else 3363 3758 dbgPrint "expand : parent cell: #{name} child cell: #{c.get_name}: parent's export port: #{cj.get_name} join: nil\n" … … 3394 3789 clone_cell_list[ "#{c.get_local_name}" ] = c2 3395 3790 clone_cell_list2 << c2 3791 clone_cell_list3[ c ] = c2 3396 3792 3397 3793 } … … 3403 3799 j.set_cloned( clone_cell_list[ "#{c.get_local_name}" ] ) 3404 3800 } 3801 dbgPrint "change_rhs_port: inner cell #{c.get_name}\n" 3802 c.change_rhs_port clone_cell_list3 3803 } 3804 clone_cell_list2.each { |c| 3805 c.expand_inner 3405 3806 } 3406 3807 return [ clone_cell_list, clone_cell_list2 ] … … 3419 3820 when :ACTIVE 3420 3821 @b_active = true 3822 when :GENERATE 3823 if @generate then 3824 cdl_error( "S9999 generate specifier duplicate" ) 3825 end 3826 @generate = [ s[1], s[2] ] # [ PluginName, "option" ] 3421 3827 else 3422 3828 cdl_error( "S1071 $1 cannot be specified for composite" , s[0] ) … … 3429 3835 end 3430 3836 3837 def get_global_name 3838 @global_name 3839 end 3840 3431 3841 def get_port_list 3432 3842 @port_list … … 3443 3853 def get_internal_allocator_list 3444 3854 @internal_allocator_list 3855 end 3856 3857 #== CompositeCelltype#get_real_celltype 3858 # port_name に接続されている内部のセルタイプを得る 3859 def get_real_celltype( port_name ) 3860 cj = find_export port_name 3861 inner_celltype = cj.get_cell.get_celltype 3862 if inner_celltype.instance_of? CompositeCelltype then 3863 return inner_celltype.get_real_celltype 3864 else 3865 return inner_celltype 3866 end 3445 3867 end 3446 3868 … … 3465 3887 def is_inactive? 3466 3888 if @b_active == false then 3467 @cell_list .get_items.each{ |c|3889 @cell_list_in_composite.get_items.each{ |c| 3468 3890 if c.get_celltype && c.get_celltype.is_inactive? == false then 3469 3891 # c.get_celltype == nil の場合はセルタイプ未定義ですでにエラー … … 3486 3908 (indent+1).times { print " " } 3487 3909 puts "active: #{@b_active}, singleton: #{@b_singleton}" 3488 @cell_list .show_tree( indent + 1 )3910 @cell_list_in_composite.show_tree( indent + 1 ) 3489 3911 (indent+1).times { print " " } 3490 3912 puts "name_list" … … 3532 3954 # @b_omit:: bool : omit 指定子が指定された (call port のみ) 3533 3955 # @b_optional:: bool : call port のみ 3534 # @b_ref_des :: bool : ref_desc キーワードが指定された3956 # @b_ref_desc:: bool : ref_desc キーワードが指定された 3535 3957 # @b_dynamic:: bool : dynamic キーワードが指定された (呼び口のみ) 3536 3958 # … … 3638 4060 @b_inline = false 3639 4061 @b_optional = false 4062 @b_omit = false 3640 4063 @b_ref_desc = false 3641 4064 @b_dynamic = false … … 3655 4078 else 3656 4079 # entry port optimize 3657 if $unopt then4080 if $unopt || $unopt_entry then 3658 4081 # 最適化なし 3659 4082 @b_VMT_useless = false # VMT 不要 (true の時 VMT を介することなく呼出す) … … 3786 4209 @b_optional = true 3787 4210 when :REF_DESC 4211 if @port_type == :ENTRY then 4212 cdl_error( "S9999 ref_desc: cannnot be specified for entry port" ) 4213 next 4214 end 3788 4215 @b_ref_desc = true 3789 4216 when :DYNAMIC … … 3806 4233 end 3807 4234 } 4235 if ( @b_dynamic || @b_ref_desc ) then 4236 if @b_dynamic then 4237 dyn_ref = "dynamic" 4238 else 4239 dyn_ref = "ref_desc" 4240 end 4241 if @b_omit then # is_omit? は is_empty? も含んでいるので使えない 4242 cdl_error( "S9999 omit cannot be specified with $1", dyn_ref ) 4243 elsif @signature && @signature.is_empty? then 4244 cdl_error( "S9999 $1 cannot be specified for empty signature", dyn_ref ) 4245 elsif @signature && @signature.has_descriptor? then 4246 # cdl_error( "S9999 $1 port '$2' cannot have Descriptor in its signature", dyn_ref, @name ) 4247 end 4248 4249 elsif @b_dynamic && @b_ref_desc then 4250 cdl_error( "S9999 both dynamic & ref_desc cannot be specified simultaneously" ) 4251 end 3808 4252 end 3809 4253 … … 3958 4402 3959 4403 def is_VMT_useless? # VMT 関数テーブルを使用しない 3960 @b_VMT_useless 4404 if @port_type == :ENTRY && $unopt_entry == true then 4405 # プラグインから $unopt_entry を設定するケースのため 4406 # ここで読み出すときに、false を返す (reset_optimize での設定変更は速すぎる) 4407 return false 4408 else 4409 return @b_VMT_useless 4410 end 3961 4411 end 3962 4412 3963 4413 def is_skelton_useless? # スケルトン関数不要 (true の時、受け口関数を呼出す) 3964 @b_skelton_useless 4414 if @port_type == :ENTRY && $unopt_entry == true then 4415 # プラグインから $unopt_entry を設定するケースのため 4416 # ここで読み出すときに、false を返す (reset_optimize での設定変更は速すぎる) 4417 return false 4418 else 4419 return @b_skelton_useless 4420 end 3965 4421 end 3966 4422 … … 4078 4534 def is_reverse_required? 4079 4535 @reverse_require_cell_path != nil 4536 end 4537 4538 #=== Port# is_dynamic? 4539 def is_dynamic? 4540 @b_dynamic 4541 end 4542 4543 #=== Port# is_ref_desc? 4544 def is_ref_desc? 4545 @b_ref_desc 4080 4546 end 4081 4547 … … 4489 4955 if ! c.get_f_def then # Namespace の @cell_list にはプロトタイプが含まれるケースあり 4490 4956 if c.get_f_ref then 4491 c dl_error( "S1093 $1 : undefined cell" , c.get_namespace_path.get_path_str )4957 c.cdl_error( "S1093 $1 : undefined cell" , c.get_namespace_path.get_path_str ) 4492 4958 elsif $verbose then 4493 c dl_warning( "W1006 $1 : only prototype, unused and undefined cell" , c.get_namespace_path.get_path_str )4959 c.cdl_warning( "W1006 $1 : only prototype, unused and undefined cell" , c.get_namespace_path.get_path_str ) 4494 4960 end 4495 4961 else … … 4498 4964 # if c.get_f_ref == false && c.is_generate? && ct && ct.is_inactive? then 4499 4965 if c.get_f_ref == false && ct && ct.is_inactive? then 4500 cdl_warning( "W1007 $1 : non-active cell has no entry join and no factory" , c.get_namespace_path.get_path_str ) 4966 c.cdl_warning( "W1007 $1 : non-active cell has no entry join and no factory" , c.get_namespace_path.get_path_str ) 4967 end 4968 if c.has_ineffective_restrict_specifier then 4969 c.cdl_warning( "W9999: $1 has ineffective restrict specifier", c.get_namespace_path.get_path_str ) 4501 4970 end 4502 4971 end … … 4657 5126 end 4658 5127 5128 #=== Namespace# set_max_entry_port_inner_cell 5129 # セルタイプに属するすべてのセルに対して実施 5130 def set_max_entry_port_inner_cell 5131 # celltype のコードを生成 5132 @cell_list.each { |c| 5133 c.set_max_entry_port_inner_cell 5134 } 5135 @namespace_list.each{ |ns| 5136 ns.set_max_entry_port_inner_cell 5137 } 5138 end 5139 4659 5140 #=== Namespace# セルの結合をチェックする 4660 5141 def check_join … … 4681 5162 end 4682 5163 5164 #== Namespace (Region) に属するセルのリスト 5165 def get_cell_list 5166 @cell_list 5167 end 5168 5169 #== Namespace (Region)# 子リージョンのリスト 5170 # 5171 # リージョンは Namespace クラスで namespace として記憶されている 5172 def get_region_list 5173 @namespace_list 5174 end 5175 4683 5176 def show_tree( indent ) 4684 5177 indent.times { print " " } … … 4904 5397 4905 5398 if object == nil then # (2) 4906 cdl_error( "S1109 \'$1\' not found" , @cell_name)5399 cdl_error( "S1109 \'$1\' not found" , nsp.to_s ) 4907 5400 elsif ! object.instance_of?( Cell ) then # (3) 4908 cdl_error( "S1110 \'$1\' not cell" , @cell_name)5401 cdl_error( "S1110 \'$1\' not cell" , nsp.to_s ) 4909 5402 else 4910 5403 dbgPrint "set_definition: set_f_ref #{@owner.get_name}.#{@name} => #{object.get_name}\n" … … 5277 5770 next_cell_nsp = @through_generated_list[ i + 1 ].get_cell_namespace_path 5278 5771 next_port_name = @through_generated_list[ i + 1 ].get_through_entry_port_name 5772 next_port_subscript = @through_generated_list[ i + 1 ].get_through_entry_port_subscript 5279 5773 rescue Exception => evar 5280 5774 cdl_error( "S1124 $1: plugin function failed: \'get_through_entry_port_name\'" , plugin_name ) … … 5295 5789 next_cell = @cell 5296 5790 next_port_name = @port_name 5791 next_port_subscript = @rhs_subscript 5297 5792 5298 5793 if next_cell == nil then … … 5306 5801 # region から @cell_name.@port_name への through がないか探す 5307 5802 # rp = @through_list[i][3].find_cell_port_through_plugin( @cell_name, @port_name ) #762 5308 rp = @through_list[i][3].find_cell_port_through_plugin( @cell.get_global_name, @port_name )5803 rp = @through_list[i][3].find_cell_port_through_plugin( @cell.get_global_name, @port_name, @rhs_subscript ) 5309 5804 # @through_list[i] と @region_through_list[i-cp_len] は同じ 5310 5805 # 共用しないようにするには、見つからなかったことにすればよい … … 5317 5812 5318 5813 if rp == nil then 5319 if( load_plugin( plugin_name, ThroughPlugin ) ) then 5320 gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name ) 5814 plClass = load_plugin( plugin_name, ThroughPlugin ) 5815 if( plClass ) then 5816 gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name, next_port_subscript, plClass ) 5321 5817 end 5322 5818 else … … 5331 5827 # 生成したものを region(@through_list[i][3]) のリストに追加 5332 5828 # @through_list[i][3].add_cell_port_through_plugin( @cell_name, @port_name, @through_generated_list[i] ) #762 5333 @through_list[i][3].add_cell_port_through_plugin( @cell.get_global_name, @port_name, @ through_generated_list[i] )5829 @through_list[i][3].add_cell_port_through_plugin( @cell.get_global_name, @port_name, @rhs_subscript, @through_generated_list[i] ) 5334 5830 end 5335 5831 end … … 5365 5861 5366 5862 #=== Join# through プラグインを呼び出して CDL 生成させるとともに、import する 5367 def gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name )5863 def gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name, next_port_subscript, plClass ) 5368 5864 5369 5865 through = @through_list[ i ] … … 5389 5885 end 5390 5886 @@plugin_creating_join = self 5391 5392 5887 caller_cell = @owner 5393 5888 5394 plugin_object = nil5395 eval_str = "plugin_object = #{plugin_name}.new( '#{generating_cell_name}'.to_sym, plugin_arg.to_s, next_cell, '#{next_port_name}'.to_sym, @definition.get_signature, @celltype, caller_cell )"5396 if $verbose then5397 print "new through: #{eval_str}\n"5398 end5399 5400 5889 begin 5401 eval( eval_str ) # plugin を生成 5890 plugin_object = plClass.new( generating_cell_name.to_sym, plugin_arg.to_s, 5891 next_cell, next_port_name.to_sym, next_port_subscript, 5892 @definition.get_signature, @celltype, caller_cell ) 5402 5893 plugin_object.set_locale @locale 5403 5894 rescue Exception => evar … … 5406 5897 print "signature: #{@definition.get_signature.get_name} from: #{caller_cell.get_name} to: #{next_cell.get_name} of celltype: #{@celltype.get_name}\n" 5407 5898 end 5408 print "eval( #{eval_str} )\n"5409 5410 5899 print_exception( evar ) 5411 5900 return … … 5596 6085 end 5597 6086 5598 def get_rhs_subscript 6087 # 末尾数字1 : CDL で指定された、右辺のセルを返す 6088 def get_rhs_cell1 # get_cell と同じ 6089 @cell 6090 end 6091 def get_rhs_port1 # get_port_name 同じ 6092 @port_name 6093 end 6094 def get_rhs_subscript1 5599 6095 @rhs_subscript 5600 6096 end … … 5606 6102 # through 指定あり? 5607 6103 if @through_list[0] then 5608 # mikan through で生成したものが root namespace 限定5609 6104 # through で生成されたセルを探す 5610 # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] ) #15611 6105 cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path ) #1 5612 6106 # cell のプラグインで生成されたポート名のポートを探す (composite なら内部の繋がるポート) … … 5615 6109 # ポートを返す(composite なら内部の繋がるポートを返す) 5616 6110 return @cell.get_real_port( @port_name ) 6111 end 6112 end 6113 6114 #=== Join# 右辺の配列添数を得る 6115 # 右辺が through の場合は挿入されたセルの添数 6116 # 右辺が composite の場合は、内部の繋がるセルのポートの添数 (composite では変わらない) 6117 # このメソッドは get_rhs_cell, と対になっている 6118 def get_rhs_subscript 6119 if @through_list[0] then 6120 return @through_generated_list[0].get_through_entry_port_subscript 6121 else 6122 return @rhs_subscript 5617 6123 end 5618 6124 end … … 5718 6224 # composite cell を展開したセルの結合を clone したセルの名前に変更 5719 6225 def change_rhs_port( clone_cell_list, celltype ) 6226 dbgPrint "change_rhs_port: name=#{@name}\n" 5720 6227 5721 6228 # debug 5722 6229 if $debug then 5723 dbgPrint "change_rhs name: #{@name} cell_name: #{@cell_name} #{@cell} #{self}\n" 6230 # if @name == :cCallB then 6231 # dbgPrint "change_rhs name: #{@name} cell_name: #{@cell_name} #{@cell} #{self}\n" 6232 print "============\n" 6233 print "CHANGE_RHS change_rhs name: #{@owner.get_name}.#{@name} rhs cell_name: #{@cell_name} #{@cell} #{self}\n" 5724 6234 5725 6235 clone_cell_list.each{ |cell, ce| 5726 dbgPrint "change_rhs: #{cell.get_name}=#{cell} : #{ce.get_name}\n" 6236 # dbgPrint "=== change_rhs: #{cell.get_name}=#{cell} : #{ce.get_name}\n" 6237 print " CHANGE_RHS change_rhs: #{cell.get_name}=#{cell} : #{ce.get_name}\n" 5727 6238 } 6239 print "============\n" 5728 6240 end 5729 6241 … … 5732 6244 5733 6245 # debug 5734 dbgPrint " cell_name:#{@cell_name} => #{c.get_global_name}, #{c.get_name}\n"6246 dbgPrint " REWRITE cell_name: #{@owner.get_name} #{@cell_name} => #{c.get_global_name}, #{c.get_name}\n" 5735 6247 5736 6248 # @rhs の内容を調整しておく(この内容は、subscript を除いて、後から使われていない) … … 5756 6268 5757 6269 # debug 5758 # p "array_member2.len : #{@array_member.length}"6270 dbgPrint "array_member2.len : #{@array_member.length}\n" 5759 6271 5760 6272 i = 0 … … 5764 6276 # 無駄に設定されているものについては、再帰的に呼び出す必要はない(clone_for_composite では対策している) 5765 6277 if @array_member2[i] != self && @array_member[i] != nil then 6278 dbgPrint "change_rhs array_member #{i}: #{@name} #{@cell_name}\n" 5766 6279 @array_member2[i].change_rhs_port( clone_cell_list, celltype ) 5767 6280 end … … 5779 6292 # @through_list などもコピーされるので、これが呼び出される前に確定する必要がある 5780 6293 def clone_for_composite( ct_name, cell_name, locale, b_need_recursive = true ) 5781 5782 6294 # debug 5783 dbgPrint " join.clone_for_composite : #{@name} #{@cell_name} #{self}\n"6295 dbgPrint "===== clone_for_composite: #{@name} #{@cell_name} #{self} =====\n" 5784 6296 cl = self.clone 5785 6297 5786 6298 if @array_member2 && b_need_recursive then 5787 cl.clone_array_member( @array_member, @array_member2,ct_name, cell_name, self, locale )6299 cl.clone_array_member( ct_name, cell_name, self, locale ) 5788 6300 end 5789 6301 … … 5796 6308 end 5797 6309 5798 def clone_array_member( array_member, array_member2,ct_name, cell_name, prev, locale )6310 def clone_array_member( ct_name, cell_name, prev, locale ) 5799 6311 # 配列のコピーを作る 5800 am = array_member.clone5801 am2 = array_member2.clone6312 am = @array_member.clone 6313 am2 = @array_member2.clone 5802 6314 5803 6315 # 配列要素のコピーを作る 5804 6316 i = 0 5805 6317 while i < am2.length 5806 if array_member2[i] == prev then6318 if @array_member2[i] == prev then 5807 6319 # 自分自身である(ので、呼出すと無限再帰呼出しとなる) 5808 6320 am2[i] = self 5809 elsif array_member2[i] then 5810 am2[i] = array_member2[i].clone_for_composite( ct_name, cell_name, locale, false ) 6321 am[i] = am2[i].get_rhs 6322 elsif @array_member2[i] then 6323 # am2[i] = @array_member2[i].clone_for_composite( ct_name, cell_name, locale, false ) 6324 am2[i] = @array_member2[i].clone_for_composite( ct_name, cell_name, locale, true ) 6325 am[i] = am2[i].get_rhs 5811 6326 else 5812 6327 # 以前のエラーで array_member2[i] は nil になっている … … 5814 6329 5815 6330 # debug 5816 dbgPrint "clone_array_member: #{@name} #{am2[i]} #{array_member2[i]}\n"6331 dbgPrint "clone_array_member: #{@name} subsript=#{i} #{am2[i]} #{@array_member2[i]}\n" 5817 6332 5818 6333 i += 1 … … 5840 6355 dbgPrint "Join#set_cloned: #{@name} prev owner: #{@owner.get_name} new owner: #{owner.get_name}\n" 5841 6356 @owner = owner 6357 if @array_member2 then 6358 @array_member2.each{ |join| 6359 dbgPrint "Joinarray#set_cloned: #{@name} prev owner: #{join.get_owner.get_name} new owner: #{owner.get_name}\n" 6360 join.set_owner owner 6361 } 6362 end 5842 6363 end 5843 6364 … … 5905 6426 if j then 5906 6427 (indent+2).times { print " " } 5907 puts "[#{i}]: #{j.get_name} id: #{j} "6428 puts "[#{i}]: #{j.get_name} id: #{j} owner=#{j.get_owner.get_name}" 5908 6429 j.get_rhs.show_tree(indent+3) 5909 (indent+3).times { print " " } 5910 puts "cell global name: #{j.get_cell_global_name}" 5911 (indent+3).times { print " " } 5912 puts "port global name: #{j.get_port_global_name}" 6430 # (indent+3).times { print " " } 6431 # puts "cell global name: #{j.get_cell_global_name}" 6432 # puts "cell global name: #{j.get_rhs_cell.get_global_name}" 6433 # (indent+3).times { print " " } 6434 # puts "port global name: #{j.get_port_global_name}" 6435 # puts "port global name: #{j.get_rhs_port.get_name}" 5913 6436 else 5914 6437 (indent+2).times { print " " } … … 6235 6758 end 6236 6759 6237 #== Domain 6760 #== DomainType 6238 6761 # 6239 6762 # region の domain を記憶するクラス … … 6256 6779 @name = name 6257 6780 @plugin_name = (name.to_s + "Plugin").to_sym 6258 load_plugin( @plugin_name, DomainPlugin )6781 plClass = load_plugin( @plugin_name, DomainPlugin ) 6259 6782 @region = region 6260 6783 @option = option … … 6272 6795 if ! @plugin then 6273 6796 pluginClass = Object.const_get @plugin_name 6797 return if pluginClass == nil 6274 6798 @plugin = pluginClass.new( @region, @name, @option ) 6799 @plugin.set_locale @locale 6275 6800 end 6276 6801 end … … 6290 6815 end 6291 6816 6292 #== Domain リージョンの Hash を得る6817 #== DomainType リージョンの Hash を得る 6293 6818 # @@domain_regions の説明参照 6294 6819 def self.get_domain_regions … … 6302 6827 def get_option 6303 6828 @option 6829 end 6830 6831 #== DomainType#ドメイン種別を得る 6832 #return::Symbol :kernel, :user, :OutOfDomain 6833 def get_kind 6834 @plugin.get_kind 6304 6835 end 6305 6836 … … 6363 6894 6364 6895 if @@domain_name then 6896 dbgPrint "Region=#{name} domain_type=#{@@domain_name} option=#{@@domain_option}\n" 6365 6897 domain_option = CDLString.remove_dquote @@domain_option.to_s 6366 6898 @domain_type = DomainType.new( self, @@domain_name, domain_option ) … … 6401 6933 6402 6934 # 再出現時に specifier が指定されているか? 6403 if( @in_through_list.length != 0 || @out_through_list.length != 0 || @to_through_list.length != 0 || @region_type != nil )then 6935 if( @in_through_list.length != 0 || @out_through_list.length != 0 || @to_through_list.length != 0 || 6936 @region_type != nil || @domain_type != nil )then 6404 6937 cdl_error( "S1140 $1: region specifier must place at first appearence" , name ) 6405 6938 end … … 6610 7143 end 6611 7144 7145 #== Region# ルートリージョン 7146 # ルートリージョンは、namespace のルートと同じインスタンス 7147 def selfget_root 7148 Namespace.get_root 7149 end 7150 6612 7151 def next_in_through_count 6613 7152 @in_through_count += 1 … … 6643 7182 #=== Region# through プラグインで、この region から cell_name.port_name へのプラグインオブジェクトを登録 6644 7183 # mikan namesppace 対応 (cell_name) 6645 def add_cell_port_through_plugin( cell_name, port_name, through_plugin_object ) 6646 @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}" ] = through_plugin_object 6647 end 6648 6649 def find_cell_port_through_plugin( cell_name, port_name ) 6650 return @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}" ] 7184 def add_cell_port_through_plugin( cell_name, port_name, subscript, through_plugin_object ) 7185 if subscript then 7186 subscript = '[' + subscript.to_s + ']' 7187 end 7188 @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}#{subscript}" ] = through_plugin_object 7189 end 7190 7191 def find_cell_port_through_plugin( cell_name, port_name, subscript ) 7192 if subscript then 7193 subscript = '[' + subscript.to_s + ']' 7194 end 7195 return @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}#{subscript}" ] 6651 7196 end 6652 7197 … … 6779 7324 end 6780 7325 7326 #== Importable class 7327 # this module is included by Import_C and Import 7328 module Importable 7329 #@last_base_dir::String 7330 7331 #=== Importable#find_file 7332 #file::String : file name to find 7333 #return::String | Nil: path to file or nil if not found 7334 #find file in 7335 def find_file file 7336 $import_path.each{ |path| 7337 if path == "." 7338 pt = file 7339 else 7340 pt = "#{path}/#{file}" 7341 end 7342 if File.exist?( pt ) 7343 if ! $base_dir[ Dir.pwd ] 7344 $base_dir[ Dir.pwd ] = true 7345 end 7346 if $verbose then 7347 print "#{file} is found in #{path}\n" 7348 end 7349 @last_base_dir = nil 7350 dbgPrint "base_dir=. while searching #{file}\n" 7351 return pt 7352 end 7353 } 7354 7355 $base_dir.each_key{ |bd| 7356 $import_path.each{ |path| 7357 # if path =~ /\A\// || path =~ /\A[a-zA-Z]:/ 7358 pt = "#{path}/#{file}" 7359 # else 7360 # pt = "#{bd}/#{path}/#{file}" 7361 # end 7362 begin 7363 Dir.chdir $run_dir 7364 Dir.chdir bd 7365 if File.exist?( pt ) 7366 if $verbose then 7367 print "#{file} is found in #{bd}/#{path}\n" 7368 end 7369 @last_base_dir = bd 7370 dbgPrint "base_dir=#{bd} while searching #{file}\n" 7371 $base_dir[ bd ] = true 7372 return pt 7373 end 7374 rescue 7375 end 7376 } 7377 } 7378 @last_base_dir = nil 7379 dbgPrint "base_dir=. while searching #{file}\n" 7380 return nil 7381 end 7382 7383 def get_base_dir 7384 return @last_base_dir 7385 $base_dir.each{ |bd, flag| 7386 if flag == true 7387 return bd 7388 end 7389 } 7390 return nil 7391 end 7392 end 7393 6781 7394 class Import_C < Node 6782 7395 … … 6785 7398 @@header_list2 = [] 6786 7399 @@define_list = {} 7400 7401 include Importable 6787 7402 6788 7403 #=== Import_C# import_C の生成(ヘッダファイルを取込む) … … 6823 7438 } 6824 7439 7440 header_path = find_file header 7441 7442 =begin 6825 7443 include_opt = "" 6826 7444 found = false … … 6844 7462 6845 7463 if found == false then 7464 =end 7465 if header_path == nil then 6846 7466 cdl_error( "S1142 $1 not found in search path" , header ) 6847 7467 return 6848 7468 end 7469 7470 include_opt = "" 7471 if get_base_dir then 7472 base = get_base_dir + "/" 7473 else 7474 base = "" 7475 end 7476 $import_path.each{ |path| 7477 include_opt = "#{include_opt} -I #{base}#{path}" 7478 } 6849 7479 6850 7480 # 読込み済み? … … 6862 7492 @@header_list2 << header 6863 7493 @@define_list[ header ] = define 7494 7495 if $verbose then 7496 print "import_C header=#{header_path}, define=#{define}\n" 7497 end 6864 7498 6865 7499 begin … … 6940 7574 * --no-gcc-extension-support for tecsgen. 6941 7575 */ 7576 #ifdef __GNUC__ 7577 6942 7578 #ifndef __attribute__ 6943 7579 #define __attribute__(x) … … 6956 7592 #endif 6957 7593 7594 #ifndef restrict 7595 #define restrict 7596 #endif 7597 7598 #endif /* ifdef __GNUC__ */ 6958 7599 #endif /* TECS_NO_GCC_EXTENSION_SUPPORT */ 6959 7600 EOT … … 6983 7624 # @cdl_path:: string: CDL のパス 6984 7625 # @b_imported:: bool: import された(コマンドライン指定されていない) 7626 7627 include Importable 6985 7628 6986 7629 # ヘッダの名前文字列のリスト 添字:expand したパス、値:Import … … 7023 7666 @b_reuse_real = @b_reuse || Generator.is_reuse? 7024 7667 7025 if Generator.get_plugin then 7026 # plugin から import されている場合 gen をサーチパスの先頭に加える 7027 search_path = [ $gen ] + $import_path 7028 else 7029 search_path = $import_path 7030 end 7031 7032 search_path.each{ |path| 7033 dbgPrint "import: searching #{path}/#{@cdl}" 7034 begin 7035 if path == "." 7036 cdl_path = @cdl 7037 else 7038 cdl_path = "#{path}/#{@cdl}" 7039 end 7040 7041 # ファイルの stat を取ってみる(なければ例外発生) 7042 File.stat( cdl_path ) 7043 7044 # cdl を見つかったファイルパスに再設定 7045 @cdl_path = cdl_path 7668 if( Generator.get_plugin ) &&( File.exist? "#{$gen}/#{@cdl}" ) then 7669 @cdl_path = "#{$gen}/#{@cdl}" 7670 found = true 7671 else 7672 path = find_file @cdl 7673 if path then 7046 7674 found = true 7047 dbgPrint ": found\n" 7048 break 7049 rescue => evar 7050 found = false 7051 dbgPrint ": not found\n" 7052 # print_exception( evar ) 7053 end 7054 } 7675 @cdl_path = path 7676 end 7677 end 7055 7678 7056 7679 if found == false then … … 7118 7741 end 7119 7742 7120 #== generate: signature プラグインのロードと実行7743 #== generate: signature, celltype, cell へのプラグインのロードと適用 7121 7744 class Generate < Node 7122 7745 #@plugin_name:: Symbol 7123 #@ signature_nsp:: NamespacePath7746 #@object_nsp:: NamespacePath 7124 7747 #@option:: String '"', '"' で囲まれている 7748 #@plugin_object:: Plugin 7125 7749 7126 7750 include PluginModule 7127 7751 7128 def initialize( plugin_name, signature_nsp, option )7752 def initialize( plugin_name, object_nsp, option ) 7129 7753 super() 7130 7754 @plugin_name = plugin_name 7131 @ signature_nsp = signature_nsp7755 @object_nsp = object_nsp 7132 7756 option = option.to_s # option は Token 7133 7757 @option = option 7134 7135 signature = Namespace.find( signature_nsp ) #mikan Namespace #1 7136 if ! signature.instance_of? Signature then 7137 cdl_error( "S1149 $1 not signature" , signature_nsp ) 7758 @plugin_object = nil 7759 7760 dbgPrint "generate: #{plugin_name} #{object_nsp.to_s} option=#{option}\n" 7761 7762 object = Namespace.find( object_nsp ) 7763 if object.kind_of?( Signature ) || 7764 object.kind_of?( Celltype ) || 7765 object.kind_of?( CompositeCelltype ) || 7766 object.kind_of?( Cell )then 7767 @plugin_object = object.apply_plugin( @plugin_name, @option ) 7768 elsif object then 7769 # V1.5.0 以前の仕様では、signature のみ可能だった 7770 # cdl_error( "S1149 $1 not signature" , signature_nsp ) 7771 cdl_error( "S9999 generate: '$1' neither signature, celltype nor cell", object_nsp ) 7138 7772 return 7139 elsif signature.is_empty? then 7140 cdl_warning( "S9999 $1 is empty. cannot apply signature plugin. ignored" , signature_nsp ) 7141 return 7142 end 7143 7144 load_plugin( plugin_name, SignaturePlugin ) 7145 7146 plugin_object = nil 7147 eval_str = "plugin_object = #{plugin_name}.new( signature, option )" 7148 if $verbose then 7149 print "new through: #{eval_str}\n" 7150 end 7151 7152 begin 7153 eval( eval_str ) # plugin を生成 7154 plugin_object.set_locale @locale 7155 rescue Exception => evar 7156 cdl_error( "S1150 $1: fail to new" , plugin_name ) 7157 print "eval( #{eval_str} )\n" 7158 7159 print_exception( evar ) 7160 end 7161 generate_and_parse plugin_object 7773 else 7774 cdl_error( "S9999 generate: '$1' not found", object_nsp ) 7775 end 7162 7776 end 7163 7777 end
Note:
See TracChangeset
for help on using the changeset viewer.