Index: EcnlProtoTool/trunk/asp3_dcre/cfg/pass1.rb
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/cfg/pass1.rb	(revision 360)
+++ EcnlProtoTool/trunk/asp3_dcre/cfg/pass1.rb	(revision 429)
@@ -4,5 +4,5 @@
 #
 #  Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
-#  Copyright (C) 2015-2017 by Embedded and Real-Time Systems Laboratory
+#  Copyright (C) 2015-2018 by Embedded and Real-Time Systems Laboratory
 #              Graduate School of Information Science, Nagoya Univ., JAPAN
 #
@@ -36,5 +36,5 @@
 #  の責任を負わない．
 #
-#  $Id$
+#  $Id: pass1.rb 165 2019-01-11 01:29:47Z ertl-hiro $
 #
 
@@ -61,5 +61,9 @@
   "LONG_MAX"  => { EXPR: "LONG_MAX",  SIGNED: true },
   "LONG_MIN"  => { EXPR: "LONG_MIN",  SIGNED: true },
-  "ULONG_MAX" => { EXPR: "ULONG_MAX" }
+  "ULONG_MAX" => { EXPR: "ULONG_MAX" },
+  "SIL_ENDIAN_BIG" \
+	=> { EXPR: "true", BOOL: true, CONDITION: "defined(SIL_ENDIAN_BIG)" },
+  "SIL_ENDIAN_LITTLE" \
+	=> { EXPR: "true", BOOL: true, CONDITION: "defined(SIL_ENDIAN_LITTLE)" }
 }
 
@@ -68,5 +72,5 @@
 #
 $apiDefinition = { "INCLUDE" =>
-  { :PARAM => [ { :NAME => :file, :STRING => true }]}}
+  { :PARAM => [ { :NAME => :file, :STRING_LITERAL => true }]}}
 
 #
@@ -121,8 +125,12 @@
             apiParam[:EXPTYPE] = "signed_t"
             apiParam[:SIGNED] = true
+          when "^"					# ポインタ整数定数式パラメータ
+            apiParam[:EXPTYPE] = "uintptr_t"
+            apiParam[:INTPTR] = true
           when "&"					# 一般整数定数式パラメータ
             # do nothing
           when "$"					# 文字列定数式パラメータ
             apiParam[:STRING] = true
+            apiParam[:EXPTYPE] = "char *"
           else
             error_exit("`#{param}' is invalid")
@@ -171,12 +179,16 @@
 						{ skip_blanks: true, skip_lines: /^#/ })
     symvalCsv.each do |record|
+      symbol = {}
+
       # 変数名
       if record[0].nil?
         error_exit("invalid variable name in " \
 						"`#{symvalTableFileName}:#{symvalCsv.to_io.lineno}'")
-      end
-
-      symbol = {}
-      variable = record[0]
+      elsif /^(.+)\[(.+)\]$/ =~ record[0]
+        variable = $1
+        symbol[:NUMSTRVAR] = $2
+      else
+        variable = record[0]
+      end
 
       # 式
@@ -192,4 +204,6 @@
         when /^[bB]/				# 真偽値
           symbol[:BOOL] = true
+        when /^[iI]/				# ポインタ整数値
+          symbol[:INTPTR] = true
         when /^[uU]/				# 符号無し整数値
           # 何も設定しない
@@ -367,5 +381,5 @@
     skipSpace(cfgFile, withinApi)
     if @line.nil?							# ファイル末であればエラー終了
-      error_exit("unexpexced end-of-file")
+      error_exit("#{cfgFile.getFileName}: unexpeced end-of-file")
     end
   end
@@ -472,5 +486,5 @@
     end
 
-    if apiParam.has_key?(:STRING)
+    if apiParam.has_key?(:STRING_LITERAL)
       return(param.unquote)
     else
@@ -604,8 +618,9 @@
         # プリプロセッサディレクティブを読む
         case @line
-        when /^#include\b(.*)$/
-          $includeFiles.push($1.strip)
-        when /^#(ifdef|ifndef|if|endif|else|elif)\b/
-          directive = { :DIRECTIVE => @line.strip }
+        when /^#(include|ifdef|ifndef|if|endif|else|elif)\b/
+          directive = {}
+          directive[:DIRECTIVE] = @line.strip
+          directive[:_FILE_] = cfgFile.getFileName
+          directive[:_LINE_] = cfgFile.getLineNo
           $cfgFileInfo.push(directive)
         else
@@ -619,5 +634,5 @@
         case apiName
         when "KERNEL_DOMAIN"
-          if $supportDomain.nil?
+          if !$supportDomain
             parse_warning(cfgFile, "`KERNEL_DOMAIN' is not supported")
           end
@@ -629,5 +644,5 @@
           @@nestDC.push("domain")
         when "DOMAIN"
-          if $supportDomain.nil?
+          if !$supportDomain
             parse_warning(cfgFile, "`DOMAIN' is not supported")
           end
@@ -655,5 +670,5 @@
           @@nestDC.push("domain")
         when "CLASS"
-          if $supportClass.nil?
+          if !$supportClass
             parse_warning(cfgFile, "`CLASS' is not supported")
           end
@@ -676,5 +691,9 @@
               includeFilePath = SearchFilePath(staticApi[:file])
               if includeFilePath.nil?
-                parse_error(cfgFile, "`#{staticApi[:file]}' not found")
+                error = {}
+                error[:DIRECTIVE] = "#error '#{staticApi[:file]}' not found."
+                error[:_FILE_] = cfgFile.getFileName
+                error[:_LINE_] = cfgFile.getLineNo
+                $cfgFileInfo.push(error)
               else
                 $dependencyFiles.push(includeFilePath)
@@ -694,4 +713,12 @@
               $cfgFileInfo.push(staticApi)
             end
+
+            # ";"を読む
+            skipToToken(cfgFile, false)		# 次の文字まで読み飛ばす
+            if (/^\;(.*)$/ =~ @line)
+              @line = $1
+            else
+              parse_error(cfgFile, "`;' expected after static API")
+            end
           else
             parse_error(cfgFile, "unknown static API: #{apiName}")
@@ -727,5 +754,5 @@
   #
   def self.OutLineNumber(cfgInfo)
-    @cfg1Out.add("#line #{cfgInfo[:_LINE_]} \"#{cfgInfo[:_FILE_].gsub('\\', '/')}\"")
+    @cfg1Out.add("#line #{cfgInfo[:_LINE_]} \"#{cfgInfo[:_FILE_]}\"")
   end
 
@@ -734,5 +761,5 @@
   #
   def self.OutClassLineNumber(cfgInfo)
-    @cfg1Out.add("#line #{cfgInfo[:CLASS_LINE_]} \"#{cfgInfo[:CLASS_FILE_].gsub('\\', '/')}\"")
+    @cfg1Out.add("#line #{cfgInfo[:CLASS_LINE_]} \"#{cfgInfo[:CLASS_FILE_]}\"")
   end
 
@@ -763,7 +790,10 @@
 EOS
 
-    # インクルードヘッダファイル
-    $includeFiles.each do |file|
-      @cfg1Out.add("#include #{file}")
+    # インクルードディレクティブ（#include）の生成
+    $cfgFileInfo.each do |cfgInfo|
+      if cfgInfo.has_key?(:DIRECTIVE)
+        OutLineNumber(cfgInfo)
+        @cfg1Out.add(cfgInfo[:DIRECTIVE])
+      end
     end
 
@@ -780,18 +810,17 @@
 #include "#{CFG1_OUT_TARGET_H}"
 
-#if defined(SIL_ENDIAN_BIG) && defined(SIL_ENDIAN_LITTLE)
-#error Both SIL_ENDIAN_BIG and SIL_ENDIAN_LITTLE are defined.
-#endif
-#if !defined(SIL_ENDIAN_BIG) && !defined(SIL_ENDIAN_LITTLE)
-#error Neither SIL_ENDIAN_BIG nor SIL_ENDIAN_LITTLE is defined.
-#endif
-
 const uint32_t #{CFG1_MAGIC_NUM} = 0x12345678;
 const uint32_t #{CFG1_SIZEOF_SIGNED} = sizeof(signed_t);
+const uint32_t #{CFG1_SIZEOF_INTPTR} = sizeof(intptr_t);
+const uint32_t #{CFG1_SIZEOF_CHARPTR} = sizeof(char *);
 EOS
 
     # 値取得シンボルの処理
     $symbolValueTable.each do |symbolName, symbolData|
-      if symbolData.has_key?(:BOOL) || symbolData.has_key?(:SIGNED)
+      if symbolData.has_key?(:BOOL)
+        type = "signed_t"
+      elsif symbolData.has_key?(:INTPTR)
+        type = "uintptr_t"
+      elsif symbolData.has_key?(:SIGNED)
         type = "signed_t"
       else
@@ -825,5 +854,9 @@
     $cfgFileInfo.each do |cfgInfo|
       if cfgInfo.has_key?(:DIRECTIVE)
-        @cfg1Out.add2(cfgInfo[:DIRECTIVE])
+        # 条件ディレクティブを出力
+        if cfgInfo[:DIRECTIVE] =~ /^#(ifdef|ifndef|if|endif|else|elif)\b/
+          OutLineNumber(cfgInfo)
+          @cfg1Out.add2(cfgInfo[:DIRECTIVE])
+        end
       else
         apiDef = $apiDefinition[cfgInfo[:APINAME]]
@@ -882,5 +915,4 @@
   $cfgFileInfo = []
   $dependencyFiles = $configFileNames.dup
-  $includeFiles = []
   $domainId = { "TDOM_KERNEL" => -1, "TDOM_NONE" => -2 }
   $configFileNames.each do |configFileName|
@@ -939,5 +971,5 @@
   #  パス2に引き渡す情報をファイルに生成
   #
-  if $omitOutputDb.nil?
+  if !$omitOutputDb
     db = PStore.new(CFG1_OUT_DB)
     db.transaction do
@@ -945,5 +977,4 @@
       db[:symbolValueTable] = $symbolValueTable
       db[:cfgFileInfo] = $cfgFileInfo
-      db[:includeFiles] = $includeFiles
       db[:domainId] = $domainId
     end
