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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +125 -0
- data/.rubocop_todo.yml +188 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +6 -0
- data/LICENSE +46 -0
- data/LICENSE.ja +32 -0
- data/README.ja.md +200 -0
- data/README.md +35 -0
- data/Rakefile +27 -0
- data/bin/tecscde +64 -0
- data/glade/tecscde-cell-property.glade +205 -0
- data/glade/tecscde-celltype-property.glade +172 -0
- data/glade/tecscde-celltype.glade +414 -0
- data/glade/tecscde-export.glade +161 -0
- data/glade/test-cell-plugin.rb +51 -0
- data/glade/test-cell-property.rb +35 -0
- data/glade/test-export.rb +35 -0
- data/glade/test-palette.rb +26 -0
- data/lib/tcflow.rb +148 -0
- data/lib/tecscde.rb +65 -0
- data/lib/tecscde/NewCell.png +0 -0
- data/lib/tecscde/SelectArrow.png +0 -0
- data/lib/tecscde/attr_tree_view.rb +253 -0
- data/lib/tecscde/cell_plugin_dialog.glade +294 -0
- data/lib/tecscde/cell_plugin_dialog.rb +89 -0
- data/lib/tecscde/celltype_tree_view.rb +105 -0
- data/lib/tecscde/change_set_control.rb +35 -0
- data/lib/tecscde/change_set_control/change_set.rb +32 -0
- data/lib/tecscde/change_set_control/change_set_manager.rb +62 -0
- data/lib/tecscde/command.rb +35 -0
- data/lib/tecscde/control.rb +491 -0
- data/lib/tecscde/highlighted_objects.rb +180 -0
- data/lib/tecscde/logger.rb +74 -0
- data/lib/tecscde/main_view_and_model.rb +80 -0
- data/lib/tecscde/palette.glade +553 -0
- data/lib/tecscde/palette.rb +174 -0
- data/lib/tecscde/preferences.glade +117 -0
- data/lib/tecscde/preferences.rb +44 -0
- data/lib/tecscde/tecs_model.rb +1137 -0
- data/lib/tecscde/tecs_model/hbar.rb +68 -0
- data/lib/tecscde/tecs_model/tm_c_port.rb +122 -0
- data/lib/tecscde/tecs_model/tm_c_port_array.rb +98 -0
- data/lib/tecscde/tecs_model/tm_cell.rb +496 -0
- data/lib/tecscde/tecs_model/tm_e_port.rb +126 -0
- data/lib/tecscde/tecs_model/tm_e_port_array.rb +78 -0
- data/lib/tecscde/tecs_model/tm_join.rb +293 -0
- data/lib/tecscde/tecs_model/tm_join_bar.rb +146 -0
- data/lib/tecscde/tecs_model/tm_port.rb +238 -0
- data/lib/tecscde/tecs_model/tm_port_array.rb +246 -0
- data/lib/tecscde/tecs_model/tm_region.rb +107 -0
- data/lib/tecscde/tecs_model/tm_uneditable.rb +68 -0
- data/lib/tecscde/tecs_model/vbar.rb +68 -0
- data/lib/tecscde/templates/_cell_info.cde.erb +15 -0
- data/lib/tecscde/templates/_join_info.cde.erb +28 -0
- data/lib/tecscde/templates/main.cde.erb +49 -0
- data/lib/tecscde/tm_object.rb +91 -0
- data/lib/tecscde/version.rb +4 -0
- data/lib/tecscde/view.rb +58 -0
- data/lib/tecscde/view/cairo_matrix.rb +90 -0
- data/lib/tecscde/view/canvas.rb +59 -0
- data/lib/tecscde/view/constants.rb +114 -0
- data/lib/tecscde/view/main_view.rb +1245 -0
- data/lib/tecsflow.rb +475 -0
- data/lib/tecsflow/C_parser.tab.rb +2471 -0
- data/lib/tecsflow/C_parser.y.rb +1087 -0
- data/lib/tecsflow/classes.rb +421 -0
- data/lib/tecsgen.rb +581 -0
- data/lib/tecsgen/core/C_parser.tab.rb +2477 -0
- data/lib/tecsgen/core/C_parser.y +1032 -0
- data/lib/tecsgen/core/bnf-deb.tab.rb +5193 -0
- data/lib/tecsgen/core/bnf.tab.rb +5193 -0
- data/lib/tecsgen/core/bnf.y +2211 -0
- data/lib/tecsgen/core/componentobj.rb +7901 -0
- data/lib/tecsgen/core/ctypes.rb +226 -0
- data/lib/tecsgen/core/expression.rb +1031 -0
- data/lib/tecsgen/core/gen_xml.rb +374 -0
- data/lib/tecsgen/core/generate.rb +5206 -0
- data/lib/tecsgen/core/location.rb +116 -0
- data/lib/tecsgen/core/messages.rb +101 -0
- data/lib/tecsgen/core/optimize.rb +456 -0
- data/lib/tecsgen/core/plugin.rb +332 -0
- data/lib/tecsgen/core/pluginModule.rb +165 -0
- data/lib/tecsgen/core/syntaxobj.rb +1234 -0
- data/lib/tecsgen/core/tecs_lang.rb +306 -0
- data/lib/tecsgen/core/tecsgen.rb +453 -0
- data/lib/tecsgen/core/tecsinfo.rb +860 -0
- data/lib/tecsgen/core/tool_info.rb +258 -0
- data/lib/tecsgen/core/types.rb +1632 -0
- data/lib/tecsgen/core/unjoin_plugin.rb +218 -0
- data/lib/tecsgen/core/value.rb +650 -0
- data/lib/tecsgen/messages/messages_console_en_US.rb +1171 -0
- data/lib/tecsgen/messages/messages_console_ja_JP.rb +1171 -0
- data/lib/tecsgen/messages/messages_file_en_US.rb +334 -0
- data/lib/tecsgen/messages/messages_file_ja_JP.rb +163 -0
- data/lib/tecsgen/plugin/ATK1AlarmPlugin.rb +196 -0
- data/lib/tecsgen/plugin/ATK1DelayTaskPlugin.rb +106 -0
- data/lib/tecsgen/plugin/ATK1EventPlugin.rb +147 -0
- data/lib/tecsgen/plugin/ATK1ISRPlugin.rb +174 -0
- data/lib/tecsgen/plugin/ATK1KernelPlugin.rb +287 -0
- data/lib/tecsgen/plugin/ATK1ResourcePlugin.rb +124 -0
- data/lib/tecsgen/plugin/ATK1TaskPlugin.rb +220 -0
- data/lib/tecsgen/plugin/C2TECSBridgePlugin.rb +210 -0
- data/lib/tecsgen/plugin/CellPlugin.rb +61 -0
- data/lib/tecsgen/plugin/CelltypePlugin.rb +72 -0
- data/lib/tecsgen/plugin/CompositePlugin.rb +66 -0
- data/lib/tecsgen/plugin/DomainPlugin.rb +89 -0
- data/lib/tecsgen/plugin/HRP2AlarmHandlerPlugin.rb +76 -0
- data/lib/tecsgen/plugin/HRP2Cache.rb +1 -0
- data/lib/tecsgen/plugin/HRP2CyclicHandlerPlugin.rb +75 -0
- data/lib/tecsgen/plugin/HRP2DataqueuePlugin.rb +68 -0
- data/lib/tecsgen/plugin/HRP2EventflagPlugin.rb +68 -0
- data/lib/tecsgen/plugin/HRP2FixedSizeMemoryPoolPlugin.rb +68 -0
- data/lib/tecsgen/plugin/HRP2HandlerPlugin.rb +117 -0
- data/lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb +372 -0
- data/lib/tecsgen/plugin/HRP2ObjectPlugin.rb +94 -0
- data/lib/tecsgen/plugin/HRP2Plugin.rb +140 -0
- data/lib/tecsgen/plugin/HRP2PostHook.rb +111 -0
- data/lib/tecsgen/plugin/HRP2PriorityDataqueuePlugin.rb +66 -0
- data/lib/tecsgen/plugin/HRP2RPCPlugin.rb +319 -0
- data/lib/tecsgen/plugin/HRP2SVCPlugin.rb +473 -0
- data/lib/tecsgen/plugin/HRP2SemaphorePlugin.rb +67 -0
- data/lib/tecsgen/plugin/HRP2TaskPlugin.rb +200 -0
- data/lib/tecsgen/plugin/HRPHandlerPlugin.rb +125 -0
- data/lib/tecsgen/plugin/HRPKernelObjectManager.rb +72 -0
- data/lib/tecsgen/plugin/HRPKernelObjectPlugin.rb +333 -0
- data/lib/tecsgen/plugin/HRPObjectPlugin.rb +93 -0
- data/lib/tecsgen/plugin/HRPPlugin.rb +356 -0
- data/lib/tecsgen/plugin/HRPRPCPlugin.rb +407 -0
- data/lib/tecsgen/plugin/HRPSVCPlugin.rb +859 -0
- data/lib/tecsgen/plugin/HRPTaskPlugin.rb +107 -0
- data/lib/tecsgen/plugin/Mruby2CBridgePlugin.rb +86 -0
- data/lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb +264 -0
- data/lib/tecsgen/plugin/MrubyBridgeCelltypePlugin.rb +293 -0
- data/lib/tecsgen/plugin/MrubyBridgeCompositePlugin.rb +49 -0
- data/lib/tecsgen/plugin/MrubyBridgePlugin.rb +67 -0
- data/lib/tecsgen/plugin/MrubyBridgeSignaturePlugin.rb +1307 -0
- data/lib/tecsgen/plugin/MrubyInfoBridgePlugin.rb +14 -0
- data/lib/tecsgen/plugin/MrubyInfoBridgeSignaturePlugin.rb +994 -0
- data/lib/tecsgen/plugin/MultiPlugin.rb +57 -0
- data/lib/tecsgen/plugin/NotifierPlugin.rb +1217 -0
- data/lib/tecsgen/plugin/OpaqueMarshalerPlugin.rb +81 -0
- data/lib/tecsgen/plugin/OpaqueRPCPlugin.rb +323 -0
- data/lib/tecsgen/plugin/RPCPlugin.rb +266 -0
- data/lib/tecsgen/plugin/RepeatCellPlugin.rb +166 -0
- data/lib/tecsgen/plugin/RepeatJoinPlugin.rb +130 -0
- data/lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb +357 -0
- data/lib/tecsgen/plugin/SharedRPCPlugin.rb +329 -0
- data/lib/tecsgen/plugin/SignaturePlugin.rb +77 -0
- data/lib/tecsgen/plugin/TECS2CBridgePlugin.rb +178 -0
- data/lib/tecsgen/plugin/TECSInfoPlugin.rb +280 -0
- data/lib/tecsgen/plugin/ThroughPlugin.rb +333 -0
- data/lib/tecsgen/plugin/TracePlugin.rb +484 -0
- data/lib/tecsgen/plugin/lib/GenHRP2Marshaler.rb +761 -0
- data/lib/tecsgen/plugin/lib/GenOpaqueMarshaler.rb +1107 -0
- data/lib/tecsgen/plugin/lib/GenParamCopy.rb +365 -0
- data/lib/tecsgen/plugin/lib/GenTransparentMarshaler.rb +683 -0
- data/lib/tecsgen/plugin/lib/MrubyBridgeCelltypePluginModule.rb +283 -0
- data/lib/tecsgen/plugin/lib/MrubyBridgeSignaturePluginModule.rb +277 -0
- data/lib/tecsgen/version.rb +6 -0
- data/samples/FigureSamples/active/active.cde +104 -0
- data/samples/FigureSamples/active/active.cdl +20 -0
- data/samples/FigureSamples/active/active.pdf +0 -0
- data/samples/FigureSamples/active/active.png +0 -0
- data/samples/FigureSamples/active/gen/tmp_C_src.c +36 -0
- data/samples/FigureSamples/active/gen/tmp_cygwin_tecs.h +1908 -0
- data/samples/FigureSamples/active/gen/tmp_plugin_post_code.cdl +0 -0
- data/samples/FigureSamples/allocator/allocator-internal.png +0 -0
- data/samples/FigureSamples/allocator/allocator.cde +171 -0
- data/samples/FigureSamples/allocator/allocator.cdl +58 -0
- data/samples/FigureSamples/allocator/allocator.png +0 -0
- data/samples/FigureSamples/basic/Makefile +87 -0
- data/samples/FigureSamples/basic/SimpleSample-trace.cdl +50 -0
- data/samples/FigureSamples/basic/SimpleSample.cde +91 -0
- data/samples/FigureSamples/basic/SimpleSample.cdl +47 -0
- data/samples/FigureSamples/basic/basic.cde +93 -0
- data/samples/FigureSamples/basic/basic.cdl +46 -0
- data/samples/FigureSamples/basic/basic.png +0 -0
- data/samples/FigureSamples/callback/callback.cde +130 -0
- data/samples/FigureSamples/callback/callback.cdl +29 -0
- data/samples/FigureSamples/callback/callback.png +0 -0
- data/samples/FigureSamples/carray/carray.cde +144 -0
- data/samples/FigureSamples/carray/carray.cdl +38 -0
- data/samples/FigureSamples/carray/carray.png +0 -0
- data/samples/FigureSamples/cearray/cearray.cde +314 -0
- data/samples/FigureSamples/cearray/cearray.cdl +60 -0
- data/samples/FigureSamples/cearray/cearray.png +0 -0
- data/samples/FigureSamples/composite/composite-internal.png +0 -0
- data/samples/FigureSamples/composite/composite.cde +216 -0
- data/samples/FigureSamples/composite/composite.cdl +95 -0
- data/samples/FigureSamples/composite/composite.png +0 -0
- data/samples/FigureSamples/earray/earray.cde +142 -0
- data/samples/FigureSamples/earray/earray.cdl +38 -0
- data/samples/FigureSamples/earray/earray.png +0 -0
- data/samples/FigureSamples/join/Makefile +87 -0
- data/samples/FigureSamples/join/join.cde +132 -0
- data/samples/FigureSamples/join/join.cdl +40 -0
- data/samples/FigureSamples/join/join.png +0 -0
- data/samples/FigureSamples/relay/Makefile +99 -0
- data/samples/FigureSamples/relay/relay-internal.png +0 -0
- data/samples/FigureSamples/relay/relay.cde +284 -0
- data/samples/FigureSamples/relay/relay.cdl +52 -0
- data/samples/FigureSamples/relay/relay.png +0 -0
- data/samples/FigureSamples/rpc/Makefile +123 -0
- data/samples/FigureSamples/rpc/rpc-expand.png +0 -0
- data/samples/FigureSamples/rpc/rpc.cde +245 -0
- data/samples/FigureSamples/rpc/rpc.png +0 -0
- data/samples/FigureSamples/rpc/rpc_sample.cdl +53 -0
- data/samples/SimpleSample/Makefile +25 -0
- data/samples/SimpleSample/SimpleSample/Makefile +86 -0
- data/samples/SimpleSample/SimpleSample/Makefile-trace +91 -0
- data/samples/SimpleSample/SimpleSample/README.txt +106 -0
- data/samples/SimpleSample/SimpleSample/SimpleSample-trace.cdl +50 -0
- data/samples/SimpleSample/SimpleSample/SimpleSample.cdl +45 -0
- data/samples/SimpleSample/SimpleSample/src/tSample.c +77 -0
- data/samples/SimpleSample/SimpleSample/src/tSimple.c +48 -0
- data/samples/SimpleSample/SimpleSample/src/tecs-types.h +27 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile +51 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile-trace +91 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/README.txt +106 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample-trace.cdl +80 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample.cdl +77 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSample/Makefile +112 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSimple/Makefile +109 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSample.c +80 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSimple.c +47 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tTaskMain.c +66 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tecs-types.h +27 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile +125 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile-trace +130 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample-trace.cdl +54 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample.cdl +53 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSample.c +80 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSimple.c +54 -0
- data/tecscde.gemspec +41 -0
- metadata +353 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# TCFlow
|
|
4
|
+
# Clanguage flow analyzer
|
|
5
|
+
#
|
|
6
|
+
# Copyright (C) 2008-2019 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: classes.rb 3041 2019-01-06 11:14:54Z okuma-top $
|
|
38
|
+
#++
|
|
39
|
+
|
|
40
|
+
module TCFlow
|
|
41
|
+
class Function
|
|
42
|
+
#@name:: Symbol
|
|
43
|
+
#@param_var::{ Symbol=>true }
|
|
44
|
+
#@local_var::{ Symbol=>true }
|
|
45
|
+
#@global_var::{ Symbol=>[n_access, n_write] }
|
|
46
|
+
#@call_func::{ Symbol=>Function }
|
|
47
|
+
#@b_ref:: Bool : true if referenced
|
|
48
|
+
#@b_printed:: Bool : true if printed already
|
|
49
|
+
#@locale::[file_name, lineno, col]
|
|
50
|
+
|
|
51
|
+
@@Function_list = {} # String(name) => Function | Integer(0)
|
|
52
|
+
@@param_list = nil
|
|
53
|
+
|
|
54
|
+
def initialize locale
|
|
55
|
+
@param_var = {}
|
|
56
|
+
@local_var = {}
|
|
57
|
+
@global_var = {}
|
|
58
|
+
@call_func = {}
|
|
59
|
+
@b_ref = false
|
|
60
|
+
@b_printed = false
|
|
61
|
+
@locale = locale
|
|
62
|
+
|
|
63
|
+
@pre_name = [0, "", 0, ""]
|
|
64
|
+
@pre_printed = false
|
|
65
|
+
@pfunc = ""
|
|
66
|
+
# @pp = ""
|
|
67
|
+
|
|
68
|
+
# param_list は先に解釈されている
|
|
69
|
+
if @@param_list
|
|
70
|
+
@@param_list.each { |param|
|
|
71
|
+
new_param param
|
|
72
|
+
}
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def set_name name # 関数をパースする最後で名前が確定
|
|
77
|
+
# print "^^^ function: #{name}\n"
|
|
78
|
+
@name = name.to_sym
|
|
79
|
+
if @@Function_list[@name] == 0
|
|
80
|
+
@b_ref = true
|
|
81
|
+
end
|
|
82
|
+
@@Function_list[@name] = self
|
|
83
|
+
@@param_list = nil
|
|
84
|
+
#p @name ###150216
|
|
85
|
+
# print "test:", @name, "\n"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# 関数が new される前に param_list が解釈されるため
|
|
89
|
+
def self.param_list param_list
|
|
90
|
+
@@param_list = param_list
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def new_param param
|
|
94
|
+
# print "new_param: #{param}\n"
|
|
95
|
+
@param_var[ param ] = param
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def new_local local
|
|
99
|
+
# print "new_local: #{local}\n"
|
|
100
|
+
@local_var[ local ] = local
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def ref_var var, b_write = false
|
|
104
|
+
#p var
|
|
105
|
+
#p @local_var
|
|
106
|
+
#p @global_var
|
|
107
|
+
if @local_var[ var ]
|
|
108
|
+
# print "ref local: #{var}\n"
|
|
109
|
+
elsif @param_var[ var ]
|
|
110
|
+
# print "ref param: #{var}\n"
|
|
111
|
+
else
|
|
112
|
+
# print "ref global: #{var}\n"
|
|
113
|
+
|
|
114
|
+
#変数のread/write回数をカウント ################
|
|
115
|
+
count_array = @global_var[ var ]
|
|
116
|
+
if count_array == nil
|
|
117
|
+
count_array = [ 0, 0 ]
|
|
118
|
+
@global_var[ var ] = count_array
|
|
119
|
+
end
|
|
120
|
+
if b_write
|
|
121
|
+
count_array[1] += 1
|
|
122
|
+
else
|
|
123
|
+
count_array[0] += 1
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def ref_func func_name
|
|
129
|
+
func_name = func_name.to_sym
|
|
130
|
+
#p func_name ###150216 この時点では表記順
|
|
131
|
+
if @@Function_list[func_name].instance_of? Function
|
|
132
|
+
function = @@Function_list[func_name]
|
|
133
|
+
function.referenced self
|
|
134
|
+
@call_func[ func_name ] = function
|
|
135
|
+
# print "call func: #{func_name} : defined\n"
|
|
136
|
+
else
|
|
137
|
+
@@Function_list[func_name] = 0
|
|
138
|
+
@call_func[ func_name ] = 0
|
|
139
|
+
# print "call func: #{func_name} : not defined\n"
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def referenced ref_func
|
|
144
|
+
@b_ref = true
|
|
145
|
+
@ref_func = ref_func
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
#=== ツリー表示
|
|
149
|
+
def self.print_all_functions
|
|
150
|
+
|
|
151
|
+
@@Function_list.each{ |name, func|
|
|
152
|
+
if func.instance_of? Function
|
|
153
|
+
func.print_all_functions(0, "")
|
|
154
|
+
end
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if ! self.all_printed?
|
|
158
|
+
# print "===== recursive functions\n"
|
|
159
|
+
funcs.each {|name|
|
|
160
|
+
func = @@Function_list[name]
|
|
161
|
+
if func.instance_of? Function
|
|
162
|
+
func.print_all_functions(-1, "")
|
|
163
|
+
end
|
|
164
|
+
}
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
#=== ツリー表示する
|
|
169
|
+
#level:: Integer: 0: top_level のものを表示する, -1: 未表示のものを表示する
|
|
170
|
+
# level = 0, -1 の場合、レベルに一致した関数だけが表示される
|
|
171
|
+
# それ以外の場合、再帰的にツリー表示が行われる
|
|
172
|
+
def print_all_functions (level)
|
|
173
|
+
|
|
174
|
+
# TOP レベルは参照されていないものだけとする
|
|
175
|
+
return if level == 0 && @b_ref == true
|
|
176
|
+
|
|
177
|
+
# @b_ref だが未印刷のもの(循環参照されている)
|
|
178
|
+
if level == -1
|
|
179
|
+
return if @b_printed
|
|
180
|
+
level = 0
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
indent = " " * level
|
|
184
|
+
|
|
185
|
+
if @b_printed
|
|
186
|
+
# 印刷済みは再帰的に印刷しない
|
|
187
|
+
print indent
|
|
188
|
+
print @name
|
|
189
|
+
print " : printed\n"
|
|
190
|
+
return
|
|
191
|
+
end
|
|
192
|
+
@b_printed = true
|
|
193
|
+
|
|
194
|
+
#変数一覧印字 ##########
|
|
195
|
+
if @global_var.length > 0
|
|
196
|
+
#print indent
|
|
197
|
+
#print " Global Vars: \n"
|
|
198
|
+
@global_var.each { |name, count_array|
|
|
199
|
+
#print indent
|
|
200
|
+
#print " "
|
|
201
|
+
#print name
|
|
202
|
+
#printf( " [R:%dW:%d]\n", count_array[0]-count_array[1], count_array[1] )
|
|
203
|
+
}
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
#関数一覧印字 #############
|
|
207
|
+
if @call_func.length > 0
|
|
208
|
+
print indent
|
|
209
|
+
print " Calling Function: \n"
|
|
210
|
+
cfuncs = @call_func.keys.sort{ |a,b| a.to_s <=> b.to_s } #名前順ソート
|
|
211
|
+
# cfuncs = @call_func.keys #関数呼び出し順 hash の順序は保障されていない【Matz版は保障されるらしい)
|
|
212
|
+
cfuncs.each{ |name|
|
|
213
|
+
func = @call_func[ name ]
|
|
214
|
+
if func.instance_of? Function
|
|
215
|
+
print indent, " ", name, "\n"
|
|
216
|
+
func.print_all_functions(level+1) #順番変更するとrecursive functionになる?
|
|
217
|
+
else
|
|
218
|
+
print indent
|
|
219
|
+
print " " ##
|
|
220
|
+
print name
|
|
221
|
+
print "() : not defined\n"
|
|
222
|
+
end
|
|
223
|
+
}
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
#Funciton#get_call_funcs
|
|
228
|
+
# ハッシュを返す (呼出し関数名=>Function)
|
|
229
|
+
def get_call_funcs
|
|
230
|
+
@call_func
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def self.all_printed?
|
|
234
|
+
# 参照されているが未印刷のものを探す
|
|
235
|
+
b_all_printed = true
|
|
236
|
+
@@Function_list.each{ |name,func|
|
|
237
|
+
if func.instance_of? Function
|
|
238
|
+
if func.is_printed? == false
|
|
239
|
+
b_all_printed = false
|
|
240
|
+
break
|
|
241
|
+
# else
|
|
242
|
+
# print "#{name} : printed\n"
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
}
|
|
246
|
+
return b_all_printed
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
#=== @call_func を update する
|
|
250
|
+
# @call_func の右辺は、構文解釈中に設定されるが、不完全である
|
|
251
|
+
# 完全になるように更新する
|
|
252
|
+
# サマリー表示の場合には必要だが、ツリー表示の場合、処理の途中で更新するので不要
|
|
253
|
+
# summarize の中でやると分かりにくくなるので、独立させた
|
|
254
|
+
def self.update
|
|
255
|
+
# print "updating: "
|
|
256
|
+
@@Function_list.each{ |name,func|
|
|
257
|
+
# print name, ", "
|
|
258
|
+
if func.instance_of? Function
|
|
259
|
+
func.update
|
|
260
|
+
end
|
|
261
|
+
}
|
|
262
|
+
# print "\n"
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def update
|
|
266
|
+
@call_func.each { |name, func|
|
|
267
|
+
if func.instance_of? Function # 関数名重複の場合、前のものを忘れない方が、よりよい(恐らく)
|
|
268
|
+
next
|
|
269
|
+
end
|
|
270
|
+
func = @@Function_list[name]
|
|
271
|
+
if func.instance_of? Function
|
|
272
|
+
@call_func[name]=func
|
|
273
|
+
func.referenced self
|
|
274
|
+
end
|
|
275
|
+
}
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
#=== サマリー表示
|
|
279
|
+
def self.print_summarize
|
|
280
|
+
self.update
|
|
281
|
+
# print "==== summary mode (all functions called from top level function)\n"
|
|
282
|
+
self.print_summarize0 false
|
|
283
|
+
if ! self.all_printed?
|
|
284
|
+
# print "===== recursive functions\n"
|
|
285
|
+
self.print_summarize0 true
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def self.print_summarize0 b_unprinted
|
|
290
|
+
funcs = @@Function_list.keys.sort{ |a,b| a.to_s <=> b.to_s }
|
|
291
|
+
funcs.each {|name|
|
|
292
|
+
func = @@Function_list[name]
|
|
293
|
+
if func.instance_of? Function
|
|
294
|
+
if ! b_unprinted
|
|
295
|
+
next if ! func.is_top?
|
|
296
|
+
else
|
|
297
|
+
next if func.is_printed?
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
@@ref_function_list = {}
|
|
301
|
+
@@ref_global_var_list = {}
|
|
302
|
+
func.summarize
|
|
303
|
+
#print name
|
|
304
|
+
locale = func.get_locale
|
|
305
|
+
#printf( "() <%s:%d>\n", locale[0], locale[1] )
|
|
306
|
+
if @@ref_function_list.length > 0
|
|
307
|
+
#print " Calling Function Summary:\n"
|
|
308
|
+
ref_funcs = @@ref_function_list.keys.sort{ |a,b| a.to_s <=> b.to_s }
|
|
309
|
+
ref_funcs.each { |name|
|
|
310
|
+
function = @@ref_function_list[name]
|
|
311
|
+
#print " "
|
|
312
|
+
#print name
|
|
313
|
+
if function.instance_of? Function
|
|
314
|
+
locale = function.get_locale
|
|
315
|
+
#printf( "() <%s:%d>\n", locale[0], locale[1] )
|
|
316
|
+
else
|
|
317
|
+
#print "() not defined\n"
|
|
318
|
+
end
|
|
319
|
+
}
|
|
320
|
+
end
|
|
321
|
+
if @@ref_global_var_list.length > 0
|
|
322
|
+
#print " Global Vars Summary:\n"
|
|
323
|
+
vars = @@ref_global_var_list.keys.sort{ |a,b| a.to_s <=> b.to_s }
|
|
324
|
+
vars.each{ |name|
|
|
325
|
+
count_array = @@ref_global_var_list[name]
|
|
326
|
+
#print " "
|
|
327
|
+
#print name
|
|
328
|
+
#printf( " [R:%dW:%d]\n", count_array[0]-count_array[1], count_array[1] )
|
|
329
|
+
}
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
}
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def summarize
|
|
336
|
+
@global_var.each { |name, count_array|
|
|
337
|
+
count_array2 = @@ref_global_var_list[name]
|
|
338
|
+
if count_array2
|
|
339
|
+
count_array2[0] += count_array[0]
|
|
340
|
+
count_array2[1] += count_array[1]
|
|
341
|
+
else
|
|
342
|
+
@@ref_global_var_list[name] = count_array.clone
|
|
343
|
+
end
|
|
344
|
+
}
|
|
345
|
+
@call_func.each { |name, function|
|
|
346
|
+
next if @@ref_function_list[name] # カウント済み
|
|
347
|
+
@@ref_function_list[name] = function
|
|
348
|
+
if function.instance_of? Function
|
|
349
|
+
function.summarize
|
|
350
|
+
end
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
@b_printed = true
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
##############
|
|
357
|
+
def is_local_var? var
|
|
358
|
+
# p "#{var}, #{@local_var[ var ]}, #{@param_var[ var ]}"
|
|
359
|
+
##ここで@local_var[var]が真にならない
|
|
360
|
+
if @local_var[ var ] || @param_var[ var ]
|
|
361
|
+
return true #local or param
|
|
362
|
+
else
|
|
363
|
+
return false #global
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def is_top?
|
|
368
|
+
@b_ref == false
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def is_printed?
|
|
372
|
+
@b_printed
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
def get_locale
|
|
376
|
+
@locale
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
def self.dump_funclist dump_file_name
|
|
380
|
+
p "Dump Funclist"
|
|
381
|
+
mar = Marshal.dump @@Function_list
|
|
382
|
+
File.write( dump_file_name, mar )
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
def self.load_funclist dump_file_name
|
|
386
|
+
mar_in = File.read( dump_file_name )
|
|
387
|
+
@@Function_list = Marshal.load( mar_in )
|
|
388
|
+
return @@Function_list
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
def self.list_all_functions
|
|
392
|
+
#print "==== function list\n"
|
|
393
|
+
funcs = @@Function_list.keys.sort{ |a,b| a.to_s <=> b.to_s }
|
|
394
|
+
funcs.each { |name|
|
|
395
|
+
if @@Function_list[name].instance_of? Function
|
|
396
|
+
func = @@Function_list[name]
|
|
397
|
+
func.print_func
|
|
398
|
+
else
|
|
399
|
+
#printf( "%-20s: %-s\n", name, "not defined" )
|
|
400
|
+
end
|
|
401
|
+
}
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
def set_printed
|
|
405
|
+
@b_printed = true
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
def print_func
|
|
409
|
+
#if @ref_func
|
|
410
|
+
# ref_func = @ref_func.get_name
|
|
411
|
+
#else
|
|
412
|
+
ref_func = ""
|
|
413
|
+
#end
|
|
414
|
+
#printf( "%-20s: %-30s line: %d %s\n", @name, @locale[0], @locale[1], ref_func )
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
def get_name
|
|
418
|
+
@name
|
|
419
|
+
end
|
|
420
|
+
end # class
|
|
421
|
+
end # module
|
data/lib/tecsgen.rb
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# TECS Generator
|
|
4
|
+
# Generator for TOPPERS Embedded Component System
|
|
5
|
+
#
|
|
6
|
+
# Copyright (C) 2008-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: tecsgen.rb 2780 2018-02-11 11:22:33Z okuma-top $
|
|
38
|
+
#++
|
|
39
|
+
|
|
40
|
+
#= tecsgen : TECS のジェネレータ
|
|
41
|
+
#
|
|
42
|
+
# Authors:: 石川 拓也(HRP2Plugin)
|
|
43
|
+
# Authors:: 原 拓(動的結合仕様)
|
|
44
|
+
# Authors:: 河田 智明(NotifierPlugin)
|
|
45
|
+
# Authors:: 高田 広章(ASP3 への TECS 組込み)
|
|
46
|
+
# Authors:: 高木 信尚(ランタイムヘッダ)
|
|
47
|
+
# Authors:: 成瀬 有美(TECS flow 実装)
|
|
48
|
+
# Authors:: 鵜飼 敬幸(ATK1Plugin)
|
|
49
|
+
# Authors:: 大山 博司(ジェネレータ実装, RPCPlugin, TracePlugin, MrubyBridgePlugin)
|
|
50
|
+
# Authors:: 山本 将也(ジェネレータ初期プロトタイプ実装)
|
|
51
|
+
# Authors:: 小南 靖雄(テストコードの一部)
|
|
52
|
+
# Authors:: 安積 卓也(ASP+TECS, EV3RT+TECS, mruby on TECS等実装)
|
|
53
|
+
# Authors list is in i-ro-ha order.
|
|
54
|
+
# Version:: see version.rb
|
|
55
|
+
|
|
56
|
+
# This doesn't work as expected in exerb version (Ruby 1.8.7?)
|
|
57
|
+
$tecsgen_base_path = File.dirname(File.expand_path __FILE__)
|
|
58
|
+
|
|
59
|
+
require "tecsgen/version"
|
|
60
|
+
|
|
61
|
+
###
|
|
62
|
+
#= Array initializer の '{', '}' で囲まれた場合
|
|
63
|
+
# mikan AggregateInitializer など、クラスを変更すべきである
|
|
64
|
+
class Array
|
|
65
|
+
#=== CDL の文字列を生成する
|
|
66
|
+
def to_CDL_str
|
|
67
|
+
str = "{ "
|
|
68
|
+
delim = ""
|
|
69
|
+
self.each{|v|
|
|
70
|
+
str += delim + v.to_CDL_str
|
|
71
|
+
delim = ", "
|
|
72
|
+
}
|
|
73
|
+
str += " }"
|
|
74
|
+
return str
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def show_tree(indent)
|
|
78
|
+
indent.times{ print " " }
|
|
79
|
+
print("Array\n")
|
|
80
|
+
self.each{|m|
|
|
81
|
+
m.show_tree(indent + 1)
|
|
82
|
+
}
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
#=== RUBY ライブラリをロードする
|
|
87
|
+
#
|
|
88
|
+
# -L, $RUBYLIB, システム(/usr/lib/rub..など) の順にサーチが行われる
|
|
89
|
+
# exerb 対応のため、上記パスにファイルが見つからない場合 require を実行してみる
|
|
90
|
+
#
|
|
91
|
+
# プラグインの場合は b_fatal = false を指定。ファイルがなくてもエラー出力後、処理続行
|
|
92
|
+
# b_fatal = false の場合 tecslib/core がサーチパスに追加される
|
|
93
|
+
# RETURN::Bool : true=成功、 false=失敗 失敗した場合、Generator.error は呼び元で出力する
|
|
94
|
+
def require_tecsgen_lib(fname, b_fatal = true)
|
|
95
|
+
dbgPrint("require_lib: #{fname}\n")
|
|
96
|
+
begin
|
|
97
|
+
b_require = false
|
|
98
|
+
b_exception = false
|
|
99
|
+
|
|
100
|
+
# -L 、 $RUBYLIB で指定されたパスおよびシステムのパスからサーチ
|
|
101
|
+
# exerb では $LOAD_PATH は ["."] のみ入っているようだ
|
|
102
|
+
($library_path + $LOAD_PATH).each{|path|
|
|
103
|
+
["", "tecslib/plugin/"].each {|lp|
|
|
104
|
+
lib = File.expand_path(path) + "/" + lp + fname
|
|
105
|
+
|
|
106
|
+
if File.exist? lib # ファイル存否と他のエラーを区別するため存在確認をする
|
|
107
|
+
begin
|
|
108
|
+
require(lib)
|
|
109
|
+
b_require = true
|
|
110
|
+
rescue Exception => evar
|
|
111
|
+
b_exception = true
|
|
112
|
+
print_exception(evar)
|
|
113
|
+
end
|
|
114
|
+
break
|
|
115
|
+
end
|
|
116
|
+
}
|
|
117
|
+
if b_require
|
|
118
|
+
break
|
|
119
|
+
end
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if b_require == false && b_exception == false
|
|
123
|
+
# exerb 対応 "." をサーチパスの最初に加える
|
|
124
|
+
# "tecslib/" は RPCPlugin.rb, TracePlugin.rb のために用意してある
|
|
125
|
+
# RPCPlugin.rb, TracePlugin.rb が tecslib 下でなければ不要になるが、このようにしておく
|
|
126
|
+
["", "tecslib/plugin/"].each{|lp|
|
|
127
|
+
path = lp + fname
|
|
128
|
+
begin
|
|
129
|
+
require path
|
|
130
|
+
return true
|
|
131
|
+
rescue LoadError => e
|
|
132
|
+
# p "LoadError to load #{fname}"
|
|
133
|
+
# 2015.12.18 exerb 版でプラグインのロードでエラーが出るので、無視する. おそらく昔からエラーは出ていた
|
|
134
|
+
# print_exception( e )
|
|
135
|
+
rescue Exception => e
|
|
136
|
+
b_exception = true
|
|
137
|
+
# 文法エラーなどが発生
|
|
138
|
+
print_exception(e)
|
|
139
|
+
break
|
|
140
|
+
end
|
|
141
|
+
}
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
if b_require == false
|
|
145
|
+
# 見つからなかった
|
|
146
|
+
if b_exception == false
|
|
147
|
+
STDERR << "tecsgen: Fail to load #{fname}. Check $RUBYLIB environment variable or -L option\n"
|
|
148
|
+
end
|
|
149
|
+
# tecsgen を構成するファイルの場合は中止する
|
|
150
|
+
if b_fatal
|
|
151
|
+
STDERR << "tecsgen: Exit because of unrecoverble error\n"
|
|
152
|
+
exit 1
|
|
153
|
+
end
|
|
154
|
+
return false
|
|
155
|
+
end
|
|
156
|
+
return true
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
#=== 例外の表示
|
|
161
|
+
# evar:: Exception
|
|
162
|
+
def print_exception(evar)
|
|
163
|
+
# もしスタックトレースが出るまでい時間がかかるようならば、次をコメントアウトしてみるべし
|
|
164
|
+
print "*** Begin Ruby exception message ***\n"
|
|
165
|
+
puts(evar.to_s)
|
|
166
|
+
|
|
167
|
+
if $debug
|
|
168
|
+
puts "#### stack trace ####"
|
|
169
|
+
pp evar.backtrace
|
|
170
|
+
end
|
|
171
|
+
print "*** End Ruby exception message ***\n"
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def dbgPrint(str)
|
|
175
|
+
if $debug
|
|
176
|
+
print str
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def dbgPrintf(*param)
|
|
181
|
+
if $debug
|
|
182
|
+
printf(*param)
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
#=== エラーおよび警告のレポート
|
|
187
|
+
def print_report
|
|
188
|
+
msg = nil
|
|
189
|
+
|
|
190
|
+
if Generator.get_n_error != 0
|
|
191
|
+
msg = "#{Generator.get_n_error} error"
|
|
192
|
+
msg = "#{msg}s" if Generator.get_n_error >= 2
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
if Generator.get_n_warning != 0
|
|
196
|
+
msg = "#{msg} " if msg
|
|
197
|
+
msg = "#{msg}#{Generator.get_n_warning} warning"
|
|
198
|
+
msg = "#{msg}s" if Generator.get_n_warning >= 2
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
puts msg if msg
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
#----- class TECSGEN -------#
|
|
205
|
+
class TECSGEN
|
|
206
|
+
@@current_tecsgen = nil
|
|
207
|
+
|
|
208
|
+
def self.init(addtional_option_parser = nil)
|
|
209
|
+
initialize_global_var
|
|
210
|
+
analyze_option addtional_option_parser
|
|
211
|
+
load_modules
|
|
212
|
+
setup unless $TECSFLOW
|
|
213
|
+
|
|
214
|
+
dbgPrint "tecspath: #{$tecsgen_base_path}, __FILE__=#{__FILE__}\n"
|
|
215
|
+
dbgPrint "ARGV(remained): #{ARGV}, argments=#{$arguments}\n"
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
#----- initialize -------#
|
|
219
|
+
def initialize
|
|
220
|
+
@cell_list = nil
|
|
221
|
+
@cell_list2 = nil
|
|
222
|
+
@celltype_list = nil
|
|
223
|
+
@root_namespace = nil
|
|
224
|
+
|
|
225
|
+
#--- obsolete ---# replaced to TOOL_INFO
|
|
226
|
+
@cell_location_list = []
|
|
227
|
+
@join_location_list = []
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def run1
|
|
231
|
+
@@current_tecsgen = self
|
|
232
|
+
|
|
233
|
+
syntax_analisys ARGV
|
|
234
|
+
semantics_analisys_1
|
|
235
|
+
semantics_analisys_2
|
|
236
|
+
|
|
237
|
+
@celltype_list = Celltype.get_celltype_list
|
|
238
|
+
@cell_list = Cell.get_cell_list
|
|
239
|
+
@cell_list2 = Cell.get_cell_list2
|
|
240
|
+
|
|
241
|
+
@@current_tecsgen = nil
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def run2
|
|
245
|
+
@@current_tecsgen = self
|
|
246
|
+
|
|
247
|
+
optimize_and_generate
|
|
248
|
+
finalize
|
|
249
|
+
|
|
250
|
+
@@current_tecsgen = nil
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
#----- initialize_global_var -----#
|
|
254
|
+
def self.initialize_global_var
|
|
255
|
+
require "optparse"
|
|
256
|
+
require "pp"
|
|
257
|
+
|
|
258
|
+
### グローバル変数定義 ###
|
|
259
|
+
|
|
260
|
+
# コマンドライン引数 (Makefile.templ へ出力)
|
|
261
|
+
$arguments = ""
|
|
262
|
+
ARGV.each {|a| $arguments += " " + a }
|
|
263
|
+
|
|
264
|
+
$unopt = false # bool: disable optimizing both call and entry port
|
|
265
|
+
$unopt_entry = false # bool: disable optimizing entry port
|
|
266
|
+
$gen_base = "gen" # string: folder path to place generated files
|
|
267
|
+
$gen = $gen_base # string: folder path to place generated files
|
|
268
|
+
$generate_all_template = false # bool: generarete template files for all celltypes (if non cell exist or system celltypes)
|
|
269
|
+
$generate_no_template = false # bool: generarete no template file (neither celltype code nor Makefile)
|
|
270
|
+
$idx_is_id = false # bool: all components are idx_is_id
|
|
271
|
+
$unique_id = false # bool: assign unique id to each cell (otherwise begin from 1 for each celltype)
|
|
272
|
+
$debug = false # bool: tecsgen debug message
|
|
273
|
+
$dryrun = false # bool: dryrun mode: syntax is checked, but not generate any files
|
|
274
|
+
$show_tree = false # bool: show parsing tree
|
|
275
|
+
$verbose = false # bool: verbose mode: show some messages
|
|
276
|
+
$yydebug = false # bool: yydebug: parser debug mode (need bnf-deb.tab.rb)
|
|
277
|
+
$run_dir = Dir.pwd # string: tecsgen/tecscde start up directory
|
|
278
|
+
$base_dir = { } # string=>bool: base dir for import_path (key:base_dir, val:actually used or specified directly)
|
|
279
|
+
$import_path = ["."] # string array : import/import_C path
|
|
280
|
+
$import_path_opt = [] # [String]
|
|
281
|
+
$library_path = [$tecsgen_base_path] # string array : path to dir where tecsgen.rb placed
|
|
282
|
+
$define = [] # string array : define
|
|
283
|
+
$ram_initializer = false # bool: generate ram initializer
|
|
284
|
+
$region_list = {} # string array : region path which is generated
|
|
285
|
+
$generating_region = nil # Region: Region to optimisze & generate code # コマンドラインオプションではない
|
|
286
|
+
# Cell#is_generate? にて参照される
|
|
287
|
+
$unit_test = false # bool: unit test verification
|
|
288
|
+
$kcode = nil # nil | String: Kanji code type "euc"|"sjis"|"none"|"utf8"
|
|
289
|
+
$force_overwrite = false # bool: force overwrite all files if file contents not differ
|
|
290
|
+
$no_banner = false # bool: not print banner
|
|
291
|
+
$print_version = false # bool: print version
|
|
292
|
+
$target = "tecs" # String: target name, ARGV[0] から再設定する("tecs" は仮のターゲット)
|
|
293
|
+
$no_default_import_path = false # bool: no default import path
|
|
294
|
+
$c_suffix = "c" # suffix for C progorams (for C++ source)
|
|
295
|
+
$h_suffix = "h" # suffix for C progoram headers (for C++ source)
|
|
296
|
+
|
|
297
|
+
if ENV["TECSGEN_DEFAULT_RAM"]
|
|
298
|
+
rom_ram_defalult = "ram"
|
|
299
|
+
else
|
|
300
|
+
rom_ram_defalult = "rom"
|
|
301
|
+
end
|
|
302
|
+
if rom_ram_defalult == "rom"
|
|
303
|
+
$rom = true # bool: ROM support : generate CB separately
|
|
304
|
+
else
|
|
305
|
+
$rom = false # bool: ROM support : generate CB separately
|
|
306
|
+
end
|
|
307
|
+
$b_cpp_specified = false
|
|
308
|
+
if $cpp.nil?
|
|
309
|
+
$cpp = "gcc -E -DTECSGEN"
|
|
310
|
+
end
|
|
311
|
+
if ENV["TECS_CPP"]
|
|
312
|
+
$cpp = ENV["TECS_CPP"]
|
|
313
|
+
$b_cpp_specified = true
|
|
314
|
+
end
|
|
315
|
+
if ENV["TECSPATH"]
|
|
316
|
+
$tecspath = ENV["TECSPATH"]
|
|
317
|
+
else
|
|
318
|
+
$tecspath = "#{$tecsgen_base_path}/tecs"
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
# 文字コードの設定
|
|
322
|
+
$ENCODING_CDL = Encoding::EUC_JP # const: NONE には ASCII を対応させる
|
|
323
|
+
$ENCODING_TECSGEN = Encoding::UTF_8 # const:
|
|
324
|
+
end # initialize_global_var
|
|
325
|
+
|
|
326
|
+
def self.analyze_option(additional_option_parser)
|
|
327
|
+
### tecsgen コマンドオプション解析 ###
|
|
328
|
+
ARGV.options {|parser|
|
|
329
|
+
parser.banner = "Usage: tecsgen [options] files"
|
|
330
|
+
parser.on("-D", "--define=def", "define cpp symbol for import_C") {|define|
|
|
331
|
+
$define << define
|
|
332
|
+
}
|
|
333
|
+
parser.on("-G", "--generate-region=path", "generate region") {|path|
|
|
334
|
+
if path =~ /^::/
|
|
335
|
+
gen_path = path
|
|
336
|
+
else
|
|
337
|
+
gen_path = "::" + path
|
|
338
|
+
end
|
|
339
|
+
$region_list[gen_path] = true
|
|
340
|
+
}
|
|
341
|
+
parser.on("-I", "--import-path=path", "imoprt/import_C path") {|path|
|
|
342
|
+
$import_path << path
|
|
343
|
+
$import_path_opt << path
|
|
344
|
+
}
|
|
345
|
+
parser.on("-L", "--library-path=path", "path to dir where tecsgen.rb (obsolete, unnecessary to specify -L, those passes are gotten from tecsgen.rb") {|path|
|
|
346
|
+
$library_path << path
|
|
347
|
+
}
|
|
348
|
+
parser.on("-R", "--RAM-initializer", "generate RAM initializer. INITIALIZE_TECS() must be called before running any TECS code."){
|
|
349
|
+
$ram_initializer = true
|
|
350
|
+
}
|
|
351
|
+
parser.on("-U", "--unoptimize", "unoptimize") {
|
|
352
|
+
$unopt = true
|
|
353
|
+
}
|
|
354
|
+
parser.on("--unoptimize-entry", "unoptimize entry port") {
|
|
355
|
+
$unopt_entry = true
|
|
356
|
+
}
|
|
357
|
+
parser.on("-c", "--cpp=cpp_cmd", "C pre-processor command used import_C (default: gcc -E -DTECSGEN), you can also specify by environment variable TECS_CPP"){|arg|
|
|
358
|
+
$cpp = arg
|
|
359
|
+
$b_cpp_specified = true
|
|
360
|
+
}
|
|
361
|
+
parser.on("-d", "--dryrun", "dryrun"){
|
|
362
|
+
$dryrun = true
|
|
363
|
+
}
|
|
364
|
+
parser.on("-f", "--force-overwrite", "force overwrite all files") {
|
|
365
|
+
$force_overwrite = true
|
|
366
|
+
}
|
|
367
|
+
parser.on("-g", "--gen=dir", "generate dir") {|dir|
|
|
368
|
+
$gen = $gen_base = dir
|
|
369
|
+
}
|
|
370
|
+
parser.on("-i", "--idx_is_id", "set idx_is_id to all celltypes") {
|
|
371
|
+
$idx_is_id = true
|
|
372
|
+
}
|
|
373
|
+
# parser.on('-k', '--kcode=code', 'set kanji code: euc|sjis|none|utf8, none is default') { |code|
|
|
374
|
+
parser.on("-k", "--kcode=code", "set kanji code: euc|sjis|none|utf8") {|code|
|
|
375
|
+
$kcode = code
|
|
376
|
+
}
|
|
377
|
+
# old_mode は V1.0.C.22 で廃止
|
|
378
|
+
# parser.on('-o', '--old-mode', 'old mode' ){
|
|
379
|
+
# $old_mode = true
|
|
380
|
+
# }
|
|
381
|
+
parser.on("-r", "--ram", "RAM only"){
|
|
382
|
+
$rom = false
|
|
383
|
+
}
|
|
384
|
+
parser.on("-s", "--show-tree", "show parsing tree"){
|
|
385
|
+
$show_tree = true
|
|
386
|
+
}
|
|
387
|
+
parser.on("-t", "--generator-debug", "generator debug"){
|
|
388
|
+
$debug = true
|
|
389
|
+
$verbose = true
|
|
390
|
+
}
|
|
391
|
+
parser.on("-u", "--unique-id", "assign unique id for each cell"){
|
|
392
|
+
$unique_id = true
|
|
393
|
+
}
|
|
394
|
+
parser.on("-v", "--verbose", "verbose mode"){
|
|
395
|
+
$verbose = true
|
|
396
|
+
}
|
|
397
|
+
parser.on("-y", "--yydebug", "yydebug"){
|
|
398
|
+
$yydebug = true
|
|
399
|
+
}
|
|
400
|
+
parser.on("--no-banner", "not display banner") {
|
|
401
|
+
$no_banner = true
|
|
402
|
+
}
|
|
403
|
+
parser.on("--version", "print version") {
|
|
404
|
+
$print_version = true
|
|
405
|
+
}
|
|
406
|
+
parser.on("--unit-test", "unit verification (test tecsgen itself)") {
|
|
407
|
+
$unit_test = true
|
|
408
|
+
}
|
|
409
|
+
parser.on("--generate-all-template", "generate all celltypes' templates") {
|
|
410
|
+
$generate_all_template = true
|
|
411
|
+
}
|
|
412
|
+
parser.on("--generate-no-template", "generate no template") {
|
|
413
|
+
$generate_no_template = true
|
|
414
|
+
}
|
|
415
|
+
parser.on("--no-default-import-path", "no default import path"){
|
|
416
|
+
$no_default_import_path = true
|
|
417
|
+
}
|
|
418
|
+
parser.on("--c-suffix=c", "C program suffix (default: c)"){| suffix |
|
|
419
|
+
$c_suffix = suffix
|
|
420
|
+
}
|
|
421
|
+
parser.on("--h-suffix=h", "C program header suffix (default: h)"){| suffix |
|
|
422
|
+
$h_suffix = suffix
|
|
423
|
+
}
|
|
424
|
+
# parser.on( '--include_path_opt_format', 'cpp include path option format, default: "-I %s"' ){
|
|
425
|
+
# }
|
|
426
|
+
parser.version = # {TECSGEN::VERSION}
|
|
427
|
+
parser.release = nil
|
|
428
|
+
if additional_option_parser
|
|
429
|
+
additional_option_parser.call(parser)
|
|
430
|
+
end
|
|
431
|
+
parser.parse!
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if ARGV.empty? && !$print_version && !$unit_test && !$TECSFLOW
|
|
435
|
+
ARGV.options{|parser|
|
|
436
|
+
puts parser.help
|
|
437
|
+
exit 1
|
|
438
|
+
}
|
|
439
|
+
end
|
|
440
|
+
end # analyze_option
|
|
441
|
+
|
|
442
|
+
def self.load_modules
|
|
443
|
+
### tecsgen モジュールのロード ####
|
|
444
|
+
# -L でパス指定可能としたため、ここからロードを開始する
|
|
445
|
+
|
|
446
|
+
# tecsgen バージョンファイルのロード
|
|
447
|
+
# これを実行するまで tecsgen のバージョンを表示できない
|
|
448
|
+
# このファイルを誤って読み込むと、異なるバージョン名を表示してしまう
|
|
449
|
+
require "tecsgen/version"
|
|
450
|
+
if $tecscde_version
|
|
451
|
+
STDERR << "tecscde version #{$tecscde_version} (tecsgen version #{TECSGEN::VERSION}) #{TECSGEN::COPYRIGHT}\n"
|
|
452
|
+
elsif !$no_banner || $print_version
|
|
453
|
+
STDERR << "tecsgen version #{TECSGEN::VERSION} #{TECSGEN::COPYRIGHT}\n"
|
|
454
|
+
end
|
|
455
|
+
if $verbose
|
|
456
|
+
STDERR << "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE} patchlevel #{RUBY_PATCHLEVEL}) [#{RUBY_PLATFORM}]\n"
|
|
457
|
+
end
|
|
458
|
+
if $print_version && ARGV.empty? && !$TECSFLOW
|
|
459
|
+
exit
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
# 文字コード決定のため最初に読みこむ
|
|
463
|
+
require "tecsgen/core/tecs_lang"
|
|
464
|
+
|
|
465
|
+
unless $yydebug
|
|
466
|
+
require "tecsgen/core/bnf.tab"
|
|
467
|
+
else
|
|
468
|
+
require "tecsgen/core/bnf-deb.tab"
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
# syntaxobj.rb には Node が定義されているので、早い段階で require
|
|
472
|
+
require "tecsgen/core/syntaxobj"
|
|
473
|
+
require "tecsgen/core/pluginModule"
|
|
474
|
+
require "tecsgen/core/plugin"
|
|
475
|
+
require "tecsgen/core/messages"
|
|
476
|
+
require "tecsgen/core/types"
|
|
477
|
+
require "tecsgen/core/value"
|
|
478
|
+
require "tecsgen/core/componentobj"
|
|
479
|
+
require "tecsgen/core/expression"
|
|
480
|
+
require "tecsgen/core/optimize"
|
|
481
|
+
require "tecsgen/core/tecsgen"
|
|
482
|
+
require "tecsgen/core/generate"
|
|
483
|
+
require "tecsgen/core/gen_xml"
|
|
484
|
+
require "tecsgen/core/location"
|
|
485
|
+
require "tecsgen/core/tool_info"
|
|
486
|
+
require "tecsgen/core/tecsinfo"
|
|
487
|
+
require "tecsgen/core/unjoin_plugin"
|
|
488
|
+
require "tecsgen/plugin/CelltypePlugin"
|
|
489
|
+
require "tecsgen/plugin/CompositePlugin"
|
|
490
|
+
require "tecsgen/plugin/CellPlugin"
|
|
491
|
+
require "tecsgen/plugin/SignaturePlugin"
|
|
492
|
+
require "tecsgen/plugin/ThroughPlugin"
|
|
493
|
+
require "tecsgen/plugin/DomainPlugin"
|
|
494
|
+
require "tecsgen/plugin/MultiPlugin"
|
|
495
|
+
|
|
496
|
+
# C 言語パーサ
|
|
497
|
+
require "tecsgen/core/C_parser.tab"
|
|
498
|
+
require "tecsgen/core/ctypes"
|
|
499
|
+
|
|
500
|
+
if $unit_test
|
|
501
|
+
exit 1
|
|
502
|
+
end
|
|
503
|
+
end # load_modules
|
|
504
|
+
|
|
505
|
+
def self.setup
|
|
506
|
+
# $import_path に環境変数 $TECSGEN およびその直下を追加
|
|
507
|
+
if $no_default_import_path == false
|
|
508
|
+
# $TECSGEN および、その直下のディレクトリをパスに追加
|
|
509
|
+
if $tecspath != "."
|
|
510
|
+
TECSGEN.add_import_path $tecspath
|
|
511
|
+
dir = nil
|
|
512
|
+
begin
|
|
513
|
+
Dir.foreach($tecspath){|f|
|
|
514
|
+
if f != "." && f != ".." && File.directory?($tecspath + "/" + f)
|
|
515
|
+
TECSGEN.add_import_path($tecspath + "/" + f)
|
|
516
|
+
end
|
|
517
|
+
}
|
|
518
|
+
rescue
|
|
519
|
+
# 無視
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
# デフォルト設定
|
|
525
|
+
TECSGEN.set_default_config
|
|
526
|
+
|
|
527
|
+
# $target の設定
|
|
528
|
+
$target = ARGV[0]
|
|
529
|
+
pos = $target.rindex(/[:\\\/]/)
|
|
530
|
+
if pos
|
|
531
|
+
$target = $target[pos + 1..-1] # ディレクトリ区切りを除いた文字列
|
|
532
|
+
end
|
|
533
|
+
pos = $target.rindex(/\./)
|
|
534
|
+
if pos
|
|
535
|
+
$target = $target[0..pos - 1] # 拡張子を取り除いた文字列
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
# gen ディレクトリの作成
|
|
539
|
+
begin
|
|
540
|
+
if !File.directory?($gen_base)
|
|
541
|
+
Dir.mkdir($gen_base)
|
|
542
|
+
end
|
|
543
|
+
rescue
|
|
544
|
+
print("Cannot mkdir #{$gen_base}. If the path has hierarchy, please create directory by manual.\n")
|
|
545
|
+
exit 1
|
|
546
|
+
end
|
|
547
|
+
end # setup
|
|
548
|
+
|
|
549
|
+
#=== TECSGEN#get_celltype_list
|
|
550
|
+
def get_celltype_list
|
|
551
|
+
@celltype_list
|
|
552
|
+
end
|
|
553
|
+
|
|
554
|
+
#=== TECSGEN#get_cell_list
|
|
555
|
+
def get_cell_list
|
|
556
|
+
@cell_list
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
def get_root_namespace
|
|
560
|
+
@root_namespace
|
|
561
|
+
end
|
|
562
|
+
end # TECSGEN
|
|
563
|
+
|
|
564
|
+
# 複数のジェネレータインスタンスを生成することは、可能だが、以下の問題がある
|
|
565
|
+
# クラス変数のリセットを確実に行う必要がある
|
|
566
|
+
|
|
567
|
+
if $TECSCDE != true && $TECSFLOW != true
|
|
568
|
+
begin
|
|
569
|
+
TECSGEN.init
|
|
570
|
+
tecsgen = TECSGEN.new
|
|
571
|
+
tecsgen.run1
|
|
572
|
+
tecsgen.run2
|
|
573
|
+
tecsgen.dump_tecsgen_rbdmp
|
|
574
|
+
rescue => evar
|
|
575
|
+
print_exception(evar)
|
|
576
|
+
STDERR << "tecsgen: exit because of unrecoverble error.\n"
|
|
577
|
+
STDERR << " please retry after resolve early error.\n"
|
|
578
|
+
STDERR << " if no error has occured, please report to TOPPERS TECS WG (users@toppers.jp or com-wg@toppers.jp).\n"
|
|
579
|
+
exit 1
|
|
580
|
+
end
|
|
581
|
+
end
|