source: asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/unjoin_plugin.rb@ 374

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

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

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-ruby;charset=UTF-8
File size: 7.2 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# TECS Generator
4# Generator for TOPPERS Embedded Component System
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$
38#++
39
40# Marshal.dump で不都合な事項への対策
41# Proc は _dump_data が定義されていないため、定義する.
42# plugin 関係は、tecsflow に Plugin クラスが存在しないため、消しておく.
43
44# Proc は、Marshal.dump することができないため _dump_data を定義
45class Proc
46 def _dump_data
47 nil
48 end
49end
50
51class Object
52 @@visited = {}
53 @@n_visited = 0
54 @@n_found = 0
55 @@n_plugin_proxy = 0
56
57 # do nothing now. this function is used to find remained Proxy object.
58 def find_plugin level, object_list
59
60 # find_plugin_1 level, object_list
61 # print "find_plugin: n_visted=", @@n_visited, " (len=", @@visited.length, ") found=", @@n_found, " proxy=", @@n_plugin_proxy, "\n"
62 end
63
64 def find_plugin_1 level, object_list
65 if @@visited[ self ] then
66 return
67 end
68 @@visited[ self ] = true
69 @@n_visited += 1
70
71 if kind_of? Expression then
72 # print # Expression では print が別に定義されている
73 get_elements.each{|ele|
74 ele.find_plugin_1 level+1, object_list
75 }
76 return
77 end
78
79 if level > 100 then # 100 is enough now, 50 is too small
80 print "reached max level: "
81 if respond_to? :get_name then
82 print "#{get_name}(#{self.class.name})\n"
83 else
84 print "(#{self.class.name})\n"
85 end
86 return
87 end
88
89 object_list.push self ##### ここから return 不可
90
91 if (kind_of? Plugin) || (kind_of? HRPSVCPlugin) then
92 @@n_found += 1
93 print "Plugin found: #{self.class.name}\n"
94 object_list.each{ |obj|
95 if obj.respond_to? :get_name then
96 print "#{obj.get_name}(#{obj.class.name}), "
97 else
98 print "(#{obj.class.name}), "
99 end
100 }
101 print "\n"
102 elsif kind_of? Join::ThroughPluginProxy then
103 @@n_plugin_proxy += 1
104 end
105
106 level += 1
107 if kind_of? Array then
108 each{ |val|
109 val.find_plugin_1 level, object_list
110 }
111 elsif kind_of? Hash then
112 each{ |key, val|
113 key.find_plugin_1 level, object_list
114 val.find_plugin_1 level, object_list
115 }
116 else
117 instance_variables.each{|iv|
118 iv_val = instance_variable_get iv
119 iv_val.find_plugin_1 level, object_list
120 }
121 end
122 object_list.pop ##### ここまで return 不可
123 end
124end
125
126class Namespace
127 def unjoin_plugin
128 @signature_list.each{ |sig| sig.unjoin_plugin }
129 @celltype_list.each{ |ct| ct.unjoin_plugin }
130 @cell_list.each{ |cell| cell.unjoin_plugin }
131 @namespace_list.each{ |ns| ns.unjoin_plugin}
132 end
133end
134
135class Region < Namespace
136 def unjoin_plugin
137 if @domain_type then
138 @domain_type.unjoin_plugin
139 end
140 @cell_port_throug_plugin_list.each{ |key, po|
141 proxy = Join::ThroughPluginProxy.new po.get_cell_namespace_path, po.get_through_entry_port_name, po.get_through_entry_port_subscript
142 @cell_port_throug_plugin_list[ key ] = proxy
143 }
144 super
145 end
146end
147
148class DomainType < Node
149 def unjoin_plugin
150 @plugin = nil
151 end
152end
153
154class Signature < NSBDNode
155 def unjoin_plugin
156 @generate = nil
157 end
158end
159
160class Celltype < NSBDNode
161 def unjoin_plugin
162 @generate = nil
163 @generate_list = []
164 @plugin = nil
165 end
166end
167
168class Cell < NSBDNode
169 def unjoin_plugin
170 @generate = nil
171 @plugin = nil
172 @join_list.get_items.each{ |j| j.unjoin_plugin }
173 end
174end
175
176class Join < BDNode
177 class ThroughPluginProxy
178 def initialize namespace_path, entry_port_name, entry_port_subscript
179 @namespace_path = namespace_path
180 @entry_port_name = entry_port_name
181 @entry_port_subscript = entry_port_subscript
182 end
183 def get_cell_namespace_path
184 @namespace_path
185 end
186 def get_through_entry_port_name
187 @entry_port_name
188 end
189 def get_through_entry_port_subscript
190 @entry_port_subscript
191 end
192 end
193
194 def unjoin_plugin
195 # @thourhg_generated_list is refered in get_rhs_cell, get_rhs_port
196 @through_generated_list.map!{|po| # po: plugin object
197 ThroughPluginProxy.new po.get_cell_namespace_path, po.get_through_entry_port_name, po.get_through_entry_port_subscript
198 }
199 @region_through_generated_list.map!{|po| # po: plugin object
200 ThroughPluginProxy.new po.get_cell_namespace_path, po.get_through_entry_port_name, po.get_through_entry_port_subscript
201 }
202 if @array_member2 then
203 @array_member2.each{ |j|
204 if j then
205 j.unjoin_plugin2
206 end
207 }
208 end
209 end
210 def unjoin_plugin2
211 @through_generated_list.map!{|po| # po: plugin object
212 ThroughPluginProxy.new po.get_cell_namespace_path, po.get_through_entry_port_name, po.get_through_entry_port_subscript
213 }
214 @region_through_generated_list.map!{|po| # po: plugin object
215 ThroughPluginProxy.new po.get_cell_namespace_path, po.get_through_entry_port_name, po.get_through_entry_port_subscript
216 }
217 end
218end
Note: See TracBrowser for help on using the repository browser.