Ignore:
Timestamp:
Jul 3, 2020, 7:19:17 PM (4 years ago)
Author:
coas-nagasima
Message:

ASP3, TINET, mbed を更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/componentobj.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2016 by TOPPERS Project
     6#   Copyright (C) 2008-2019 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    7979#  @b_checked_as_allocator_signature:: bool:  アロケータシグニチャとしてチェック済み
    8080#  @b_empty:: Bool: 空(関数が一つもない状態)
     81#  @descriptor_list:: nil | { Signature => ParamDecl }  最後の ParamDecl しか記憶しないことに注意
     82#  @generate:: [ Symbol, String, Plugin ]  = [ PluginName, option, Plugin ] Plugin は生成後に追加される
     83
     84  include PluginModule
    8185
    8286  @@nest_stack_index = -1
     
    123127    @b_empty = false
    124128    @b_checked_as_allocator_signature = false
     129    @descriptor_list = nil
     130    @generate = nil
    125131    @@current_object = self
    126132    set_specifier_list( Generator.get_statement_specifier )
     
    136142    function_head_list.get_items.each{ |f|
    137143      @func_name_to_id[ f.get_name ] = id
     144      f.set_owner self
    138145      id += 1
    139146    }
     
    142149    end
    143150
     151    # set_descriptor_list ##
     152
     153    if @generate then
     154      signature_plugin
     155    end
     156
    144157    @@current_object = nil
     158
    145159    return self
    146160  end
     
    170184      when :DEVIATE
    171185        @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" ]
    172191      else
    173192        cdl_error( "S1002 \'$1\': unknown specifier for signature" , s[0] )
     
    309328  end
    310329
    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
     358end
     359
     360  #== Signature# 引数で参照されている Descriptor 型のリストを
    312361  #RETURN:: Hash { Signature => ParamDecl }:  複数の ParamDecl から参照されている場合、最後のものしか返さない
    313362  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
    314378    desc_list = { }
    315379    # p "has_desc #{@name}"
    316380    fha = get_function_head_array                       # 呼び口または受け口のシグニチャの関数配列
    317381    if fha == nil then                                  # nil の場合、自己参照によるケースと仮定
     382      @descriptor_list = desc_list
    318383      return desc_list
    319384    end
     
    330395            # p "has_desc #{param.get_name} #{t}"
    331396            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
    333406            end
    334407          }
     
    336409      end
    337410    }
    338     return desc_list
     411    @descriptor_list = desc_list
    339412  end
    340413
    341414  #=== Signature# 引数に Descriptor があるか?
    342415  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 型である
    346420      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
    367426  end
    368427
     
    411470
    412471end
     472
     473module 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
     537end #CelltypePluginModule
    413538
    414539class Celltype < NSBDNode # < Nestable
     
    423548# @ct_factory_list::    Factory[] :    celltype factory
    424549# @cell_list:: Cell[] : 定義のみ (V1.0.0.2 以降)
     550# @ordered_cell_list:: Cell[] : ID 順に順序付けされたセルリスト、最適化以降有効 (リンク単位ごとに生成されなおす)
    425551# @singleton:: bool
    426552# @idx_is_id:: bool
    427553# @idx_is_id_act:: bool: actual value
     554# @b_need_ptab:: bool: true if having cells in multi-domain
    428555# @active:: bool
    429556# @b_reuse:: bool :  reuse 指定されて import された(template 不要)
    430557# @generate:: [ Symbol, String, Plugin ]  = [ PluginName, option, Plugin ] Plugin は生成後に追加される
     558# @generate_list:: [ [ Symbol, String, Plugin ], ... ]   generate 文で追加された generate
    431559#
    432560# @n_attribute_ro:: int >= 0    none specified
     
    437565# @n_var_omit:: int >= 0        # of [omit] specified vars # mikan var の omit は有?
    438566# @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
    441569# @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
    442574# @n_entry_port:: int >= 0
    443575# @n_entry_port_array:: int >= 0
     
    455587
    456588  include PluginModule
    457 
     589  include CelltypePluginModule
     590 
    458591  @@nest_stack_index = -1
    459592  @@nest_stack = []
     
    496629    @active = false
    497630    @generate = nil
     631    @generate_list = []
    498632
    499633    @n_attribute_ro = 0
     
    507641    @n_call_port_array = 0
    508642    @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
    509647    @n_entry_port = 0
    510648    @n_entry_port_array = 0
     
    528666    if $idx_is_id then
    529667      @idx_is_id = true
     668      @idx_is_id_act = true
     669      @b_need_ptab = true
    530670    else
    531671      @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
    534675
    535676    Namespace.new_celltype( self )
    536677    set_namespace_path # @NamespacePath の設定
    537678    set_specifier_list( Generator.get_statement_specifier )
    538 
    539     if @singleton then
    540       @idx_is_id_act = false
    541     end
    542679
    543680    @included_header = {}
     
    577714      celltype_plugin
    578715    end
     716
     717    # check_dynamic_join ##
    579718
    580719    @@current_object = nil
     
    592731      @n_call_port += 1
    593732      @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
    594741    else
    595742      @n_entry_port += 1
     
    753900      when :IDX_IS_ID
    754901        @idx_is_id = true
     902        @idx_is_id_act = true
     903        @b_need_ptab = true
    755904      when :ACTIVE
    756905        @active = true
     
    764913      end
    765914    }
     915    if @singleton then
     916      @idx_is_id_act = false
     917      @b_need_ptab = false
     918    end
    766919  end
    767920
     
    8631016  end
    8641017
    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
    8891135  end
    8901136
     
    8951141  # シングルトンセルが同じ linkunit に複数ないかチェック
    8961142  def new_cell( cell )
     1143    dbgPrint "Celltype#new_cell( #{cell.get_name} )\n"
    8971144    # Celltype では Cell の set_owner しない
    8981145    # シングルトンで、プロトタイプ宣言でない場合、コード生成対象リージョンの場合
     
    9051152    end
    9061153    @cell_list << cell
     1154
     1155    # プラグインにより生成されたセルタイプか ?
    9071156    if @plugin then
    9081157      @plugin.new_cell cell
    9091158    end
     1159
     1160    # セルタイププラグインの適用
     1161    celltype_plugin_new_cell cell
    9101162  end
    9111163
     
    9191171  #     呼び口(ただし、最適化で不要となるものは除く)
    9201172  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
    9241183  end
    9251184
     
    9341193  def has_CB?
    9351194    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
    9371196      # return @n_attribute_rw > 0 || @n_var > 0
    9381197    else
     
    9431202  #=== Celltype# SET_CB_INIB_POINTER, INITIALIZE_CB が必要か
    9441203  def need_CB_initializer?
    945     @n_var_init > 0 || has_CB?
     1204    @n_var_init > 0 || has_CB? || ( @n_call_port_dynamic && $ram_initializer )
    9461205  end
    9471206
     
    9981257  def is_active?
    9991258    @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
    10001267  end
    10011268
     
    11201387#                                               逆require ポートに対して複数の結合がないかチェックする
    11211388# @generate:: [ Symbol, String, Plugin ]  = [ PluginName, option, Plugin ] Plugin は生成後に追加される
     1389# @b_post_code_generated:: Bool: true if generated in tmp_plugin_post_code.cdl
    11221390#
    11231391# composite のためインスタンス変数
     
    11421410# @id:: Integer : コード生成直前に設定  (プロトタイプ宣言の場合は -1 のまま放置)
    11431411# @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 が参照れた
    11451415
    11461416=begin
     
    11871457  end
    11881458
    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 
    11961459  def initialize( ct_path, in_composite = false )
    11971460    super()
     
    12331496    @referenced_port_list = {}
    12341497    @restrict_list = {}
     1498    @restrict_list2 = {}
     1499    @b_restrict_referenced = false
     1500    @b_post_code_generated = false
    12351501
    12361502    @cell_list = {}
     
    12581524      cell_prev = CompositeCelltype.find( name )
    12591525      if cell_prev == nil then
    1260         CompositeCelltype.new_cell( self )
     1526        CompositeCelltype.new_cell_in_composite( self )
    12611527      end
    12621528    else
     
    14371703
    14381704    else
     1705      dbgPrint "new_join: cell=#{@name} add_item=#{join.get_name}\n"
    14391706      # join
    14401707      @join_list.add_item( join )
     
    15001767
    15011768        # 呼び口側のセルと、そのセルタイプ
    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
    15031775        if ! cell.instance_of? Cell then
    15041776          cdl_error( "S9999 '$1': not cell for reverse join", cp_cell_nsp.get_path_str )
     
    15101782        end
    15111783
    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
    15131791        ep_subscript_val = ep_subscript ? ep_subscript.eval_const( nil ) : nil
    15141792        rhs = Expression.create_cell_join_expression( ep_cell_nsp, ep_subscript_val, ep_name, rj.get_locale )
     
    15211799          ss_str = ""
    15221800        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"
    15241802      }
    15251803    end
     
    15651843      set_specifier_list( Generator.get_statement_specifier )
    15661844    end
     1845    if TECSGEN.post_coded?
     1846      @b_post_code_generated = true
     1847    end
    15671848    set_f_def f_def
    15681849
     
    15811862
    15821863    if ! @in_composite then
    1583       if @celltype.instance_of? Celltype then
     1864      # if @celltype.instance_of? Celltype then
     1865      if @celltype then  # composite でも呼びだす, エラー時 nil
    15841866        @celltype.new_cell self
    15851867      end
     
    17021984  end
    17031985
    1704   #=== Cell# セルタイププラグイン (generate 指定子)
     1986  #=== Cell# セルプラグイン (generate 指定子)
    17051987  def cell_plugin
    1706 
    1707     load_plugin( @generate[0], CellPlugin )
    1708 
    17091988    plugin_name = @generate[0]
    17101989    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 # 従来と仕様が変わるので、継続する
    17132000    if $verbose then
    1714       print "new cell : #{eval_str}\n"
     2001      print "new cell plugin: plugin_object = #{plClass.class.name}.new( #{@name}, #{option} )\n"
    17152002    end
    17162003
    17172004    begin
    1718       eval( eval_str )     # plugin を生成
     2005      plugin_object = plClass.new( self, option )
    17192006      plugin_object.set_locale @locale
    1720       @generate[ 2 ] = plugin_object
    17212007      generate_and_parse plugin_object
    17222008    rescue Exception => evar
    17232009      cdl_error( "S1166 $1: fail to new", plugin_name )
    1724       print "eval( #{eval_str} )\n"
    1725 
    17262010      print_exception( evar )
    17272011    end
     2012    return  plugin_object
    17282013  end
    17292014
     
    17422027
    17432028    # 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"
    17452031
    17462032    @my_clone = self.clone
    1747     @@cloned_cell_list[ self ] = @my_clone
    17482033
    17492034    # clone したセルの内部に持つ名前情報を調整する
    1750 
    17512035    @my_clone.set_cloned( name, global_name, namespacePath, join_array, ct_name, region, plugin, locale )
    17522036
     
    17722056    # debug
    17732057    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"
    17752059    @global_name = :"#{global_name}_#{@name}"
    17762060    @name = :"#{name}_#{@name}"
     
    17962080    @alloc_list = []
    17972081    @require_joined_list = {}
    1798     @entry_array_max_subscript = {}
     2082    @entry_array_max_subscript = @entry_array_max_subscript.dup
    17992083    @cell_list = {}
    18002084    @cell_list2 = []
     
    18052089      @join_list.change_item j
    18062090    }
     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
    18072099
    18082100    # clone しようとするセルが composit セルタイプ?
     
    18112103      @cell_list, @cell_list2 = @celltype.expand( @name, @global_name, @NamespacePath, @join_list, @region, @plugin, @locale )
    18122104    end
    1813 
    18142105  end
    18152106
    18162107  #=== Cell# clone された cell の join_list の右辺の変更
    18172108  #  呼び口の右辺の cell を他の clone された cell に置換え
    1818   def change_rhs_port
     2109  def change_rhs_port cloned_cell_list
    18192110
    18202111    # debug
    1821     dbgPrint "Cell change_rhs_port: global_name: #{@global_name}\n"
     2112    dbgPrint "=====   Cell#change_rhs_port: name=#{@name}   =====\n"
    18222113
    18232114    @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    }
    18342117  end
    18352118
     
    18912174  def is_in_composite?
    18922175    @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
    18932190  end
    18942191
     
    19802277
    19812278      # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる)
     2279      # print "get_real_cell: cell=#{@name} port=#{port_name}\n"
     2280      # pp @cell_list
    19822281      cj = @celltype.find_export( port_name )
    19832282
     
    19912290  end
    19922291
     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
    19932301
    19942302  #=== Cell# 受け口のport の参照カウントをアップする
     
    20332341  end
    20342342
     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
    20352355  def get_celltype
    20362356    @celltype
     
    20752395  #=== Cell# composite の内側セルの受け口配列の添数の最大値を設定
    20762396  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 展開前
    20792399    end
    20802400
    20812401    # composite の内側のセルに伝播
    20822402    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
    20832406      cj = @celltype.find_export port.get_name
    20842407      if cj && @cell_list[ cj.get_cell_name.to_s ] then
     
    22782601        else
    22792602          cell = j.get_rhs_cell2
    2280           next if cell == nil     # 右辺が見つからなかった.既にエラー
     2603          next if cell == nil || cell.get_celltype == nil     # 右辺が見つからなかった.既にエラー
    22812604          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
    22822611          dbgPrint( "set_port_reference_count: #{@name}.#{j.get_name} => #{cell.get_name}.#{port.get_name}\n")
    22832612          cell.port_referenced port
     
    26723001          }
    26733002        else
     3003          dbgPrint "set_definition_join: #{@name}.#{join.get_name} celltype=#{@celltype.get_name}\n"
    26743004          join.set_definition( @celltype.find(join.get_name) )
    26753005        end
     
    26873017      expand
    26883018    end
    2689 
    2690     # celltype に generate が指定されされているか
    2691     celltype_plugin = @celltype.get_celltype_plugin
    2692     if celltype_plugin then
    2693       begin
    2694         celltype_plugin.new_cell self
    2695       rescue Exception => evar
    2696         cdl_error( "S1037 $1: celltype plugin fail to new_cell" , celltype_plugin.class.name )
    2697         print_exception( evar )
    2698       end
    2699     end
    27003019  end
    27013020
     
    27053024
    27063025    #debug
    2707     dbgPrint "expanding #{@name} #{@celltype.get_name}\n"
    2708 
    2709     # 展開されたセルのリスト
    2710     @@cloned_cell_list = {}
     3026    dbgPrint "=====    expanding   #{@name}     =====\n"
    27113027
    27123028    # composite celltype の cell を展開
     
    27183034      set_f_ref
    27193035    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"
    27233045
    27243046    # プロトタイプ宣言で設定されていたものを反映する
    27253047    @entry_array_max_subscript.each{ |port,name|
     3048      dbgPrint "set_entry_inner_port_max_subscript( #{port}, #{name} )\n"
    27263049      set_entry_inner_port_max_subscript( port, name )
    27273050    }
     
    27303053  #=== Cell#restrict を追加
    27313054  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
    27393125          end
    27403126        }
    27413127      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
    27813156      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
    28003162  def show_tree( indent )
    28013163    indent.times { print "  " }
     
    28573219# @name:: str
    28583220# @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
    28603223# @export_name_list:: NamedList : CompositeCelltypeJoin
    28613224# @port_list:: CompositeCelltypeJoin[]
     
    28673230# @name_list:: NamedList item: Decl (attribute), Port エクスポート定義
    28683231# @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
    28693234
    28703235  @@nest_stack_index = -1
    28713236  @@nest_stack = []
    28723237  @@current_object = nil
     3238
     3239  include CelltypePluginModule
     3240  include PluginModule
    28733241
    28743242  def self.push
     
    28893257    super()
    28903258    @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 = []
    28923261    @export_name_list = NamedList.new( nil, "export in composite celltype #{name}" )
    28933262    @name_list = NamedList.new( nil, "in composite celltype #{name}" )
     
    29103279    @attr_list = []
    29113280    @internal_allocator_list = []
     3281    @generate_list = []
    29123282    set_specifier_list( Generator.get_statement_specifier )
    29133283  end
     
    29203290  # CompositeCelltype#end_of_parse
    29213291  def end_of_parse
    2922 
    29233292    # singleton に関するチェック
    29243293    if @b_singleton && @real_singleton == nil then
     
    29603329    # mikan relay が正しく抜けているかチェックされていない
    29613330
     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
    29623339    # 意味解析
    2963     @cell_list.get_items.each{ |c|
     3340    @cell_list_in_composite.get_items.each{ |c|
    29643341      c.set_definition_join
    29653342    }
    29663343
    29673344    # cell の未結合の呼び口がないかチェック
    2968     @cell_list.get_items.each{ |c|
     3345    @cell_list_in_composite.get_items.each{ |c|
    29693346      c.check_join
    29703347      c.check_reverse_require
     
    30043381      }
    30053382    }
    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 )
    30153397    cell.set_owner self  # Cell (in_omposite)
    3016     @cell_list.add_item( cell )
     3398    @cell_list_in_composite.add_item( cell )
    30173399    if cell.get_celltype then    # nil ならば、すでにセルタイプなしエラー
    30183400      if cell.get_celltype.is_singleton? then
     
    30313413                                         internal_cell_elem_name, type )
    30323414   
     3415  end
     3416
     3417 ### CompositeCelltype#new_cell
     3418  def new_cell cell
     3419    @cell_list << cell
     3420
     3421    # セルタイププラグインの適用
     3422    celltype_plugin_new_cell cell
    30333423  end
    30343424
     
    30503440    dbgPrint "new_join: #{export_name} #{internal_cell_name} #{internal_cell_elem_name}\n"
    30513441
    3052     cell = @cell_list.get_item( internal_cell_name )
     3442    cell = @cell_list_in_composite.get_item( internal_cell_name )
    30533443    if cell == nil then
    30543444      cdl_error( "S1057 $1 not found in $2" , internal_cell_name, @name )
     
    31073497        elsif obj.is_omit? != obj2.is_omit? then
    31083498          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 )
    31093503        end
    31103504      else
     
    32923686  def find name
    32933687    dbgPrint "CompositeCelltype: find in composite: #{name}\n"
    3294     cell = @cell_list.get_item( name )
     3688    cell = @cell_list_in_composite.get_item( name )
    32953689    return cell if cell
    32963690
     
    33333727    clone_cell_list = {}
    33343728    clone_cell_list2 = []
     3729    clone_cell_list3 = {}
    33353730
    33363731    #  composite 内部のすべての cell について
    3337     @cell_list.get_items.each { |c|
     3732    @cell_list_in_composite.get_items.each { |c|
    33383733
    33393734      # debug
     
    33593754          # debug
    33603755          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"
    33623757          else
    33633758            dbgPrint "expand : parent cell: #{name} child cell: #{c.get_name}:  parent's export port: #{cj.get_name}  join: nil\n"
     
    33943789      clone_cell_list[ "#{c.get_local_name}" ] = c2
    33953790      clone_cell_list2 << c2
     3791      clone_cell_list3[ c ] = c2
    33963792
    33973793    }
     
    34033799        j.set_cloned( clone_cell_list[ "#{c.get_local_name}" ] )
    34043800      }
     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
    34053806    }
    34063807    return [ clone_cell_list, clone_cell_list2 ]
     
    34193820      when :ACTIVE
    34203821        @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" ]
    34213827      else
    34223828        cdl_error( "S1071 $1 cannot be specified for composite" , s[0] )
     
    34293835  end
    34303836
     3837  def get_global_name
     3838    @global_name
     3839  end
     3840
    34313841  def get_port_list
    34323842    @port_list
     
    34433853  def get_internal_allocator_list
    34443854    @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
    34453867  end
    34463868
     
    34653887  def is_inactive?
    34663888    if @b_active == false then
    3467       @cell_list.get_items.each{ |c|
     3889      @cell_list_in_composite.get_items.each{ |c|
    34683890        if c.get_celltype && c.get_celltype.is_inactive? == false then
    34693891          # c.get_celltype == nil の場合はセルタイプ未定義ですでにエラー
     
    34863908    (indent+1).times { print "  " }
    34873909    puts "active: #{@b_active}, singleton: #{@b_singleton}"
    3488     @cell_list.show_tree( indent + 1 )
     3910    @cell_list_in_composite.show_tree( indent + 1 )
    34893911    (indent+1).times { print "  " }
    34903912    puts "name_list"
     
    35323954# @b_omit:: bool : omit 指定子が指定された (call port のみ)
    35333955# @b_optional:: bool : call port のみ
    3534 # @b_ref_des:: bool :  ref_desc キーワードが指定された
     3956# @b_ref_desc:: bool :  ref_desc キーワードが指定された
    35353957# @b_dynamic:: bool :  dynamic キーワードが指定された (呼び口のみ)
    35363958#
     
    36384060    @b_inline = false
    36394061    @b_optional = false
     4062    @b_omit = false
    36404063    @b_ref_desc = false
    36414064    @b_dynamic = false
     
    36554078    else
    36564079      # entry port optimize
    3657       if $unopt then
     4080      if $unopt || $unopt_entry then
    36584081        # 最適化なし
    36594082        @b_VMT_useless = false                     # VMT 不要 (true の時 VMT を介することなく呼出す)
     
    37864209        @b_optional = true
    37874210      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
    37884215        @b_ref_desc = true
    37894216      when :DYNAMIC
     
    38064233      end
    38074234    }
     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
    38084252  end
    38094253
     
    39584402
    39594403  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
    39614411  end
    39624412
    39634413  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
    39654421  end
    39664422
     
    40784534  def is_reverse_required?
    40794535    @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
    40804546  end
    40814547
     
    44894955      if ! c.get_f_def then   # Namespace の @cell_list にはプロトタイプが含まれるケースあり
    44904956        if c.get_f_ref then
    4491           cdl_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 )
    44924958        elsif $verbose then
    4493           cdl_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 )
    44944960        end
    44954961      else
     
    44984964        # if c.get_f_ref == false && c.is_generate? && ct && ct.is_inactive? then
    44994965        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 )
    45014970        end
    45024971      end
     
    46575126  end
    46585127
     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
    46595140  #=== Namespace# セルの結合をチェックする
    46605141  def check_join
     
    46815162  end
    46825163
     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 
    46835176  def show_tree( indent )
    46845177    indent.times { print "  " }
     
    49045397
    49055398    if object == nil then                                             # (2)
    4906       cdl_error( "S1109 \'$1\' not found" , @cell_name )
     5399      cdl_error( "S1109 \'$1\' not found" , nsp.to_s )
    49075400    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 )
    49095402    else
    49105403      dbgPrint "set_definition: set_f_ref #{@owner.get_name}.#{@name} => #{object.get_name}\n"
     
    52775770          next_cell_nsp       = @through_generated_list[ i + 1 ].get_cell_namespace_path
    52785771          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
    52795773        rescue Exception => evar
    52805774          cdl_error( "S1124 $1: plugin function failed: \'get_through_entry_port_name\'" , plugin_name )
     
    52955789        next_cell      = @cell
    52965790        next_port_name = @port_name
     5791        next_port_subscript = @rhs_subscript
    52975792
    52985793        if next_cell == nil then
     
    53065801        # region から @cell_name.@port_name への through がないか探す
    53075802        # 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 )
    53095804           # @through_list[i] と @region_through_list[i-cp_len] は同じ
    53105805        # 共用しないようにするには、見つからなかったことにすればよい
     
    53175812
    53185813      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 )
    53215817        end
    53225818      else
     
    53315827          # 生成したものを region(@through_list[i][3]) のリストに追加
    53325828          # @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] )
    53345830        end
    53355831      end
     
    53655861
    53665862  #=== 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 )
    53685864
    53695865    through = @through_list[ i ]
     
    53895885    end
    53905886    @@plugin_creating_join = self
    5391 
    53925887    caller_cell = @owner
    53935888
    5394     plugin_object = nil
    5395     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 then
    5397       print "new through: #{eval_str}\n"
    5398     end
    5399 
    54005889    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 )
    54025893      plugin_object.set_locale @locale
    54035894    rescue Exception => evar
     
    54065897        print "signature: #{@definition.get_signature.get_name} from: #{caller_cell.get_name} to: #{next_cell.get_name} of celltype: #{@celltype.get_name}\n"
    54075898      end
    5408       print "eval( #{eval_str} )\n"
    5409 
    54105899      print_exception( evar )
    54115900      return
     
    55966085  end
    55976086
    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
    55996095    @rhs_subscript
    56006096  end
     
    56066102    # through 指定あり?
    56076103    if @through_list[0] then
    5608       # mikan through で生成したものが root namespace 限定
    56096104      # through で生成されたセルを探す
    5610 #      cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] )    #1
    56116105      cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path )    #1
    56126106      # cell のプラグインで生成されたポート名のポートを探す (composite なら内部の繋がるポート)
     
    56156109      # ポートを返す(composite なら内部の繋がるポートを返す)
    56166110      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
    56176123    end
    56186124  end
     
    57186224  # composite cell を展開したセルの結合を clone したセルの名前に変更
    57196225  def change_rhs_port( clone_cell_list, celltype )
     6226    dbgPrint "change_rhs_port: name=#{@name}\n"
    57206227
    57216228    # debug
    57226229    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"
    57246234
    57256235      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"
    57276238      }
     6239      print "============\n"
    57286240    end
    57296241
     
    57326244
    57336245    # 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"
    57356247
    57366248    # @rhs の内容を調整しておく(この内容は、subscript を除いて、後から使われていない)
     
    57566268
    57576269      # debug
    5758       # p "array_member2.len : #{@array_member.length}"
     6270      dbgPrint "array_member2.len : #{@array_member.length}\n"
    57596271
    57606272      i = 0
     
    57646276        # 無駄に設定されているものについては、再帰的に呼び出す必要はない(clone_for_composite では対策している)
    57656277        if @array_member2[i] != self && @array_member[i] != nil then
     6278          dbgPrint "change_rhs array_member #{i}: #{@name}  #{@cell_name}\n"
    57666279          @array_member2[i].change_rhs_port( clone_cell_list, celltype )
    57676280        end
     
    57796292  # @through_list などもコピーされるので、これが呼び出される前に確定する必要がある
    57806293  def clone_for_composite( ct_name, cell_name, locale, b_need_recursive = true )
    5781 
    57826294    # debug
    5783     dbgPrint "join.clone_for_composite : #{@name} #{@cell_name} #{self}\n"
     6295    dbgPrint "=====  clone_for_composite: #{@name} #{@cell_name} #{self}   =====\n"
    57846296    cl = self.clone
    57856297
    57866298    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 )
    57886300    end
    57896301
     
    57966308  end
    57976309
    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 )
    57996311    # 配列のコピーを作る
    5800     am  = array_member.clone
    5801     am2 = array_member2.clone
     6312    am  = @array_member.clone
     6313    am2 = @array_member2.clone
    58026314
    58036315    # 配列要素のコピーを作る
    58046316    i = 0
    58056317    while i < am2.length
    5806       if array_member2[i] == prev then
     6318      if @array_member2[i] == prev then
    58076319        # 自分自身である(ので、呼出すと無限再帰呼出しとなる)
    58086320        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
    58116326      else
    58126327        # 以前のエラーで array_member2[i] は nil になっている
     
    58146329
    58156330      # 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"
    58176332
    58186333      i += 1
     
    58406355    dbgPrint "Join#set_cloned: #{@name}  prev owner: #{@owner.get_name} new owner: #{owner.get_name}\n"
    58416356    @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
    58426363  end
    58436364
     
    59056426        if j then
    59066427          (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}"
    59086429          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}"
    59136436        else
    59146437          (indent+2).times { print "  " }
     
    62356758end
    62366759
    6237 #== Domain
     6760#== DomainType
    62386761#
    62396762# region の domain を記憶するクラス
     
    62566779    @name = name
    62576780    @plugin_name = (name.to_s + "Plugin").to_sym
    6258     load_plugin( @plugin_name, DomainPlugin )
     6781    plClass = load_plugin( @plugin_name, DomainPlugin )
    62596782    @region = region
    62606783    @option = option
     
    62726795    if ! @plugin then
    62736796      pluginClass = Object.const_get @plugin_name
     6797      return if pluginClass == nil
    62746798      @plugin = pluginClass.new( @region, @name, @option )
     6799      @plugin.set_locale @locale
    62756800    end
    62766801  end
     
    62906815  end
    62916816
    6292   #== Domain リージョンの Hash を得る
     6817  #== DomainType リージョンの Hash を得る
    62936818  # @@domain_regions の説明参照
    62946819  def self.get_domain_regions
     
    63026827  def get_option
    63036828    @option
     6829  end
     6830
     6831  #== DomainType#ドメイン種別を得る
     6832  #return::Symbol :kernel, :user, :OutOfDomain
     6833  def get_kind
     6834    @plugin.get_kind
    63046835  end
    63056836
     
    63636894
    63646895    if @@domain_name then
     6896      dbgPrint "Region=#{name} domain_type=#{@@domain_name} option=#{@@domain_option}\n"
    63656897      domain_option = CDLString.remove_dquote @@domain_option.to_s
    63666898      @domain_type = DomainType.new( self, @@domain_name, domain_option )
     
    64016933
    64026934        # 再出現時に 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
    64046937          cdl_error( "S1140 $1: region specifier must place at first appearence" , name )
    64056938        end
     
    66107143  end
    66117144
     7145  #== Region# ルートリージョン
     7146  # ルートリージョンは、namespace のルートと同じインスタンス
     7147  def selfget_root
     7148    Namespace.get_root
     7149  end
     7150
    66127151  def next_in_through_count
    66137152    @in_through_count += 1
     
    66437182  #=== Region# through プラグインで、この region から cell_name.port_name へのプラグインオブジェクトを登録
    66447183  # 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}" ]
    66517196  end
    66527197
     
    67797324end
    67807325
     7326#== Importable class
     7327# this module is included by Import_C and Import
     7328module 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
     7392end
     7393
    67817394class Import_C < Node
    67827395
     
    67857398  @@header_list2 = []
    67867399  @@define_list = {}
     7400
     7401  include Importable
    67877402
    67887403  #=== Import_C# import_C の生成(ヘッダファイルを取込む)
     
    68237438    }
    68247439
     7440    header_path = find_file header
     7441
     7442=begin
    68257443    include_opt = ""
    68267444    found = false
     
    68447462
    68457463    if found == false then
     7464=end
     7465    if header_path == nil then
    68467466      cdl_error( "S1142 $1 not found in search path" , header )
    68477467      return
    68487468    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    }
    68497479
    68507480    # 読込み済み?
     
    68627492    @@header_list2 << header
    68637493    @@define_list[ header ] = define
     7494
     7495    if $verbose then
     7496      print "import_C header=#{header_path}, define=#{define}\n"
     7497    end
    68647498
    68657499    begin
     
    69407574 * --no-gcc-extension-support for tecsgen.
    69417575 */
     7576#ifdef __GNUC__
     7577
    69427578#ifndef __attribute__
    69437579#define __attribute__(x)
     
    69567592#endif
    69577593
     7594#ifndef restrict
     7595#define restrict
     7596#endif
     7597
     7598#endif /* ifdef __GNUC__ */
    69587599#endif /* TECS_NO_GCC_EXTENSION_SUPPORT */
    69597600EOT
     
    69837624# @cdl_path:: string:   CDL のパス
    69847625# @b_imported:: bool:   import された(コマンドライン指定されていない)
     7626
     7627  include Importable
    69857628
    69867629  # ヘッダの名前文字列のリスト  添字:expand したパス、値:Import
     
    70237666    @b_reuse_real = @b_reuse || Generator.is_reuse?
    70247667
    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
    70467674        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
    70557678
    70567679    if found == false then
     
    71187741end
    71197742
    7120 #== generate: signature プラグインのロードと実行
     7743#== generate: signature, celltype, cell へのプラグインのロードと適用
    71217744class Generate < Node
    71227745#@plugin_name:: Symbol
    7123 #@signature_nsp:: NamespacePath
     7746#@object_nsp:: NamespacePath
    71247747#@option::         String '"', '"' で囲まれている
     7748#@plugin_object:: Plugin
    71257749
    71267750  include PluginModule
    71277751
    7128   def initialize( plugin_name, signature_nsp, option )
     7752  def initialize( plugin_name, object_nsp, option )
    71297753    super()
    71307754    @plugin_name = plugin_name
    7131     @signature_nsp = signature_nsp
     7755    @object_nsp = object_nsp
    71327756    option = option.to_s    # option は Token
    71337757    @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 )
    71387772      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
    71627776  end
    71637777end
Note: See TracChangeset for help on using the changeset viewer.