## @file
# preprocess source file
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import sys
import os
import re
import CodeFragmentCollector
import FileProfile
from EotToolError import *
import EotGlobalData
# Global Dicts
IncludeFileListDict = {}
IncludePathListDict = {}
ComplexTypeDict = {}
SUDict = {}
## GetFuncDeclPattern() method
#
# Get the pattern of function declaration
#
# @return p: the pattern of function declaration
#
def GetFuncDeclPattern():
return p
## GetArrayPattern() method
#
# Get the pattern of array
#
# @return p: the pattern of array
#
def GetArrayPattern():
return p
## GetTypedefFuncPointerPattern() method
#
# Get the pattern of function pointer
#
# @return p: the pattern of function pointer
#
def GetTypedefFuncPointerPattern():
return p
## GetDB() method
#
# Get global database instance
#
# @return EotGlobalData.gDb: the global database instance
#
def GetDB():
return EotGlobalData.gDb
## PrintErrorMsg() method
#
# print error message
#
# @param ErrorType: Type of error
# @param Msg: Error message
# @param TableName: table name of error found
# @param ItemId: id of item
#
Msg = ''
for Part in MsgPartList:
Msg += ' '
GetDB().TblReport.Insert(ErrorType, OtherMsg = Msg, BelongsToTable = TableName, BelongsToItem = ItemId)
## GetIdType() method
#
# Find type of input string
#
# @param Str: String to be parsed
#
# @return Type: The type of the string
#
else:
return Type
## GetIdentifierList() method
#
# Get id of all files
#
# @return IdList: The list of all id of files
#
def GetIdentifierList():
IdList = []
IdPP = DataClass.IdentifierClass(-1, '', '', '', pp.Content, Type, -1, -1, pp.StartPos[0],pp.StartPos[1],pp.EndPos[0],pp.EndPos[1])
IdAE = DataClass.IdentifierClass(-1, ae.Operator, '', ae.Name, ae.Value, DataClass.MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION, -1, -1, ae.StartPos[0],ae.StartPos[1],ae.EndPos[0],ae.EndPos[1])
Index = 0
Index += 1
IdVar = DataClass.IdentifierClass(-1, var.Modifier, '', var.Declarator, '', DataClass.MODEL_IDENTIFIER_FUNCTION_DECLARATION, -1, -1, var.StartPos[0],var.StartPos[1],var.EndPos[0],var.EndPos[1])
continue
IdVar = DataClass.IdentifierClass(-1, var.Modifier, '', Name, (len(DeclList) > 1 and [DeclList[1]]or [''])[0], DataClass.MODEL_IDENTIFIER_VARIABLE, -1, -1, var.StartPos[0],var.StartPos[1],var.EndPos[0],var.EndPos[1])
else:
IdVar = DataClass.IdentifierClass(-1, var.Modifier, '', Name, (len(DeclList) > 1 and [DeclList[1]]or [''])[0], DataClass.MODEL_IDENTIFIER_VARIABLE, -1, -1, var.StartPos[0],var.StartPos[1],var.EndPos[0],var.EndPos[1])
IdEnum = DataClass.IdentifierClass(-1, '', '', Name, Value, DataClass.MODEL_IDENTIFIER_ENUMERATE, -1, -1, enum.StartPos[0],enum.StartPos[1],enum.EndPos[0],enum.EndPos[1])
SkipLen = 6
SkipLen = 5
Value = ''
else:
IdPE = DataClass.IdentifierClass(-1, '', '', Name, Value, Type, -1, -1, su.StartPos[0],su.StartPos[1],su.EndPos[0],su.EndPos[1])
Modifier = ''
if StarPos != -1:
StarPos += 1
IdTd = DataClass.IdentifierClass(-1, Modifier, '', Name, Value, DataClass.MODEL_IDENTIFIER_TYPEDEF, -1, -1, td.StartPos[0],td.StartPos[1],td.EndPos[0],td.EndPos[1])
IdFC = DataClass.IdentifierClass(-1, '', '', funcCall.FuncName, funcCall.ParamList, DataClass.MODEL_IDENTIFIER_FUNCTION_CALLING, -1, -1, funcCall.StartPos[0],funcCall.StartPos[1],funcCall.EndPos[0],funcCall.EndPos[1])
return IdList
## GetParamList() method
#
# Get a list of parameters
#
# @param FuncDeclarator: Function declarator
# @param FuncNameLine: Line number of function name
# @param FuncNameOffset: Offset of function name
#
# @return ParamIdList: A list of parameters
#
ParamIdList = []
return ParamIdList
LineSkipped = 0
OffsetSkipped = 0
Start = 0
LineSkipped += 1
OffsetSkipped = 0
Start += 1
continue
if ParamName == 'OPTIONAL':
if ParamModifier == '':
DeclText = ''
else:
ParamModifier += 'OPTIONAL'
Start = 0
LineSkipped += 1
OffsetSkipped = 0
Start += 1
IdParam = DataClass.IdentifierClass(-1, ParamModifier, '', ParamName, '', DataClass.MODEL_IDENTIFIER_PARAMETER, -1, -1, ParamBeginLine, ParamBeginOffset, ParamEndLine, ParamEndOffset)
return ParamIdList
## GetFunctionList()
#
# Get a list of functions
#
# @return FuncObjList: A list of function objects
#
def GetFunctionList():
FuncObjList = []
ParamIdList = []
continue
Index = 0
Index += 1
FuncObj = DataClass.FunctionClass(-1, FuncDef.Declarator, FuncDef.Modifier, FuncName.strip(), '', FuncDef.StartPos[0],FuncDef.StartPos[1],FuncDef.EndPos[0],FuncDef.EndPos[1], FuncDef.LeftBracePos[0], FuncDef.LeftBracePos[1], -1, ParamIdList, [])
return FuncObjList
## CreateCCodeDB() method
#
# Create database for all c code
#
# @param FileNameList: A list of all c code file names
#
FileObjList = []
ParseErrorFileList = []
ParsedFiles = {}
for FullName in FileNameList:
continue
try:
except:
FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), [])
EdkLogger.info("Found unrecoverable error during parsing:\n\t%s\n" % "\n\t".join(ParseErrorFileList))
for file in FileObjList:
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
# script.
#
if __name__ == '__main__':
print 'Done!'