Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/core/tecsinfo.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/core/tecsinfo.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/core/tecsinfo.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2017 by TOPPERS Project
+#   Copyright (C) 2017-2018 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -49,5 +49,7 @@
 #{indent0}region rTECSInfo {
 EOT
-    # mikan 全部生成するのではなく、region 下のセルのセルタイプと、そこから参照されるシグニチャ、セルタイプに限定して出力する．
+    Type.reset_print_info
+
+    # mikan 全部生成するのではなく、region 下のセルのセルタイプと、そこから参照されるシグニチャ、セルタイプに限定して出力すべき
     # しかし、意味解析後に出力するため、これは容易ではない．最適化とコード生成は、リンクルートごとに行われる．
     Namespace.print_info f, indent
@@ -149,4 +151,7 @@
                  "#{tag.get_ID_str}_#{decl.get_name}",
                  "(uint32_t)(intptr_t)&(((#{tag.get_type_str}#{tag.get_type_str_post}*)0)->#{decl.get_name})"
+        f.printf "#define PLACE_OF_%-30s  (%s)\n",
+                 "#{tag.get_ID_str}_#{decl.get_name}",
+                 "VARDECL_PLACE_STRUCT"
       }
     }
@@ -213,4 +218,5 @@
       name = @global_name
     end
+    # p "region:#{get_name}"
     f.print "\n#{indent}/*** #{get_namespace_path} region information cell ***/\n"
     f.print <<EOT
@@ -219,11 +225,20 @@
 EOT
     @cell_list.each{ |cell|
-      if cell.get_global_name != :rTECSInfo_TECSInfoSub then
+        # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 1\n"
+      if ! cell.exclude_info? then
+        # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 2\n"
         f.print "#{indent}    cCellInfo[] = #{cell.get_global_name}CellInfo.eCellInfo;\n"
       end
+    }
+    @namespace_list.each { |region|
+      if region.instance_of? Region then
+        f.print "#{indent}    cRegionInfo[] = #{region.get_global_name}RegionInfo.eRegionInfo;\n"
+       end
     }
     f.print "#{indent}};\n"
     @cell_list.each{ |cell|
-      cell.print_info f, indent
+      if ! cell.exclude_info? then
+        cell.print_info f, indent
+      end
     }
   end
@@ -256,4 +271,5 @@
     ct_list = {}
     @cell_list.each{ |cell|
+      next if cell.exclude_info_factory?
       ct_list[ cell.get_celltype ] = true
     }
@@ -264,9 +280,12 @@
     f.print "\n"
     @cell_list.each{ |cell|
+      next if cell.exclude_info_factory?
       name_array = cell.get_celltype.get_name_array cell
       if cell.get_celltype.has_CB?
         cb = "(void*)#{name_array[8]}"
+        cb_proto = "extern #{cell.get_celltype.get_global_name}_CB #{name_array[4]};\n"
       else
         cb = "0"
+        cb_proto = ""
       end
       if cell.get_celltype.has_INIB?
@@ -277,7 +296,7 @@
         inib_proto = ""
       end
-      if cell.get_global_name != :rTECSInfo_TECSInfoSub then
+      if ! cell.exclude_info_factory? then
         f.print <<EOT
-#define  #{cell.get_global_name}__CBP   #{cb}
+#{cb_proto}#define  #{cell.get_global_name}__CBP   #{cb}
 #{inib_proto}#define  #{cell.get_global_name}__INIBP #{inib}
 EOT
@@ -287,4 +306,31 @@
       if region.instance_of? Region then
         region.print_cell_define f
+      end
+    }
+  end
+
+  def print_entry_descriptor_define f
+    @cell_list.each{ |cell|
+      next if cell.exclude_info_factory?
+
+      signatures = {}
+      cell.get_celltype.get_port_list.each{ |port|
+        next if port.get_port_type != :ENTRY
+
+        if signatures[ port.get_signature ] == nil then
+          f.print "#include \"#{port.get_signature.get_global_name}_tecsgen.h\"\n"
+        end
+        if cell.get_celltype.get_global_name == :nTECSInfo_tRawEntryDescriptorInfo then
+          f.print "const struct tag_#{cell.get_celltype.get_global_name}_#{port.get_name}_DES "
+          f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
+        else
+          f.print "extern struct tag_#{port.get_signature.get_global_name}_VDES "
+          f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
+        end
+      }
+    }
+    @namespace_list.each { |region|
+      if region.instance_of? Region then
+        region.print_entry_descriptor_define f
       end
     }
@@ -342,8 +388,8 @@
     }
     @attribute.each{ |decl|
-      decl.print_info f, @global_name, indent
+      decl.print_info f, @global_name, indent, :DECLTYPE_ATTR
     }
     @var.each{ |decl|
-      decl.print_info f, @global_name, indent
+      decl.print_info f, @global_name, indent, :DECLTYPE_VAR
     }
   end
@@ -364,16 +410,21 @@
         if ! decl.is_omit? then
           offset = "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
+          place = inib_cb
         else
           offset = "0xffffffff"
+          place = "NON"
         end
         f.printf "#define OFFSET_OF_%-30s  (%s)\n", "#{@global_name}_#{decl.get_name}", offset
+        f.printf "#define PLACE_OF_%-30s  VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
       }
       @var.each{ |decl|
-        if decl.get_size_is then
+        if decl.get_size_is && has_INIB? then
           inib_cb = "INIB"
         else
           inib_cb = "CB"
         end
-          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})"
+        place = inib_cb
+        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})"
+        f.printf "#define PLACE_OF_%-30s  VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
       }
     else
@@ -385,7 +436,9 @@
       @attribute.each{ |decl|
         f.printf "#define OFFSET_OF_%-30s  (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
+        f.printf "#define PLACE_OF_%-30s   VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
       }
       @var.each{ |decl|
         f.printf "#define OFFSET_OF_%-30s  (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
+        f.printf "#define PLACE_OF_%-30s   VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
       }
     end
@@ -404,9 +457,16 @@
     end
 
-    f.printf "\n#include \"#{@global_name}_tecsgen.h\"\n"
-    f.printf "#define %-50s (#{@idx_is_id_act})\n",     "#{@global_name}__IDX_is_ID_act"
-    f.printf "#define %-50s (#{size_CB})\n",            "#{@global_name}__sizeOfCB"
-    f.printf "#define %-50s (#{size_INIB})\n",          "#{@global_name}__sizeOfINIB"
-    f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
+    if @n_cell_gen > 0 then
+      f.printf "\n#include \"#{@global_name}_tecsgen.h\"\n"
+      f.printf "#define %-50s (#{@idx_is_id_act})\n",     "#{@global_name}__IDX_is_ID_act"
+      f.printf "#define %-50s (#{size_CB})\n",            "#{@global_name}__sizeOfCB"
+      f.printf "#define %-50s (#{size_INIB})\n",          "#{@global_name}__sizeOfINIB"
+      f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
+    else
+      f.printf "#define %-50s (false)\n",                 "#{@global_name}__IDX_is_ID_act"
+      f.printf "#define %-50s (0)\n",                     "#{@global_name}__sizeOfCB"
+      f.printf "#define %-50s (0)\n",                     "#{@global_name}__sizeOfINIB"
+      f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
+    end
   end
 
@@ -446,5 +506,5 @@
         end
       end
-      if ( port.is_VMT_useless? && port.is_cell_unique? ) || @n_cell_gen == 0 then
+      if ( port.is_VMT_useless? && port.is_cell_unique? ) || port.is_omit? || @n_cell_gen == 0 then
         offset = "0xffffffff"
       else
@@ -525,5 +585,5 @@
 class Cell
   def print_info f, indent
-    if @global_name == :rTECSInfo_TECSInfoSub then
+    if exclude_info? then
       return
     end
@@ -536,6 +596,67 @@
 #{indent}    inibp           = C_EXP( \"#{@global_name}__INIBP\" );
 #{indent}    cCelltypeInfo   = #{@celltype.get_global_name}CelltypeInfo.eCelltypeInfo;
-#{indent}};
-EOT
+EOT
+    @celltype.get_port_list.each{ |port|
+      next if port.get_port_type != :ENTRY
+
+      f.print <<EOT
+#{indent}    cRawEntryDescriptor[] = #{@global_name}_#{port.get_name}RawEntryDescriptorInfo.eRawEntryDescriptor;
+EOT
+    }
+    f.print "#{indent}};\n"
+
+    # RawEntryDescriptorInfo cells
+    @celltype.get_port_list.each{ |port|
+      next if port.get_port_type != :ENTRY
+
+      size = port.get_array_size
+      if size == nil then
+        size = 1
+      elsif size == "[]" then
+        size = @entry_array_max_subscript[ port ]
+      end
+      if ! port.is_omit? then
+        red = "C_EXP( \"&#{@global_name}_#{port.get_name}_des\" )"
+      else
+        red = "(void *)0"
+      end
+      # mikan 受け口配列
+      f.print <<EOT
+#{indent}cell nTECSInfo::tRawEntryDescriptorInfo #{@global_name}_#{port.get_name}RawEntryDescriptorInfo {
+#{indent}   size = #{size};
+#{indent}   rawEntryDescriptor = { #{red} };
+EOT
+#  #{indent}   cEntryInfo = #{@celltype.get_global_name}_#{port.get_name}EntryInfo.eEntryInfo;
+      f.print "#{indent}};\n"
+    }
+  end
+
+  def exclude_info?
+    # print "exclude_info?: name=" + get_name.to_s
+    if @celltype == nil ||
+       is_of_composite? ||
+       @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
+       post_code_generated? ||
+       @b_defined == false then
+      # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
+      return true
+    else
+      # print ": false\n"
+      return false
+    end
+  end
+
+  def exclude_info_factory?
+    # print "exclude_info_factory?: name=" + get_name.to_s
+    if @celltype == nil ||
+       is_of_composite? ||
+       @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
+       ! @celltype.need_generate? then
+      # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
+      return true
+    else
+      # print ": false\n"
+      return false
+    end
   end
 end
@@ -569,5 +690,5 @@
     f.print <<EOT
 #{indent}cell nTECSInfo::tFunctionInfo #{sig_name}_#{func_name}FunctionInfo {
-#{indent}    name            = "#{@owner.get_global_name}_#{@name}";
+#{indent}    name            = "#{get_name}";
 #{indent}    bOneway         = #{is_oneway?};
 EOT
@@ -625,5 +746,5 @@
 
 class Decl
-  def print_info f, parent_ID_str, indent
+  def print_info f, parent_ID_str, indent, decl_type
     if @size_is then
       size = "\"mikan\"";
@@ -635,6 +756,7 @@
 #{indent}    name            = "#{get_name}";
 #{indent}    sizeIsExpr      = #{size};
-#{indent}    declType        = DECLTYPE_STMEMBER;
+#{indent}    declType        = #{decl_type};
 #{indent}    offset          = C_EXP( "OFFSET_OF_#{parent_ID_str}_#{get_name}" );
+#{indent}    place           = C_EXP( "PLACE_OF_#{parent_ID_str}_#{get_name}" );
 #{indent}    cTypeInfo       = #{get_type.get_ID_str}TypeInfo.eTypeInfo;
 #{indent}};
@@ -646,4 +768,9 @@
 class Type
   @@typeinfo_printed = {}
+
+  def self.reset_print_info
+    @@typeinfo_printed = {}
+  end
+
   def print_info f, indent
     # Type の info は、最後にまとめて出力するので、ここでは記録するだけ
@@ -661,5 +788,5 @@
     elsif self.kind_of? StructType then
       get_members_decl.get_items.each{ |decl|
-        decl.get_type.print_info f, indent
+        decl.print_info f, get_ID_str, indent, :DECLTYPE_STMEMBER
       }
     end
@@ -673,8 +800,4 @@
 
   def print_info_post f, indent
-    bit_size = get_bit_size
-    if bit_size <= 0 then
-      bit_size = "C_EXP( \"sizeof(#{get_type_str}#{get_type_str_post})\" )"
-    end
     if self.class.superclass == Type then     # 親クラスが Type の場合 types.rb のクラス
       type_name = self.class.name
@@ -689,17 +812,17 @@
 #{indent}    name           = "#{get_type_str}#{get_type_str_post}";
 #{indent}    typeKind       = TECSTypeKind_#{type_name};
-#{indent}    size           = #{bit_size};
+#{indent}    size           = C_EXP( "sizeof(#{get_type_str}#{get_type_str_post})" );
 #{indent}    b_const        = #{is_const?};
 #{indent}    b_volatile     = #{is_volatile?};
 EOT
     if self.kind_of? PtrType then
-      f.print "#{indent}    cTypeInfo      = #{get_referto.get_ID_str}TypeInfo.eTypeInfo;\n"
+      f.print "#{indent}    cTypeInfo        = #{get_referto.get_ID_str}TypeInfo.eTypeInfo;\n"
     elsif self.kind_of? ArrayType then
-      f.print "#{indent}    cTypeInfo      = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
+      f.print "#{indent}    cTypeInfo        = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
     elsif self.kind_of? DefinedType then
-      f.print "#{indent}    cTypeInfo      = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
+      f.print "#{indent}    cTypeInfo        = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
     elsif self.kind_of? StructType then
       get_members_decl.get_items.each{ |decl|
-        f.print "#{indent}    cTypeInfo[]    = #{decl.get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
+        f.print "#{indent}    cVarDeclInfo[] = #{get_ID_str}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;\n"
       }
     elsif self.kind_of? DescriptorType then
