tecscde 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rubocop.yml +125 -0
  4. data/.rubocop_todo.yml +188 -0
  5. data/CHANGELOG.md +3 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE +46 -0
  8. data/LICENSE.ja +32 -0
  9. data/README.ja.md +200 -0
  10. data/README.md +35 -0
  11. data/Rakefile +27 -0
  12. data/bin/tecscde +64 -0
  13. data/glade/tecscde-cell-property.glade +205 -0
  14. data/glade/tecscde-celltype-property.glade +172 -0
  15. data/glade/tecscde-celltype.glade +414 -0
  16. data/glade/tecscde-export.glade +161 -0
  17. data/glade/test-cell-plugin.rb +51 -0
  18. data/glade/test-cell-property.rb +35 -0
  19. data/glade/test-export.rb +35 -0
  20. data/glade/test-palette.rb +26 -0
  21. data/lib/tcflow.rb +148 -0
  22. data/lib/tecscde.rb +65 -0
  23. data/lib/tecscde/NewCell.png +0 -0
  24. data/lib/tecscde/SelectArrow.png +0 -0
  25. data/lib/tecscde/attr_tree_view.rb +253 -0
  26. data/lib/tecscde/cell_plugin_dialog.glade +294 -0
  27. data/lib/tecscde/cell_plugin_dialog.rb +89 -0
  28. data/lib/tecscde/celltype_tree_view.rb +105 -0
  29. data/lib/tecscde/change_set_control.rb +35 -0
  30. data/lib/tecscde/change_set_control/change_set.rb +32 -0
  31. data/lib/tecscde/change_set_control/change_set_manager.rb +62 -0
  32. data/lib/tecscde/command.rb +35 -0
  33. data/lib/tecscde/control.rb +491 -0
  34. data/lib/tecscde/highlighted_objects.rb +180 -0
  35. data/lib/tecscde/logger.rb +74 -0
  36. data/lib/tecscde/main_view_and_model.rb +80 -0
  37. data/lib/tecscde/palette.glade +553 -0
  38. data/lib/tecscde/palette.rb +174 -0
  39. data/lib/tecscde/preferences.glade +117 -0
  40. data/lib/tecscde/preferences.rb +44 -0
  41. data/lib/tecscde/tecs_model.rb +1137 -0
  42. data/lib/tecscde/tecs_model/hbar.rb +68 -0
  43. data/lib/tecscde/tecs_model/tm_c_port.rb +122 -0
  44. data/lib/tecscde/tecs_model/tm_c_port_array.rb +98 -0
  45. data/lib/tecscde/tecs_model/tm_cell.rb +496 -0
  46. data/lib/tecscde/tecs_model/tm_e_port.rb +126 -0
  47. data/lib/tecscde/tecs_model/tm_e_port_array.rb +78 -0
  48. data/lib/tecscde/tecs_model/tm_join.rb +293 -0
  49. data/lib/tecscde/tecs_model/tm_join_bar.rb +146 -0
  50. data/lib/tecscde/tecs_model/tm_port.rb +238 -0
  51. data/lib/tecscde/tecs_model/tm_port_array.rb +246 -0
  52. data/lib/tecscde/tecs_model/tm_region.rb +107 -0
  53. data/lib/tecscde/tecs_model/tm_uneditable.rb +68 -0
  54. data/lib/tecscde/tecs_model/vbar.rb +68 -0
  55. data/lib/tecscde/templates/_cell_info.cde.erb +15 -0
  56. data/lib/tecscde/templates/_join_info.cde.erb +28 -0
  57. data/lib/tecscde/templates/main.cde.erb +49 -0
  58. data/lib/tecscde/tm_object.rb +91 -0
  59. data/lib/tecscde/version.rb +4 -0
  60. data/lib/tecscde/view.rb +58 -0
  61. data/lib/tecscde/view/cairo_matrix.rb +90 -0
  62. data/lib/tecscde/view/canvas.rb +59 -0
  63. data/lib/tecscde/view/constants.rb +114 -0
  64. data/lib/tecscde/view/main_view.rb +1245 -0
  65. data/lib/tecsflow.rb +475 -0
  66. data/lib/tecsflow/C_parser.tab.rb +2471 -0
  67. data/lib/tecsflow/C_parser.y.rb +1087 -0
  68. data/lib/tecsflow/classes.rb +421 -0
  69. data/lib/tecsgen.rb +581 -0
  70. data/lib/tecsgen/core/C_parser.tab.rb +2477 -0
  71. data/lib/tecsgen/core/C_parser.y +1032 -0
  72. data/lib/tecsgen/core/bnf-deb.tab.rb +5193 -0
  73. data/lib/tecsgen/core/bnf.tab.rb +5193 -0
  74. data/lib/tecsgen/core/bnf.y +2211 -0
  75. data/lib/tecsgen/core/componentobj.rb +7901 -0
  76. data/lib/tecsgen/core/ctypes.rb +226 -0
  77. data/lib/tecsgen/core/expression.rb +1031 -0
  78. data/lib/tecsgen/core/gen_xml.rb +374 -0
  79. data/lib/tecsgen/core/generate.rb +5206 -0
  80. data/lib/tecsgen/core/location.rb +116 -0
  81. data/lib/tecsgen/core/messages.rb +101 -0
  82. data/lib/tecsgen/core/optimize.rb +456 -0
  83. data/lib/tecsgen/core/plugin.rb +332 -0
  84. data/lib/tecsgen/core/pluginModule.rb +165 -0
  85. data/lib/tecsgen/core/syntaxobj.rb +1234 -0
  86. data/lib/tecsgen/core/tecs_lang.rb +306 -0
  87. data/lib/tecsgen/core/tecsgen.rb +453 -0
  88. data/lib/tecsgen/core/tecsinfo.rb +860 -0
  89. data/lib/tecsgen/core/tool_info.rb +258 -0
  90. data/lib/tecsgen/core/types.rb +1632 -0
  91. data/lib/tecsgen/core/unjoin_plugin.rb +218 -0
  92. data/lib/tecsgen/core/value.rb +650 -0
  93. data/lib/tecsgen/messages/messages_console_en_US.rb +1171 -0
  94. data/lib/tecsgen/messages/messages_console_ja_JP.rb +1171 -0
  95. data/lib/tecsgen/messages/messages_file_en_US.rb +334 -0
  96. data/lib/tecsgen/messages/messages_file_ja_JP.rb +163 -0
  97. data/lib/tecsgen/plugin/ATK1AlarmPlugin.rb +196 -0
  98. data/lib/tecsgen/plugin/ATK1DelayTaskPlugin.rb +106 -0
  99. data/lib/tecsgen/plugin/ATK1EventPlugin.rb +147 -0
  100. data/lib/tecsgen/plugin/ATK1ISRPlugin.rb +174 -0
  101. data/lib/tecsgen/plugin/ATK1KernelPlugin.rb +287 -0
  102. data/lib/tecsgen/plugin/ATK1ResourcePlugin.rb +124 -0
  103. data/lib/tecsgen/plugin/ATK1TaskPlugin.rb +220 -0
  104. data/lib/tecsgen/plugin/C2TECSBridgePlugin.rb +210 -0
  105. data/lib/tecsgen/plugin/CellPlugin.rb +61 -0
  106. data/lib/tecsgen/plugin/CelltypePlugin.rb +72 -0
  107. data/lib/tecsgen/plugin/CompositePlugin.rb +66 -0
  108. data/lib/tecsgen/plugin/DomainPlugin.rb +89 -0
  109. data/lib/tecsgen/plugin/HRP2AlarmHandlerPlugin.rb +76 -0
  110. data/lib/tecsgen/plugin/HRP2Cache.rb +1 -0
  111. data/lib/tecsgen/plugin/HRP2CyclicHandlerPlugin.rb +75 -0
  112. data/lib/tecsgen/plugin/HRP2DataqueuePlugin.rb +68 -0
  113. data/lib/tecsgen/plugin/HRP2EventflagPlugin.rb +68 -0
  114. data/lib/tecsgen/plugin/HRP2FixedSizeMemoryPoolPlugin.rb +68 -0
  115. data/lib/tecsgen/plugin/HRP2HandlerPlugin.rb +117 -0
  116. data/lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb +372 -0
  117. data/lib/tecsgen/plugin/HRP2ObjectPlugin.rb +94 -0
  118. data/lib/tecsgen/plugin/HRP2Plugin.rb +140 -0
  119. data/lib/tecsgen/plugin/HRP2PostHook.rb +111 -0
  120. data/lib/tecsgen/plugin/HRP2PriorityDataqueuePlugin.rb +66 -0
  121. data/lib/tecsgen/plugin/HRP2RPCPlugin.rb +319 -0
  122. data/lib/tecsgen/plugin/HRP2SVCPlugin.rb +473 -0
  123. data/lib/tecsgen/plugin/HRP2SemaphorePlugin.rb +67 -0
  124. data/lib/tecsgen/plugin/HRP2TaskPlugin.rb +200 -0
  125. data/lib/tecsgen/plugin/HRPHandlerPlugin.rb +125 -0
  126. data/lib/tecsgen/plugin/HRPKernelObjectManager.rb +72 -0
  127. data/lib/tecsgen/plugin/HRPKernelObjectPlugin.rb +333 -0
  128. data/lib/tecsgen/plugin/HRPObjectPlugin.rb +93 -0
  129. data/lib/tecsgen/plugin/HRPPlugin.rb +356 -0
  130. data/lib/tecsgen/plugin/HRPRPCPlugin.rb +407 -0
  131. data/lib/tecsgen/plugin/HRPSVCPlugin.rb +859 -0
  132. data/lib/tecsgen/plugin/HRPTaskPlugin.rb +107 -0
  133. data/lib/tecsgen/plugin/Mruby2CBridgePlugin.rb +86 -0
  134. data/lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb +264 -0
  135. data/lib/tecsgen/plugin/MrubyBridgeCelltypePlugin.rb +293 -0
  136. data/lib/tecsgen/plugin/MrubyBridgeCompositePlugin.rb +49 -0
  137. data/lib/tecsgen/plugin/MrubyBridgePlugin.rb +67 -0
  138. data/lib/tecsgen/plugin/MrubyBridgeSignaturePlugin.rb +1307 -0
  139. data/lib/tecsgen/plugin/MrubyInfoBridgePlugin.rb +14 -0
  140. data/lib/tecsgen/plugin/MrubyInfoBridgeSignaturePlugin.rb +994 -0
  141. data/lib/tecsgen/plugin/MultiPlugin.rb +57 -0
  142. data/lib/tecsgen/plugin/NotifierPlugin.rb +1217 -0
  143. data/lib/tecsgen/plugin/OpaqueMarshalerPlugin.rb +81 -0
  144. data/lib/tecsgen/plugin/OpaqueRPCPlugin.rb +323 -0
  145. data/lib/tecsgen/plugin/RPCPlugin.rb +266 -0
  146. data/lib/tecsgen/plugin/RepeatCellPlugin.rb +166 -0
  147. data/lib/tecsgen/plugin/RepeatJoinPlugin.rb +130 -0
  148. data/lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb +357 -0
  149. data/lib/tecsgen/plugin/SharedRPCPlugin.rb +329 -0
  150. data/lib/tecsgen/plugin/SignaturePlugin.rb +77 -0
  151. data/lib/tecsgen/plugin/TECS2CBridgePlugin.rb +178 -0
  152. data/lib/tecsgen/plugin/TECSInfoPlugin.rb +280 -0
  153. data/lib/tecsgen/plugin/ThroughPlugin.rb +333 -0
  154. data/lib/tecsgen/plugin/TracePlugin.rb +484 -0
  155. data/lib/tecsgen/plugin/lib/GenHRP2Marshaler.rb +761 -0
  156. data/lib/tecsgen/plugin/lib/GenOpaqueMarshaler.rb +1107 -0
  157. data/lib/tecsgen/plugin/lib/GenParamCopy.rb +365 -0
  158. data/lib/tecsgen/plugin/lib/GenTransparentMarshaler.rb +683 -0
  159. data/lib/tecsgen/plugin/lib/MrubyBridgeCelltypePluginModule.rb +283 -0
  160. data/lib/tecsgen/plugin/lib/MrubyBridgeSignaturePluginModule.rb +277 -0
  161. data/lib/tecsgen/version.rb +6 -0
  162. data/samples/FigureSamples/active/active.cde +104 -0
  163. data/samples/FigureSamples/active/active.cdl +20 -0
  164. data/samples/FigureSamples/active/active.pdf +0 -0
  165. data/samples/FigureSamples/active/active.png +0 -0
  166. data/samples/FigureSamples/active/gen/tmp_C_src.c +36 -0
  167. data/samples/FigureSamples/active/gen/tmp_cygwin_tecs.h +1908 -0
  168. data/samples/FigureSamples/active/gen/tmp_plugin_post_code.cdl +0 -0
  169. data/samples/FigureSamples/allocator/allocator-internal.png +0 -0
  170. data/samples/FigureSamples/allocator/allocator.cde +171 -0
  171. data/samples/FigureSamples/allocator/allocator.cdl +58 -0
  172. data/samples/FigureSamples/allocator/allocator.png +0 -0
  173. data/samples/FigureSamples/basic/Makefile +87 -0
  174. data/samples/FigureSamples/basic/SimpleSample-trace.cdl +50 -0
  175. data/samples/FigureSamples/basic/SimpleSample.cde +91 -0
  176. data/samples/FigureSamples/basic/SimpleSample.cdl +47 -0
  177. data/samples/FigureSamples/basic/basic.cde +93 -0
  178. data/samples/FigureSamples/basic/basic.cdl +46 -0
  179. data/samples/FigureSamples/basic/basic.png +0 -0
  180. data/samples/FigureSamples/callback/callback.cde +130 -0
  181. data/samples/FigureSamples/callback/callback.cdl +29 -0
  182. data/samples/FigureSamples/callback/callback.png +0 -0
  183. data/samples/FigureSamples/carray/carray.cde +144 -0
  184. data/samples/FigureSamples/carray/carray.cdl +38 -0
  185. data/samples/FigureSamples/carray/carray.png +0 -0
  186. data/samples/FigureSamples/cearray/cearray.cde +314 -0
  187. data/samples/FigureSamples/cearray/cearray.cdl +60 -0
  188. data/samples/FigureSamples/cearray/cearray.png +0 -0
  189. data/samples/FigureSamples/composite/composite-internal.png +0 -0
  190. data/samples/FigureSamples/composite/composite.cde +216 -0
  191. data/samples/FigureSamples/composite/composite.cdl +95 -0
  192. data/samples/FigureSamples/composite/composite.png +0 -0
  193. data/samples/FigureSamples/earray/earray.cde +142 -0
  194. data/samples/FigureSamples/earray/earray.cdl +38 -0
  195. data/samples/FigureSamples/earray/earray.png +0 -0
  196. data/samples/FigureSamples/join/Makefile +87 -0
  197. data/samples/FigureSamples/join/join.cde +132 -0
  198. data/samples/FigureSamples/join/join.cdl +40 -0
  199. data/samples/FigureSamples/join/join.png +0 -0
  200. data/samples/FigureSamples/relay/Makefile +99 -0
  201. data/samples/FigureSamples/relay/relay-internal.png +0 -0
  202. data/samples/FigureSamples/relay/relay.cde +284 -0
  203. data/samples/FigureSamples/relay/relay.cdl +52 -0
  204. data/samples/FigureSamples/relay/relay.png +0 -0
  205. data/samples/FigureSamples/rpc/Makefile +123 -0
  206. data/samples/FigureSamples/rpc/rpc-expand.png +0 -0
  207. data/samples/FigureSamples/rpc/rpc.cde +245 -0
  208. data/samples/FigureSamples/rpc/rpc.png +0 -0
  209. data/samples/FigureSamples/rpc/rpc_sample.cdl +53 -0
  210. data/samples/SimpleSample/Makefile +25 -0
  211. data/samples/SimpleSample/SimpleSample/Makefile +86 -0
  212. data/samples/SimpleSample/SimpleSample/Makefile-trace +91 -0
  213. data/samples/SimpleSample/SimpleSample/README.txt +106 -0
  214. data/samples/SimpleSample/SimpleSample/SimpleSample-trace.cdl +50 -0
  215. data/samples/SimpleSample/SimpleSample/SimpleSample.cdl +45 -0
  216. data/samples/SimpleSample/SimpleSample/src/tSample.c +77 -0
  217. data/samples/SimpleSample/SimpleSample/src/tSimple.c +48 -0
  218. data/samples/SimpleSample/SimpleSample/src/tecs-types.h +27 -0
  219. data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile +51 -0
  220. data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile-trace +91 -0
  221. data/samples/SimpleSample/SimpleSampleOpaqueRPC/README.txt +106 -0
  222. data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample-trace.cdl +80 -0
  223. data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample.cdl +77 -0
  224. data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSample/Makefile +112 -0
  225. data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSimple/Makefile +109 -0
  226. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSample.c +80 -0
  227. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSimple.c +47 -0
  228. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tTaskMain.c +66 -0
  229. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tecs-types.h +27 -0
  230. data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile +125 -0
  231. data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile-trace +130 -0
  232. data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample-trace.cdl +54 -0
  233. data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample.cdl +53 -0
  234. data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSample.c +80 -0
  235. data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSimple.c +54 -0
  236. data/tecscde.gemspec +41 -0
  237. metadata +353 -0
@@ -0,0 +1,475 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ #
4
+ # TECSFlow
5
+ # TECS Flow Analyzer
6
+ #
7
+ # Copyright (C) 2008-2019 by TOPPERS Project
8
+ #--
9
+ # 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
10
+ # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
11
+ # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
12
+ # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
13
+ # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
14
+ # スコード中に含まれていること.
15
+ # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
16
+ # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
17
+ # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
18
+ # の無保証規定を掲載すること.
19
+ # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
20
+ # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
21
+ # と.
22
+ # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
23
+ # 作権表示,この利用条件および下記の無保証規定を掲載すること.
24
+ # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
25
+ # 報告すること.
26
+ # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
27
+ # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
28
+ # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
29
+ # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
30
+ # 免責すること.
31
+ #
32
+ # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
33
+ # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
34
+ # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
35
+ # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
36
+ # の責任を負わない.
37
+ #
38
+ # $Id: tecsflow.rb 3043 2019-01-12 08:41:25Z okuma-top $
39
+ #++
40
+ $tecsflow_base_path = File.dirname( File.expand_path __FILE__ )
41
+
42
+ require 'optparse'
43
+ $TECSFLOW = true
44
+ $title = "tecsflow"
45
+ $tool_version = "1.G.0"
46
+
47
+ require "#{$tecsflow_base_path}/flowlib/classes.rb"
48
+ require "#{$tecsflow_base_path}/tecslib/version.rb"
49
+ require "#{$tecsflow_base_path}/tecsgen.rb"
50
+
51
+ TECSGEN.init
52
+ tecsgen = TECSGEN.new
53
+
54
+ $tecsgen_dump_file_name = "#{$gen}/tecsgen.rbdmp"
55
+ $tcflow_dump_file_name = "#{$gen}/tcflow.rbdmp"
56
+ $root_namespace = nil
57
+ $tcflow_funclist = nil
58
+
59
+ def print_indent( level )
60
+ if level > 0 then
61
+ print " " * level
62
+ return level
63
+ else
64
+ return - level
65
+ end
66
+ end
67
+
68
+ class Namespace
69
+ def self.set_root root
70
+ @@root_namespace = root
71
+ end
72
+
73
+ #=== print_all_cells
74
+ # print all call flow beginning with active cell's call port function
75
+ def print_all_cells
76
+ # for each active cell
77
+ @cell_list.each{|cell|
78
+ celltype = cell.get_celltype
79
+ call_funcs = {}
80
+ if celltype.is_active? then
81
+ if ! celltype.kind_of? CompositeCelltype then
82
+ print "[active cell] #{cell.get_namespace_path}\n"
83
+ cell.get_join_list.get_items.each{ |j|
84
+ if j.get_definition.kind_of? Port then
85
+ port = j.get_definition
86
+ port.get_signature.get_function_head_array.each{ |f|
87
+ func_name = "->#{port.get_name}.#{f.get_name}__T".to_sym
88
+ call_funcs[ func_name ] = false
89
+ }
90
+ end
91
+ }
92
+ # isn't the call port function called from entry port function ?
93
+ # if called, it's not actually active (task main, handler main is not called from entry function)
94
+ celltype.get_port_list.each{ |ep|
95
+ if ep.get_port_type == :ENTRY then
96
+ ep.get_signature.get_function_head_array.each{ |f|
97
+ ep_func = "#{celltype.get_global_name}_#{ep.get_name}_#{f.get_name}".to_sym
98
+ if $tcflow_funclist[ ep_func ] then
99
+ $tcflow_funclist[ ep_func ].get_call_funcs.each{ |cf, cff|
100
+ if call_funcs[cf] == false then
101
+ # printf "#{ep_func} calls #{cf}\n"
102
+ call_funcs[cf] = true
103
+ end
104
+ }
105
+ else
106
+ print "ep_func #{ep_func} not found. why not defined ?\n"
107
+ end
108
+ }
109
+ end
110
+ }
111
+ call_funcs.each{ |call_func_name, v|
112
+ if v == false then # not called from entry port func
113
+ # print " #{f} \n"
114
+ # decompose
115
+ indent_level = 1
116
+ no_caller_cell = true
117
+ cell.print_call_func_flow no_caller_cell, call_func_name, indent_level
118
+ end
119
+ }
120
+ end
121
+ end
122
+ }
123
+ @namespace_list.each{|ns|
124
+ ns.print_all_cells
125
+ }
126
+ if false then
127
+ $tcflow_funclist.each{|name, func|
128
+ print name, "\n"
129
+ if func.kind_of? TCFlow::Function then
130
+ func.get_call_funcs.each{ |cname,cfunc|
131
+ print " -> ", cname, "\n"
132
+ }
133
+ end
134
+ }
135
+ end
136
+ end
137
+ end
138
+
139
+ class Cell
140
+ @@printed_func_nsp_list = {} # function path in CDL like format
141
+ @@printed_cell_list = {}
142
+ @@printed_celltype_list = {}
143
+
144
+ def self.print_unused_func
145
+ parent_cell = []
146
+ indent_level = 1
147
+ @@printed_cell_list.keys.each{ |cell|
148
+ cell_printed = false
149
+ ct = cell.get_celltype
150
+ if cell.is_in_composite? then
151
+ # print "unreferenced in composite #{ct.get_name} #{cell.get_name}\n"
152
+ next
153
+ end
154
+ # if @@printed_celltype_list[ ct ] == true then
155
+ # next
156
+ # end
157
+ # @@printed_celltype_list[ ct ] = true
158
+ ct.get_port_list.each{ |port|
159
+ next if port.get_port_type == :CALL
160
+ entry_port_name = port.get_name
161
+ port.get_signature.get_function_head_array.each{ |func|
162
+ func_name = func.get_name
163
+ # func_nsp = get_function_nsp port_name, func_name, parent_cell
164
+ # if @@printed_func_nsp_list[ func_nsp ] != true then
165
+ # end
166
+ ep_func = "#{ct.get_global_name}_#{entry_port_name}_#{func_name}".to_sym
167
+ # print " ", ep_func, "\n"
168
+ if $tcflow_funclist[ ep_func ].kind_of? TCFlow::Function then
169
+ func = $tcflow_funclist[ ep_func ]
170
+ if ! func.is_printed? then
171
+ #if cell_printed == false then
172
+ # cell_printed = true
173
+ # if cell.get_namespace_path == nil then
174
+ # cell.show_tree 0
175
+ # end
176
+ print "[unreferenced entry function] #{cell.get_namespace_path}.#{entry_port_name}.#{func_name}"
177
+ #end
178
+ cell.print_entry_func_flow entry_port_name, func_name, indent_level, parent_cell
179
+ end
180
+ end
181
+ }
182
+ }
183
+ }
184
+ end
185
+
186
+ def get_function_nsp port_name, func_name, parent_cell
187
+ if @in_composite == false then
188
+ nsp = get_namespace_path.to_s.sub( /^::/, "")
189
+ return "#{nsp}.#{port_name}.#{func_name}".to_sym
190
+ else
191
+ len = parent_cell.length
192
+ if parent_cell[0] == nil then
193
+ # Bug trap
194
+ print "\nname=", @name, ", len=", len, " nsp=", get_namespace_path, "\n"
195
+ nsp = "__" + @name.to_s
196
+ else
197
+ nsp = parent_cell[0].get_namespace_path.to_s
198
+ end
199
+ i = 1
200
+ while i < len
201
+ nsp = nsp + '_' + parent_cell[i].get_name.to_s
202
+ i+=1
203
+ end
204
+ return "#{nsp}_#{@name}.#{port_name}.#{func_name}".to_sym
205
+ end
206
+ end
207
+
208
+ def print_entry_func_flow entry_port_name, func_name, indent_level, parent_cell
209
+ func_nsp = get_function_nsp entry_port_name, func_name, parent_cell
210
+ # print "\nentry:", func_nsp, "\n"
211
+ @@printed_cell_list[ self ] = true
212
+ if @@printed_func_nsp_list[ func_nsp ] then
213
+ # print "\n"
214
+ # print_indent indent_level
215
+ # print func_nsp
216
+ print ": printed\n"
217
+ return
218
+ end
219
+ @@printed_func_nsp_list[ func_nsp ] = true
220
+ if ! @celltype.kind_of? CompositeCelltype
221
+ print "\n"
222
+ ep_func = "#{@celltype.get_global_name}_#{entry_port_name}_#{func_name}".to_sym
223
+ if $tcflow_funclist[ ep_func ] then
224
+ function = $tcflow_funclist[ ep_func ]
225
+ function.set_printed
226
+ function.get_call_funcs.each{ |call_func_name, func|
227
+ # print "#{indent}#{fname} \n"
228
+ # decompose
229
+ no_caller_cell = true
230
+ print_call_func_flow no_caller_cell, call_func_name, indent_level, parent_cell
231
+ }
232
+ else
233
+ indent_level = print_indent indent_level
234
+ print "not found '#{ep_func}' !!!\n"
235
+ end
236
+ else
237
+ cj = @celltype.find_export entry_port_name
238
+ cell = cj.get_cell
239
+ ep_name = cj.get_cell_elem_name
240
+ print " == [inner]#{cell.get_name}.#{ep_name}"
241
+ parent_cell = parent_cell.dup
242
+ # print "\n#{@name} PUSH\n"
243
+ parent_cell.push self
244
+ # parent_cell.each{|c| print c.get_name, "\n" }
245
+ cell.print_entry_func_flow ep_name, func_name, indent_level, parent_cell
246
+ end
247
+ end
248
+
249
+ def print_call_func_flow no_caller_cell, call_func_name, indent_level, parent_cell = []
250
+ m = TECSFlow.analyze_call_port_func_name call_func_name
251
+ if m then
252
+ call_port = m[0]
253
+ function = m[1]
254
+ call_subsc = m[2]
255
+ # print "print_call_func_flow: #{call_func_name} => #{call_port}.#{function}\n"
256
+ # p "call_subsc=", call_subsc
257
+ if call_subsc == nil then
258
+ join = get_join_list.get_item call_port
259
+ print_call_func_flow_sub indent_level, no_caller_cell, call_port, call_subsc, function, join, parent_cell
260
+ else
261
+ # print "call_subsc=#{call_subsc}\n"
262
+ join_0 = get_join_list.get_item call_port
263
+ if join_0 then
264
+ am = join_0.get_array_member2
265
+ call_subsc = 0
266
+ am.each{ |join|
267
+ print_call_func_flow_sub indent_level, no_caller_cell, call_port, call_subsc, function, join, parent_cell
268
+ call_subsc += 1
269
+ }
270
+ else
271
+ print_call_func_flow_sub indent_level, no_caller_cell, call_port, call_subsc, function, join, parent_cell
272
+ end
273
+ end
274
+ else
275
+ # non TECS function
276
+ func = $tcflow_funclist[ call_func_name ]
277
+ if func.kind_of? TCFlow::Function then
278
+ if func.is_printed? then
279
+ indent_level = print_indent indent_level
280
+ print func.get_name, ": printed\n"
281
+ else
282
+ indent_level = print_indent indent_level
283
+ print "#{call_func_name} [Function Out of TECS]\n"
284
+ func.set_printed
285
+ func.get_call_funcs.each{ |cf, cff|
286
+ no_caller_cell = false
287
+ print_call_func_flow no_caller_cell, cf, indent_level + 1, parent_cell
288
+ }
289
+ end
290
+ else
291
+ indent_level = print_indent indent_level
292
+ print call_func_name, ": [Function Out of TECS, not defined]\n"
293
+ end
294
+ # print "#{" "*indent_level}fail to analyze #{call_func_name}\n"
295
+ end
296
+ end
297
+
298
+ def print_call_func_flow_sub indent_level, no_caller_cell, call_port, call_subsc, function, join, parent_cell
299
+ j = join
300
+ if j != nil then
301
+ if ! $unopt then
302
+ callee_cell = j.get_rhs_cell
303
+ callee_port = j.get_rhs_port.get_name
304
+ callee_subsc = j.get_rhs_subscript
305
+ else
306
+ callee_cell = j.get_rhs_cell1
307
+ callee_port = j.get_rhs_port1
308
+ callee_subsc = j.get_rhs_subscript1
309
+ end
310
+ print_flow indent_level, no_caller_cell, call_port, call_subsc, callee_cell, callee_port, callee_subsc, function
311
+ callee_cell.print_entry_func_flow callee_port, function, indent_level + 1, parent_cell
312
+ else
313
+ if parent_cell.length > 0 then
314
+ # print "len = ", parent_cell.length, "\n"
315
+ composite = parent_cell.last.get_celltype
316
+ compjoin = nil
317
+ # search from exporting ports to find call port which matches inner cell's call port
318
+ composite.get_port_list.each{|cj|
319
+ if cj.get_cell.get_name == @name && cj.get_cell_elem_name == call_port then
320
+ compjoin = cj
321
+ break
322
+ end
323
+ }
324
+ if compjoin then
325
+ indent_level = print_indent indent_level
326
+ if no_caller_cell == false then
327
+ print "[inner]#{@name}."
328
+ end
329
+ print "#{call_port} == "
330
+ j = parent_cell.last.get_join_list.get_item compjoin.get_name
331
+ if j != nil then
332
+ if ! $unopt then
333
+ callee_cell = j.get_rhs_cell
334
+ callee_port = j.get_rhs_port.get_name
335
+ callee_subsc = j.get_rhs_subscript
336
+ else
337
+ callee_cell = j.get_rhs_cell1
338
+ callee_port = j.get_rhs_port1
339
+ callee_subsc = j.get_rhs_subscript1
340
+ end
341
+ no_caller_cell = false
342
+ parent_cell.last.print_flow (-indent_level), no_caller_cell, call_port, call_subsc, callee_cell, callee_port, callee_subsc, function
343
+ pc = parent_cell.dup
344
+ # print "#{pc.last.get_name} POP\n"
345
+ pc.pop
346
+ callee_cell.print_entry_func_flow callee_port, function, indent_level + 1, pc
347
+ # break
348
+ else
349
+ # recursive case, parent's port is joined to grand parent's exporting port.
350
+ cf_name = "->#{compjoin.get_name}.#{function}__T".to_sym
351
+ pc = parent_cell.dup
352
+ # print "func = ", cf_name, "\n"
353
+ # print "#{pc.last.get_name} POP\n"
354
+ pc.pop
355
+ # print parent_cell.last.get_name, ".", compjoin.get_name, ".", function, "\n"
356
+ if indent_level > 0 then
357
+ tmp_indent_level = - indent_level
358
+ else
359
+ tmp_indent_level = indent_level
360
+ end
361
+ no_caller_cell = false
362
+ parent_cell.last.print_call_func_flow no_caller_cell, cf_name, tmp_indent_level, pc
363
+ # break
364
+ end
365
+ else
366
+ # print "name=", @name, " "
367
+ # composite.get_port_list.each{|cj|
368
+ # print cj.get_name, ", "
369
+ # }
370
+ print "\n"
371
+ indent_level = print_indent indent_level
372
+ print "#{@name}.#{call_port} not found in composite #{parent_cell.last.get_name}\n"
373
+ # break
374
+ end
375
+ else
376
+ indent_level = print_indent indent_level
377
+ print "#{@name}.#{call_port} not joined\n"
378
+ end # end while
379
+ end
380
+ end
381
+
382
+ def print_name no_cell_name, port_name, subsc, func_name
383
+ if ! no_cell_name then
384
+ nsp = get_namespace_path.to_s.sub( /^::/, "")
385
+ # pp nsp.class.name
386
+ if nsp != "" then
387
+ print nsp, "."
388
+ else
389
+ print @name, "."
390
+ end
391
+ end
392
+
393
+ print port_name
394
+ if subsc then
395
+ print '[', subsc, ']'
396
+ end
397
+ print ".", func_name
398
+ end
399
+
400
+ def print_flow indent_level, no_caller_cell, call_port_name, call_subsc, callee_cell, entry_port_name, callee_subsc, func_name
401
+ indent_level = print_indent indent_level
402
+ no_cell_name = no_caller_cell
403
+ print_name no_cell_name, call_port_name, call_subsc, func_name
404
+ print " => "
405
+ no_cell_name = false
406
+ callee_cell.print_name no_cell_name, entry_port_name, callee_subsc, func_name
407
+ end
408
+ end
409
+
410
+ module TECSFlow
411
+ def self.main
412
+ doing = "nothing"
413
+ begin
414
+ print "reading '#{$tecsgen_dump_file_name}'\n"
415
+ doing = "file reading"
416
+ mar_in = File.read( $tecsgen_dump_file_name )
417
+ TCFlow::Function.load_funclist $tecsgen_dump_file_name
418
+ doing = "Marshal.load"
419
+ $root_namespace = Marshal.load( mar_in )
420
+ # ここではクラス変数を設定していないため、それらを参照するメソッドは使用できないことに注意!
421
+ rescue => e
422
+ pp e
423
+ print "fatal: fail to load #{$tecsgen_dump_file_name} in #{doing}\n"
424
+ exit 1
425
+ end
426
+
427
+ begin
428
+ print "reading '#{$tcflow_dump_file_name}'\n"
429
+ # doing = "file reading"
430
+ # mar_in = File.read( $tcflow_dump_file_name )
431
+ # doing = "Marshal.load"
432
+ # $tcflow_funclist = Marshal.load( mar_in )
433
+ $tcflow_funclist = TCFlow::Function.load_funclist $tcflow_dump_file_name
434
+ rescue
435
+ print "fatal: fail to load #{$tecsgen_dump_file_name} in #{doing}\n"
436
+ exit 1
437
+ end
438
+ Namespace.set_root $root_namespace
439
+ $root_namespace.print_all_cells
440
+ print_unref_function
441
+ end
442
+
443
+ def self.analyze_call_port_func_name fname
444
+ m = /-\>(?<cp>\w+)(?<subsc>(\[\])*)\.(?<func>\w+)__T/.match fname.to_s
445
+ if m then
446
+ call_port = m[:cp].to_sym
447
+ function = m[:func].to_sym
448
+ subsc = m[:subsc]
449
+ subsc = nil if subsc == ""
450
+ return [ call_port, function, subsc ]
451
+ else
452
+ return nil
453
+ end
454
+ end
455
+
456
+ def self.print_unref_function
457
+ print "--- unreferenced entry functions ---\n"
458
+ Cell.print_unused_func
459
+ print "--- unreferenced C functions ---\n"
460
+ TCFlow::Function.update
461
+ $tcflow_funclist.each{ |fname, func|
462
+ if func.kind_of? TCFlow::Function then
463
+ if ! func.is_printed? && func.is_top? then
464
+ print "[Function Out of TECS, unreferenced] ", func.get_name, "\n"
465
+ func.print_all_functions 0
466
+ end
467
+ # else
468
+ # print_indent 0
469
+ # print fname, "\n"
470
+ end
471
+ }
472
+ end
473
+ end
474
+
475
+ TECSFlow.main