[388] | 1 | # -*- coding: utf-8 -*-
|
---|
| 2 | #
|
---|
| 3 | # TECS Generator
|
---|
| 4 | # Generator for TOPPERS Embedded Component System
|
---|
| 5 | #
|
---|
| 6 | # Copyright (C) 2017-2018 by TOPPERS Project
|
---|
| 7 | #--
|
---|
| 8 | # ä¸è¨èä½æ¨©è
|
---|
| 9 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
| 10 | # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
| 11 | # å¤ã»åé
|
---|
| 12 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 13 | # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 14 | # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 15 | # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 16 | # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 17 | # ç¨ã§ããå½¢ã§åé
|
---|
| 18 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 19 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 20 | # è
|
---|
| 21 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 22 | # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 23 | # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 24 | # ç¨ã§ããªãå½¢ã§åé
|
---|
| 25 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 26 | # ã¨ï¼
|
---|
| 27 | # (a) åé
|
---|
| 28 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 29 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 30 | # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 31 | # (b) åé
|
---|
| 32 | å¸ã®å½¢æ
|
---|
| 33 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 34 | # å ±åãããã¨ï¼
|
---|
| 35 | # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 36 | # 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 37 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 38 | 責ãããã¨ï¼
|
---|
| 39 | # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
| 40 | # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 41 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
| 42 | # å
|
---|
| 43 | 責ãããã¨ï¼
|
---|
| 44 | #
|
---|
| 45 | # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 46 | ã
|
---|
| 47 | # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
| 48 | # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
| 49 | # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
| 50 | # ã®è²¬ä»»ãè² ããªãï¼
|
---|
| 51 | #
|
---|
| 52 | # $Id$
|
---|
| 53 | #++
|
---|
| 54 |
|
---|
| 55 | # TECS æ
|
---|
| 56 | å ±ã»ã«ã®çæ
|
---|
| 57 | module TECSInfo
|
---|
| 58 | # region 㯠Link root ã®ãã¨
|
---|
| 59 | def self.print_info f, region
|
---|
| 60 | # p "region: "+ region.get_name.to_s
|
---|
| 61 | nest = region.gen_region_str_pre f
|
---|
| 62 | indent0 = " " * nest
|
---|
| 63 | indent = " " * ( nest + 1 )
|
---|
| 64 | f.print <<EOT
|
---|
| 65 | #{indent0}region rTECSInfo {
|
---|
| 66 | EOT
|
---|
| 67 | Type.reset_print_info
|
---|
| 68 |
|
---|
| 69 | # mikan å
|
---|
| 70 | ¨é¨çæããã®ã§ã¯ãªããregion ä¸ã®ã»ã«ã®ã»ã«ã¿ã¤ãã¨ãããããåç
|
---|
| 71 | §ãããã·ã°ããã£ãã»ã«ã¿ã¤ãã«éå®ãã¦åºåãã¹ã
|
---|
| 72 | # ããããæå³è§£æå¾ã«åºåãããããããã¯å®¹æã§ã¯ãªãï¼æé©åã¨ã³ã¼ãçæã¯ããªã³ã¯ã«ã¼ããã¨ã«è¡ãããï¼
|
---|
| 73 | Namespace.print_info f, indent
|
---|
| 74 | region.get_link_root.print_info f, indent
|
---|
| 75 |
|
---|
| 76 | f.print "\n#{indent}/*** TYPE information cell ***/\n"
|
---|
| 77 | Type.print_info_post f, indent
|
---|
| 78 |
|
---|
| 79 | f.print "\n#{indent}/*** TECS information cell ***/\n"
|
---|
| 80 | f.print <<EOT
|
---|
| 81 | #{indent}cell nTECSInfo::tTECSInfoSub TECSInfoSub {
|
---|
| 82 | #{indent} cNamespaceInfo = _RootNamespaceInfo.eNamespaceInfo;
|
---|
| 83 | #{indent} cRegionInfo = _LinkRootRegionInfo.eRegionInfo;
|
---|
| 84 | #{indent}} /* TECSInfoSub */;
|
---|
| 85 | #{indent0}}; /* rTECSInfo */
|
---|
| 86 | EOT
|
---|
| 87 | region.gen_region_str_post f
|
---|
| 88 | end
|
---|
| 89 | end
|
---|
| 90 |
|
---|
| 91 | class Namespace
|
---|
| 92 | # RootRegion 㨠LinkRegion ã¯åã Region ã¯ã©ã¹ã®ãªãã¸ã§ã¯ãã§ãã
|
---|
| 93 | # åãã¼ã ã¹ãã¼ã¹ã¯ Namespace ã¯ã©ã¹ã®ãåãªã¼ã¸ã§ã³ã¯ Region ã¯ã©ã¹ã®ãªãã¸ã§ã¯ãã§ãã
|
---|
| 94 | # ããã¯ãæå³è§£æ段éã§å¼ã³åºãããããããªã³ã¯ã¦ããããã¨ã«åºãããããã¨ãã§ããªã
|
---|
| 95 | # åºããããã«ã¯ã2ãã¹ã«ããå¿
|
---|
| 96 | è¦ããã
|
---|
| 97 | def print_info_ns_sub f, indent
|
---|
| 98 | if @name == "::" then
|
---|
| 99 | name = "_Root"
|
---|
| 100 | else
|
---|
| 101 | name = @global_name
|
---|
| 102 | end
|
---|
| 103 | f.print "\n#{indent}/*** #{get_namespace_path} namespace information cell ***/\n"
|
---|
| 104 | f.print <<EOT
|
---|
| 105 | #{indent}cell nTECSInfo::tNamespaceInfo #{name}NamespaceInfo{
|
---|
| 106 | #{indent} name = "#{@name}";
|
---|
| 107 | EOT
|
---|
| 108 | if @signature_list.length > 0 then
|
---|
| 109 | f.print "\n#{indent} /* SIGNATURE info */\n"
|
---|
| 110 | end
|
---|
| 111 | @signature_list.each{ |sig|
|
---|
| 112 | f.print <<EOT
|
---|
| 113 | #{indent} cSignatureInfo[] = #{sig.get_global_name}SignatureInfo.eSignatureInfo;
|
---|
| 114 | EOT
|
---|
| 115 | }
|
---|
| 116 | if @celltype_list.length > 0 then
|
---|
| 117 | f.print "\n#{indent} /* CELLTYPE info */\n"
|
---|
| 118 | end
|
---|
| 119 | @celltype_list.each{ |ct|
|
---|
| 120 | if ct.get_cell_list.length > 0 then
|
---|
| 121 | f.print <<EOT
|
---|
| 122 | #{indent} cCelltypeInfo[] = #{ct.get_global_name}CelltypeInfo.eCelltypeInfo;
|
---|
| 123 | EOT
|
---|
| 124 | end
|
---|
| 125 | }
|
---|
| 126 | if @namespace_list.length > 0 then
|
---|
| 127 | f.print "\n#{indent} /* NAMESPACE info */\n"
|
---|
| 128 | end
|
---|
| 129 | @namespace_list.each{ |ns|
|
---|
| 130 | if ns.instance_of? Namespace then
|
---|
| 131 | f.print <<EOT
|
---|
| 132 | #{indent} cNamespaceInfo[] = #{ns.get_global_name}NamespaceInfo.eNamespaceInfo;
|
---|
| 133 | EOT
|
---|
| 134 | end
|
---|
| 135 | }
|
---|
| 136 | f.print <<EOT
|
---|
| 137 | #{indent}}; /* cell nTECSInfo::tNamespaceInfo #{name}NamespaceInfo */
|
---|
| 138 | EOT
|
---|
| 139 | end
|
---|
| 140 |
|
---|
| 141 | def print_info_ns f, indent
|
---|
| 142 | # p "print_info: #{self.get_global_name}"
|
---|
| 143 | print_info_ns_sub f, indent
|
---|
| 144 | @signature_list.each { |sig|
|
---|
| 145 | sig.print_info f, indent
|
---|
| 146 | }
|
---|
| 147 | @celltype_list.each { |ct|
|
---|
| 148 | if ct.get_cell_list.length > 0 then
|
---|
| 149 | ct.print_info f, indent
|
---|
| 150 | end
|
---|
| 151 | }
|
---|
| 152 | @namespace_list.each { |ns|
|
---|
| 153 | if ns.instance_of? Namespace then # region ãå«ããªã
|
---|
| 154 | ns.print_info_ns f, indent
|
---|
| 155 | end
|
---|
| 156 | }
|
---|
| 157 | end
|
---|
| 158 |
|
---|
| 159 | def self.print_info( f, indent )
|
---|
| 160 | @@root_namespace.print_info_ns f, indent
|
---|
| 161 | end
|
---|
| 162 |
|
---|
| 163 | #=== Namespace# æ§é ä½ã¡ã³ãã¼ã®ãªãã»ããå®ç¾©
|
---|
| 164 | def print_struct_define f
|
---|
| 165 | f.print "\n/***** Offset of members of structures *****/\n"
|
---|
| 166 | @struct_tag_list.get_items.each{ |tag, sttype|
|
---|
| 167 | # print "sttype: #{tag.get_name} #{sttype}\n"
|
---|
| 168 | tag.get_members_decl.get_items.each{ |decl|
|
---|
| 169 | f.printf "#define OFFSET_OF_%-30s (%s)\n",
|
---|
| 170 | "#{tag.get_ID_str}_#{decl.get_name}",
|
---|
| 171 | "(uint32_t)(intptr_t)&(((#{tag.get_type_str}#{tag.get_type_str_post}*)0)->#{decl.get_name})"
|
---|
| 172 | f.printf "#define PLACE_OF_%-30s (%s)\n",
|
---|
| 173 | "#{tag.get_ID_str}_#{decl.get_name}",
|
---|
| 174 | "VARDECL_PLACE_STRUCT"
|
---|
| 175 | }
|
---|
| 176 | }
|
---|
| 177 | end
|
---|
| 178 |
|
---|
| 179 | def print_celltype_define_offset f
|
---|
| 180 | @celltype_list.each { |ct|
|
---|
| 181 | if ct.get_cell_list.length > 0 then
|
---|
| 182 | ct.print_define_offset f
|
---|
| 183 | end
|
---|
| 184 | }
|
---|
| 185 | @namespace_list.each { |ns|
|
---|
| 186 | if ns.instance_of? Namespace then # region ãå«ããªã
|
---|
| 187 | ns.print_celltype_define_offset f
|
---|
| 188 | end
|
---|
| 189 | }
|
---|
| 190 | end
|
---|
| 191 |
|
---|
| 192 | def print_celltype_define f
|
---|
| 193 | @celltype_list.each { |ct|
|
---|
| 194 | if ct.get_cell_list.length > 0 then
|
---|
| 195 | ct.print_celltype_define f
|
---|
| 196 | end
|
---|
| 197 | }
|
---|
| 198 | @namespace_list.each { |ns|
|
---|
| 199 | if ns.instance_of? Namespace then # region ãå«ããªã
|
---|
| 200 | ns.print_celltype_define f
|
---|
| 201 | end
|
---|
| 202 | }
|
---|
| 203 | end
|
---|
| 204 |
|
---|
| 205 | def print_call_define f
|
---|
| 206 | @celltype_list.each { |ct|
|
---|
| 207 | if ct.get_cell_list.length > 0 then
|
---|
| 208 | ct.print_call_define f
|
---|
| 209 | end
|
---|
| 210 | }
|
---|
| 211 | @namespace_list.each { |ns|
|
---|
| 212 | if ns.instance_of? Namespace then # region ãå«ããªã
|
---|
| 213 | ns.print_call_define f
|
---|
| 214 | end
|
---|
| 215 | }
|
---|
| 216 | end
|
---|
| 217 |
|
---|
| 218 | def print_entry_define f
|
---|
| 219 | @celltype_list.each { |ct|
|
---|
| 220 | if ct.get_cell_list.length > 0 then
|
---|
| 221 | ct.print_entry_define f
|
---|
| 222 | end
|
---|
| 223 | }
|
---|
| 224 | @namespace_list.each { |ns|
|
---|
| 225 | if ns.instance_of? Namespace then # region ãå«ããªã
|
---|
| 226 | ns.print_entry_define f
|
---|
| 227 | end
|
---|
| 228 | }
|
---|
| 229 | end
|
---|
| 230 | end
|
---|
| 231 |
|
---|
| 232 | class Region
|
---|
| 233 | def print_info_region_sub f, indent
|
---|
| 234 | if get_link_root == self then
|
---|
| 235 | name = "_LinkRoot"
|
---|
| 236 | else
|
---|
| 237 | name = @global_name
|
---|
| 238 | end
|
---|
| 239 | # p "region:#{get_name}"
|
---|
| 240 | f.print "\n#{indent}/*** #{get_namespace_path} region information cell ***/\n"
|
---|
| 241 | f.print <<EOT
|
---|
| 242 | #{indent}cell nTECSInfo::tRegionInfo #{name}RegionInfo{
|
---|
| 243 | #{indent} name = "#{@name}";
|
---|
| 244 | EOT
|
---|
| 245 | @cell_list.each{ |cell|
|
---|
| 246 | # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 1\n"
|
---|
| 247 | if ! cell.exclude_info? then
|
---|
| 248 | # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 2\n"
|
---|
| 249 | f.print "#{indent} cCellInfo[] = #{cell.get_global_name}CellInfo.eCellInfo;\n"
|
---|
| 250 | end
|
---|
| 251 | }
|
---|
| 252 | @namespace_list.each { |region|
|
---|
| 253 | if region.instance_of? Region then
|
---|
| 254 | f.print "#{indent} cRegionInfo[] = #{region.get_global_name}RegionInfo.eRegionInfo;\n"
|
---|
| 255 | end
|
---|
| 256 | }
|
---|
| 257 | f.print "#{indent}};\n"
|
---|
| 258 | @cell_list.each{ |cell|
|
---|
| 259 | if ! cell.exclude_info? then
|
---|
| 260 | cell.print_info f, indent
|
---|
| 261 | end
|
---|
| 262 | }
|
---|
| 263 | end
|
---|
| 264 |
|
---|
| 265 | def print_info_region( f, indent )
|
---|
| 266 | self.print_info_region_sub f, indent
|
---|
| 267 | @namespace_list.each { |region|
|
---|
| 268 | if region.instance_of? Region then
|
---|
| 269 | region.print_info_region f, indent
|
---|
| 270 | end
|
---|
| 271 | }
|
---|
| 272 | end
|
---|
| 273 |
|
---|
| 274 | def print_info( f, indent )
|
---|
| 275 | #p "print_info: #{self.get_global_name}"
|
---|
| 276 | self.print_info_region f, indent
|
---|
| 277 | end
|
---|
| 278 |
|
---|
| 279 | def self.print_cell_define f
|
---|
| 280 | region.get_link_root.print_cell_define f
|
---|
| 281 | region.get_link_root.get_region{ |region|
|
---|
| 282 | if region.instance_of? Region then
|
---|
| 283 | region.print_cell_define_offset f
|
---|
| 284 | end
|
---|
| 285 |
|
---|
| 286 | }
|
---|
| 287 | end
|
---|
| 288 |
|
---|
| 289 | def print_cell_define f
|
---|
| 290 | ct_list = {}
|
---|
| 291 | @cell_list.each{ |cell|
|
---|
| 292 | next if cell.exclude_info_factory?
|
---|
| 293 | ct_list[ cell.get_celltype ] = true
|
---|
| 294 | }
|
---|
| 295 | f.print "#define TOPPERS_CB_TYPE_ONLY\n"
|
---|
| 296 | ct_list.each{ |ct, val|
|
---|
| 297 | f.print "#include \"#{ct.get_global_name}_tecsgen.h\"\n"
|
---|
| 298 | }
|
---|
| 299 | f.print "\n"
|
---|
| 300 | @cell_list.each{ |cell|
|
---|
| 301 | next if cell.exclude_info_factory?
|
---|
| 302 | name_array = cell.get_celltype.get_name_array cell
|
---|
| 303 | if cell.get_celltype.has_CB?
|
---|
| 304 | cb = "(void*)#{name_array[8]}"
|
---|
| 305 | cb_proto = "extern #{cell.get_celltype.get_global_name}_CB #{name_array[4]};\n"
|
---|
| 306 | else
|
---|
| 307 | cb = "0"
|
---|
| 308 | cb_proto = ""
|
---|
| 309 | end
|
---|
| 310 | if cell.get_celltype.has_INIB?
|
---|
| 311 | inib = "(void*)&#{name_array[5]}"
|
---|
| 312 | inib_proto = "extern #{cell.get_celltype.get_global_name}_INIB #{name_array[11]};\n"
|
---|
| 313 | else
|
---|
| 314 | inib = "0"
|
---|
| 315 | inib_proto = ""
|
---|
| 316 | end
|
---|
| 317 | if ! cell.exclude_info_factory? then
|
---|
| 318 | f.print <<EOT
|
---|
| 319 | #{cb_proto}#define #{cell.get_global_name}__CBP #{cb}
|
---|
| 320 | #{inib_proto}#define #{cell.get_global_name}__INIBP #{inib}
|
---|
| 321 | EOT
|
---|
| 322 | end
|
---|
| 323 | }
|
---|
| 324 | @namespace_list.each { |region|
|
---|
| 325 | if region.instance_of? Region then
|
---|
| 326 | region.print_cell_define f
|
---|
| 327 | end
|
---|
| 328 | }
|
---|
| 329 | end
|
---|
| 330 |
|
---|
| 331 | def print_entry_descriptor_define f
|
---|
| 332 | @cell_list.each{ |cell|
|
---|
| 333 | next if cell.exclude_info_factory?
|
---|
| 334 |
|
---|
| 335 | signatures = {}
|
---|
| 336 | cell.get_celltype.get_port_list.each{ |port|
|
---|
| 337 | next if port.get_port_type != :ENTRY
|
---|
| 338 |
|
---|
| 339 | if signatures[ port.get_signature ] == nil then
|
---|
| 340 | f.print "#include \"#{port.get_signature.get_global_name}_tecsgen.h\"\n"
|
---|
| 341 | end
|
---|
| 342 | if cell.get_celltype.get_global_name == :nTECSInfo_tRawEntryDescriptorInfo then
|
---|
| 343 | f.print "const struct tag_#{cell.get_celltype.get_global_name}_#{port.get_name}_DES "
|
---|
| 344 | f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
|
---|
| 345 | else
|
---|
| 346 | f.print "extern struct tag_#{port.get_signature.get_global_name}_VDES "
|
---|
| 347 | f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
|
---|
| 348 | end
|
---|
| 349 | }
|
---|
| 350 | }
|
---|
| 351 | @namespace_list.each { |region|
|
---|
| 352 | if region.instance_of? Region then
|
---|
| 353 | region.print_entry_descriptor_define f
|
---|
| 354 | end
|
---|
| 355 | }
|
---|
| 356 | end
|
---|
| 357 | end
|
---|
| 358 |
|
---|
| 359 | class Celltype
|
---|
| 360 | def print_info f, indent
|
---|
| 361 | f.print <<EOT
|
---|
| 362 | #{indent}cell nTECSInfo::tCelltypeInfo #{@global_name}CelltypeInfo {
|
---|
| 363 | #{indent} name = "#{@name}";
|
---|
| 364 | #{indent} b_singleton = #{@singleton};
|
---|
| 365 | #{indent} b_IDX_is_ID_act = C_EXP( "#{@global_name}__IDX_is_ID_act" );
|
---|
| 366 | #{indent} sizeOfCB = C_EXP( "#{@global_name}__sizeOfCB" );
|
---|
| 367 | #{indent} sizeOfINIB = C_EXP( "#{@global_name}__sizeOfINIB" );
|
---|
| 368 | #{indent} n_cellInLinkUnit = C_EXP( "#{@global_name}__NCELLINLINKUNIT" );
|
---|
| 369 | #{indent} n_cellInSystem = #{@cell_list.length};
|
---|
| 370 | EOT
|
---|
| 371 | @port.each{ |port|
|
---|
| 372 | if port.get_port_type == :ENTRY then
|
---|
| 373 | f.print <<EOT
|
---|
| 374 | #{indent} cEntryInfo[] = #{@global_name}_#{port.get_name}EntryInfo.eEntryInfo;
|
---|
| 375 | EOT
|
---|
| 376 | end
|
---|
| 377 | }
|
---|
| 378 | @port.each{ |port|
|
---|
| 379 | if port.get_port_type == :CALL then
|
---|
| 380 | f.print <<EOT
|
---|
| 381 | #{indent} cCallInfo[] = #{@global_name}_#{port.get_name}CallInfo.eCallInfo;
|
---|
| 382 | EOT
|
---|
| 383 | end
|
---|
| 384 | }
|
---|
| 385 | @attribute.each{ |decl|
|
---|
| 386 | f.print <<EOT
|
---|
| 387 | #{indent} cAttrInfo[] = #{@global_name}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;
|
---|
| 388 | EOT
|
---|
| 389 | }
|
---|
| 390 | @var.each{ |decl|
|
---|
| 391 | f.print <<EOT
|
---|
| 392 | #{indent} cVarInfo[] = #{@global_name}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;
|
---|
| 393 | EOT
|
---|
| 394 | }
|
---|
| 395 | f.print <<EOT
|
---|
| 396 | #{indent}};
|
---|
| 397 | EOT
|
---|
| 398 | @port.each{ |port|
|
---|
| 399 | if port.get_port_type == :ENTRY then
|
---|
| 400 | port.print_info f, @global_name, indent
|
---|
| 401 | end
|
---|
| 402 | }
|
---|
| 403 | @port.each{ |port|
|
---|
| 404 | if port.get_port_type == :CALL then
|
---|
| 405 | port.print_info f, @global_name, indent
|
---|
| 406 | end
|
---|
| 407 | }
|
---|
| 408 | @attribute.each{ |decl|
|
---|
| 409 | decl.print_info f, @global_name, indent, :DECLTYPE_ATTR
|
---|
| 410 | }
|
---|
| 411 | @var.each{ |decl|
|
---|
| 412 | decl.print_info f, @global_name, indent, :DECLTYPE_VAR
|
---|
| 413 | }
|
---|
| 414 | end
|
---|
| 415 |
|
---|
| 416 | def print_define_offset f
|
---|
| 417 | # intptr_t ã«ä¸åãã£ã¹ãããã®ã¯ 64bit çãèéãã¦ã®ãã¨ï¼ããã 32bit ã¨ãã¦ããã®ã§ 4GB ãè¶
|
---|
| 418 | ããæ§é ä½çã¯æ±ããªã
|
---|
| 419 | if @n_cell_gen > 0 then
|
---|
| 420 | f.print <<EOT
|
---|
| 421 |
|
---|
| 422 | #include "#{@global_name}_tecsgen.h"
|
---|
| 423 | EOT
|
---|
| 424 | @attribute.each{ |decl|
|
---|
| 425 | if has_INIB? then
|
---|
| 426 | inib_cb = "INIB"
|
---|
| 427 | else
|
---|
| 428 | inib_cb = "CB"
|
---|
| 429 | end
|
---|
| 430 | if ! decl.is_omit? then
|
---|
| 431 | offset = "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
|
---|
| 432 | place = inib_cb
|
---|
| 433 | else
|
---|
| 434 | offset = "0xffffffff"
|
---|
| 435 | place = "NON"
|
---|
| 436 | end
|
---|
| 437 | f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", offset
|
---|
| 438 | f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
|
---|
| 439 | }
|
---|
| 440 | @var.each{ |decl|
|
---|
| 441 | if decl.get_size_is && has_INIB? then
|
---|
| 442 | inib_cb = "INIB"
|
---|
| 443 | else
|
---|
| 444 | inib_cb = "CB"
|
---|
| 445 | end
|
---|
| 446 | place = inib_cb
|
---|
| 447 | f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
|
---|
| 448 | f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
|
---|
| 449 | }
|
---|
| 450 | else
|
---|
| 451 | f.print <<EOT
|
---|
| 452 |
|
---|
| 453 | // #include "#{@global_name}_tecsgen.h" // no cell exist
|
---|
| 454 | EOT
|
---|
| 455 | # çæãããªãã»ã«ã¿ã¤ã
|
---|
| 456 | @attribute.each{ |decl|
|
---|
| 457 | f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
|
---|
| 458 | f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
|
---|
| 459 | }
|
---|
| 460 | @var.each{ |decl|
|
---|
| 461 | f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
|
---|
| 462 | f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
|
---|
| 463 | }
|
---|
| 464 | end
|
---|
| 465 | end
|
---|
| 466 |
|
---|
| 467 | def print_celltype_define f
|
---|
| 468 | if has_INIB? then
|
---|
| 469 | size_INIB = "(sizeof(#{@global_name}_INIB))"
|
---|
| 470 | else
|
---|
| 471 | size_INIB = "(0)"
|
---|
| 472 | end
|
---|
| 473 | if has_CB? then
|
---|
| 474 | size_CB = "(sizeof(#{@global_name}_CB))"
|
---|
| 475 | else
|
---|
| 476 | size_CB = "(0)"
|
---|
| 477 | end
|
---|
| 478 |
|
---|
| 479 | if @n_cell_gen > 0 then
|
---|
| 480 | f.printf "\n#include \"#{@global_name}_tecsgen.h\"\n"
|
---|
| 481 | f.printf "#define %-50s (#{@idx_is_id_act})\n", "#{@global_name}__IDX_is_ID_act"
|
---|
| 482 | f.printf "#define %-50s (#{size_CB})\n", "#{@global_name}__sizeOfCB"
|
---|
| 483 | f.printf "#define %-50s (#{size_INIB})\n", "#{@global_name}__sizeOfINIB"
|
---|
| 484 | f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
|
---|
| 485 | else
|
---|
| 486 | f.printf "#define %-50s (false)\n", "#{@global_name}__IDX_is_ID_act"
|
---|
| 487 | f.printf "#define %-50s (0)\n", "#{@global_name}__sizeOfCB"
|
---|
| 488 | f.printf "#define %-50s (0)\n", "#{@global_name}__sizeOfINIB"
|
---|
| 489 | f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
|
---|
| 490 | end
|
---|
| 491 | end
|
---|
| 492 |
|
---|
| 493 | def print_call_define f
|
---|
| 494 | if @n_cell_gen > 0 then
|
---|
| 495 | f.print <<EOT
|
---|
| 496 |
|
---|
| 497 | #include "#{@global_name}_tecsgen.h"
|
---|
| 498 | EOT
|
---|
| 499 | else
|
---|
| 500 | f.print <<EOT
|
---|
| 501 |
|
---|
| 502 | // #include "#{@global_name}_tecsgen.h" // no cell exist
|
---|
| 503 | EOT
|
---|
| 504 | end
|
---|
| 505 | @port.each{ |port|
|
---|
| 506 | next if port.get_port_type == :ENTRY
|
---|
| 507 | if port.is_omit? || ( port.is_VMT_useless? && port.is_cell_unique? ) || @n_cell_gen == 0 then
|
---|
| 508 | place = "CALL_PLACE_NON"
|
---|
| 509 | elsif port.is_dynamic?
|
---|
| 510 | if port.get_array_size then
|
---|
| 511 | place = "CALL_PLACE_INIB_DES"
|
---|
| 512 | else
|
---|
| 513 | place = "CALL_PLACE_CB_DES"
|
---|
| 514 | end
|
---|
| 515 | elsif ! has_INIB? then
|
---|
| 516 | if port.is_VMT_useless? then
|
---|
| 517 | place = "CALL_PLACE_CB_IDX"
|
---|
| 518 | else
|
---|
| 519 | place = "CALL_PLACE_CB_DES"
|
---|
| 520 | end
|
---|
| 521 | else
|
---|
| 522 | if port.is_VMT_useless? then
|
---|
| 523 | place = "CALL_PLACE_INIB_IDX"
|
---|
| 524 | else
|
---|
| 525 | place = "CALL_PLACE_INIB_DES"
|
---|
| 526 | end
|
---|
| 527 | end
|
---|
| 528 | if ( port.is_VMT_useless? && port.is_cell_unique? ) || port.is_omit? || @n_cell_gen == 0 then
|
---|
| 529 | offset = "0xffffffff"
|
---|
| 530 | else
|
---|
| 531 | if port.is_dynamic? || ! has_INIB? then
|
---|
| 532 | cb_inib = "CB"
|
---|
| 533 | else
|
---|
| 534 | cb_inib = "INIB"
|
---|
| 535 | end
|
---|
| 536 | offset = "(uint32_t)(intptr_t)&((#{@global_name}_#{cb_inib}*)0)->#{port.get_name}"
|
---|
| 537 | end
|
---|
| 538 | array_size = port.get_array_size
|
---|
| 539 | if array_size == "[]" then
|
---|
| 540 | array_size = "0xffffffff"
|
---|
| 541 | elsif array_size == nil then
|
---|
| 542 | array_size = "0"
|
---|
| 543 | end
|
---|
| 544 |
|
---|
| 545 | f.printf "#define %-50s (#{offset})\n", "#{@global_name}_#{port.get_name}__offset"
|
---|
| 546 | f.printf "#define %-50s (#{array_size})\n", "#{@global_name}_#{port.get_name}__array_size"
|
---|
| 547 | f.printf "#define %-50s (#{place})\n", "#{@global_name}_#{port.get_name}__place"
|
---|
| 548 | f.printf "#define %-50s (#{port.is_VMT_useless?})\n", "#{@global_name}_#{port.get_name}__b_VMT_useless"
|
---|
| 549 | f.printf "#define %-50s (#{port.is_skelton_useless?})\n", "#{@global_name}_#{port.get_name}__b_skelton_useless"
|
---|
| 550 | f.printf "#define %-50s (#{port.is_cell_unique?})\n", "#{@global_name}_#{port.get_name}__b_cell_unique"
|
---|
| 551 | }
|
---|
| 552 | end
|
---|
| 553 |
|
---|
| 554 | def print_entry_define f
|
---|
| 555 | @port.each{ |port|
|
---|
| 556 | next if port.get_port_type == :CALL
|
---|
| 557 | array_size = port.get_array_size
|
---|
| 558 | if array_size == "[]" then
|
---|
| 559 | array_size = "0xffffffff"
|
---|
| 560 | elsif array_size == nil then
|
---|
| 561 | array_size = "0"
|
---|
| 562 | end
|
---|
| 563 |
|
---|
| 564 | f.printf "#define %-50s (#{array_size})\n", "#{@global_name}_#{port.get_name}__array_size"
|
---|
| 565 | }
|
---|
| 566 | end
|
---|
| 567 | end
|
---|
| 568 |
|
---|
| 569 | class Port
|
---|
| 570 | def print_info f, ct_global, indent
|
---|
| 571 | return if @signature == nil # signature not found error in cdl
|
---|
| 572 | if @port_type == :ENTRY then
|
---|
| 573 | f.print <<EOT
|
---|
| 574 | #{indent}cell nTECSInfo::tEntryInfo #{ct_global}_#{@name}EntryInfo{
|
---|
| 575 | #{indent} name = "#{@name}";
|
---|
| 576 | #{indent} cSignatureInfo = #{@signature.get_global_name}SignatureInfo.eSignatureInfo;
|
---|
| 577 | #{indent} b_inline = #{@b_inline};
|
---|
| 578 | #{indent} array_size = C_EXP( "#{ct_global}_#{@name}__array_size" );
|
---|
| 579 | #{indent}};
|
---|
| 580 | EOT
|
---|
| 581 | else
|
---|
| 582 | f.print <<EOT
|
---|
| 583 | #{indent}cell nTECSInfo::tCallInfo #{ct_global}_#{@name}CallInfo{
|
---|
| 584 | #{indent} name = "#{@name}";
|
---|
| 585 | #{indent} cSignatureInfo = #{@signature.get_global_name}SignatureInfo.eSignatureInfo;
|
---|
| 586 | #{indent} offset = C_EXP( "#{ct_global}_#{@name}__offset" );
|
---|
| 587 | #{indent} array_size = C_EXP( "#{ct_global}_#{@name}__array_size" );
|
---|
| 588 | #{indent} b_optional = #{@b_optional};
|
---|
| 589 | #{indent} b_omit = #{@b_omit};
|
---|
| 590 | #{indent} b_dynamic = #{@b_dynamic};
|
---|
| 591 | #{indent} b_ref_desc = #{@b_ref_desc};
|
---|
| 592 | #{indent} b_allocator_port = #{@allocator_port!=nil ? true : false};
|
---|
| 593 | #{indent} b_require_port = #{@b_require};
|
---|
| 594 | #{indent} place = C_EXP( "#{ct_global}_#{@name}__place" );
|
---|
| 595 | #{indent} b_VMT_useless = C_EXP( "#{ct_global}_#{@name}__b_VMT_useless" );
|
---|
| 596 | #{indent} b_skelton_useless = C_EXP( "#{ct_global}_#{@name}__b_skelton_useless" );
|
---|
| 597 | #{indent} b_cell_unique = C_EXP( "#{ct_global}_#{@name}__b_cell_unique" );
|
---|
| 598 |
|
---|
| 599 | #{indent}};
|
---|
| 600 | EOT
|
---|
| 601 | end
|
---|
| 602 | end
|
---|
| 603 | end
|
---|
| 604 |
|
---|
| 605 | class Cell
|
---|
| 606 | def print_info f, indent
|
---|
| 607 | if exclude_info? then
|
---|
| 608 | return
|
---|
| 609 | end
|
---|
| 610 | f.print <<EOT
|
---|
| 611 |
|
---|
| 612 | #{indent}/*** #{@global_name} cell information ****/
|
---|
| 613 | #{indent}cell nTECSInfo::tCellInfo #{@global_name}CellInfo {
|
---|
| 614 | #{indent} name = "#{@name}";
|
---|
| 615 | #{indent} cbp = C_EXP( \"#{@global_name}__CBP\" );
|
---|
| 616 | #{indent} inibp = C_EXP( \"#{@global_name}__INIBP\" );
|
---|
| 617 | #{indent} cCelltypeInfo = #{@celltype.get_global_name}CelltypeInfo.eCelltypeInfo;
|
---|
| 618 | EOT
|
---|
| 619 | @celltype.get_port_list.each{ |port|
|
---|
| 620 | next if port.get_port_type != :ENTRY
|
---|
| 621 |
|
---|
| 622 | f.print <<EOT
|
---|
| 623 | #{indent} cRawEntryDescriptor[] = #{@global_name}_#{port.get_name}RawEntryDescriptorInfo.eRawEntryDescriptor;
|
---|
| 624 | EOT
|
---|
| 625 | }
|
---|
| 626 | f.print "#{indent}};\n"
|
---|
| 627 |
|
---|
| 628 | # RawEntryDescriptorInfo cells
|
---|
| 629 | @celltype.get_port_list.each{ |port|
|
---|
| 630 | next if port.get_port_type != :ENTRY
|
---|
| 631 |
|
---|
| 632 | size = port.get_array_size
|
---|
| 633 | if size == nil then
|
---|
| 634 | size = 1
|
---|
| 635 | elsif size == "[]" then
|
---|
| 636 | size = @entry_array_max_subscript[ port ]
|
---|
| 637 | end
|
---|
| 638 | if ! port.is_omit? then
|
---|
| 639 | red = "C_EXP( \"&#{@global_name}_#{port.get_name}_des\" )"
|
---|
| 640 | else
|
---|
| 641 | red = "(void *)0"
|
---|
| 642 | end
|
---|
| 643 | # mikan åãå£é
|
---|
| 644 | å
|
---|
| 645 | f.print <<EOT
|
---|
| 646 | #{indent}cell nTECSInfo::tRawEntryDescriptorInfo #{@global_name}_#{port.get_name}RawEntryDescriptorInfo {
|
---|
| 647 | #{indent} size = #{size};
|
---|
| 648 | #{indent} rawEntryDescriptor = { #{red} };
|
---|
| 649 | EOT
|
---|
| 650 | # #{indent} cEntryInfo = #{@celltype.get_global_name}_#{port.get_name}EntryInfo.eEntryInfo;
|
---|
| 651 | f.print "#{indent}};\n"
|
---|
| 652 | }
|
---|
| 653 | end
|
---|
| 654 |
|
---|
| 655 | def exclude_info?
|
---|
| 656 | # print "exclude_info?: name=" + get_name.to_s
|
---|
| 657 | if @celltype == nil ||
|
---|
| 658 | is_of_composite? ||
|
---|
| 659 | @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
|
---|
| 660 | post_code_generated? ||
|
---|
| 661 | @b_defined == false then
|
---|
| 662 | # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
|
---|
| 663 | return true
|
---|
| 664 | else
|
---|
| 665 | # print ": false\n"
|
---|
| 666 | return false
|
---|
| 667 | end
|
---|
| 668 | end
|
---|
| 669 |
|
---|
| 670 | def exclude_info_factory?
|
---|
| 671 | # print "exclude_info_factory?: name=" + get_name.to_s
|
---|
| 672 | if @celltype == nil ||
|
---|
| 673 | is_of_composite? ||
|
---|
| 674 | @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
|
---|
| 675 | ! @celltype.need_generate? then
|
---|
| 676 | # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
|
---|
| 677 | return true
|
---|
| 678 | else
|
---|
| 679 | # print ": false\n"
|
---|
| 680 | return false
|
---|
| 681 | end
|
---|
| 682 | end
|
---|
| 683 | end
|
---|
| 684 |
|
---|
| 685 | class Signature
|
---|
| 686 | def print_info f, indent
|
---|
| 687 | f.print <<EOT
|
---|
| 688 |
|
---|
| 689 | #{indent}/*** #{@global_name} signature information ****/
|
---|
| 690 | #{indent}cell nTECSInfo::tSignatureInfo #{@global_name}SignatureInfo {
|
---|
| 691 | #{indent} name = "#{@name}";
|
---|
| 692 | EOT
|
---|
| 693 | @function_head_list.get_items.each{ |fh|
|
---|
| 694 | f.print <<EOT
|
---|
| 695 | #{indent} cFunctionInfo[] = #{@global_name}_#{fh.get_name}FunctionInfo.eFunctionInfo;
|
---|
| 696 | EOT
|
---|
| 697 | }
|
---|
| 698 | f.print <<EOT
|
---|
| 699 | #{indent}};
|
---|
| 700 | EOT
|
---|
| 701 | @function_head_list.get_items.each{ |fh|
|
---|
| 702 | fh.print_info f, indent
|
---|
| 703 | }
|
---|
| 704 | end
|
---|
| 705 | end
|
---|
| 706 |
|
---|
| 707 | class FuncHead
|
---|
| 708 | def print_info f, indent
|
---|
| 709 | sig_name = @owner.get_global_name
|
---|
| 710 | func_name = get_name
|
---|
| 711 | f.print <<EOT
|
---|
| 712 | #{indent}cell nTECSInfo::tFunctionInfo #{sig_name}_#{func_name}FunctionInfo {
|
---|
| 713 | #{indent} name = "#{get_name}";
|
---|
| 714 | #{indent} bOneway = #{is_oneway?};
|
---|
| 715 | EOT
|
---|
| 716 | get_paramlist.get_items.each{ |param|
|
---|
| 717 | f.print <<EOT
|
---|
| 718 | #{indent} cParamInfo[] = #{sig_name}_#{func_name}_#{param.get_name}ParamInfo.eParamInfo;
|
---|
| 719 | EOT
|
---|
| 720 | }
|
---|
| 721 | f.print <<EOT
|
---|
| 722 | #{indent} cReturnTypeInfo = #{get_return_type.get_ID_str}TypeInfo.eTypeInfo;
|
---|
| 723 | #{indent}};
|
---|
| 724 | EOT
|
---|
| 725 | get_paramlist.get_items.each{ |param|
|
---|
| 726 | dbgPrint "param_list #{sig_name}, #{func_name}, #{param.get_name}\n"
|
---|
| 727 | param.print_info f, sig_name, func_name, get_paramlist, indent
|
---|
| 728 | }
|
---|
| 729 | get_return_type.print_info f, indent
|
---|
| 730 | end
|
---|
| 731 | end
|
---|
| 732 |
|
---|
| 733 | class ParamDecl
|
---|
| 734 | def print_info f, signature_global_name, func_name, paramdecl_list, indent
|
---|
| 735 | if @size then
|
---|
| 736 | size = "\"#{@size.get_rpn( paramdecl_list )}\""
|
---|
| 737 | else
|
---|
| 738 | size = "(char_t*)0";
|
---|
| 739 | end
|
---|
| 740 | if @count then
|
---|
| 741 | count = "\"#{@count.get_rpn( paramdecl_list )}\""
|
---|
| 742 | else
|
---|
| 743 | count = "(char_t*)0";
|
---|
| 744 | end
|
---|
| 745 | if @string then
|
---|
| 746 | if @string == -1 then
|
---|
| 747 | string = '""'
|
---|
| 748 | else
|
---|
| 749 | string = "\"#{@string.get_rpn( paramdecl_list )}\""
|
---|
| 750 | end
|
---|
| 751 | else
|
---|
| 752 | string = "(char_t*)0";
|
---|
| 753 | end
|
---|
| 754 | f.print <<EOT
|
---|
| 755 | #{indent}cell nTECSInfo::tParamInfo #{signature_global_name}_#{func_name}_#{get_name}ParamInfo {
|
---|
| 756 | #{indent} name = "#{get_name}";
|
---|
| 757 | #{indent} dir = PARAM_DIR_#{@direction};
|
---|
| 758 | #{indent} sizeIsExpr = #{size};
|
---|
| 759 | #{indent} countIsExpr = #{count};
|
---|
| 760 | #{indent} stringExpr = #{string};
|
---|
| 761 | #{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;
|
---|
| 762 | #{indent}};
|
---|
| 763 | EOT
|
---|
| 764 | get_type.print_info f, indent
|
---|
| 765 | end
|
---|
| 766 | end
|
---|
| 767 |
|
---|
| 768 | class Decl
|
---|
| 769 | def print_info f, parent_ID_str, indent, decl_type
|
---|
| 770 | if @size_is then
|
---|
| 771 | size = "\"mikan\"";
|
---|
| 772 | else
|
---|
| 773 | size = "(char_t*)0";
|
---|
| 774 | end
|
---|
| 775 | f.print <<EOT
|
---|
| 776 | #{indent}cell nTECSInfo::tVarDeclInfo #{parent_ID_str}_#{get_name}VarDeclInfo {
|
---|
| 777 | #{indent} name = "#{get_name}";
|
---|
| 778 | #{indent} sizeIsExpr = #{size};
|
---|
| 779 | #{indent} declType = #{decl_type};
|
---|
| 780 | #{indent} offset = C_EXP( "OFFSET_OF_#{parent_ID_str}_#{get_name}" );
|
---|
| 781 | #{indent} place = C_EXP( "PLACE_OF_#{parent_ID_str}_#{get_name}" );
|
---|
| 782 | #{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;
|
---|
| 783 | #{indent}};
|
---|
| 784 | EOT
|
---|
| 785 | get_type.print_info f, indent
|
---|
| 786 | end
|
---|
| 787 | end
|
---|
| 788 |
|
---|
| 789 | class Type
|
---|
| 790 | @@typeinfo_printed = {}
|
---|
| 791 |
|
---|
| 792 | def self.reset_print_info
|
---|
| 793 | @@typeinfo_printed = {}
|
---|
| 794 | end
|
---|
| 795 |
|
---|
| 796 | def print_info f, indent
|
---|
| 797 | # Type ã® info ã¯ãæå¾ã«ã¾ã¨ãã¦åºåããã®ã§ãããã§ã¯è¨é²ããã ã
|
---|
| 798 | if @@typeinfo_printed[ get_ID_str ] then
|
---|
| 799 | return
|
---|
| 800 | end
|
---|
| 801 | # p "ID Str: #{get_ID_str}"
|
---|
| 802 | @@typeinfo_printed[ get_ID_str ] = self
|
---|
| 803 | if self.kind_of? PtrType then
|
---|
| 804 | get_referto.print_info f, indent
|
---|
| 805 | elsif self.kind_of? ArrayType then
|
---|
| 806 | get_type.print_info f, indent
|
---|
| 807 | elsif self.kind_of? DefinedType then
|
---|
| 808 | get_type.print_info f, indent
|
---|
| 809 | elsif self.kind_of? StructType then
|
---|
| 810 | get_members_decl.get_items.each{ |decl|
|
---|
| 811 | decl.print_info f, get_ID_str, indent, :DECLTYPE_STMEMBER
|
---|
| 812 | }
|
---|
| 813 | end
|
---|
| 814 | end
|
---|
| 815 |
|
---|
| 816 | def self.print_info_post f, indent
|
---|
| 817 | @@typeinfo_printed.each{ |nm, type|
|
---|
| 818 | type.print_info_post f, indent
|
---|
| 819 | }
|
---|
| 820 | end
|
---|
| 821 |
|
---|
| 822 | def print_info_post f, indent
|
---|
| 823 | if self.class.superclass == Type then # 親ã¯ã©ã¹ã Type ã®å ´å types.rb ã®ã¯ã©ã¹
|
---|
| 824 | type_name = self.class.name
|
---|
| 825 | else
|
---|
| 826 | type_name = self.class.superclass.name # ctypes.rb ã®ã¯ã©ã¹ (親ã¯ã©ã¹ã types.rb ã®ã¯ã©ã¹)
|
---|
| 827 | end
|
---|
| 828 | # p "type: #{type_name}, #{self.class.name}"
|
---|
| 829 |
|
---|
| 830 | # p "class=#{self.class.name} size=#{bit_size}"
|
---|
| 831 | f.print <<EOT
|
---|
| 832 | #{indent}cell nTECSInfo::t#{type_name}Info #{get_ID_str}TypeInfo{
|
---|
| 833 | #{indent} name = "#{get_type_str}#{get_type_str_post}";
|
---|
| 834 | #{indent} typeKind = TECSTypeKind_#{type_name};
|
---|
| 835 | #{indent} size = C_EXP( "sizeof(#{get_type_str}#{get_type_str_post})" );
|
---|
| 836 | #{indent} b_const = #{is_const?};
|
---|
| 837 | #{indent} b_volatile = #{is_volatile?};
|
---|
| 838 | EOT
|
---|
| 839 | if self.kind_of? PtrType then
|
---|
| 840 | f.print "#{indent} cTypeInfo = #{get_referto.get_ID_str}TypeInfo.eTypeInfo;\n"
|
---|
| 841 | elsif self.kind_of? ArrayType then
|
---|
| 842 | f.print "#{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
|
---|
| 843 | elsif self.kind_of? DefinedType then
|
---|
| 844 | f.print "#{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
|
---|
| 845 | elsif self.kind_of? StructType then
|
---|
| 846 | get_members_decl.get_items.each{ |decl|
|
---|
| 847 | f.print "#{indent} cVarDeclInfo[] = #{get_ID_str}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;\n"
|
---|
| 848 | }
|
---|
| 849 | elsif self.kind_of? DescriptorType then
|
---|
| 850 | f.print "#{indent} cSignatureInfo = #{get_signature.get_global_name}SignatureInfo.eSignatureInfo;\n"
|
---|
| 851 | end
|
---|
| 852 |
|
---|
| 853 | f.print <<EOT
|
---|
| 854 | #{indent}};
|
---|
| 855 | EOT
|
---|
| 856 | end
|
---|
| 857 |
|
---|
| 858 | #=== Type# åæååã®èå¥åå
|
---|
| 859 | #åæååã«å«ã¾ããèå¥åã¨ãã¦ç¨ãããã¨ã®ã§ããªãæåãç¨ãããã¨ã®ã§ããæååã«ç½®ãæãã
|
---|
| 860 | # ç©ºç½ => __
|
---|
| 861 | # * => _Ptr_
|
---|
| 862 | # [] => _Array_
|
---|
| 863 | # Descriptor() => Descriptor_of_
|
---|
| 864 | def get_ID_str
|
---|
| 865 | # puts "get_ID_str: #{self.class.name}"
|
---|
| 866 | if kind_of? PtrType then
|
---|
| 867 | str = get_referto.get_ID_str + "_Ptr_"
|
---|
| 868 | elsif kind_of? ArrayType then
|
---|
| 869 | str = get_type.get_ID_str + "_Array" + get_subscript.eval_const( nil ).to_s + "_"
|
---|
| 870 | elsif kind_of? StructType then
|
---|
| 871 | str = "struct #{@tag}"
|
---|
| 872 | elsif kind_of? DescriptorType then
|
---|
| 873 | str = "Descriptor_of_" + get_signature.get_global_name.to_s
|
---|
| 874 | else
|
---|
| 875 | str = get_type_str + get_type_str_post
|
---|
| 876 | end
|
---|
| 877 | # p "before: #{str}"
|
---|
| 878 | str.gsub!( / /, "__" )
|
---|
| 879 | # p "after: #{str}"
|
---|
| 880 | return str
|
---|
| 881 | end
|
---|
| 882 | end
|
---|
| 883 |
|
---|