diff options
author | jkim <jkim@FreeBSD.org> | 2012-03-20 18:17:33 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2012-03-20 18:17:33 +0000 |
commit | f65c4f80d1c60e597f67836e51986ebf3cd669f7 (patch) | |
tree | 3fa3a8ab860459d0b2c9768eed9142052be1ced3 /source/compiler/preprocess.h | |
parent | a6dfe3119152f97e640cc135d963b9f7c95c84ef (diff) | |
download | FreeBSD-src-f65c4f80d1c60e597f67836e51986ebf3cd669f7.zip FreeBSD-src-f65c4f80d1c60e597f67836e51986ebf3cd669f7.tar.gz |
Import ACPICA 20120320.
Diffstat (limited to 'source/compiler/preprocess.h')
-rw-r--r-- | source/compiler/preprocess.h | 290 |
1 files changed, 290 insertions, 0 deletions
diff --git a/source/compiler/preprocess.h b/source/compiler/preprocess.h new file mode 100644 index 0000000..09b7b76 --- /dev/null +++ b/source/compiler/preprocess.h @@ -0,0 +1,290 @@ +/****************************************************************************** + * + * Module Name: preprocess.h - header for iASL Preprocessor + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2012, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#define __PREPROCESS_H__ + +#ifndef _PREPROCESS +#define _PREPROCESS + +#undef PR_EXTERN + +#ifdef _DECLARE_PR_GLOBALS +#define PR_EXTERN +#define PR_INIT_GLOBAL(a,b) (a)=(b) +#else +#define PR_EXTERN extern +#define PR_INIT_GLOBAL(a,b) (a) +#endif + + +/* + * Configuration + */ +#define PR_MAX_MACRO_ARGS 32 /* Max number of macro args */ +#define PR_MAX_ARG_INSTANCES 24 /* Max instances of any one arg */ +#define PR_LINES_PER_BLOCK 4096 /* Max input source lines per block */ + + +/* + * Local defines and macros + */ +#define PR_TOKEN_SEPARATORS " ,(){}\t\n" +#define PR_MACRO_SEPARATORS " ,(){}~!*/%+-<>=&^|\"\t\n" +#define PR_MACRO_ARGUMENTS " ,\t\n" +#define PR_EXPR_SEPARATORS " ,(){}~!*/%+-<>=&^|\"\t\n" + +#define PR_PREFIX_ID "Pr(%.4u) - " /* Used for debug output */ + +#define THIS_TOKEN_OFFSET(t) ((t-Gbl_MainTokenBuffer) + 1) + + +/* + * Preprocessor structures + */ +typedef struct pr_macro_arg +{ + char *Name; + UINT32 Offset[PR_MAX_ARG_INSTANCES]; + UINT16 UseCount; + +} PR_MACRO_ARG; + +typedef struct pr_define_info +{ + struct pr_define_info *Previous; + struct pr_define_info *Next; + char *Identifier; + char *Replacement; + char *Body; /* Macro body */ + PR_MACRO_ARG *Args; /* Macro arg list */ + UINT16 ArgCount; /* Macro arg count */ + BOOLEAN Persist; /* Keep for entire compiler run */ + +} PR_DEFINE_INFO; + +typedef struct pr_directive_info +{ + char *Name; /* Directive name */ + UINT8 ArgCount; /* Required # of args */ + +} PR_DIRECTIVE_INFO; + +typedef struct pr_operator_info +{ + char *Op; + +} PR_OPERATOR_INFO; + +typedef struct pr_file_node +{ + struct pr_file_node *Next; + FILE *File; + char *Filename; + UINT32 CurrentLineNumber; + +} PR_FILE_NODE; + +typedef struct pr_line_mapping +{ + UINT32 *Map; + struct pr_line_mapping *Next; + +} PR_LINE_MAPPING; + + +/* + * Globals + */ +PR_EXTERN char XXXEvalBuffer[ASL_LINE_BUFFER_SIZE]; +PR_EXTERN char Gbl_MainTokenBuffer[ASL_LINE_BUFFER_SIZE]; +PR_EXTERN char Gbl_MacroTokenBuffer[ASL_LINE_BUFFER_SIZE]; +PR_EXTERN char Gbl_ExpressionTokenBuffer[ASL_LINE_BUFFER_SIZE]; + +PR_EXTERN PR_LINE_MAPPING *Gbl_MapBlockHead; +PR_EXTERN PR_FILE_NODE *Gbl_InputFileList; +PR_EXTERN PR_DEFINE_INFO PR_INIT_GLOBAL (*Gbl_DefineList, NULL); +PR_EXTERN UINT32 Gbl_PreprocessorLineNumber; +PR_EXTERN int Gbl_IfDepth; +PR_EXTERN BOOLEAN PR_INIT_GLOBAL (Gbl_PreprocessorError, FALSE); + + +/* + * prscan - Preprocessor entry + */ +void +PrInitializePreprocessor ( + void); + +void +PrInitializeGlobals ( + void); + +void +PrTerminatePreprocessor ( + void); + +BOOLEAN +PrDoPreprocess ( + void); + +UINT32 +PrGetLineNumber ( + UINT32 PreprocessorLineNumber); + +UINT64 +PrIsDefined ( + char *Identifier); + +UINT64 +PrResolveDefine ( + char *Identifier); + +int +PrInitLexer ( + char *String); + +void +PrTerminateLexer ( + void); + + +/* + * prmacros - Support for #defines and macros + */ +void +PrDumpPredefinedNames ( + void); + +PR_DEFINE_INFO * +PrAddDefine ( + char *Token, + char *Token2, + BOOLEAN Persist); + +void +PrRemoveDefine ( + char *DefineName); + +PR_DEFINE_INFO * +PrMatchDefine ( + char *MatchString); + +void +PrAddMacro ( + char *Name, + char **Next); + +void +PrDoMacroInvocation ( + char *TokenBuffer, + char *MacroStart, + PR_DEFINE_INFO *DefineInfo, + char **Next); + + +/* + * prexpress - #if expression support + */ +ACPI_STATUS +PrResolveIntegerExpression ( + char *Line, + UINT64 *ReturnValue); + +char * +PrPrioritizeExpression ( + char *OriginalLine); + +/* + * prparser - lex/yacc expression parser + */ +UINT64 +PrEvaluateExpression ( + char *ExprString); + + +/* + * prutils - Preprocesor utilities + */ +char * +PrGetNextToken ( + char *Buffer, + char *MatchString, + char **Next); + +void +PrSetLineNumber ( + UINT32 OriginalLineNumber, + UINT32 NewLineNumber); + +void +PrError ( + UINT8 Level, + UINT8 MessageId, + UINT32 Column); + +void +PrReplaceData ( + char *Buffer, + UINT32 LengthToRemove, + char *BufferToAdd, + UINT32 LengthToAdd); + +void +PrOpenIncludeFile ( + char *Filename); + +FILE * +PrOpenIncludeWithPrefix ( + char *PrefixDir, + char *Filename); + +void +PrPushInputFileStack ( + FILE *InputFile, + char *Filename); + +BOOLEAN +PrPopInputFileStack ( + void); + +#endif |