1 /******************************************************************************
3 * Module Name: preprocess.h - header for iASL Preprocessor
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #define __PREPROCESS_H__
51 #ifdef _DECLARE_PR_GLOBALS
53 #define PR_INIT_GLOBAL(a,b) (a)=(b)
55 #define PR_EXTERN extern
56 #define PR_INIT_GLOBAL(a,b) (a)
63 #define PR_MAX_MACRO_ARGS 32 /* Max number of macro args */
64 #define PR_MAX_ARG_INSTANCES 24 /* Max instances of any one arg */
65 #define PR_LINES_PER_BLOCK 4096 /* Max input source lines per block */
69 * Local defines and macros
71 #define PR_TOKEN_SEPARATORS " ,(){}\t\n"
72 #define PR_MACRO_SEPARATORS " ,(){}~!*/%+-<>=&^|\"\t\n"
73 #define PR_MACRO_ARGUMENTS " ,\t\n"
74 #define PR_EXPR_SEPARATORS " ,(){}~!*/%+-<>=&^|\"\t\n"
76 #define PR_PREFIX_ID "Pr(%.4u) - " /* Used for debug output */
78 #define THIS_TOKEN_OFFSET(t) ((t-Gbl_MainTokenBuffer) + 1)
82 * Preprocessor structures
84 typedef struct pr_macro_arg
87 UINT32 Offset[PR_MAX_ARG_INSTANCES];
92 typedef struct pr_define_info
94 struct pr_define_info *Previous;
95 struct pr_define_info *Next;
98 char *Body; /* Macro body */
99 PR_MACRO_ARG *Args; /* Macro arg list */
100 UINT16 ArgCount; /* Macro arg count */
101 BOOLEAN Persist; /* Keep for entire compiler run */
105 typedef struct pr_directive_info
107 char *Name; /* Directive name */
108 UINT8 ArgCount; /* Required # of args */
112 typedef struct pr_operator_info
118 typedef struct pr_file_node
120 struct pr_file_node *Next;
123 UINT32 CurrentLineNumber;
127 #define MAX_ARGUMENT_LENGTH 24
129 typedef struct directive_info
131 struct directive_info *Next;
132 char Argument[MAX_ARGUMENT_LENGTH];
134 BOOLEAN IgnoringThisCodeBlock;
142 #if 0 /* TBD for macros */
143 PR_EXTERN char PR_INIT_GLOBAL (*XXXEvalBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
146 PR_EXTERN char PR_INIT_GLOBAL (*Gbl_MainTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
147 PR_EXTERN char PR_INIT_GLOBAL (*Gbl_MacroTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
148 PR_EXTERN char PR_INIT_GLOBAL (*Gbl_ExpressionTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
150 PR_EXTERN UINT32 Gbl_PreprocessorLineNumber;
151 PR_EXTERN int Gbl_IfDepth;
152 PR_EXTERN PR_FILE_NODE *Gbl_InputFileList;
153 PR_EXTERN PR_DEFINE_INFO PR_INIT_GLOBAL (*Gbl_DefineList, NULL);
154 PR_EXTERN BOOLEAN PR_INIT_GLOBAL (Gbl_PreprocessorError, FALSE);
155 PR_EXTERN BOOLEAN PR_INIT_GLOBAL (Gbl_IgnoringThisCodeBlock, FALSE);
156 PR_EXTERN DIRECTIVE_INFO PR_INIT_GLOBAL (*Gbl_DirectiveStack, NULL);
159 * prscan - Preprocessor entry
162 PrInitializePreprocessor (
166 PrInitializeGlobals (
170 PrTerminatePreprocessor (
195 * prmacros - Support for #defines and macros
198 PrDumpPredefinedNames (
221 PrDoMacroInvocation (
224 PR_DEFINE_INFO *DefineInfo,
229 * prexpress - #if expression support
232 PrResolveIntegerExpression (
234 UINT64 *ReturnValue);
237 PrPrioritizeExpression (
241 * prparser - lex/yacc expression parser
244 PrEvaluateExpression (
249 * prutils - Preprocesor utilities
266 UINT32 LengthToRemove,
275 PrOpenIncludeWithPrefix (
280 PrPushInputFileStack (
285 PrPopInputFileStack (