prexpress.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: prexpress - Preprocessor #if expression support
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, 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 _COMPONENT ASL_PREPROCESSOR
ACPI_MODULE_NAME ("prexpress")
/* Local prototypes */
static char *
char *Line);
#ifdef _UNDER_DEVELOPMENT
/******************************************************************************
*
* FUNCTION: PrUnTokenize
*
* PARAMETERS: Buffer - Token Buffer
* Next - "Next" buffer from GetNextToken
*
* RETURN: None
*
* DESCRIPTION: Un-tokenized the current token buffer. The implementation is
* to simply set the null inserted by GetNextToken to a blank.
* If Next is NULL, there were no tokens found in the Buffer,
* so there is nothing to do.
*
*****************************************************************************/
static void
char *Buffer,
char *Next)
{
if (!Next)
{
return;
}
{
}
}
#endif
/******************************************************************************
*
* FUNCTION: PrExpandMacros
*
* PARAMETERS: Line - Pointer into the current line
*
* RETURN: Updated pointer into the current line
*
* DESCRIPTION: Expand any macros found in the current line buffer.
*
*****************************************************************************/
static char *
char *Line)
{
char *Token;
char *ReplaceString;
char *Next;
int OffsetAdjust;
OffsetAdjust = 0;
while (Token)
{
if (DefineInfo)
{
if (DefineInfo->Body)
{
/* This is a macro. TBD: Is this allowed? */
"Matched Macro: %s->%s\n",
DefineInfo, &Next);
}
else
{
/* Replace the name in the original line buffer */
/* Adjust for length difference between old and new name length */
"Matched #define within expression: %s->%s\n",
}
}
}
return (Line);
}
/******************************************************************************
*
* FUNCTION: PrIsDefined
*
* PARAMETERS: Identifier - Name to be resolved
*
* RETURN: 64-bit boolean integer value
*
* DESCRIPTION: Returns TRUE if the name is defined, FALSE otherwise (0).
*
*****************************************************************************/
char *Identifier)
{
Value = 0; /* Default is "Not defined" -- FALSE */
if (DefineInfo)
{
}
"[#if defined %s] resolved to: %8.8X%8.8X\n",
return (Value);
}
/******************************************************************************
*
* FUNCTION: PrResolveDefine
*
* PARAMETERS: Identifier - Name to be resolved
*
* RETURN: A 64-bit boolean integer value
*
* DESCRIPTION: Returns TRUE if the name is defined, FALSE otherwise (0).
*
*****************************************************************************/
char *Identifier)
{
Value = 0; /* Default is "Not defined" -- FALSE */
if (DefineInfo)
{
}
"[#if defined %s] resolved to: %8.8X%8.8X\n",
return (Value);
}
/******************************************************************************
*
* FUNCTION: PrResolveIntegerExpression
*
* PARAMETERS: Line - Pointer to integer expression
* ReturnValue - Where the resolved 64-bit integer is
* returned.
*
* RETURN: Status
*
* DESCRIPTION: Resolve an integer expression to a single value. Supports
* both integer constants and labels.
*
*****************************************************************************/
char *Line,
{
char *ExpandedLine;
/* Expand all macros within the expression first */
/* Now we can evaluate the expression */
"**** Expression Resolved to: %8.8X%8.8X\n",
*ReturnValue = Result;
return (AE_OK);
#if 0
return (AE_ERROR);
"**** Expression Resolved to: %8.8X%8.8X\n",
*ReturnValue = Value1;
return (AE_OK);
#endif
}