Class: TECSInfoPlugin

Inherits:
CelltypePlugin show all
Defined in:
lib/tecsgen/plugin/TECSInfoPlugin.rb

Overview

CelltypePlugin for tTECSInfo

Constant Summary collapse

@@cell_list =
[]

Constants inherited from Plugin

Plugin::PluginArgProc

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plugin

#cdl_error, #check_plugin_arg, #gen_cdl_file, #gen_ep_func?, #gen_postamble, #gen_preamble, #parse_plugin_arg, #print_msg, #set_locale, #set_silent

Methods inherited from Node

#cdl_error, #cdl_error2, #cdl_error3, #cdl_info, #cdl_info2, #cdl_warning, #cdl_warning2, #get_locale, #locale_str, #set_locale

Constructor Details

#initialize(celltype, option) ⇒ TECSInfoPlugin

celltype

Celltype セルタイプ(インスタンス)



48
49
50
51
52
53
54
# File 'lib/tecsgen/plugin/TECSInfoPlugin.rb', line 48

def initialize(celltype, option)
  super
  if $unopt_entry == false
    cdl_info("TIF0001 forcely set --unoptimize-entry by TECSInfoPlugin (by importing TECSInfo.cdl)")
    $unopt_entry = true
  end
end

Class Method Details

.gen_post_code(file) ⇒ Object

後ろの CDL コードを生成

プラグインの後ろの CDL コードを生成

file

File:



266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/tecsgen/plugin/TECSInfoPlugin.rb', line 266

def self.gen_post_code(file)
  if Generator.get_n_error > 0
    Generator.info("I9999 TECSInfoPlugin does not generate TECSInfo code because of early error")
    return
  end
  # 複数のプラグインの post_code が一つのファイルに含まれるため、以下のような見出しをつけること
  file.print <<EOT
/*------------ #{self.name} post code ------------*/
EOT
  @@cell_list.each{|cell|
    root = cell.get_region # .get_link_root
    TECSInfo.print_info file, root
  }
end

Instance Method Details

#gen_factory(file) ⇒ Object

tCelltype_factory.h に挿入するコードを生成する

file 以外の他のファイルにファクトリコードを生成してもよい セルタイププラグインが指定されたセルタイプのみ呼び出される



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/tecsgen/plugin/TECSInfoPlugin.rb', line 96

def gen_factory(file)
  File.open("#{$gen}/include_all_signature_header.h", "w"){|f|
    f.print <<EOT
#ifndef include_all_signature_header_h
#define include_all_signature_header_h

EOT
    Namespace.get_root.travers_all_signature{|sig|
      f.print "#include \"#{sig.get_global_name}_tecsgen.h\"\n"
    }
    f.print <<EOT

#endif /* include_all_signature_header_h */
EOT
  }

  undefs2 = [:INITIALIZE_CB, :FOREACH_CELL, :END_FOREACH_CELL]
  f = AppFile.open("#{$gen}/nTECSInfo_tVarDeclInfo_factory.h")
  Namespace.get_root.print_struct_define f

  undefs = [:VALID_IDX, :GET_CELLCB, :CELLCB, :CELLIDX,
             :tVarDeclInfo_IDX, :ATTR_name, :ATTR_sizeIsExpr,
             :ATTR_declType, :ATTR_offset]

  f.print <<EOT

/***** Offset of attr & var of celltype  *****/
#define TOPPERS_CB_TYPE_ONLY

/* In case a celltype has 'inline' entry,
 * some macros are temporally defined
 * even if TOPPERS_CB_TYPE_ONLY is defined.
 * To avoid redefinition warning, undef these macros.
 */
#{undefs.map {|u| "#undef #{u}\n"}.join}
EOT
  if $ram_initializer
    undefs2.each{|u|
      f.print "#undef #{u}\n"
    }
  end
  Namespace.get_root.print_celltype_define_offset f
  f.print <<EOT

/* redefine macros */
#define tVarDeclInfo_IDX  nTECSInfo_tVarDeclInfo_IDX

EOT
  if $ram_initializer
    f.print <<EOT
#define FOREACH_CELL(i,p_cb)   { (void)(i);
#define END_FOREACH_CELL   }
#define INITIALIZE_CB(p_that)   (void)(p_that);
#define SET_CB_INIB_POINTER(i,p_that)
EOT
  end
  f.close

  undefs = [:N_CP_cEntryInfo, :NCP_cEntryInfo, :N_CP_cCallInfo, :NCP_cCallInfo,
             :N_CP_cAttrInfo, :NCP_cAttrInfo, :N_CP_cVarInfo, :NCP_cVarInfo,
             :VALID_IDX, :GET_CELLCB, :CELLCB, :CELLIDX, :ATTR_name, :ATTR_b_singleton,
             :ATTR_b_IDX_is_ID_act, :ATTR_sizeOfCB, :ATTR_sizeOfINIB, :ATTR_n_cellInLinUnit,
             :ATTR_n_cellInSystem, :cEntryInfo_getName, :cEntryInfo_getNameLength,
             :cEntryInfo_getSignatureInfo, :cEntryInfo_getArraySize, :cEntryInfo_isInline,
             :cCallInfo_getName, :cCallInfo_getNameLength, :cCallInfo_getSignatureInfo,
             :cCallInfo_getArraySize, :cCallInfo_getSpecifierInfo, :cCallInfo_getInternalInfo,
             :cCallInfo_getLocationInfo, :cCallInfo_getOptimizeInfo, :cAttrInfo_getName,
             :cAttrInfo_getOffset, :cAttrInfo_getTypeInfo, :cAttrInfo_getSizeIsExpr,
             :cAttrInfo_getSizeIs, :cVarInfo_getName, :cVarInfo_getOffset, :cVarInfo_getTypeInfo,
             :cVarInfo_getSizeIsExpr, :cVarInfo_getSizeIs, :cEntryInfo_refer_to_descriptor,
             :cEntryInfo_ref_desc, :cCallInfo_refer_to_descriptor, :cCallInfo_ref_desc,
             :cAttrInfo_refer_to_descriptor, :cAttrInfo_ref_desc, :cVarInfo_refer_to_descriptor,
             :cVarInfo_ref_desc, :is_cEntryInfo_joined, :is_cCallInfo_joined,
             :is_cAttrInfo_joined, :is_cVarInfo_joined, :eCelltypeInfo_getName,
             :eCelltypeInfo_getNameLength, :eCelltypeInfo_getNAttr, :eCelltypeInfo_getAttrInfo,
             :eCelltypeInfo_getNVar, :eCelltypeInfo_getVarInfo, :eCelltypeInfo_getNCall,
             :eCelltypeInfo_getCallInfo, :eCelltypeInfo_getNEntry, :eCelltypeInfo_getEntryInfo,
             :eCelltypeInfo_isSingleton, :eCelltypeInfo_isIDX_is_ID, :eCelltypeInfo_hasCB,
             :eCelltypeInfo_hasINIB, :FOREACH_CELL, :END_FOREACH_CELL]

  f = AppFile.open("#{$gen}/nTECSInfo_tCelltypeInfo_factory.h")
  undefs.each{|u|
    f.print "#undef #{u}\n"
  }
  f.print "#define TOPPERS_CB_TYPE_ONLY\n"
  Namespace.get_root.print_celltype_define f
  # FOREACH_CELL を出しなおす
  ct = Namespace.find ["::", :nTECSInfo, :tCelltypeInfo]
  ct.gen_ph_foreach_cell f
  ct.gen_ph_cb_initialize_macro f
  f.print "\n"
  f.close

  undefs = [:VALID_IDX, :GET_CELLCB, :CELLCB, :CELLIDX,
             :tCallInfo_IDX, :ATTR_name, :ATTR_offset, :ATTR_b_inCB,
             :ATTR_b_optional, :ATTR_b_omit, :ATTR_b_dynamic,
             :ATTR_b_ref_desc, :ATTR_b_allocator_port,
             :ATTR_b_require_port, :ATTR_b_VMT_useless,
             :ATTR_b_skelton_useless, :ATTR_b_cell_unique,
             :cSignatureInfo_getName, :cSignatureInfo_getNameLength,
             :cSignatureInfo_getNFunction,
             :cSignatureInfo_getFunctionInfo,
             :cSignatureInfo_refer_to_descriptor,
             :cSignatureInfo_ref_desc, :eCallInfo_getName,
             :eCallInfo_getNameLength, :eCallInfo_getSignatureInfo,
             :eCallInfo_getArraySize, :eCallInfo_isOptional,
             :eCallInfo_isDynamic, :eCallInfo_isRefDesc,
             :eCallInfo_isOmit]

  f = AppFile.open("#{$gen}/nTECSInfo_tCallInfo_factory.h")
  f.print <<EOT

/***** Offset of attr & var of celltype  *****/
#define TOPPERS_CB_TYPE_ONLY

/* In case a celltype has 'inline' entry,
 * some macros are temporally defined
 * even if TOPPERS_CB_TYPE_ONLY is defined.
 * To avoid redefinition warning, undef these macros.
 */
#{undefs.map{|u| "#undef #{u}\n"}.join}
EOT
  if $ram_initializer
    undefs2.each{|u|
      f.print "#undef #{u}\n"
    }
  end

  Namespace.get_root.print_call_define f
  f.print <<EOT

/* redefine macros */
#define tCallInfo_IDX  nTECSInfo_tCallInfo_IDX

EOT
  if $ram_initializer
    f.print <<EOT
#define FOREACH_CELL(i,p_cb)   { (void)(i);
#define END_FOREACH_CELL   }
#define INITIALIZE_CB(p_that)   (void)(p_that);
#define SET_CB_INIB_POINTER(i,p_that)

EOT
  end
  f.close

  f = AppFile.open("#{$gen}/nTECSInfo_tEntryInfo_factory.h")
  Namespace.get_root.print_entry_define f
  f.close

  undefs = [:GET_CELLCB, :CELLCB, :CELLIDX, :ATTR_name, :INITIALIZE_CB, :FOREACH_CELL]
  f = AppFile.open("#{$gen}/nTECSInfo_tCellInfo_factory.h")
  undefs.each{|u|
    f.print "#undef #{u}\n"
  }
  Region.get_root.print_cell_define f
  # FOREACH_CELL を出しなおす
  ct = Namespace.find ["::", :nTECSInfo, :tCellInfo]
  ct.gen_ph_foreach_cell f
  ct.gen_ph_cb_initialize_macro f
  f.close

  f = AppFile.open("#{$gen}/nTECSInfo_tRawEntryDescriptorInfo_factory.h")
  Region.get_root.print_entry_descriptor_define f
  f.close
end

#new_cell(cell) ⇒ Object

新しいセル

cell

Cell セル

celltype プラグインを指定されたセルタイプのセルが生成された セルタイププラグインに対する新しいセルの報告



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/tecsgen/plugin/TECSInfoPlugin.rb', line 61

def new_cell(cell)
  @@cell_list << cell

  # AppFile は、重ね書きようなので、やめる
  # p "import: cell nTECSInfo::tTECSInfoSub TECSInfoSub under #{cell.get_region.get_name}"
  # TECSInfoSub セルのプロトタイプ宣言
  fn = "#{$gen}/tmp_#{cell.get_region.get_global_name}_TECSInfoSub.cdl"
  File.open(fn, "w"){|f|
    f.print "/* prototype declaration of TECSInfoSub */\n"
    nest = cell.get_region.gen_region_str_pre f
    indent = "    " * nest
    f.print <<EOT
#{indent}[in_through()]
#{indent}region rTECSInfo {
#{indent}    cell nTECSInfo::tTECSInfoSub TECSInfoSub;
#{indent}}; /* rTECSInfo} */
EOT
    cell.get_region.gen_region_str_post f
  }
  Import.new fn

  # セルに cTECSInfo の結合があるか?
  if cell.get_join_list.get_item(:cTECSInfo).nil?
    # cTECSInfo = rTECSInfo::TECSInfosub.eTECSInfo; の追加
    nsp = NamespacePath.new(:rTECSInfo, false)
    nsp.append! :TECSInfoSub
    rhs = Expression.create_cell_join_expression nsp, nil, :eTECSInfo
    join = Join.new :cTECSInfo, nil, rhs
    cell.new_join join
  end
end