source: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/core/tecsinfo.rb@ 374

Last change on this file since 374 was 374, checked in by coas-nagasima, 5 years ago

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-ruby;charset=UTF-8
File size: 28.8 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# TECS Generator
4# Generator for TOPPERS Embedded Component System
5#
6# Copyright (C) 2017-2018 by TOPPERS Project
7#--
8# 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
9# ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
10# 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
11# (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
12# 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
13# スコード中に含まれていること.
14# (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
15# 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
16# 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
17# の無保証規定を掲載すること.
18# (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
19# 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
20# と.
21# (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
22# 作権表示,この利用条件および下記の無保証規定を掲載すること.
23# (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
24# 報告すること.
25# (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
26# 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
27# また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
28# 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
29# 免責すること.
30#
31# 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
32# よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
33# に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
34# アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
35# の責任を負わない.
36#
37# $Id$
38#++
39
40# TECS 情報セルの生成
41module TECSInfo
42 # region は Link root のこと
43 def self.print_info f, region
44 # p "region: "+ region.get_name.to_s
45 nest = region.gen_region_str_pre f
46 indent0 = " " * nest
47 indent = " " * ( nest + 1 )
48 f.print <<EOT
49#{indent0}region rTECSInfo {
50EOT
51 Type.reset_print_info
52
53 # mikan 全部生成するのではなく、region 下のセルのセルタイプと、そこから参照されるシグニチャ、セルタイプに限定して出力すべき
54 # しかし、意味解析後に出力するため、これは容易ではない.最適化とコード生成は、リンクルートごとに行われる.
55 Namespace.print_info f, indent
56 region.get_link_root.print_info f, indent
57
58 f.print "\n#{indent}/*** TYPE information cell ***/\n"
59 Type.print_info_post f, indent
60
61 f.print "\n#{indent}/*** TECS information cell ***/\n"
62 f.print <<EOT
63#{indent}cell nTECSInfo::tTECSInfoSub TECSInfoSub {
64#{indent} cNamespaceInfo = _RootNamespaceInfo.eNamespaceInfo;
65#{indent} cRegionInfo = _LinkRootRegionInfo.eRegionInfo;
66#{indent}} /* TECSInfoSub */;
67#{indent0}}; /* rTECSInfo */
68EOT
69 region.gen_region_str_post f
70 end
71end
72
73class Namespace
74 # RootRegion と LinkRegion は同じ Region クラスのオブジェクトである
75 # 子ネームスペースは Namespace クラスの、子リージョンは Region クラスのオブジェクトである
76 # これは、意味解析段階で呼び出されるため、リンクユニットごとに出しわけることができない
77 # 出しわけるには、2パスにする必要がある
78 def print_info_ns_sub f, indent
79 if @name == "::" then
80 name = "_Root"
81 else
82 name = @global_name
83 end
84 f.print "\n#{indent}/*** #{get_namespace_path} namespace information cell ***/\n"
85 f.print <<EOT
86#{indent}cell nTECSInfo::tNamespaceInfo #{name}NamespaceInfo{
87#{indent} name = "#{@name}";
88EOT
89 if @signature_list.length > 0 then
90 f.print "\n#{indent} /* SIGNATURE info */\n"
91 end
92 @signature_list.each{ |sig|
93 f.print <<EOT
94#{indent} cSignatureInfo[] = #{sig.get_global_name}SignatureInfo.eSignatureInfo;
95EOT
96 }
97 if @celltype_list.length > 0 then
98 f.print "\n#{indent} /* CELLTYPE info */\n"
99 end
100 @celltype_list.each{ |ct|
101 if ct.get_cell_list.length > 0 then
102 f.print <<EOT
103#{indent} cCelltypeInfo[] = #{ct.get_global_name}CelltypeInfo.eCelltypeInfo;
104EOT
105 end
106 }
107 if @namespace_list.length > 0 then
108 f.print "\n#{indent} /* NAMESPACE info */\n"
109 end
110 @namespace_list.each{ |ns|
111 if ns.instance_of? Namespace then
112 f.print <<EOT
113#{indent} cNamespaceInfo[] = #{ns.get_global_name}NamespaceInfo.eNamespaceInfo;
114EOT
115 end
116 }
117 f.print <<EOT
118#{indent}}; /* cell nTECSInfo::tNamespaceInfo #{name}NamespaceInfo */
119EOT
120 end
121
122 def print_info_ns f, indent
123 # p "print_info: #{self.get_global_name}"
124 print_info_ns_sub f, indent
125 @signature_list.each { |sig|
126 sig.print_info f, indent
127 }
128 @celltype_list.each { |ct|
129 if ct.get_cell_list.length > 0 then
130 ct.print_info f, indent
131 end
132 }
133 @namespace_list.each { |ns|
134 if ns.instance_of? Namespace then # region を含めない
135 ns.print_info_ns f, indent
136 end
137 }
138 end
139
140 def self.print_info( f, indent )
141 @@root_namespace.print_info_ns f, indent
142 end
143
144 #=== Namespace# 構造体メンバーのオフセット定義
145 def print_struct_define f
146 f.print "\n/***** Offset of members of structures *****/\n"
147 @struct_tag_list.get_items.each{ |tag, sttype|
148 # print "sttype: #{tag.get_name} #{sttype}\n"
149 tag.get_members_decl.get_items.each{ |decl|
150 f.printf "#define OFFSET_OF_%-30s (%s)\n",
151 "#{tag.get_ID_str}_#{decl.get_name}",
152 "(uint32_t)(intptr_t)&(((#{tag.get_type_str}#{tag.get_type_str_post}*)0)->#{decl.get_name})"
153 f.printf "#define PLACE_OF_%-30s (%s)\n",
154 "#{tag.get_ID_str}_#{decl.get_name}",
155 "VARDECL_PLACE_STRUCT"
156 }
157 }
158 end
159
160 def print_celltype_define_offset f
161 @celltype_list.each { |ct|
162 if ct.get_cell_list.length > 0 then
163 ct.print_define_offset f
164 end
165 }
166 @namespace_list.each { |ns|
167 if ns.instance_of? Namespace then # region を含めない
168 ns.print_celltype_define_offset f
169 end
170 }
171 end
172
173 def print_celltype_define f
174 @celltype_list.each { |ct|
175 if ct.get_cell_list.length > 0 then
176 ct.print_celltype_define f
177 end
178 }
179 @namespace_list.each { |ns|
180 if ns.instance_of? Namespace then # region を含めない
181 ns.print_celltype_define f
182 end
183 }
184 end
185
186 def print_call_define f
187 @celltype_list.each { |ct|
188 if ct.get_cell_list.length > 0 then
189 ct.print_call_define f
190 end
191 }
192 @namespace_list.each { |ns|
193 if ns.instance_of? Namespace then # region を含めない
194 ns.print_call_define f
195 end
196 }
197 end
198
199 def print_entry_define f
200 @celltype_list.each { |ct|
201 if ct.get_cell_list.length > 0 then
202 ct.print_entry_define f
203 end
204 }
205 @namespace_list.each { |ns|
206 if ns.instance_of? Namespace then # region を含めない
207 ns.print_entry_define f
208 end
209 }
210 end
211end
212
213class Region
214 def print_info_region_sub f, indent
215 if get_link_root == self then
216 name = "_LinkRoot"
217 else
218 name = @global_name
219 end
220 # p "region:#{get_name}"
221 f.print "\n#{indent}/*** #{get_namespace_path} region information cell ***/\n"
222 f.print <<EOT
223#{indent}cell nTECSInfo::tRegionInfo #{name}RegionInfo{
224#{indent} name = "#{@name}";
225EOT
226 @cell_list.each{ |cell|
227 # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 1\n"
228 if ! cell.exclude_info? then
229 # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 2\n"
230 f.print "#{indent} cCellInfo[] = #{cell.get_global_name}CellInfo.eCellInfo;\n"
231 end
232 }
233 @namespace_list.each { |region|
234 if region.instance_of? Region then
235 f.print "#{indent} cRegionInfo[] = #{region.get_global_name}RegionInfo.eRegionInfo;\n"
236 end
237 }
238 f.print "#{indent}};\n"
239 @cell_list.each{ |cell|
240 if ! cell.exclude_info? then
241 cell.print_info f, indent
242 end
243 }
244 end
245
246 def print_info_region( f, indent )
247 self.print_info_region_sub f, indent
248 @namespace_list.each { |region|
249 if region.instance_of? Region then
250 region.print_info_region f, indent
251 end
252 }
253 end
254
255 def print_info( f, indent )
256 #p "print_info: #{self.get_global_name}"
257 self.print_info_region f, indent
258 end
259
260 def self.print_cell_define f
261 region.get_link_root.print_cell_define f
262 region.get_link_root.get_region{ |region|
263 if region.instance_of? Region then
264 region.print_cell_define_offset f
265 end
266
267 }
268 end
269
270 def print_cell_define f
271 ct_list = {}
272 @cell_list.each{ |cell|
273 next if cell.exclude_info_factory?
274 ct_list[ cell.get_celltype ] = true
275 }
276 f.print "#define TOPPERS_CB_TYPE_ONLY\n"
277 ct_list.each{ |ct, val|
278 f.print "#include \"#{ct.get_global_name}_tecsgen.h\"\n"
279 }
280 f.print "\n"
281 @cell_list.each{ |cell|
282 next if cell.exclude_info_factory?
283 name_array = cell.get_celltype.get_name_array cell
284 if cell.get_celltype.has_CB?
285 cb = "(void*)#{name_array[8]}"
286 cb_proto = "extern #{cell.get_celltype.get_global_name}_CB #{name_array[4]};\n"
287 else
288 cb = "0"
289 cb_proto = ""
290 end
291 if cell.get_celltype.has_INIB?
292 inib = "(void*)&#{name_array[5]}"
293 inib_proto = "extern #{cell.get_celltype.get_global_name}_INIB #{name_array[11]};\n"
294 else
295 inib = "0"
296 inib_proto = ""
297 end
298 if ! cell.exclude_info_factory? then
299 f.print <<EOT
300#{cb_proto}#define #{cell.get_global_name}__CBP #{cb}
301#{inib_proto}#define #{cell.get_global_name}__INIBP #{inib}
302EOT
303 end
304 }
305 @namespace_list.each { |region|
306 if region.instance_of? Region then
307 region.print_cell_define f
308 end
309 }
310 end
311
312 def print_entry_descriptor_define f
313 @cell_list.each{ |cell|
314 next if cell.exclude_info_factory?
315
316 signatures = {}
317 cell.get_celltype.get_port_list.each{ |port|
318 next if port.get_port_type != :ENTRY
319
320 if signatures[ port.get_signature ] == nil then
321 f.print "#include \"#{port.get_signature.get_global_name}_tecsgen.h\"\n"
322 end
323 if cell.get_celltype.get_global_name == :nTECSInfo_tRawEntryDescriptorInfo then
324 f.print "const struct tag_#{cell.get_celltype.get_global_name}_#{port.get_name}_DES "
325 f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
326 else
327 f.print "extern struct tag_#{port.get_signature.get_global_name}_VDES "
328 f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
329 end
330 }
331 }
332 @namespace_list.each { |region|
333 if region.instance_of? Region then
334 region.print_entry_descriptor_define f
335 end
336 }
337 end
338end
339
340class Celltype
341 def print_info f, indent
342 f.print <<EOT
343#{indent}cell nTECSInfo::tCelltypeInfo #{@global_name}CelltypeInfo {
344#{indent} name = "#{@name}";
345#{indent} b_singleton = #{@singleton};
346#{indent} b_IDX_is_ID_act = C_EXP( "#{@global_name}__IDX_is_ID_act" );
347#{indent} sizeOfCB = C_EXP( "#{@global_name}__sizeOfCB" );
348#{indent} sizeOfINIB = C_EXP( "#{@global_name}__sizeOfINIB" );
349#{indent} n_cellInLinkUnit = C_EXP( "#{@global_name}__NCELLINLINKUNIT" );
350#{indent} n_cellInSystem = #{@cell_list.length};
351EOT
352 @port.each{ |port|
353 if port.get_port_type == :ENTRY then
354 f.print <<EOT
355#{indent} cEntryInfo[] = #{@global_name}_#{port.get_name}EntryInfo.eEntryInfo;
356EOT
357 end
358 }
359 @port.each{ |port|
360 if port.get_port_type == :CALL then
361 f.print <<EOT
362#{indent} cCallInfo[] = #{@global_name}_#{port.get_name}CallInfo.eCallInfo;
363EOT
364 end
365 }
366 @attribute.each{ |decl|
367 f.print <<EOT
368#{indent} cAttrInfo[] = #{@global_name}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;
369EOT
370 }
371 @var.each{ |decl|
372 f.print <<EOT
373#{indent} cVarInfo[] = #{@global_name}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;
374EOT
375 }
376 f.print <<EOT
377#{indent}};
378EOT
379 @port.each{ |port|
380 if port.get_port_type == :ENTRY then
381 port.print_info f, @global_name, indent
382 end
383 }
384 @port.each{ |port|
385 if port.get_port_type == :CALL then
386 port.print_info f, @global_name, indent
387 end
388 }
389 @attribute.each{ |decl|
390 decl.print_info f, @global_name, indent, :DECLTYPE_ATTR
391 }
392 @var.each{ |decl|
393 decl.print_info f, @global_name, indent, :DECLTYPE_VAR
394 }
395 end
396
397 def print_define_offset f
398 # intptr_t に一回キャストするのは 64bit 版を考量してのこと.しかし 32bit としているので 4GB を超える構造体等は扱えない
399 if @n_cell_gen > 0 then
400 f.print <<EOT
401
402#include "#{@global_name}_tecsgen.h"
403EOT
404 @attribute.each{ |decl|
405 if has_INIB? then
406 inib_cb = "INIB"
407 else
408 inib_cb = "CB"
409 end
410 if ! decl.is_omit? then
411 offset = "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
412 place = inib_cb
413 else
414 offset = "0xffffffff"
415 place = "NON"
416 end
417 f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", offset
418 f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
419 }
420 @var.each{ |decl|
421 if decl.get_size_is && has_INIB? then
422 inib_cb = "INIB"
423 else
424 inib_cb = "CB"
425 end
426 place = inib_cb
427 f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
428 f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
429 }
430 else
431 f.print <<EOT
432
433// #include "#{@global_name}_tecsgen.h" // no cell exist
434EOT
435 # 生成されないセルタイプ
436 @attribute.each{ |decl|
437 f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
438 f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
439 }
440 @var.each{ |decl|
441 f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
442 f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
443 }
444 end
445 end
446
447 def print_celltype_define f
448 if has_INIB? then
449 size_INIB = "(sizeof(#{@global_name}_INIB))"
450 else
451 size_INIB = "(0)"
452 end
453 if has_CB? then
454 size_CB = "(sizeof(#{@global_name}_CB))"
455 else
456 size_CB = "(0)"
457 end
458
459 if @n_cell_gen > 0 then
460 f.printf "\n#include \"#{@global_name}_tecsgen.h\"\n"
461 f.printf "#define %-50s (#{@idx_is_id_act})\n", "#{@global_name}__IDX_is_ID_act"
462 f.printf "#define %-50s (#{size_CB})\n", "#{@global_name}__sizeOfCB"
463 f.printf "#define %-50s (#{size_INIB})\n", "#{@global_name}__sizeOfINIB"
464 f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
465 else
466 f.printf "#define %-50s (false)\n", "#{@global_name}__IDX_is_ID_act"
467 f.printf "#define %-50s (0)\n", "#{@global_name}__sizeOfCB"
468 f.printf "#define %-50s (0)\n", "#{@global_name}__sizeOfINIB"
469 f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
470 end
471 end
472
473 def print_call_define f
474 if @n_cell_gen > 0 then
475 f.print <<EOT
476
477#include "#{@global_name}_tecsgen.h"
478EOT
479 else
480 f.print <<EOT
481
482// #include "#{@global_name}_tecsgen.h" // no cell exist
483EOT
484 end
485 @port.each{ |port|
486 next if port.get_port_type == :ENTRY
487 if port.is_omit? || ( port.is_VMT_useless? && port.is_cell_unique? ) || @n_cell_gen == 0 then
488 place = "CALL_PLACE_NON"
489 elsif port.is_dynamic?
490 if port.get_array_size then
491 place = "CALL_PLACE_INIB_DES"
492 else
493 place = "CALL_PLACE_CB_DES"
494 end
495 elsif ! has_INIB? then
496 if port.is_VMT_useless? then
497 place = "CALL_PLACE_CB_IDX"
498 else
499 place = "CALL_PLACE_CB_DES"
500 end
501 else
502 if port.is_VMT_useless? then
503 place = "CALL_PLACE_INIB_IDX"
504 else
505 place = "CALL_PLACE_INIB_DES"
506 end
507 end
508 if ( port.is_VMT_useless? && port.is_cell_unique? ) || port.is_omit? || @n_cell_gen == 0 then
509 offset = "0xffffffff"
510 else
511 if port.is_dynamic? || ! has_INIB? then
512 cb_inib = "CB"
513 else
514 cb_inib = "INIB"
515 end
516 offset = "(uint32_t)(intptr_t)&((#{@global_name}_#{cb_inib}*)0)->#{port.get_name}"
517 end
518 array_size = port.get_array_size
519 if array_size == "[]" then
520 array_size = "0xffffffff"
521 elsif array_size == nil then
522 array_size = "0"
523 end
524
525 f.printf "#define %-50s (#{offset})\n", "#{@global_name}_#{port.get_name}__offset"
526 f.printf "#define %-50s (#{array_size})\n", "#{@global_name}_#{port.get_name}__array_size"
527 f.printf "#define %-50s (#{place})\n", "#{@global_name}_#{port.get_name}__place"
528 f.printf "#define %-50s (#{port.is_VMT_useless?})\n", "#{@global_name}_#{port.get_name}__b_VMT_useless"
529 f.printf "#define %-50s (#{port.is_skelton_useless?})\n", "#{@global_name}_#{port.get_name}__b_skelton_useless"
530 f.printf "#define %-50s (#{port.is_cell_unique?})\n", "#{@global_name}_#{port.get_name}__b_cell_unique"
531 }
532 end
533
534 def print_entry_define f
535 @port.each{ |port|
536 next if port.get_port_type == :CALL
537 array_size = port.get_array_size
538 if array_size == "[]" then
539 array_size = "0xffffffff"
540 elsif array_size == nil then
541 array_size = "0"
542 end
543
544 f.printf "#define %-50s (#{array_size})\n", "#{@global_name}_#{port.get_name}__array_size"
545 }
546 end
547end
548
549class Port
550 def print_info f, ct_global, indent
551 return if @signature == nil # signature not found error in cdl
552 if @port_type == :ENTRY then
553 f.print <<EOT
554#{indent}cell nTECSInfo::tEntryInfo #{ct_global}_#{@name}EntryInfo{
555#{indent} name = "#{@name}";
556#{indent} cSignatureInfo = #{@signature.get_global_name}SignatureInfo.eSignatureInfo;
557#{indent} b_inline = #{@b_inline};
558#{indent} array_size = C_EXP( "#{ct_global}_#{@name}__array_size" );
559#{indent}};
560EOT
561 else
562 f.print <<EOT
563#{indent}cell nTECSInfo::tCallInfo #{ct_global}_#{@name}CallInfo{
564#{indent} name = "#{@name}";
565#{indent} cSignatureInfo = #{@signature.get_global_name}SignatureInfo.eSignatureInfo;
566#{indent} offset = C_EXP( "#{ct_global}_#{@name}__offset" );
567#{indent} array_size = C_EXP( "#{ct_global}_#{@name}__array_size" );
568#{indent} b_optional = #{@b_optional};
569#{indent} b_omit = #{@b_omit};
570#{indent} b_dynamic = #{@b_dynamic};
571#{indent} b_ref_desc = #{@b_ref_desc};
572#{indent} b_allocator_port = #{@allocator_port!=nil ? true : false};
573#{indent} b_require_port = #{@b_require};
574#{indent} place = C_EXP( "#{ct_global}_#{@name}__place" );
575#{indent} b_VMT_useless = C_EXP( "#{ct_global}_#{@name}__b_VMT_useless" );
576#{indent} b_skelton_useless = C_EXP( "#{ct_global}_#{@name}__b_skelton_useless" );
577#{indent} b_cell_unique = C_EXP( "#{ct_global}_#{@name}__b_cell_unique" );
578
579#{indent}};
580EOT
581 end
582 end
583end
584
585class Cell
586 def print_info f, indent
587 if exclude_info? then
588 return
589 end
590 f.print <<EOT
591
592#{indent}/*** #{@global_name} cell information ****/
593#{indent}cell nTECSInfo::tCellInfo #{@global_name}CellInfo {
594#{indent} name = "#{@name}";
595#{indent} cbp = C_EXP( \"#{@global_name}__CBP\" );
596#{indent} inibp = C_EXP( \"#{@global_name}__INIBP\" );
597#{indent} cCelltypeInfo = #{@celltype.get_global_name}CelltypeInfo.eCelltypeInfo;
598EOT
599 @celltype.get_port_list.each{ |port|
600 next if port.get_port_type != :ENTRY
601
602 f.print <<EOT
603#{indent} cRawEntryDescriptor[] = #{@global_name}_#{port.get_name}RawEntryDescriptorInfo.eRawEntryDescriptor;
604EOT
605 }
606 f.print "#{indent}};\n"
607
608 # RawEntryDescriptorInfo cells
609 @celltype.get_port_list.each{ |port|
610 next if port.get_port_type != :ENTRY
611
612 size = port.get_array_size
613 if size == nil then
614 size = 1
615 elsif size == "[]" then
616 size = @entry_array_max_subscript[ port ]
617 end
618 if ! port.is_omit? then
619 red = "C_EXP( \"&#{@global_name}_#{port.get_name}_des\" )"
620 else
621 red = "(void *)0"
622 end
623 # mikan 受け口配列
624 f.print <<EOT
625#{indent}cell nTECSInfo::tRawEntryDescriptorInfo #{@global_name}_#{port.get_name}RawEntryDescriptorInfo {
626#{indent} size = #{size};
627#{indent} rawEntryDescriptor = { #{red} };
628EOT
629# #{indent} cEntryInfo = #{@celltype.get_global_name}_#{port.get_name}EntryInfo.eEntryInfo;
630 f.print "#{indent}};\n"
631 }
632 end
633
634 def exclude_info?
635 # print "exclude_info?: name=" + get_name.to_s
636 if @celltype == nil ||
637 is_of_composite? ||
638 @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
639 post_code_generated? ||
640 @b_defined == false then
641 # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
642 return true
643 else
644 # print ": false\n"
645 return false
646 end
647 end
648
649 def exclude_info_factory?
650 # print "exclude_info_factory?: name=" + get_name.to_s
651 if @celltype == nil ||
652 is_of_composite? ||
653 @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
654 ! @celltype.need_generate? then
655 # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
656 return true
657 else
658 # print ": false\n"
659 return false
660 end
661 end
662end
663
664class Signature
665 def print_info f, indent
666 f.print <<EOT
667
668#{indent}/*** #{@global_name} signature information ****/
669#{indent}cell nTECSInfo::tSignatureInfo #{@global_name}SignatureInfo {
670#{indent} name = "#{@name}";
671EOT
672 @function_head_list.get_items.each{ |fh|
673 f.print <<EOT
674#{indent} cFunctionInfo[] = #{@global_name}_#{fh.get_name}FunctionInfo.eFunctionInfo;
675EOT
676 }
677 f.print <<EOT
678#{indent}};
679EOT
680 @function_head_list.get_items.each{ |fh|
681 fh.print_info f, indent
682 }
683 end
684end
685
686class FuncHead
687 def print_info f, indent
688 sig_name = @owner.get_global_name
689 func_name = get_name
690 f.print <<EOT
691#{indent}cell nTECSInfo::tFunctionInfo #{sig_name}_#{func_name}FunctionInfo {
692#{indent} name = "#{get_name}";
693#{indent} bOneway = #{is_oneway?};
694EOT
695 get_paramlist.get_items.each{ |param|
696 f.print <<EOT
697#{indent} cParamInfo[] = #{sig_name}_#{func_name}_#{param.get_name}ParamInfo.eParamInfo;
698EOT
699 }
700 f.print <<EOT
701#{indent} cReturnTypeInfo = #{get_return_type.get_ID_str}TypeInfo.eTypeInfo;
702#{indent}};
703EOT
704 get_paramlist.get_items.each{ |param|
705 dbgPrint "param_list #{sig_name}, #{func_name}, #{param.get_name}\n"
706 param.print_info f, sig_name, func_name, get_paramlist, indent
707 }
708 get_return_type.print_info f, indent
709 end
710end
711
712class ParamDecl
713 def print_info f, signature_global_name, func_name, paramdecl_list, indent
714 if @size then
715 size = "\"#{@size.get_rpn( paramdecl_list )}\""
716 else
717 size = "(char_t*)0";
718 end
719 if @count then
720 count = "\"#{@count.get_rpn( paramdecl_list )}\""
721 else
722 count = "(char_t*)0";
723 end
724 if @string then
725 if @string == -1 then
726 string = '""'
727 else
728 string = "\"#{@string.get_rpn( paramdecl_list )}\""
729 end
730 else
731 string = "(char_t*)0";
732 end
733 f.print <<EOT
734#{indent}cell nTECSInfo::tParamInfo #{signature_global_name}_#{func_name}_#{get_name}ParamInfo {
735#{indent} name = "#{get_name}";
736#{indent} dir = PARAM_DIR_#{@direction};
737#{indent} sizeIsExpr = #{size};
738#{indent} countIsExpr = #{count};
739#{indent} stringExpr = #{string};
740#{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;
741#{indent}};
742EOT
743 get_type.print_info f, indent
744 end
745end
746
747class Decl
748 def print_info f, parent_ID_str, indent, decl_type
749 if @size_is then
750 size = "\"mikan\"";
751 else
752 size = "(char_t*)0";
753 end
754 f.print <<EOT
755#{indent}cell nTECSInfo::tVarDeclInfo #{parent_ID_str}_#{get_name}VarDeclInfo {
756#{indent} name = "#{get_name}";
757#{indent} sizeIsExpr = #{size};
758#{indent} declType = #{decl_type};
759#{indent} offset = C_EXP( "OFFSET_OF_#{parent_ID_str}_#{get_name}" );
760#{indent} place = C_EXP( "PLACE_OF_#{parent_ID_str}_#{get_name}" );
761#{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;
762#{indent}};
763EOT
764 get_type.print_info f, indent
765 end
766end
767
768class Type
769 @@typeinfo_printed = {}
770
771 def self.reset_print_info
772 @@typeinfo_printed = {}
773 end
774
775 def print_info f, indent
776 # Type の info は、最後にまとめて出力するので、ここでは記録するだけ
777 if @@typeinfo_printed[ get_ID_str ] then
778 return
779 end
780 # p "ID Str: #{get_ID_str}"
781 @@typeinfo_printed[ get_ID_str ] = self
782 if self.kind_of? PtrType then
783 get_referto.print_info f, indent
784 elsif self.kind_of? ArrayType then
785 get_type.print_info f, indent
786 elsif self.kind_of? DefinedType then
787 get_type.print_info f, indent
788 elsif self.kind_of? StructType then
789 get_members_decl.get_items.each{ |decl|
790 decl.print_info f, get_ID_str, indent, :DECLTYPE_STMEMBER
791 }
792 end
793 end
794
795 def self.print_info_post f, indent
796 @@typeinfo_printed.each{ |nm, type|
797 type.print_info_post f, indent
798 }
799 end
800
801 def print_info_post f, indent
802 if self.class.superclass == Type then # 親クラスが Type の場合 types.rb のクラス
803 type_name = self.class.name
804 else
805 type_name = self.class.superclass.name # ctypes.rb のクラス (親クラスが types.rb のクラス)
806 end
807 # p "type: #{type_name}, #{self.class.name}"
808
809 # p "class=#{self.class.name} size=#{bit_size}"
810 f.print <<EOT
811#{indent}cell nTECSInfo::t#{type_name}Info #{get_ID_str}TypeInfo{
812#{indent} name = "#{get_type_str}#{get_type_str_post}";
813#{indent} typeKind = TECSTypeKind_#{type_name};
814#{indent} size = C_EXP( "sizeof(#{get_type_str}#{get_type_str_post})" );
815#{indent} b_const = #{is_const?};
816#{indent} b_volatile = #{is_volatile?};
817EOT
818 if self.kind_of? PtrType then
819 f.print "#{indent} cTypeInfo = #{get_referto.get_ID_str}TypeInfo.eTypeInfo;\n"
820 elsif self.kind_of? ArrayType then
821 f.print "#{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
822 elsif self.kind_of? DefinedType then
823 f.print "#{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
824 elsif self.kind_of? StructType then
825 get_members_decl.get_items.each{ |decl|
826 f.print "#{indent} cVarDeclInfo[] = #{get_ID_str}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;\n"
827 }
828 elsif self.kind_of? DescriptorType then
829 f.print "#{indent} cSignatureInfo = #{get_signature.get_global_name}SignatureInfo.eSignatureInfo;\n"
830 end
831
832 f.print <<EOT
833#{indent}};
834EOT
835 end
836
837 #=== Type# 型文字列の識別子化
838 #型文字列に含まれる識別子として用いることのできない文字を用いることのできる文字列に置き換える
839 # 空白 => __
840 # * => _Ptr_
841 # [] => _Array_
842 # Descriptor() => Descriptor_of_
843 def get_ID_str
844 # puts "get_ID_str: #{self.class.name}"
845 if kind_of? PtrType then
846 str = get_referto.get_ID_str + "_Ptr_"
847 elsif kind_of? ArrayType then
848 str = get_type.get_ID_str + "_Array" + get_subscript.eval_const( nil ).to_s + "_"
849 elsif kind_of? StructType then
850 str = "struct #{@tag}"
851 elsif kind_of? DescriptorType then
852 str = "Descriptor_of_" + get_signature.get_global_name.to_s
853 else
854 str = get_type_str + get_type_str_post
855 end
856 # p "before: #{str}"
857 str.gsub!( / /, "__" )
858 # p "after: #{str}"
859 return str
860 end
861end
862
Note: See TracBrowser for help on using the repository browser.