1 | # -*- coding: utf-8 -*-
|
---|
2 | #
|
---|
3 | # TECS Generator
|
---|
4 | # Generator for TOPPERS Embedded Component System
|
---|
5 | #
|
---|
6 | # Copyright (C) 2015 by Ushio Laboratory
|
---|
7 | # Graduate School of Engineering Science, Osaka Univ., JAPAN
|
---|
8 | # Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory
|
---|
9 | # Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
10 | # Copyright (C) 2015-2018 by TOPPERS Project
|
---|
11 | #
|
---|
12 | #--
|
---|
13 | # ä¸è¨èä½æ¨©è
|
---|
14 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
15 | # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
16 | # å¤ã»åé
|
---|
17 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
18 | # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
19 | # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
20 | # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
21 | # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
22 | # ç¨ã§ããå½¢ã§åé
|
---|
23 | å¸ããå ´åã«ã¯ï¼åé
|
---|
24 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
25 | # è
|
---|
26 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
27 | # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
28 | # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
29 | # ç¨ã§ããªãå½¢ã§åé
|
---|
30 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
31 | # ã¨ï¼
|
---|
32 | # (a) åé
|
---|
33 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
34 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
35 | # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
36 | # (b) åé
|
---|
37 | å¸ã®å½¢æ
|
---|
38 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
39 | # å ±åãããã¨ï¼
|
---|
40 | # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
41 | # 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
42 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
43 | 責ãããã¨ï¼
|
---|
44 | # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
45 | # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
46 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
47 | # å
|
---|
48 | 責ãããã¨ï¼
|
---|
49 | #
|
---|
50 | # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
51 | ã
|
---|
52 | # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
53 | # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
54 | # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
55 | # ã®è²¬ä»»ãè² ããªãï¼
|
---|
56 | #
|
---|
57 | # $Id$
|
---|
58 | #++
|
---|
59 |
|
---|
60 | NotifierPluginArgProc = {
|
---|
61 | "factory" => Proc.new { |obj, rhs| obj.set_factory(rhs) },
|
---|
62 | "output_file" => Proc.new { |obj, rhs| obj.set_factory_output_file(rhs) }
|
---|
63 | }
|
---|
64 |
|
---|
65 | class NotifierPlugin < CelltypePlugin
|
---|
66 |
|
---|
67 | # ---------- ã¢ããã¿é¢æ°ã®çæ -------------
|
---|
68 | #
|
---|
69 | # siHandlerBodyã®åãå£é¢æ°ã¯ï¼ã¿ã¤ã ã¤ãã³ãéç¥ã®éç¥å
|
---|
70 | ã¨ãã¦ç´æ¥æå®ãã
|
---|
71 | # ãã¨ã¯ã§ããªãï¼ã·ã°ããã£ãä¸è´ãã¦ããªããã¨ãçç±ã§ããï¼ãã®ããï¼ã¢ã
|
---|
72 | # ãã¿ã¨ãã¦åä½ããé¢æ°ãçæãï¼ã«ã¼ãã«ããã®å¼åºããTECSã®å¼åºãã«å¤æã§
|
---|
73 | # ããããã«ããå¿
|
---|
74 | è¦ãããï¼
|
---|
75 | #
|
---|
76 | # åºæ¬çã«ã¯ï¼åãå£æ¯ã«ã¢ããã¿é¢æ°ãçæããã°ååã§ããï¼ãããï¼ããã§ã¯
|
---|
77 | # ã¡ã¢ãªæ¶è²»éãä¸å¿
|
---|
78 | è¦ã«å¢å ãã¦ãã¾ãï¼ããã§ï¼éç¥å
|
---|
79 | é¢æ°ã«intptr_tåã®å¼æ°
|
---|
80 | # ã渡ãããã¨ã«çç®ãï¼é¢æ°ã®"ä¸è¬å"ãå³ãï¼ããªãã¡åãå£ã®ããå±æ§(ãã
|
---|
81 | # ã§ã¯ï¼çµåå
|
---|
82 | ã®ã»ã«ï¼æ·»åãªã©ãæã)ãï¼ã¢ããã¿é¢æ°ã®å¼æ°ã¨ãã¦åãåãã
|
---|
83 | # ããã«ãï¼1åã®ã¢ããã¿é¢æ°ã2å以ä¸ã®çµåã«å¯¾ãç¨ãããã¨ãã§ããããã«
|
---|
84 | # ããï¼
|
---|
85 | #
|
---|
86 | # ã¢ããã¿é¢æ°ã®å±æ§ã«ã¤ãã¦æ´çããã¨ï¼
|
---|
87 | # - åãå£é¢æ° - ä¸è¬åãè¡ãã¨ï¼å®è¡æã³ã¹ãã大ããå¢å¤§ãã¦ãã¾ããã¨ã
|
---|
88 | # 確èªããã¦ããï¼ãã®ããï¼ä¸è¬åã¯è¡ããªãï¼EntryPropertyã«ãå«ããªãï¼
|
---|
89 | # - ã»ã«ã¤ã³ããã¯ã¹ - CELLIDXåã§ï¼åã®è¦å®ã¯ãªããï¼"ããã¤ã³ã¿å¤ã¦ããã£ãã
|
---|
90 | # æ´æ°å¤ã¦ããã£ããããã" (TECS 5.3.6) ããï¼ã¤ã³ããã¯ã¹ããã¤ã³ã¿ãã
|
---|
91 | # ãã¨ãåããï¼ã¤ã³ããã¯ã¹ã ã¨ããã¨ï¼ãã®å¤ã¯ã»ã«CBã®ã¢ãã¬ãã·ã³ã°ã«
|
---|
92 | # 使ç¨ãããã®ã§ï¼intptr_tã«åã¾ãçã§ããï¼ãã¤ã³ã¿ã®å ´åï¼å½ç¶intptr_t
|
---|
93 | # ã«åã¾ãï¼
|
---|
94 | # - åãå£é
|
---|
95 | åã®æ·»å - int_tï¼åæ§ã«intptr_tã«åã¾ãçã§ããï¼
|
---|
96 | # ãããã®ãã¡ï¼ã»ã«ã¤ã³ããã¯ã¹ã¨åãå£é
|
---|
97 | åã®æ·»åã¯ãã©ã¡ã¼ã¿ã«å«ãããã¨ã
|
---|
98 | # ã§ãããã§ãããï¼ä¸¡æ¹ã¯ç¡çã§ããï¼
|
---|
99 | # 両æ¹ãæ ¼ç´ããé
|
---|
100 | åãçæãï¼ãã®é
|
---|
101 | åã®è¦ç´ ã¸ã®ãã¤ã³ã¿ã渡ãããã«ããã¨ã
|
---|
102 | # ãé¸æè¢ãå¯è½ã§ãããï¼å®è¡é度ãåªå
|
---|
103 | ããããã«ï¼ãã®æ¹æ³ã¯ã¨ããªãã£ãï¼
|
---|
104 | #
|
---|
105 | # ãã®ããï¼ä¸è¬åã¯ä»¥ä¸ã®ãã¿ã¼ã³ã«åé¡ãã¦è¡ãï¼
|
---|
106 | #
|
---|
107 | # 1. ã»ã«ã¤ã³ããã¯ã¹ã®ã¿ä¸è¬åï¼ã»ã«ã¤ã³ããã¯ã¹ã®ãã¿ã¼ã³æ°ãåãå£é
|
---|
108 | åã®
|
---|
109 | # æ·»åã®ãã¿ã¼ã³æ°ããå¤ããï¼ãããã¯åãå£ãé
|
---|
110 | åã§ãªãå ´åã«è¡ãããï¼
|
---|
111 | # 2. åãå£é
|
---|
112 | åã®æ·»åã®ã¿ä¸è¬åï¼ãã®å ´åï¼ã»ã«ãã¨ã«ç°ãªãé¢æ°ãç¨ããï¼
|
---|
113 | #
|
---|
114 | # ããããï¼ååãå£é¢æ°ã«ã¤ãã¦ï¼ã¢ããã¿é¢æ°ã®çæåæ°ã¯ï¼
|
---|
115 | # O(min{ã»ã«ã¤ã³ããã¯ã¹ã®ãã¿ã¼ã³æ°, æ·»åã®ãã¿ã¼ã³æ°})
|
---|
116 | # ã¨ãªãï¼
|
---|
117 | #
|
---|
118 | # ãã©ã°ã¤ã³ã§ã®å¦çãã¯ã³ãã¹ã§è¡ãããã«ï¼tecsgen.cfgã§ã¯ã¢ããã¿é¢æ°ãç´
|
---|
119 | # æ¥æå®ããã®ã§ã¯ãªãï¼ä»£ããã«ã¢ããã¿é¢æ°ã表ããã¯ãã使ç¨ããï¼ãã®
|
---|
120 | # ãã¯ãã¯ã¢ããã¿é¢æ°ãã³ãã«ã¨å¼ã¶ãã¨ã«ããï¼
|
---|
121 | # ã¢ããã¿é¢æ°ãã³ãã«ã¯ï¼æ¬¡ã®2åã®è¦ç´ ããæãï¼
|
---|
122 | # - ã¢ããã¿é¢æ°ã¸ã®ã®ãã¤ã³ã¿
|
---|
123 | # - ã¢ããã¿é¢æ°ã®å¼æ°
|
---|
124 | #
|
---|
125 | # $Id$
|
---|
126 |
|
---|
127 | # @private
|
---|
128 | class AdapterGenerator
|
---|
129 |
|
---|
130 | # çµåå
|
---|
131 | ã«é¢ããå±æ§ãå«ãï¼ã»ã«ï¼åãå£é
|
---|
132 | åã®æ·»åããæãï¼
|
---|
133 | # åä¸ã®EntryPropertyã¨ãªãçµåã¯ï¼å
|
---|
134 | ¨ãåãæ¹æ³ã§ãã®åãå£é¢æ°ãå¼ã³
|
---|
135 | # åºããï¼
|
---|
136 | # @private
|
---|
137 | class EntryProperty
|
---|
138 | # @return [Cell] åãå£å´ã®ã»ã«ï¼
|
---|
139 | attr_reader :cell
|
---|
140 |
|
---|
141 | # @return [Integer, nil] åãå£é
|
---|
142 | åã®æ·»åï¼é
|
---|
143 | åã§ãªãå ´åã¯nilï¼
|
---|
144 | attr_reader :subscript
|
---|
145 |
|
---|
146 | def initialize(cell, subscript)
|
---|
147 | @cell = cell
|
---|
148 | @subscript = subscript
|
---|
149 | end
|
---|
150 |
|
---|
151 | def self.from_join(join)
|
---|
152 | EntryProperty.new(join.get_rhs_cell, join.get_rhs_subscript)
|
---|
153 | end
|
---|
154 |
|
---|
155 | # åå¤æ§ã®å®ç¾©ï¼Hashã®ãã¼ã¨ãã¦ä½¿ç¨ããã®ã«å¿
|
---|
156 | è¦ï¼
|
---|
157 | def eql?(o) @cell == o.cell && @subscript == o.subscript end
|
---|
158 | def hash() @cell.hash ^ @subscript.hash end
|
---|
159 | end
|
---|
160 |
|
---|
161 | # @private
|
---|
162 | class EntryPort
|
---|
163 | # @param [Port] port çµåå
|
---|
164 | ã®ã»ã«ã®ã»ã«ã¿ã¤ãã®åãå£ï¼
|
---|
165 | def initialize(port, prefix)
|
---|
166 | @port = port
|
---|
167 | @global_name = "#{prefix}_#{@port.get_celltype.get_global_name}_#{@port.get_name}"
|
---|
168 |
|
---|
169 | # åãå£é¢æ°åï¼siHandlerBodyãæ³å®ãã¦ããã®ã§ï¼é¢æ°åã¯mainã§åºå®ã§ããï¼
|
---|
170 | @entry_fn_name = "#{@port.get_celltype.get_global_name}_#{@port.get_name}_main"
|
---|
171 |
|
---|
172 | @props = [] # Array<EntryProperty>
|
---|
173 | @prop_map = {} # Hash<EntryProperty, Integer>
|
---|
174 | end
|
---|
175 |
|
---|
176 | # @return [String] ã°ãã¼ãã«ã«ä¸æ(ãªãã®ã¨ãã¦æ±ãããã)ãªèå¥åï¼
|
---|
177 | attr_reader :global_name
|
---|
178 |
|
---|
179 | # @return [Port]
|
---|
180 | attr_reader :port
|
---|
181 |
|
---|
182 | # æå®ããEntryPropertyã«å¯¾å¿ããã¢ããã¿é¢æ°ãã³ãã«ãåå¾ããï¼
|
---|
183 | # @param [EntryProperty] ep
|
---|
184 | # @return [String] ã¢ããã¿é¢æ°ãã³ãã«ï¼
|
---|
185 | # @private
|
---|
186 | def adapter_handle_for_entry_property(ep)
|
---|
187 | index = @prop_map.fetch(ep)
|
---|
188 | return [
|
---|
189 | "#{@global_name}_#{index}_fp",
|
---|
190 | "#{@global_name}_#{index}_arg"
|
---|
191 | ]
|
---|
192 | end
|
---|
193 |
|
---|
194 | # çµåå
|
---|
195 | ã®æ
|
---|
196 | å ±ã«å¿ããã¢ããã¿é¢æ°ãã½ã¼ã¹ã»ãããã¼ã«åºåããï¼
|
---|
197 | # ä¸è¬åæå®ã¯ï¼`cell`ã¾ãã¯`subscript`ã®ä¸æ¹ã®ã¿è¡ããã¨ãã§ããï¼
|
---|
198 | #
|
---|
199 | # @param [AdapterGenerator] context
|
---|
200 | # @param [String] fn_name é¢æ°åï¼
|
---|
201 | # @param [Cell, Symbol] cell ã»ã«ï¼ã»ã«ã«ã¤ãã¦ä¸è¬åããå ´å㯠`:generic`
|
---|
202 | # @param [Integer, Symbol, nil] subscript æ·»åï¼æ·»åã«ã¤ãã¦ä¸è¬åããå ´å㯠`:generic`
|
---|
203 | # @param [Celltype] å¼ã³å
|
---|
204 | ã®ã»ã«ã¿ã¤ããcell==:generic ã®å ´åã®ã¿æå¹
|
---|
205 | # @private
|
---|
206 | def generate_inner(context, fn_name, cell, subscript, callee_ct=nil)
|
---|
207 | source_file = context.source_file
|
---|
208 | header_file = context.header_file
|
---|
209 |
|
---|
210 | source_file.print "void #{fn_name}(intptr_t extinf) {\n"
|
---|
211 |
|
---|
212 | params = []
|
---|
213 | ct = @port.get_celltype
|
---|
214 |
|
---|
215 | # ã·ã³ã°ã«ãã³ã»ã«ã¿ã¤ã以å¤ã§ã¯ï¼CELLIDXã®æå®ãå¿
|
---|
216 | è¦ï¼
|
---|
217 | unless ct.is_singleton?
|
---|
218 | if cell == :generic
|
---|
219 | params << "(#{callee_ct.get_global_name}_IDX)extinf"
|
---|
220 | # params << "(CELLIDX)extinf"
|
---|
221 | else
|
---|
222 | # ã»ã«ã®CELLIDXãå¾ã
|
---|
223 | if ct.has_INIB? || ct.has_CB?
|
---|
224 | params << ct.get_name_array(cell)[7]
|
---|
225 | else
|
---|
226 | params << "0"
|
---|
227 | end
|
---|
228 | end
|
---|
229 | end
|
---|
230 |
|
---|
231 | # åãå£é
|
---|
232 | åã®æ·»åï¼
|
---|
233 | if @port.get_array_size
|
---|
234 | if subscript == :generic
|
---|
235 | params << "(int_t)extinf"
|
---|
236 | else
|
---|
237 | params << "#{subscript}"
|
---|
238 | end
|
---|
239 | end
|
---|
240 |
|
---|
241 | params_str = params.join(", ")
|
---|
242 |
|
---|
243 | source_file.print "\t#{@entry_fn_name}(#{params_str});\n"
|
---|
244 | source_file.print "}\n\n"
|
---|
245 |
|
---|
246 | header_file.print "extern void #{fn_name}(intptr_t extinf);\n\n"
|
---|
247 |
|
---|
248 | end
|
---|
249 |
|
---|
250 | # æå®ããJoinã«å¯¾å¿ããã¢ããã¿é¢æ°ãã³ãã«ãåå¾ããï¼
|
---|
251 | # @return [Array] ã¢ããã¿é¢æ°ãã³ãã«ï¼
|
---|
252 | def make_adapter_handle(join)
|
---|
253 | prop = EntryProperty.from_join(join)
|
---|
254 | unless @prop_map.has_key?(prop)
|
---|
255 | @prop_map[prop] = @props.length
|
---|
256 | @props << prop
|
---|
257 | end
|
---|
258 | return adapter_handle_for_entry_property(prop)
|
---|
259 | end
|
---|
260 |
|
---|
261 | # ã½ã¼ã¹ã»ãããã¼ã®è¨è¿°ãçæããï¼
|
---|
262 | # @param [AdapterGenerator] context
|
---|
263 | def generate(context)
|
---|
264 | header_file = context.header_file
|
---|
265 | return if @props.empty?
|
---|
266 |
|
---|
267 | ct = @port.get_celltype
|
---|
268 |
|
---|
269 | header_file.print "/*\n * #{@global_name}\n"
|
---|
270 |
|
---|
271 | cells = @props.group_by { |prop| prop.cell }
|
---|
272 | subscripts = @props.group_by { |prop| prop.subscript }
|
---|
273 | no_cellidx = false
|
---|
274 | if !(ct.has_INIB? || ct.has_CB?)
|
---|
275 | # CB, INIBæé©åã«ããï¼CB, INIBã両æ¹ä¸è¦ã«ãªã£ãã±ã¼ã¹ï¼
|
---|
276 | # CELLIDXãä¸è¦ã§ããã®ã§ï¼ã»ã«ã«ã¤ãã¦ä¸è¬åãã¦ãæå³
|
---|
277 | # ã¯ãªãã®ã§ï¼æ·»åã«ããä¸è¬åãé¸æããï¼
|
---|
278 | generalize_by_cell_idx = false
|
---|
279 | no_cellidx = true
|
---|
280 |
|
---|
281 | # å
|
---|
282 | ¨ã¦ã®ã»ã«ãåä¸è¦ããï¼
|
---|
283 | cells = { @props[0].cell => @props }
|
---|
284 |
|
---|
285 | header_file.print " * No INIB & CB: generalized by subscript\n"
|
---|
286 | elsif @port.get_array_size
|
---|
287 | # ä¸è¬åãã¿ã¼ã³ã®åé¡ãè¡ãããã«ï¼åãå£å´ã»ã«ãæ·»åã®
|
---|
288 | # ãã¿ã¼ã³æ°ãåæãã¦ï¼æé©ãªæ¹ãé¸æããï¼
|
---|
289 | generalize_by_cell_idx = cells.length >= subscripts.length
|
---|
290 | if generalize_by_cell_idx
|
---|
291 | header_file.print " * more cells than subscripts: generalized by cell\n"
|
---|
292 | else
|
---|
293 | header_file.print " * more subscripts than cells: generalized by subscript\n"
|
---|
294 | end
|
---|
295 | else
|
---|
296 | # 常ã«CELLIDXã§ä¸è¬å
|
---|
297 | generalize_by_cell_idx = true
|
---|
298 | header_file.print " * non-array entry port: generalized by cell\n"
|
---|
299 | end
|
---|
300 |
|
---|
301 | header_file.print " */\n\n"
|
---|
302 |
|
---|
303 | if generalize_by_cell_idx
|
---|
304 | # CELLIDXã«ã¤ãã¦ä¸è¬å
|
---|
305 | subscripts.each { |subscript, props|
|
---|
306 | if subscript
|
---|
307 | fn_name = "#{@global_name}_adap_#{subscript}"
|
---|
308 | else
|
---|
309 | # åãå£é
|
---|
310 | åã§ãªãå ´å
|
---|
311 | fn_name = "#{@global_name}_adap"
|
---|
312 | end
|
---|
313 |
|
---|
314 | generate_inner context, fn_name,
|
---|
315 | :generic, subscript, ct
|
---|
316 |
|
---|
317 | props.each { |prop|
|
---|
318 | handle = adapter_handle_for_entry_property(prop)
|
---|
319 |
|
---|
320 | # ã»ã«ã®CELLIDXãå¾ã
|
---|
321 | if ct.has_INIB? || ct.has_CB?
|
---|
322 | idx = ct.get_name_array(prop.cell)[7]
|
---|
323 | else
|
---|
324 | idx = "0"
|
---|
325 | end
|
---|
326 | header_file.print "\#define #{handle[0]} &#{fn_name}\n"
|
---|
327 | header_file.print "\#define #{handle[1]} #{idx}\n\n"
|
---|
328 | }
|
---|
329 | }
|
---|
330 | else
|
---|
331 | # æ·»åã«ã¤ãã¦ä¸è¬å
|
---|
332 | cells.each { |cell, props|
|
---|
333 | if no_cellidx
|
---|
334 | # CB/INIB ãªã
|
---|
335 | fn_name = "#{@global_name}_adap"
|
---|
336 | else
|
---|
337 | fn_name = "#{@global_name}_adap_#{cell.get_global_name}"
|
---|
338 | end
|
---|
339 |
|
---|
340 | generate_inner context, fn_name,
|
---|
341 | cell, :generic
|
---|
342 |
|
---|
343 | props.each { |prop|
|
---|
344 | handle = adapter_handle_for_entry_property(prop)
|
---|
345 |
|
---|
346 | header_file.print "\#define #{handle[0]} &#{fn_name}\n"
|
---|
347 | header_file.print "\#define #{handle[1]} #{prop.subscript || 0}\n\n"
|
---|
348 | }
|
---|
349 | }
|
---|
350 | end
|
---|
351 | end
|
---|
352 | end
|
---|
353 |
|
---|
354 | # @private
|
---|
355 | attr :source_file
|
---|
356 |
|
---|
357 | # @private
|
---|
358 | attr :header_file
|
---|
359 |
|
---|
360 | # @param [String] celltype_name ãã³ãã©é¢æ°ã®ã»ã«ã¿ã¤ãï¼
|
---|
361 | # @param [String] prefix ååè¡çªãé²ãããã®ãã¬ãã£ãã¯ã¹ï¼
|
---|
362 | def initialize(celltype_name, prefix)
|
---|
363 | @celltype_name = celltype_name
|
---|
364 | @prefix = prefix
|
---|
365 |
|
---|
366 | # Hash<Port, EntryPort>
|
---|
367 | @entry_ports = {}
|
---|
368 | end
|
---|
369 |
|
---|
370 | # ===AdapterGenerator#make_adapter_handle===
|
---|
371 | # æå®ããçµåã®å¼åºããè¡ãããã®ã¢ããã¿é¢æ°ãã³ãã«ãçæããï¼
|
---|
372 | # @return [Array] ã¢ããã¿é¢æ°ãã³ãã«ï¼
|
---|
373 | def make_adapter_handle(join)
|
---|
374 | entry_port = @entry_ports[join.get_rhs_port]
|
---|
375 | unless entry_port
|
---|
376 | entry_port = EntryPort.new(join.get_rhs_port,
|
---|
377 | "#{@celltype_name}_#{@prefix}")
|
---|
378 | @entry_ports[join.get_rhs_port] = entry_port
|
---|
379 | end
|
---|
380 | return entry_port.make_adapter_handle(join)
|
---|
381 | end
|
---|
382 |
|
---|
383 | # ===AdapterGenerator#finish===
|
---|
384 | # ååãå£ã«å¯¾ãï¼ã¢ããã¿é¢æ°ãçæããï¼
|
---|
385 | def finish
|
---|
386 | @source_file = AppFile.open( "#{$gen}/#{@celltype_name}.c" )
|
---|
387 | @source_file.print "\n/* Generated by #{self.class.name} */\n\n"
|
---|
388 | @source_file.print "\#include \"#{@celltype_name}_aux.h\"\n\n"
|
---|
389 | @source_file.print "\#include \"#{@celltype_name}_tecsgen.h\"\n\n"
|
---|
390 |
|
---|
391 | @header_file = AppFile.open( "#{$gen}/#{@celltype_name}.h" )
|
---|
392 | @header_file.print "\n/* Generated by #{self.class.name} */\n\n"
|
---|
393 |
|
---|
394 | # NotifierPluginã使ç¨ããã»ã«ã¿ã¤ããè¤æ°ããå ´åï¼ããããã«
|
---|
395 | # 対ãAdapterGenerator#finishãå¼ã³åºãããï¼tTimeEventHandler.hã«
|
---|
396 | # ç¶ãã¦æ¸ãè¾¼ãã§ãã¾ãã¨ï¼ãããã¼ã¬ã¼ãã®é¢ä¿ã§2åç®ä»¥éã®è¨è¿°
|
---|
397 | # ãèªã¿è¾¼ã¾ããªããªã£ã¦ãã¾ãï¼ãã®ããï¼ãã¡ã¤ã«å + ã»ã«ã¿ã¤ãå
|
---|
398 | # ã¨ããå°ãç¹æ®ãªãããã¼ã¬ã¼ããç¨ããï¼
|
---|
399 | header_guard = "#{@celltype_name}_H_#{@prefix}"
|
---|
400 |
|
---|
401 | @header_file.print "\#ifndef #{header_guard}\n"
|
---|
402 | @header_file.print "\#define #{header_guard}\n\n"
|
---|
403 |
|
---|
404 | # ã«ã¼ãã«ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ãå®è¡ããéï¼ãã³ãã©åãå£ã®ã»ã«ã¿ã¤ã
|
---|
405 | # ã®ã»ã«CBã®å®ç¾©ãå¿
|
---|
406 | è¦ãªå ´åãããï¼
|
---|
407 | @header_file.print "\#include \"#{@celltype_name}_aux.h\"\n\n"
|
---|
408 |
|
---|
409 | # çµåå
|
---|
410 | ã®ã»ã«ã¿ã¤ãã®å®ç¾©ã¯ï¼èªåã®ã»ã«ã®tecsgen.hãããå
|
---|
411 | ã«
|
---|
412 | # èªã¿è¾¼ã¾ãªããã°ãªããªããï¼ãã®ãã©ã°ã¤ã³ãè¤æ°å®è¡ãããã¨ï¼
|
---|
413 | # é åºãå´©ãã¦ãã¾ãï¼ããã§ï¼çµåå
|
---|
414 | ã®ã»ã«ã¿ã¤ãã®å®ç¾©ã¯ããä¸ã¤ã®
|
---|
415 | # ãããã¼ãã¡ã¤ã«(tCelltypeName_aux.h)ããèªã¿è¾¼ãããã«ããï¼
|
---|
416 | aux_header_file = AppFile.open( "#{$gen}/#{@celltype_name}_aux.h" )
|
---|
417 | aux_header_file.print "\n/* Generated by #{self.class.name} */\n\n"
|
---|
418 |
|
---|
419 | aux_header_guard = "#{@celltype_name}_AUX_H_#{@prefix}"
|
---|
420 |
|
---|
421 | aux_header_file.print "\#ifndef #{aux_header_guard}\n"
|
---|
422 | aux_header_file.print "\#define #{aux_header_guard}\n\n"
|
---|
423 |
|
---|
424 | cb_type_only_guard = "#{@celltype_name}_AUX_H_#{@prefix}_CB_TYPE_ONLY"
|
---|
425 |
|
---|
426 | # çµåå
|
---|
427 | ã®ã»ã«ã¿ã¤ãã®å®ç¾©ãèªã¿è¾¼ã
|
---|
428 | aux_header_file.print "#ifndef TOPPERS_CB_TYPE_ONLY\n"
|
---|
429 | aux_header_file.print "#define TOPPERS_CB_TYPE_ONLY\n"
|
---|
430 | aux_header_file.print "#define #{cb_type_only_guard}\n"
|
---|
431 | aux_header_file.print "#endif\n"
|
---|
432 | @entry_ports.values.map { |ep|
|
---|
433 | ep.port.get_celltype
|
---|
434 | }.uniq.each { |ct|
|
---|
435 | hname = "#{ct.get_global_name}_tecsgen.#{$h_suffix}"
|
---|
436 | aux_header_file.print "\#include \"#{hname}\"\n"
|
---|
437 | }
|
---|
438 | aux_header_file.print "#ifdef #{cb_type_only_guard}\n"
|
---|
439 | aux_header_file.print "#undef #{cb_type_only_guard}\n"
|
---|
440 | aux_header_file.print "#undef TOPPERS_CB_TYPE_ONLY\n"
|
---|
441 | aux_header_file.print "#endif\n\n"
|
---|
442 |
|
---|
443 | aux_header_file.print "\#endif\n"
|
---|
444 | aux_header_file.close
|
---|
445 |
|
---|
446 | @entry_ports.each { |port, entry_port|
|
---|
447 | entry_port.generate self
|
---|
448 | }
|
---|
449 |
|
---|
450 | @header_file.print "\#endif\n"
|
---|
451 |
|
---|
452 | @source_file.close
|
---|
453 | @header_file.close
|
---|
454 | end
|
---|
455 |
|
---|
456 | end
|
---|
457 |
|
---|
458 | # ------ éç¥ã®ãã³ãã©ã®ç¨®é¡ã®å®ç¾© -------
|
---|
459 |
|
---|
460 | class Handler
|
---|
461 | def initialize(call_port_name)
|
---|
462 | @call_port_name = call_port_name
|
---|
463 | end
|
---|
464 |
|
---|
465 | attr :call_port_name
|
---|
466 | end
|
---|
467 |
|
---|
468 | # é常ã®ãã³ãã©
|
---|
469 | EVENT_HANDLER = Handler::new("ciNotificationHandler")
|
---|
470 |
|
---|
471 | # ã¨ã©ã¼ãã³ãã© (é常ã®ãã³ãã©ã失æããå ´åã«å¼ã³åºããã)
|
---|
472 | ERROR_HANDLER = Handler::new("ciErrorNotificationHandler")
|
---|
473 |
|
---|
474 | HANDLERS = [
|
---|
475 | EVENT_HANDLER,
|
---|
476 | ERROR_HANDLER
|
---|
477 | ]
|
---|
478 |
|
---|
479 | class HandlerAttribute
|
---|
480 | def initialize(name, error_name = nil)
|
---|
481 | @name = name
|
---|
482 | @error_name = error_name || (name + 'ForError')
|
---|
483 | end
|
---|
484 |
|
---|
485 | def name_for_handler(handler)
|
---|
486 | case handler
|
---|
487 | when EVENT_HANDLER then return @name
|
---|
488 | when ERROR_HANDLER then return @error_name
|
---|
489 | else raise "unknown handler #{handler}"
|
---|
490 | end
|
---|
491 | end
|
---|
492 | end
|
---|
493 |
|
---|
494 | # ------ éç¥ã®å±æ§ã®å®ç¾© -------
|
---|
495 | #
|
---|
496 | # ãã³ãã©ã¿ã¤ãã«åè´ããªãå±æ§ãæå®ãããå ´åã«
|
---|
497 | # ã¨ã©ã¼ãåºåã§ãããããå
|
---|
498 | ¨ã¦ã®å±æ§ãããã§åæããã
|
---|
499 |
|
---|
500 | SETVAR_ADDR_ATTR = HandlerAttribute::new("setVariableAddress")
|
---|
501 | SETVAR_VALUE_ATTR = HandlerAttribute::new("setVariableValue")
|
---|
502 | INCVAR_ADDR_ATTR = HandlerAttribute::new("incrementedVariableAddress")
|
---|
503 | SNDDTQ_VALUE_ATTR = HandlerAttribute::new("dataqueueSentValue")
|
---|
504 | SETFLG_FLAG_ATTR = HandlerAttribute::new("flagPattern")
|
---|
505 |
|
---|
506 | ATTRS = [
|
---|
507 | SETVAR_ADDR_ATTR,
|
---|
508 | SETVAR_VALUE_ATTR,
|
---|
509 | INCVAR_ADDR_ATTR,
|
---|
510 | SNDDTQ_VALUE_ATTR,
|
---|
511 | SETFLG_FLAG_ATTR
|
---|
512 | ]
|
---|
513 |
|
---|
514 | # ------ ãã³ãã©ã¿ã¤ãã®å®ç¾© -------
|
---|
515 |
|
---|
516 | class BaseHandlerType
|
---|
517 |
|
---|
518 | def initialize()
|
---|
519 | super
|
---|
520 |
|
---|
521 | # HandlerAttribute[]
|
---|
522 | @required_attributes = []
|
---|
523 | end
|
---|
524 |
|
---|
525 | attr :required_attributes
|
---|
526 |
|
---|
527 | #=== NotifierPlugin#BaseHandlerType#validate_join
|
---|
528 | # æå®ããã»ã«ã®çµåå
|
---|
529 | ãããã®ãã³ãã©ã¿ã¤ãã«è©²å½ããããæ¤è¨¼
|
---|
530 | # handler:: Handler : ãã³ãã©
|
---|
531 | # cell:: Cell : ã»ã«
|
---|
532 | # join:: Join : çµå (declarationãPortã§ãããã®)
|
---|
533 | def validate_join(handler, cell, join)
|
---|
534 | return !generate_attr_map(handler, cell).nil?
|
---|
535 | end
|
---|
536 |
|
---|
537 | #=== NotifierPlugin#BaseHandlerType#generate_attr_map
|
---|
538 | # æå®ããã»ã«ã®å±æ§ã¨ãæ¢ç¥ã®HandlerAttributeã®ãããã³ã°ã
|
---|
539 | # çæããHash<HandlerAttribute, Join> (åå±æ§ã¨ããã«å¯¾å¿ãã
|
---|
540 | # Join(declarationãDeclã®ãã®)ã表ãHash)ããããã¯ã
|
---|
541 | # ãããã³ã°ãè¡ããªãå ´å(å±æ§ã®ä¸è¶³ãéå°)ã¯nilãè¿ãã
|
---|
542 | #
|
---|
543 | # handler:: Handler : ãã³ãã©
|
---|
544 | # cell:: Cell : ã»ã«
|
---|
545 | def generate_attr_map(handler, cell)
|
---|
546 | map = {}
|
---|
547 |
|
---|
548 | join_list = cell.get_join_list
|
---|
549 |
|
---|
550 | ATTRS.each { |known_attr|
|
---|
551 | attr_name = known_attr.name_for_handler(handler)
|
---|
552 | join = join_list.get_item(attr_name.to_sym)
|
---|
553 |
|
---|
554 | # ãã®ã»ã«ã¿ã¤ãã«ããã¦å¿
|
---|
555 | é ã®å±æ§ã?
|
---|
556 | is_required = @required_attributes.include?(known_attr)
|
---|
557 |
|
---|
558 | # å±æ§ã®æå®ãä¸è¶³ãã¦ãã? or éå°?
|
---|
559 | # 注: ãã³ãã©ã¿ã¤ãã®å¤å¥ã«ã¯ãã»ã«ã§å¤ãæå®ããã¦ããã
|
---|
560 | # ãèæ
|
---|
561 | ®ããããã»ã«ã¿ã¤ãã§åæå¤ãæå®ããã¦ãã¦ãã
|
---|
562 | # ããã¯ãã³ãã©ã¿ã¤ãã®æ±ºå®ã«å½±é¿ããªãã
|
---|
563 | return nil if join.nil? != !is_required
|
---|
564 |
|
---|
565 | # å¿
|
---|
566 | è¦ã®ãªãå±æ§ã§ãããæå®ãããã¦ããªãã®ã§é£ã°ã
|
---|
567 | next if join.nil?
|
---|
568 |
|
---|
569 | # TODO: attrã®çµåã§ãããã¨ãæ¤è¨¼
|
---|
570 |
|
---|
571 | map[known_attr] = join
|
---|
572 | }
|
---|
573 |
|
---|
574 | return map
|
---|
575 | end
|
---|
576 |
|
---|
577 | #=== NotifierPlugin#BaseHandlerType#gen_cfg_handler_type
|
---|
578 | # ã¿ã¤ã ã¤ãã³ãã®éç¥ã®ç¨®é¡ã表ãã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã®è¨è¿°ãçæããStringã¾ãã¯nilãè¿ã
|
---|
579 | # handler:: Handler : ãã³ãã©
|
---|
580 | def gen_cfg_handler_type(handler)
|
---|
581 | raise "called abstract method gen_cfg_handler_type"
|
---|
582 | end
|
---|
583 |
|
---|
584 | #=== NotifierPlugin#BaseHandlerType#gen_cfg_handler_parameters
|
---|
585 | # ã¿ã¤ã ã¤ãã³ãã®éç¥ã®å¼æ°ã表ãã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã®è¨è¿°ãçæããString[]ãè¿ã
|
---|
586 | # handler:: Handler : ãã³ãã©
|
---|
587 | # join:: Join : çµå (declarationãPortã§ãããã®)
|
---|
588 | # attrMap:: Hash<HandlerAttribute, Join> :
|
---|
589 | # åå±æ§ã¨ããã«å¯¾å¿ããJoin (declarationãDeclã®ãã®)
|
---|
590 | # cell:: Cell : ã»ã«
|
---|
591 | # adpt_gen:: AdapterGenerator : ã¢ããã¿é¢æ°ãçæãããªãã¸ã§ã¯ã
|
---|
592 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
593 | return nil
|
---|
594 | end
|
---|
595 |
|
---|
596 | #=== NotifierPlugin#BaseHandlerType#might_fail
|
---|
597 | # éç¥ã®éãã¨ã©ã¼ãçºçãããã®çµæã¨ã©ã¼éç¥ãå¼ã¶å¿
|
---|
598 | è¦ãçãã
|
---|
599 | # ãã©ãããè¿ãã
|
---|
600 | def might_fail
|
---|
601 | return false
|
---|
602 | end
|
---|
603 |
|
---|
604 | end
|
---|
605 | class BaseTaskHandlerType < BaseHandlerType
|
---|
606 | def validate_join(handler, cell, join, *args)
|
---|
607 | return super(handler, cell, join, *args) &&
|
---|
608 | join && join.get_rhs_cell.get_celltype.get_name == :tTask
|
---|
609 | end
|
---|
610 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
611 | taskCell = join.get_cell
|
---|
612 | id_attr_join = taskCell.get_join_list.get_item(:id)
|
---|
613 | id_attr = join.get_rhs_cell.get_celltype.find(:id)
|
---|
614 | if id_attr_join
|
---|
615 | # ã»ã«çææã«åæåããå ´å
|
---|
616 | id = id_attr_join.get_rhs.to_s
|
---|
617 | else
|
---|
618 | # ã»ã«ã¿ã¤ãã®åæåå¤ã使ãå ´å
|
---|
619 | id = id_attr.get_initializer.to_s
|
---|
620 | end
|
---|
621 |
|
---|
622 | # $id$çã®ç½®æ
|
---|
623 | name_array = taskCell.get_celltype.get_name_array(taskCell)
|
---|
624 | id = taskCell.get_celltype.subst_name(id, name_array)
|
---|
625 |
|
---|
626 | return [id]
|
---|
627 | end
|
---|
628 | def might_fail
|
---|
629 | return true
|
---|
630 | end
|
---|
631 | end
|
---|
632 | class ActivateTaskHandlerType < BaseTaskHandlerType
|
---|
633 | def validate_join(handler, cell, join, *args)
|
---|
634 | return super(handler, cell, join, *args) &&
|
---|
635 | join.get_port_name == :eiActivateNotificationHandler
|
---|
636 | end
|
---|
637 | def gen_cfg_handler_type(handler)
|
---|
638 | case handler
|
---|
639 | when EVENT_HANDLER then return "TNFY_ACTTSK"
|
---|
640 | when ERROR_HANDLER then return "TENFY_ACTTSK"
|
---|
641 | else raise "unknown handler #{handler}"
|
---|
642 | end
|
---|
643 | end
|
---|
644 | end
|
---|
645 | class WakeUpTaskHandlerType < BaseTaskHandlerType
|
---|
646 | def validate_join(handler, cell, join, *args)
|
---|
647 | return super(handler, cell, join, *args) &&
|
---|
648 | join.get_port_name == :eiWakeUpNotificationHandler
|
---|
649 | end
|
---|
650 | def gen_cfg_handler_type(handler)
|
---|
651 | case handler
|
---|
652 | when EVENT_HANDLER then return "TNFY_WUPTSK"
|
---|
653 | when ERROR_HANDLER then return "TENFY_WUPTSK"
|
---|
654 | else raise "unknown handler #{handler}"
|
---|
655 | end
|
---|
656 | end
|
---|
657 | end
|
---|
658 | class SetVariableHandlerType < BaseHandlerType
|
---|
659 | def initialize()
|
---|
660 | super
|
---|
661 | @required_attributes = [
|
---|
662 | SETVAR_ADDR_ATTR,
|
---|
663 | SETVAR_VALUE_ATTR
|
---|
664 | ] # .to_set
|
---|
665 | end
|
---|
666 | def validate_join(handler, cell, join, *args)
|
---|
667 | return super(handler, cell, join, *args) &&
|
---|
668 | join.nil? &&
|
---|
669 | handler == EVENT_HANDLER
|
---|
670 | end
|
---|
671 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
672 | var_addr = attrMap[SETVAR_ADDR_ATTR].get_rhs.to_s
|
---|
673 | var_value = attrMap[SETVAR_VALUE_ATTR].get_rhs.to_s
|
---|
674 |
|
---|
675 | # $id$çã®ç½®æ
|
---|
676 | name_array = cell.get_celltype.get_name_array(cell)
|
---|
677 | var_addr = cell.get_celltype.subst_name(var_addr, name_array)
|
---|
678 | var_value = cell.get_celltype.subst_name(var_value, name_array)
|
---|
679 |
|
---|
680 | return [var_addr, var_value]
|
---|
681 | end
|
---|
682 | def gen_cfg_handler_type(handler)
|
---|
683 | case handler
|
---|
684 | when EVENT_HANDLER then return "TNFY_SETVAR"
|
---|
685 | else raise "unknown handler #{handler}"
|
---|
686 | end
|
---|
687 | end
|
---|
688 | end
|
---|
689 | class SetVariableToErrorCodeHandlerType < BaseHandlerType
|
---|
690 | def initialize()
|
---|
691 | super
|
---|
692 | @required_attributes = [
|
---|
693 | SETVAR_ADDR_ATTR
|
---|
694 | ] # .to_set
|
---|
695 | end
|
---|
696 | def validate_join(handler, cell, join, *args)
|
---|
697 | return super(handler, cell, join, *args) &&
|
---|
698 | join.nil? &&
|
---|
699 | handler == ERROR_HANDLER
|
---|
700 | end
|
---|
701 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
702 | var_addr = attrMap[SETVAR_ADDR_ATTR].get_rhs.to_s
|
---|
703 |
|
---|
704 | # $id$çã®ç½®æ
|
---|
705 | name_array = cell.get_celltype.get_name_array(cell)
|
---|
706 | var_addr = cell.get_celltype.subst_name(var_addr, name_array)
|
---|
707 |
|
---|
708 | return [var_addr]
|
---|
709 | end
|
---|
710 | def gen_cfg_handler_type(handler)
|
---|
711 | case handler
|
---|
712 | when ERROR_HANDLER then return "TENFY_SETVAR"
|
---|
713 | else raise "unknown handler #{handler}"
|
---|
714 | end
|
---|
715 | end
|
---|
716 | end
|
---|
717 | class IncrementVariableHandlerType < BaseHandlerType
|
---|
718 | def initialize()
|
---|
719 | super
|
---|
720 | @required_attributes = [
|
---|
721 | INCVAR_ADDR_ATTR
|
---|
722 | ] # .to_set
|
---|
723 | end
|
---|
724 | def validate_join(handler, cell, join, *args)
|
---|
725 | return super(handler, cell, join, *args) &&
|
---|
726 | join.nil?
|
---|
727 | end
|
---|
728 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
729 | var_addr = attrMap[INCVAR_ADDR_ATTR].get_rhs.to_s
|
---|
730 |
|
---|
731 | # $id$çã®ç½®æ
|
---|
732 | name_array = cell.get_celltype.get_name_array(cell)
|
---|
733 | var_addr = cell.get_celltype.subst_name(var_addr, name_array)
|
---|
734 |
|
---|
735 | return [var_addr]
|
---|
736 | end
|
---|
737 | def gen_cfg_handler_type(handler)
|
---|
738 | case handler
|
---|
739 | when EVENT_HANDLER then return "TNFY_INCVAR"
|
---|
740 | when ERROR_HANDLER then return "TENFY_INCVAR"
|
---|
741 | else raise "unknown handler #{handler}"
|
---|
742 | end
|
---|
743 | end
|
---|
744 | end
|
---|
745 | class SignalSemaphoreHandlerType < BaseHandlerType
|
---|
746 | def validate_join(handler, cell, join, *args)
|
---|
747 | return super(handler, cell, join, *args) &&
|
---|
748 | join && join.get_rhs_cell.get_celltype.get_name == :tSemaphore
|
---|
749 | end
|
---|
750 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
751 | semaphoreCell = join.get_cell
|
---|
752 | id_attr_join = semaphoreCell.get_join_list.get_item(:id)
|
---|
753 | id_attr = join.get_rhs_cell.get_celltype.find(:id)
|
---|
754 | if id_attr_join
|
---|
755 | # ã»ã«çææã«åæåããå ´å
|
---|
756 | id = id_attr_join.get_rhs.to_s
|
---|
757 | else
|
---|
758 | # ã»ã«ã¿ã¤ãã®åæåå¤ã使ãå ´å
|
---|
759 | id = id_attr.get_initializer.to_s
|
---|
760 | end
|
---|
761 |
|
---|
762 | # $id$çã®ç½®æ
|
---|
763 | name_array = semaphoreCell.get_celltype.get_name_array(semaphoreCell)
|
---|
764 | id = semaphoreCell.get_celltype.subst_name(id, name_array)
|
---|
765 |
|
---|
766 | return [id]
|
---|
767 | end
|
---|
768 | def might_fail
|
---|
769 | return true
|
---|
770 | end
|
---|
771 | def gen_cfg_handler_type(handler)
|
---|
772 | case handler
|
---|
773 | when EVENT_HANDLER then return "TNFY_SIGSEM"
|
---|
774 | when ERROR_HANDLER then return "TENFY_SIGSEM"
|
---|
775 | else raise "unknown handler #{handler}"
|
---|
776 | end
|
---|
777 | end
|
---|
778 | end
|
---|
779 | class SetEventflagHandlerType < BaseHandlerType
|
---|
780 | def initialize()
|
---|
781 | super
|
---|
782 | @required_attributes = [
|
---|
783 | SETFLG_FLAG_ATTR
|
---|
784 | ] # .to_set
|
---|
785 | end
|
---|
786 | def validate_join(handler, cell, join, *args)
|
---|
787 | return super(handler, cell, join, *args) &&
|
---|
788 | join && join.get_rhs_cell.get_celltype.get_name == :tEventflag
|
---|
789 | end
|
---|
790 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
791 | eventflagCell = join.get_cell
|
---|
792 | id_attr_join = eventflagCell.get_join_list.get_item(:id)
|
---|
793 | id_attr = join.get_rhs_cell.get_celltype.find(:id)
|
---|
794 | if id_attr_join
|
---|
795 | # ã»ã«çææã«åæåããå ´å
|
---|
796 | id = id_attr_join.get_rhs.to_s
|
---|
797 | else
|
---|
798 | # ã»ã«ã¿ã¤ãã®åæåå¤ã使ãå ´å
|
---|
799 | id = id_attr.get_initializer.to_s
|
---|
800 | end
|
---|
801 | flg_pattern = attrMap[SETFLG_FLAG_ATTR].get_rhs.to_s
|
---|
802 |
|
---|
803 | # $id$çã®ç½®æ
|
---|
804 | name_array = eventflagCell.get_celltype.get_name_array(eventflagCell)
|
---|
805 | id = eventflagCell.get_celltype.subst_name(id, name_array)
|
---|
806 |
|
---|
807 | name_array = cell.get_celltype.get_name_array(cell)
|
---|
808 | flg_pattern = cell.get_celltype.subst_name(flg_pattern, name_array)
|
---|
809 |
|
---|
810 | return [id, flg_pattern]
|
---|
811 | end
|
---|
812 | def might_fail
|
---|
813 | return true
|
---|
814 | end
|
---|
815 | def gen_cfg_handler_type(handler)
|
---|
816 | case handler
|
---|
817 | when EVENT_HANDLER then return "TNFY_SETFLG"
|
---|
818 | when ERROR_HANDLER then return "TENFY_SETFLG"
|
---|
819 | else raise "unknown handler #{handler}"
|
---|
820 | end
|
---|
821 | end
|
---|
822 | end
|
---|
823 | class DataqueueHandlerType < BaseHandlerType
|
---|
824 | def initialize()
|
---|
825 | super
|
---|
826 | end
|
---|
827 | def validate_join(handler, cell, join, *args)
|
---|
828 | return super(handler, cell, join, *args) &&
|
---|
829 | join && join.get_rhs_cell.get_celltype.get_name == :tDataqueue
|
---|
830 | end
|
---|
831 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
832 | dataqueueCell = join.get_cell
|
---|
833 | id_attr_join = dataqueueCell.get_join_list.get_item(:id)
|
---|
834 | id_attr = join.get_rhs_cell.get_celltype.find(:id)
|
---|
835 | if id_attr_join
|
---|
836 | # ã»ã«çææã«åæåããå ´å
|
---|
837 | id = id_attr_join.get_rhs.to_s
|
---|
838 | else
|
---|
839 | # ã»ã«ã¿ã¤ãã®åæåå¤ã使ãå ´å
|
---|
840 | id = id_attr.get_initializer.to_s
|
---|
841 | end
|
---|
842 |
|
---|
843 | # $id$çã®ç½®æ
|
---|
844 | name_array = dataqueueCell.get_celltype.get_name_array(dataqueueCell)
|
---|
845 | id = dataqueueCell.get_celltype.subst_name(id, name_array)
|
---|
846 |
|
---|
847 | name_array = cell.get_celltype.get_name_array(cell)
|
---|
848 |
|
---|
849 | return [id]
|
---|
850 | end
|
---|
851 | def might_fail
|
---|
852 | return true
|
---|
853 | end
|
---|
854 | end
|
---|
855 | class SendToDataqueueHandlerType < DataqueueHandlerType
|
---|
856 | def initialize()
|
---|
857 | super
|
---|
858 | @required_attributes = [
|
---|
859 | SNDDTQ_VALUE_ATTR
|
---|
860 | ] # .to_set
|
---|
861 | end
|
---|
862 | def validate_join(handler, cell, join, *args)
|
---|
863 | return super(handler, cell, join, *args) && handler == EVENT_HANDLER
|
---|
864 | end
|
---|
865 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
866 | params = super(handler, join, attrMap, cell, adpt_gen)
|
---|
867 |
|
---|
868 | sent_value = attrMap[SNDDTQ_VALUE_ATTR].get_rhs.to_s
|
---|
869 |
|
---|
870 | # $id$çã®ç½®æ
|
---|
871 | name_array = cell.get_celltype.get_name_array(cell)
|
---|
872 | sent_value = cell.get_celltype.subst_name(sent_value, name_array)
|
---|
873 |
|
---|
874 | params << sent_value
|
---|
875 |
|
---|
876 | return params
|
---|
877 | end
|
---|
878 | def gen_cfg_handler_type(handler)
|
---|
879 | case handler
|
---|
880 | when EVENT_HANDLER then return "TNFY_SNDDTQ"
|
---|
881 | else raise "unknown handler #{handler}"
|
---|
882 | end
|
---|
883 | end
|
---|
884 | end
|
---|
885 | class SendErrorCodeToDataqueueHandlerType < DataqueueHandlerType
|
---|
886 | def initialize()
|
---|
887 | super
|
---|
888 | end
|
---|
889 | def validate_join(handler, cell, join, *args)
|
---|
890 | return super(handler, cell, join, *args) && handler == ERROR_HANDLER
|
---|
891 | end
|
---|
892 | def gen_cfg_handler_type(handler)
|
---|
893 | case handler
|
---|
894 | when ERROR_HANDLER then return "TENFY_SNDDTQ"
|
---|
895 | else raise "unknown handler #{handler}"
|
---|
896 | end
|
---|
897 | end
|
---|
898 | end
|
---|
899 | class UserHandlerType < BaseHandlerType
|
---|
900 | def validate_join(handler, cell, join, *args)
|
---|
901 | return super(handler, cell, join, *args) &&
|
---|
902 | handler != ERROR_HANDLER && # invalid for error handler
|
---|
903 | join && join.get_rhs_cell.get_celltype.get_name == :tTimeEventHandler
|
---|
904 | end
|
---|
905 | def gen_cfg_handler_type(handler)
|
---|
906 | case handler
|
---|
907 | when EVENT_HANDLER then return "TNFY_HANDLER"
|
---|
908 | else raise "unknown handler #{handler}"
|
---|
909 | end
|
---|
910 | end
|
---|
911 | def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
|
---|
912 | # tTimeEventHandlerã®çµåå
|
---|
913 | ãåå¾
|
---|
914 | handler_cell = join.get_rhs_cell
|
---|
915 | call_join = handler_cell.get_join_list.get_item(:ciHandlerBody)
|
---|
916 |
|
---|
917 | # çµåããã¦ããªãå ´åã¯tecsgenãã¨ã©ã¼ãåºãã¯ããªã®ã§ããã§ã¯
|
---|
918 | # ã¨ã©ã¼ã«ããç¡è¦ããï¼
|
---|
919 | return [] unless call_join
|
---|
920 |
|
---|
921 | # ã¢ããã¿é¢æ°ãã³ãã«ãåå¾
|
---|
922 | adapter_handle = adpt_gen.make_adapter_handle(call_join)
|
---|
923 | return [adapter_handle[1], adapter_handle[0]]
|
---|
924 | end
|
---|
925 | end
|
---|
926 | class NullHandlerType < BaseHandlerType
|
---|
927 | def validate_join(handler, cell, join, *args)
|
---|
928 | return super(handler, cell, join, *args) &&
|
---|
929 | join.nil? &&
|
---|
930 | handler != EVENT_HANDLER # handler is mandatory for normal handler!
|
---|
931 | end
|
---|
932 | def gen_cfg_handler_type(handler)
|
---|
933 | case handler
|
---|
934 | when ERROR_HANDLER then return nil
|
---|
935 | else raise "unknown handler #{handler}"
|
---|
936 | end
|
---|
937 | end
|
---|
938 | end
|
---|
939 |
|
---|
940 | HANDLER_TYPES = [
|
---|
941 | ActivateTaskHandlerType.new,
|
---|
942 | WakeUpTaskHandlerType.new,
|
---|
943 | SetVariableHandlerType.new,
|
---|
944 | SetVariableToErrorCodeHandlerType.new,
|
---|
945 | IncrementVariableHandlerType.new,
|
---|
946 | SignalSemaphoreHandlerType.new,
|
---|
947 | SetEventflagHandlerType.new,
|
---|
948 | SendToDataqueueHandlerType.new,
|
---|
949 | SendErrorCodeToDataqueueHandlerType.new,
|
---|
950 | UserHandlerType.new,
|
---|
951 | NullHandlerType.new
|
---|
952 | ]
|
---|
953 |
|
---|
954 | #@celltype:: Celltype
|
---|
955 | #@option:: String :ãªãã·ã§ã³æåå
|
---|
956 | def initialize( celltype, option )
|
---|
957 | super
|
---|
958 | @plugin_arg_check_proc_tab = NotifierPluginArgProc
|
---|
959 | @plugin_arg_str = option
|
---|
960 | @plugin_arg_str = option.gsub( /\A"(.*)/, '\1' ) # åå¾ã® "" ãåãé¤ã
|
---|
961 | @plugin_arg_str.sub!( /(.*)"\z/, '\1' )
|
---|
962 | @factory = nil
|
---|
963 | @output_file = nil
|
---|
964 | parse_plugin_arg
|
---|
965 | unless @factory
|
---|
966 | cdl_error("NTF1003 celltype $1: option factory is not specified",
|
---|
967 | celltype.get_name)
|
---|
968 | end
|
---|
969 | unless @output_file
|
---|
970 | cdl_error("NTF1003 celltype $1: option output_file is not specified",
|
---|
971 | celltype.get_name)
|
---|
972 | end
|
---|
973 | end
|
---|
974 |
|
---|
975 | def set_factory(template_string)
|
---|
976 | unless @factory.nil?
|
---|
977 | cdl_error("NTF1003 celltype $1: option factory was specified more than once",
|
---|
978 | celltype.get_name)
|
---|
979 | end
|
---|
980 | @factory = template_string
|
---|
981 | end
|
---|
982 |
|
---|
983 | def set_factory_output_file(output_file)
|
---|
984 | unless @output_file.nil?
|
---|
985 | cdl_error("NTF1003 celltype $1: option output_file was specified more than once",
|
---|
986 | celltype.get_name)
|
---|
987 | end
|
---|
988 | @output_file = output_file
|
---|
989 | end
|
---|
990 |
|
---|
991 | def gen_factory file
|
---|
992 | # puts "===== begin #{@celltype.get_name.to_s} plugin ====="
|
---|
993 |
|
---|
994 | kernelCfg = AppFile.open( "#{$gen}/#{@output_file}" )
|
---|
995 | kernelCfg.print "\n/* Generated by #{self.class.name} */\n"
|
---|
996 | kernelCfg.print "\#include \"tTimeEventHandler.h\"\n"
|
---|
997 |
|
---|
998 | # ã¢ããã¿é¢æ°ãçæããæºå
|
---|
999 | @adpt_gen = AdapterGenerator.new("tTimeEventHandler", @celltype.get_global_name)
|
---|
1000 |
|
---|
1001 | # å±æ§ç½®æãè¡ãããã¨ãæ¤è¨¼ããã
|
---|
1002 | # ããã§è¡ãã®ã¯ãfactoryã§æå®ãããå±æ§åã
|
---|
1003 | # åå¨ãããã¨ã確èªããããªããã°ã¨ã©ã¼ãåºåãããã¨ã®ã¿ã§ããã
|
---|
1004 | # ã»ã«ãã¨ã®å¦çã®æä¸ã«ã¨ã©ã¼ãåºåãããã¨ãå¯è½ã§ã¯ãããã
|
---|
1005 | # ããããã¨ã»ã«ã¿ã¤ãå´ã®åé¡ã§ããã®ã«ãããããããã»ã«ãã¨ã«
|
---|
1006 | # ã¨ã©ã¼ã表示ããã¦ãã¾ãã
|
---|
1007 | # {{attribute_name}} -> attribute_value
|
---|
1008 | @factory.scan(/\{\{([a-zA-Z0-9_]*?)\}\}/) { |match|
|
---|
1009 | name = $1.to_sym
|
---|
1010 |
|
---|
1011 | # {{_handler_params_}} ã¯ãã³ãã©ã«é¢ããæå®ããã©ã°ã¤ã³å
|
---|
1012 | ã§å¤ãçæããã
|
---|
1013 | next if name == :_handler_params_
|
---|
1014 |
|
---|
1015 | subst_attr = @celltype.find(name)
|
---|
1016 | unless subst_attr
|
---|
1017 | cdl_error( "NTF1007 celltype $1: additional_param: attribute $2 does not exist.",
|
---|
1018 | @celltype.get_name, name)
|
---|
1019 | end
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | @celltype.get_cell_list.each { |cell|
|
---|
1023 | gen_factory_for_cell kernelCfg, cell
|
---|
1024 | }
|
---|
1025 |
|
---|
1026 | # ã¢ããã¿é¢æ°ã®çæãå®äºããã
|
---|
1027 | @adpt_gen.finish
|
---|
1028 |
|
---|
1029 | kernelCfg.close
|
---|
1030 | # puts "===== end #{@celltype.get_name.to_s} plugin ====="
|
---|
1031 | end
|
---|
1032 |
|
---|
1033 | def gen_factory_for_cell(kernelCfg, cell)
|
---|
1034 | # print "########## gen_factory_for_cell cell=#{cell.get_name}\n"
|
---|
1035 | handler_flags = []
|
---|
1036 | handler_args = []
|
---|
1037 |
|
---|
1038 | event_handler_might_fail = true
|
---|
1039 | handler_flag = nil
|
---|
1040 |
|
---|
1041 | # ignoreErrorsãåå¾
|
---|
1042 | ignoreErrors_attr_join = cell.get_join_list.get_item(:ignoreErrors)
|
---|
1043 | ignoreErrors_attr = cell.get_celltype.find(:ignoreErrors)
|
---|
1044 | if ignoreErrors_attr_join
|
---|
1045 | # ã»ã«çææã«åæåããå ´å
|
---|
1046 | ignoreErrors = ignoreErrors_attr_join.get_rhs.to_s
|
---|
1047 | else
|
---|
1048 | # ã»ã«ã¿ã¤ãã®åæåå¤ã使ãå ´å
|
---|
1049 | ignoreErrors = ignoreErrors_attr.get_initializer.to_s
|
---|
1050 | end
|
---|
1051 | case ignoreErrors
|
---|
1052 | when 'true' then ignoreErrors = true
|
---|
1053 | when 'false' then ignoreErrors = false
|
---|
1054 | else
|
---|
1055 | cdl_warning2( cell.get_locale, "NTF1005 cell $1: unrecognized value '$2' specified for ignoreErrors",
|
---|
1056 | cell.get_name, ignoreErrors )
|
---|
1057 | ignoreErrors = false
|
---|
1058 | end
|
---|
1059 |
|
---|
1060 | # ãã¡ã¤ã³æå®ç¨æåå
|
---|
1061 | pre_text = ""
|
---|
1062 | post_text = "\n"
|
---|
1063 | indent = ""
|
---|
1064 |
|
---|
1065 | [EVENT_HANDLER, ERROR_HANDLER].each { |handler|
|
---|
1066 | # å¼ã³å£ã®çµåãåå¾
|
---|
1067 | call_join = cell.get_join_list.get_item(handler.call_port_name.to_sym)
|
---|
1068 | domain_root = cell.get_region.get_domain_root
|
---|
1069 | if cell.get_region.get_domain_root.get_domain_type then
|
---|
1070 | # print "cell=#{cell.get_name} domain_root=#{domain_root.get_name} domain_type=#{domain_root.get_domain_type.get_name} domain_option=#{domain_root.get_domain_type.get_option}\n"
|
---|
1071 | else
|
---|
1072 | # print "cell=#{cell.get_name} domain_root=#{cell.get_region.get_domain_root.get_name}\n"
|
---|
1073 | end
|
---|
1074 | if call_join
|
---|
1075 | # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name} join=#{call_join.get_name} rhs_cell=#{call_join.get_cell}\n"
|
---|
1076 | else
|
---|
1077 | # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name}\n"
|
---|
1078 | end
|
---|
1079 |
|
---|
1080 | # ãã³ãã©ã¿ã¤ããå¤å¥ãã
|
---|
1081 | matches = HANDLER_TYPES.select { |handler_type|
|
---|
1082 | handler_type.validate_join(handler, cell, call_join)
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 | if matches.length == 0
|
---|
1086 | cdl_error2( cell.get_locale, "NTF1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name )
|
---|
1087 | next
|
---|
1088 | end
|
---|
1089 |
|
---|
1090 | # æåã«è¦ã¤ãã£ãæå¹ãªãã³ãã©ã¿ã¤ãã使ç¨
|
---|
1091 | ht = matches[0]
|
---|
1092 |
|
---|
1093 | # ãã¡ã¤ã³ãã©ã°ã¤ã³ãæå®ããã¦ããå ´åãæå±ãã¡ã¤ã³ã®ãã§ãã¯
|
---|
1094 | domain_root = cell.get_region.get_domain_root
|
---|
1095 | if domain_root.get_domain_type then
|
---|
1096 | if domain_root.get_domain_type.get_name == :HRP then
|
---|
1097 | option = domain_root.get_domain_type.get_option
|
---|
1098 | matches.each{ |match|
|
---|
1099 | # p "match:#{match}"
|
---|
1100 | case match
|
---|
1101 | when ActivateTaskHandlerType, WakeUpTaskHandlerType,
|
---|
1102 | SetVariableHandlerType, SetVariableToErrorCodeHandlerType,
|
---|
1103 | IncrementVariableHandlerType, SignalSemaphoreHandlerType,
|
---|
1104 | SetEventflagHandlerType, SendToDataqueueHandlerType,
|
---|
1105 | SendErrorCodeToDataqueueHandlerType
|
---|
1106 | if option == "OutOfDomain" then
|
---|
1107 | cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 cannot be placed out of domain", cell.get_name )
|
---|
1108 | elsif call_join.get_cell.get_region.get_domain_root == nil ||
|
---|
1109 | call_join.get_cell.get_region.get_domain_root != domain_root then
|
---|
1110 | cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 and $2 must be placed in same domain", cell.get_name, call_join.get_cell.get_name )
|
---|
1111 | end
|
---|
1112 | dbgPrint "#{self.class.name}: match pattern 1.\n"
|
---|
1113 | when UserHandlerType
|
---|
1114 | if option != "kernel" then
|
---|
1115 | cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 can be placed in kernel domain only, because notify target is handler", cell.get_name )
|
---|
1116 | elsif call_join.get_cell.get_region.get_domain_root == nil ||
|
---|
1117 | call_join.get_cell.get_region.get_domain_root != domain_root then
|
---|
1118 | cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 and $2 must be placed in same domain", cell.get_name, call_join.get_cell.get_name )
|
---|
1119 | end
|
---|
1120 | dbgPrint "#{self.class.name}: match pattern 2.\n"
|
---|
1121 | when NullHandlerType.new # ã¨ã©ã¼éç¥ãæå®ãã¦ããªã
|
---|
1122 | dbgPrint "#{self.class.name}: match pattern 3.\n"
|
---|
1123 | end
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 | # if cell.get_region.get_param == :KERNEL_DOMAIN
|
---|
1127 | if option == "kernel"
|
---|
1128 | pre_text = "KERNEL_DOMAIN{\n"
|
---|
1129 | post_text = "}\n"
|
---|
1130 | indent = "\t"
|
---|
1131 | elsif option != "OutOfDomain" then
|
---|
1132 | pre_text = "DOMAIN(#{domain_root.get_name.to_s}){\n"
|
---|
1133 | post_text = "}\n"
|
---|
1134 | indent = "\t"
|
---|
1135 | end
|
---|
1136 | else
|
---|
1137 | cdl_error( "NTF9999: NotifierPlugin: unknown domain type $1", domain_root.get_domain_type.get_name )
|
---|
1138 | end
|
---|
1139 |
|
---|
1140 | end
|
---|
1141 |
|
---|
1142 | # éç¥ãã³ãã©ã§ãã¨ã©ã¼ãçºçããã¯ãããªããã®ã«ãã¨ã©ã¼ãã³ãã©ãæå®ããã¦ããã
|
---|
1143 | # ãããã¯ãã®éã®ãã¿ã¼ã³ãæ¤åºããã
|
---|
1144 | # (handler_flagãnilã§ããå ´åããã³ãã©ã¿ã¤ããä¸æã§ãããã¨ã©ã¼ãçºçãããä¸æ
|
---|
1145 | # ãªãããæ¤åºã¯è¡ããªãã)
|
---|
1146 | if handler == ERROR_HANDLER && !ht.is_a?(NullHandlerType) && !event_handler_might_fail
|
---|
1147 | cdl_error2( cell.get_locale, "NTF1004 cell $1: handler type $2 which never raises an error was inferred for the normal notification handler, but an error notification handler was specified.",
|
---|
1148 | cell.get_name, handler_flag)
|
---|
1149 | end
|
---|
1150 | if handler == ERROR_HANDLER && ht.is_a?(NullHandlerType) && event_handler_might_fail && !ignoreErrors
|
---|
1151 | cdl_warning2( cell.get_locale, "NTF1006 cell $1: handler type $2 which might raise an error was inferred for the normal notificaton handler, but an error notification handler was not specified.",
|
---|
1152 | cell.get_name, handler_flag)
|
---|
1153 | end
|
---|
1154 |
|
---|
1155 | # assertion
|
---|
1156 | unless ht.validate_join(handler, cell, call_join)
|
---|
1157 | raise "!validate_join"
|
---|
1158 | end
|
---|
1159 |
|
---|
1160 | # éç¥æ¹æ³ã®éçAPIè¨è¿°ãçæãã
|
---|
1161 | handler_flag = ht.gen_cfg_handler_type(handler)
|
---|
1162 | handler_flags << handler_flag if handler_flag
|
---|
1163 |
|
---|
1164 | attr_map = ht.generate_attr_map(handler, cell)
|
---|
1165 |
|
---|
1166 | handler_arg = ht.gen_cfg_handler_parameters(handler, call_join, attr_map, cell, @adpt_gen)
|
---|
1167 | handler_args += handler_arg if handler_arg
|
---|
1168 |
|
---|
1169 | if handler == EVENT_HANDLER
|
---|
1170 | event_handler_might_fail = ht.might_fail
|
---|
1171 | end
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | # $id$çã®ç½®æ
|
---|
1175 | name_array = cell.get_celltype.get_name_array(cell)
|
---|
1176 | handler_args.collect! { |e|
|
---|
1177 | if e == "$cbp$"
|
---|
1178 | cell.get_celltype.subst_name(e, name_array)
|
---|
1179 | else
|
---|
1180 | e
|
---|
1181 | end
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 | # tecsgen.cfgã®è¨è¿°ãçæããã
|
---|
1185 | # factoryã«å¯¾ãããã©ã¡ã¼ã¿ç½®æãè¡ãã
|
---|
1186 | # {{attribute_name}} -> attribute_value
|
---|
1187 | text = @factory.gsub(/\{\{([a-zA-Z0-9_]*?)\}\}/) { |match|
|
---|
1188 | name = $1.to_sym
|
---|
1189 | subst_attr = cell.get_celltype.find(name)
|
---|
1190 |
|
---|
1191 | # {{_handler_params_}} ã¯ãã³ãã©ã®æå®ã«ç½®æããã
|
---|
1192 | if name == :_handler_params_
|
---|
1193 | args_joined = handler_flags.join(' | ')
|
---|
1194 | if handler_args.length > 0
|
---|
1195 | args_joined << ", "
|
---|
1196 | args_joined << handler_args.join(', ')
|
---|
1197 | end
|
---|
1198 | next args_joined
|
---|
1199 | end
|
---|
1200 |
|
---|
1201 | unless subst_attr
|
---|
1202 | # å±æ§ãè¦ã¤ãããªãã¨ããã¨ã©ã¼ã¯ãã§ã«å ±åããã¦ããã®ã§
|
---|
1203 | # ããã§ã¯ããã¼å¤ãè¿ãã¦ããã ãã§ããã
|
---|
1204 | next ""
|
---|
1205 | end
|
---|
1206 |
|
---|
1207 | subst_attr_join = cell.get_join_list.get_item(name)
|
---|
1208 | if subst_attr_join
|
---|
1209 | # ã»ã«çææã«åæåããå ´å
|
---|
1210 | subst = subst_attr_join.get_rhs.to_s
|
---|
1211 | else
|
---|
1212 | # ã»ã«ã¿ã¤ãã®åæåå¤ã使ãå ´å
|
---|
1213 | subst = subst_attr.get_initializer.to_s
|
---|
1214 | end
|
---|
1215 |
|
---|
1216 | # $id$çã®ç½®æ
|
---|
1217 | cell.get_celltype.subst_name(subst, name_array)
|
---|
1218 | }
|
---|
1219 |
|
---|
1220 | # åºå (CRE_xxx)
|
---|
1221 | kernelCfg.print pre_text
|
---|
1222 | kernelCfg.print indent, text, "\n"
|
---|
1223 | gen_sac kernelCfg, cell, indent
|
---|
1224 | kernelCfg.print post_text
|
---|
1225 | end
|
---|
1226 |
|
---|
1227 | def gen_sac file, cell, indent
|
---|
1228 | domain_root = cell.get_region.get_domain_root
|
---|
1229 | if domain_root.get_domain_type then
|
---|
1230 | id = (cell.get_attr_initializer :id).to_s
|
---|
1231 | name_array = cell.get_celltype.get_name_array(cell)
|
---|
1232 | case cell.get_celltype.get_name
|
---|
1233 | when :tCyclicNotifier
|
---|
1234 | obj_type = "CYC"
|
---|
1235 | when :tAlarmNotifier
|
---|
1236 | obj_type = "ALM"
|
---|
1237 | else
|
---|
1238 | raise "NotifierPlugin: unknown celltype #{cell.get_celltype.get_name}"
|
---|
1239 | end
|
---|
1240 | id = cell.get_celltype.subst_name(id, name_array)
|
---|
1241 | # p obj_type
|
---|
1242 | # p HRPPlugin.get_sac_str cell
|
---|
1243 | file.print indent, "SAC_#{obj_type}( #{id}, #{HRPPlugin.get_sac_str cell} );\n"
|
---|
1244 | end
|
---|
1245 | end
|
---|
1246 | private :gen_factory_for_cell
|
---|
1247 |
|
---|
1248 | end
|
---|