Class: Region
- Inherits:
-
Namespace
show all
- Defined in:
- lib/tecsgen/core/componentobj.rb,
lib/tecsgen/core/generate.rb,
lib/tecsgen/core/tecsinfo.rb,
lib/tecsgen/core/unjoin_plugin.rb
Overview
Region クラス
Region は Namespace を継承している root region は特殊で、root namespace と同じである
cell は region に属する region に属する cell のリストは Namespace クラスのインスタンス変数として記憶される
Constant Summary
collapse
- @@in_through_list =
@domain_root::Region : domain 指定されていなる Region (root の場合 nil)
[]
- @@out_through_list =
[]
- @@to_through_list =
[]
- @@region_type =
nil
- @@region_type_param =
nil
- @@domain_name =
nil
- @@domain_option =
nil
- @@link_roots =
[]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Namespace
#check_join, #check_ref_but_undef, #end_of_parse, #find, find, #find_one, find_one, #find_tag, find_tag, #gen_XML, gen_XML, #gen_celltype_names, #gen_celltype_names_domain, #gen_celltype_names_domain2, #gen_global_header, #gen_global_header_post, #gen_makefile, #gen_makefile_tecsgen, #gen_makefile_template, #generate, #generate_post, #get_global_name, get_global_name, #get_n_cells, #is_root?, #is_typename?, is_typename?, new_cell, #new_cell, #new_celltype, new_celltype, #new_compositecelltype, new_compositecelltype, new_const_decl, #new_const_decl, #new_namespace, new_namespace, #new_signature, new_signature, #new_structtype, new_structtype, new_typedef, #new_typedef, #optimize, #pop, pop, #print_all_cells, #print_call_define, #print_celltype_define, #print_celltype_define_offset, #print_entry_define, print_info, #print_info_ns, #print_info_ns_sub, #print_struct_define, #push, push, #reset_optimize, #set_cell_id_and_domain, #set_definition_join, #set_max_entry_port_inner_cell, #set_port_reference_count, #set_require_join, set_root, #travers_all_celltype, #travers_all_celltype_proc, #travers_all_signature, #travers_all_signature_proc
Methods inherited from NSBDNode
#get_namespace, #get_namespace_path, #is_imported?, #set_namespace_path
Methods inherited from BDNode
#get_owner, #set_owner
Methods inherited from Node
#cdl_error, #cdl_error2, #cdl_error3, #cdl_info, #cdl_info2, #cdl_warning, #cdl_warning2, #get_locale, #locale_str, #set_locale
Constructor Details
#initialize(name) ⇒ Region
Returns a new instance of Region.
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
|
# File 'lib/tecsgen/core/componentobj.rb', line 6806
def initialize(name)
if name != "::"
object = Namespace.get_current.find(name) else
object = nil
@@region_type = :NODE
end
@in_through_list = @@in_through_list
@out_through_list = @@out_through_list
@to_through_list = @@to_through_list
@region_type = @@region_type
@region_type_param = @@region_type_param
if @@domain_name
dbgPrint "Region=#{name} domain_type=#{@@domain_name} option=#{@@domain_option}\n"
domain_option = CDLString.remove_dquote @@domain_option.to_s
@domain_type = DomainType.new(self, @@domain_name, domain_option)
@@domain_name = nil
@@domain_option = nil
else
@domain_type = nil
end
@@in_through_list = []
@@out_through_list = []
@@to_through_list = []
@@region_type = nil
@@region_type_param = nil
@in_through_count = -1
@out_through_count = -1
@to_through_count = {}
super(name)
if object
if object.instance_of?(Region)
dbgPrint "Region.new: re-appear #{@name}\n"
if @in_through_list.length != 0 || @out_through_list.length != 0 || @to_through_list.length != 0 ||
!@region_type.nil? || !@domain_type.nil?
cdl_error("S1140 $1: region specifier must place at first appearence", name)
end
return
else
cdl_error("S1141 $1 duplication, previous one : $2", name, object.class)
end
else
dbgPrint "Region.new: #{@name}\n"
set_region_family_line
if @region_type == :NODE || @region_type == :LINKUNIT
dbgPrint "new LinkRoot: #{@name}\n"
@@link_roots << self
end
end
@cell_port_throug_plugin_list = {}
end
|
Class Method Details
.get_current ⇒ Object
Region# 構文解析中の region を得る
構文解析中 Namespace (あるいは子クラスの Region) の上位をたどって Region を見つける cell が namespace 下におくことができなければ、ループをまわす必要はない
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
|
# File 'lib/tecsgen/core/componentobj.rb', line 7089
def self.get_current
region = Namespace.get_current
while 1
if region.instance_of? Region
break
end
region = region.get_owner
end
return region
end
|
.get_link_roots ⇒ Object
7015
7016
7017
|
# File 'lib/tecsgen/core/componentobj.rb', line 7015
def self.get_link_roots
@@link_roots
end
|
Region ルートリージョンを得る
ルートリージョンは、ルートネームスペースと同じである
6931
6932
6933
|
# File 'lib/tecsgen/core/componentobj.rb', line 6931
def self.get_root
Namespace.get_root
end
|
.new_in_through(plugin_name = nil, plugin_arg = nil) ⇒ Object
6900
6901
6902
|
# File 'lib/tecsgen/core/componentobj.rb', line 6900
def self.new_in_through(plugin_name = nil, plugin_arg = nil)
@@in_through_list << [plugin_name, plugin_arg]
end
|
.new_out_through(plugin_name = nil, plugin_arg = nil) ⇒ Object
6904
6905
6906
|
# File 'lib/tecsgen/core/componentobj.rb', line 6904
def self.new_out_through(plugin_name = nil, plugin_arg = nil)
@@out_through_list << [plugin_name, plugin_arg]
end
|
.new_to_through(dst_region, plugin_name, plugin_arg) ⇒ Object
6908
6909
6910
6911
|
# File 'lib/tecsgen/core/componentobj.rb', line 6908
def self.new_to_through(dst_region, plugin_name, plugin_arg)
@@to_through_list << [dst_region, plugin_name, plugin_arg]
end
|
.print_cell_define(f) ⇒ Object
259
260
261
262
263
264
265
266
267
|
# File 'lib/tecsgen/core/tecsinfo.rb', line 259
def self.print_cell_define(f)
region.get_link_root.print_cell_define f
region.get_link_root.get_region{|region|
if region.instance_of? Region
region.print_cell_define_offset f
end
}
end
|
.set_domain(name, option) ⇒ Object
6921
6922
6923
6924
6925
6926
6927
|
# File 'lib/tecsgen/core/componentobj.rb', line 6921
def self.set_domain(name, option)
if @@domain_name
Generator.error("S9999 $1 domain specifier duplicate, previous $2", type, @@region_type)
end
@@domain_name = name
@@domain_option = option
end
|
.set_type(type, param = nil) ⇒ Object
6913
6914
6915
6916
6917
6918
6919
|
# File 'lib/tecsgen/core/componentobj.rb', line 6913
def self.set_type(type, param = nil)
if @@region_type
Generator.error("S1178 $1 region type specifier duplicate, previous $2", type, @@region_type)
end
@@region_type = type
@@region_type_param = param
end
|
Instance Method Details
#add_cell_port_through_plugin(cell_name, port_name, subscript, through_plugin_object) ⇒ Object
Region# through プラグインで、この region から cell_name.port_name へのプラグインオブジェクトを登録
mikan namesppace 対応 (cell_name)
7103
7104
7105
7106
7107
7108
|
# File 'lib/tecsgen/core/componentobj.rb', line 7103
def add_cell_port_through_plugin(cell_name, port_name, subscript, through_plugin_object)
if subscript
subscript = "[" + subscript.to_s + "]"
end
@cell_port_throug_plugin_list["#{cell_name}.#{port_name}#{subscript}"] = through_plugin_object
end
|
#create_domain_plugin ⇒ Object
7117
7118
7119
7120
7121
|
# File 'lib/tecsgen/core/componentobj.rb', line 7117
def create_domain_plugin
if @domain_type
@domain_type.create_domain_plugin
end
end
|
#distance(to_region) ⇒ Object
Region# to_region への距離(unreachable な場合 nil)
mikan Cell#check_region とRegion へたどり着くまでための処理に共通性が高い region#distance は require で用いられる
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
|
# File 'lib/tecsgen/core/componentobj.rb', line 7126
def distance(to_region)
r1 = self r2 = to_region dist = 0
if !r1.equal? r2
f1 = r1.get_family_line
len1 = f1.length
f2 = r2.get_family_line
len2 = f2.length
i = 1 while i < len1 && i < len2
if f1[i] != f2[i]
break
end
i += 1
end
sibling_level = i
i = len1 - 1
while i >= sibling_level
dbgPrint "going out from #{f1[i].get_name} level=#{i}\n"
domain = f1[i].get_domain_type
domain_ok = false
if domain
if !f1[i].get_domain_type.joinable?(f1[i], f1[i - 1], :OUT_THROUGH)
return nil
end
domain_ok = true
end
if !domain_ok
out_through_list = f1[i].get_out_through_list if out_through_list.length == 0
return nil
end
end
i -= 1
dist += 1
end
if f1[sibling_level] && f2[sibling_level]
dbgPrint "going from #{f1[sibling_level].get_name} to #{f2[sibling_level].get_name}\n"
domain = f1[sibling_level].get_domain_type
domain_ok = false
if domain
if !f1[i].get_domain_type.joinable?(f1[i], f1[i - 1], :TO_THROUGH)
return nil
end
domain_ok = true
end
if !domain_ok
found = 0
f1[sibling_level].get_to_through_list.each {|t|
if t[0][0] == f2[sibling_level].get_name found = 1
end
}
if found == 0
return nil
end
end
dist += 1
end
i = sibling_level
while i < len2
dbgPrint "going in to #{f2[i].get_name} level=#{i}\n"
domain = f2[i].get_domain_type
domain_ok = false
if domain
if !f2[i].get_domain_type.joinable?(f2[i - 1], f2[i], :IN_THROUGH)
return nil
end
domain_ok = true
end
if !domain_ok
in_through_list = f2[i].get_in_through_list if in_through_list.length == 0
return nil
end
end
i += 1
dist += 1
end
end
dbgPrint "dsitance=#{dist} from #{r1.get_name} to #{r2.get_name}\n"
return dist
end
|
#find_cell_port_through_plugin(cell_name, port_name, subscript) ⇒ Object
7110
7111
7112
7113
7114
7115
|
# File 'lib/tecsgen/core/componentobj.rb', line 7110
def find_cell_port_through_plugin(cell_name, port_name, subscript)
if subscript
subscript = "[" + subscript.to_s + "]"
end
return @cell_port_throug_plugin_list["#{cell_name}.#{port_name}#{subscript}"]
end
|
#gen_region_str_post(f) ⇒ Object
5190
5191
5192
5193
5194
5195
5196
5197
5198
|
# File 'lib/tecsgen/core/generate.rb', line 5190
def gen_region_str_post(f)
nest = @family_line.length - 1
while nest >= 1
f.print " " * (nest - 1)
f.print "};\n"
nest -= 1
end
return nest - 1
end
|
#gen_region_str_pre(f) ⇒ Object
5180
5181
5182
5183
5184
5185
5186
5187
5188
|
# File 'lib/tecsgen/core/generate.rb', line 5180
def gen_region_str_pre(f)
nest = 1
while nest < @family_line.length
f.print " " * (nest - 1)
f.print "region #{@family_line[nest].get_name}{\n"
nest += 1
end
return nest - 1
end
|
#get_domain_root ⇒ Object
Region# domain の根っことなる region を得る
Region のインスタンスを返す domain 指定子があれば、そのリージョンがドメインルートである なければ、親リージョンのドメインルートとする
7047
7048
7049
|
# File 'lib/tecsgen/core/componentobj.rb', line 7047
def get_domain_root
@domain_root
end
|
#get_domain_type ⇒ Object
7039
7040
7041
|
# File 'lib/tecsgen/core/componentobj.rb', line 7039
def get_domain_type
@domain_type
end
|
#get_family_line ⇒ Object
7019
7020
7021
|
# File 'lib/tecsgen/core/componentobj.rb', line 7019
def get_family_line
@family_line
end
|
#get_in_through_list ⇒ Object
7023
7024
7025
|
# File 'lib/tecsgen/core/componentobj.rb', line 7023
def get_in_through_list
@in_through_list
end
|
#get_link_root ⇒ Object
7035
7036
7037
|
# File 'lib/tecsgen/core/componentobj.rb', line 7035
def get_link_root
@link_root
end
|
7066
7067
7068
|
# File 'lib/tecsgen/core/componentobj.rb', line 7066
def get_name
@name
end
|
#get_out_through_list ⇒ Object
7027
7028
7029
|
# File 'lib/tecsgen/core/componentobj.rb', line 7027
def get_out_through_list
@out_through_list
end
|
#get_path_string ⇒ Object
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
|
# File 'lib/tecsgen/core/componentobj.rb', line 7051
def get_path_string
pstring = ""
delim = ""
@family_line.each{|p|
pstring = "#{pstring}#{delim}#{p.get_name}"
delim = "."
}
dbgPrint "get_path_string: #{pstring}\n"
pstring
end
|
#get_region_type ⇒ Object
7062
7063
7064
|
# File 'lib/tecsgen/core/componentobj.rb', line 7062
def get_region_type
@region_type
end
|
#get_to_through_list ⇒ Object
7031
7032
7033
|
# File 'lib/tecsgen/core/componentobj.rb', line 7031
def get_to_through_list
@to_through_list
end
|
#next_in_through_count ⇒ Object
7070
7071
7072
|
# File 'lib/tecsgen/core/componentobj.rb', line 7070
def next_in_through_count
@in_through_count += 1
end
|
#next_out_through_count ⇒ Object
7074
7075
7076
|
# File 'lib/tecsgen/core/componentobj.rb', line 7074
def next_out_through_count
@out_through_count += 1
end
|
#next_to_through_count(symRegionName) ⇒ Object
7078
7079
7080
7081
7082
7083
7084
|
# File 'lib/tecsgen/core/componentobj.rb', line 7078
def next_to_through_count(symRegionName)
if @to_through_count[symRegionName].nil?
@to_through_count[symRegionName] = 0
else
@to_through_count[symRegionName] += 1
end
end
|
#print_cell_define(f) ⇒ Object
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
# File 'lib/tecsgen/core/tecsinfo.rb', line 269
def print_cell_define(f)
ct_list = {}
@cell_list.each{|cell|
next if cell.exclude_info_factory?
ct_list[cell.get_celltype] = true
}
f.print "#define TOPPERS_CB_TYPE_ONLY\n"
ct_list.each{|ct, val|
f.print "#include \"#{ct.get_global_name}_tecsgen.h\"\n"
}
f.print "\n"
@cell_list.each{|cell|
next if cell.exclude_info_factory?
name_array = cell.get_celltype.get_name_array cell
if cell.get_celltype.has_CB?
cb = "(void*)#{name_array[8]}"
cb_proto = "extern #{cell.get_celltype.get_global_name}_CB #{name_array[4]};\n"
else
cb = "0"
cb_proto = ""
end
if cell.get_celltype.has_INIB?
inib = "(void*)&#{name_array[5]}"
inib_proto = "extern #{cell.get_celltype.get_global_name}_INIB #{name_array[11]};\n"
else
inib = "0"
inib_proto = ""
end
if !cell.exclude_info_factory?
f.print <<EOT
#{cb_proto}#define #{cell.get_global_name}__CBP #{cb}
#{inib_proto}#define #{cell.get_global_name}__INIBP #{inib}
EOT
end
}
@namespace_list.each {|region|
if region.instance_of? Region
region.print_cell_define f
end
}
end
|
#print_entry_descriptor_define(f) ⇒ Object
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
# File 'lib/tecsgen/core/tecsinfo.rb', line 311
def print_entry_descriptor_define(f)
@cell_list.each{|cell|
next if cell.exclude_info_factory?
signatures = {}
cell.get_celltype.get_port_list.each{|port|
next if port.get_port_type != :ENTRY
if signatures[port.get_signature].nil?
f.print "#include \"#{port.get_signature.get_global_name}_tecsgen.h\"\n"
end
if cell.get_celltype.get_global_name == :nTECSInfo_tRawEntryDescriptorInfo
f.print "const struct tag_#{cell.get_celltype.get_global_name}_#{port.get_name}_DES "
f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
else
f.print "extern struct tag_#{port.get_signature.get_global_name}_VDES "
f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
end
}
}
@namespace_list.each {|region|
if region.instance_of? Region
region.print_entry_descriptor_define f
end
}
end
|
#print_info(f, indent) ⇒ Object
254
255
256
257
|
# File 'lib/tecsgen/core/tecsinfo.rb', line 254
def print_info(f, indent)
self.print_info_region f, indent
end
|
#print_info_region(f, indent) ⇒ Object
245
246
247
248
249
250
251
252
|
# File 'lib/tecsgen/core/tecsinfo.rb', line 245
def print_info_region(f, indent)
self.print_info_region_sub f, indent
@namespace_list.each {|region|
if region.instance_of? Region
region.print_info_region f, indent
end
}
end
|
#print_info_region_sub(f, indent) ⇒ Object
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
# File 'lib/tecsgen/core/tecsinfo.rb', line 213
def print_info_region_sub(f, indent)
if get_link_root == self
name = "_LinkRoot"
else
name = @global_name
end
f.print "\n#{indent}/*** #{get_namespace_path} region information cell ***/\n"
f.print <<EOT
#{indent}cell nTECSInfo::tRegionInfo #{name}RegionInfo{
#{indent} name = "#{@name}";
EOT
@cell_list.each{|cell|
if !cell.exclude_info?
f.print "#{indent} cCellInfo[] = #{cell.get_global_name}CellInfo.eCellInfo;\n"
end
}
@namespace_list.each {|region|
if region.instance_of? Region
f.print "#{indent} cRegionInfo[] = #{region.get_global_name}RegionInfo.eRegionInfo;\n"
end
}
f.print "#{indent}};\n"
@cell_list.each{|cell|
if !cell.exclude_info?
cell.print_info f, indent
end
}
end
|
#set_domain_type(domain_type) ⇒ Object
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
|
# File 'lib/tecsgen/core/componentobj.rb', line 7000
def set_domain_type(domain_type)
if @region_type == :NODE
if @domain_type
if @domain_type.get_name != domain_type.get_name
cdl_error("S9999 '$1' node root cannot belong to both $2 and $3", @name, @domain_type.get_name, domain_type.get_name)
end
else
@domain_type = DomainType.new(self, domain_type.get_name, "OutOfDomain")
@domain_type.create_domain_plugin
end
elsif @domain_type.nil?
@owner.set_domain_type domain_type
end
end
|
#set_region_family_line ⇒ Object
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
|
# File 'lib/tecsgen/core/componentobj.rb', line 6935
def set_region_family_line
dbgPrint "set_region_family_line: Region: #{@name} \n"
if @name == "::"
@region_type = :NODE
end
if @region_type == :NODE || @region_type == :LINKUNIT
@link_root = self
else
@link_root = @owner.get_link_root
end
if !@domain_type.nil? || @owner.nil?
@domain_root = self
else
@domain_root = @owner.get_domain_root
end
if @domain_type
@owner.set_domain_type @domain_type
end
if @owner
@family_line = @owner.get_family_line.dup << self
else
@family_line = [self] end
=begin
@family_line = []
@link_root = nil
# @family_line を作成する
# @link_root もみつける
# (上位にたどっていって Region で node または linkunit のいずれか先に見つかったものが @link_root となる)
# root namespace は Region かつ node なので必ず @link_root は見つかる
# mikan: self が node, linkUnit の場合、ここで期待したとおりに設定されないため、Region#initialize で再設定
obj = self
while 1
if obj.instance_of? Region then
@family_line << obj
if @link_root == nil then
if obj.get_region_type == :NODE || obj.get_region_type == :LINKUNIT then
@link_root = obj
end
end
else
# さもなければ Namespace
# namespace の下に region がある場合
end
# root namespace にたどり着けば終り
break if obj.get_name == "::"
obj = obj.get_owner
end
# print "#{@name}: linkRoot: #{@link_root.get_name} (this can be wrong if #{@name} is node or linkunit, and corret later\n"
@family_line.reverse!
=end
end
|
#show_tree(indent) ⇒ Object
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
|
# File 'lib/tecsgen/core/componentobj.rb', line 7232
def show_tree(indent)
super
(indent + 1).times { print(" ") }
puts "path: #{get_path_string}"
(indent + 1).times { print(" ") }
puts "namespace: #{@namespace ? @namespace.get_name : "nil"} owner: #{@owner.class}.#{@owner ? @owner.get_name : "nil"}"
if @domain
@domain.show_tree(indent + 1)
end
end
|
#unjoin_plugin ⇒ Object
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/tecsgen/core/unjoin_plugin.rb', line 136
def unjoin_plugin
if @domain_type then
@domain_type.unjoin_plugin
end
@cell_port_throug_plugin_list.each{ |key, po|
proxy = Join::ThroughPluginProxy.new po.get_cell_namespace_path, po.get_through_entry_port_name, po.get_through_entry_port_subscript
@cell_port_throug_plugin_list[ key ] = proxy
}
super
end
|