2005-06-29 21:14:33 +04:00
|
|
|
/*_________________________________________________________________________
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Copyright (C) Intel Corporation 1994-1997
|
|
|
|
|
|
|
|
|
| All rights reserved. No part of this program or publication may be
|
|
|
|
| reproduced, transmitted, transcribed, stored in a retrieval system, or
|
|
|
|
| translated into any language or computer language, in any form or by any
|
|
|
|
| means, electronic, mechanical, magnetic, optical, chemical, manual, or
|
|
|
|
| otherwise, without the prior written permission of Intel Corporation.
|
|
|
|
|__________________________________________________________________________
|
|
|
|
|
|
|
|
|
| ModuleName: nsstack - Scope stack manipulation
|
|
|
|
|__________________________________________________________________________
|
|
|
|
*/
|
2005-06-29 20:55:00 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
#define __NSSTACK_C__
|
2005-06-29 20:55:00 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
#include <acpi.h>
|
|
|
|
#include <interpreter.h>
|
|
|
|
#include <namespace.h>
|
2005-06-29 20:55:00 +04:00
|
|
|
|
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
#define _THIS_MODULE "nsstack.c"
|
|
|
|
#define _COMPONENT NAMESPACE
|
2005-06-29 20:55:00 +04:00
|
|
|
|
2005-06-29 21:01:41 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
static ST_KEY_DESC_TABLE KDT[] = {
|
|
|
|
{"0000", '1', "NsPushCurrentScope: null scope passed", "NsPushCurrentScope: null scope passed"},
|
|
|
|
{"0001", 'W', "NsPushCurrentScope: type code out of range", "NsPushCurrentScope: type code out of range"},
|
|
|
|
{"0002", '1', "Scope stack overflow", "Scope stack overflow"},
|
|
|
|
{"0003", '1', "NsPushMethodScope: null scope passed", "NsPushMethodScope: null scope passed"},
|
|
|
|
{"0004", '1', "Scope stack overflow", "Scope stack overflow"},
|
|
|
|
{"0005", 'W', "NsPopCurrent: type code out of range", "NsPopCurrent: type code out of range"},
|
|
|
|
{NULL, 'I', NULL, NULL}
|
|
|
|
};
|
2005-06-29 21:01:41 +04:00
|
|
|
|
2005-06-29 20:55:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
*
|
2005-06-29 21:14:33 +04:00
|
|
|
* FUNCTION: NsPushCurrentScope
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
2005-06-29 21:14:33 +04:00
|
|
|
* PARAMETERS: nte *NewScope, name to be made current
|
|
|
|
* NsType Type, type of frame being pushed
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
2005-06-29 21:14:33 +04:00
|
|
|
* DESCRIPTION: Push the current scope on the scope stack, and make the
|
|
|
|
* passed nte current.
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
void
|
2005-06-29 21:14:33 +04:00
|
|
|
NsPushCurrentScope (nte *NewScope, NsType Type)
|
2005-06-29 20:55:00 +04:00
|
|
|
{
|
2005-06-29 20:55:48 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
FUNCTION_TRACE ("NsPushCurrentScope");
|
2005-06-29 21:13:36 +04:00
|
|
|
|
2005-06-29 20:55:00 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
if (!NewScope)
|
2005-06-29 20:55:00 +04:00
|
|
|
{
|
2005-06-29 21:14:33 +04:00
|
|
|
/* invalid scope */
|
2005-06-29 20:55:00 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
REPORT_ERROR (&KDT[0]);
|
|
|
|
}
|
2005-06-29 20:55:00 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (OUTRANGE (Type, NsTypeNames) ||
|
|
|
|
BadType == NsTypeNames[Type])
|
|
|
|
{
|
|
|
|
/* type code out of range */
|
|
|
|
|
|
|
|
REPORT_WARNING (&KDT[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CurrentScope < &ScopeStack[MAXNEST-1]) /* check for overflow */
|
|
|
|
{
|
|
|
|
/* no Scope stack overflow */
|
|
|
|
|
|
|
|
CurrentScope++;
|
|
|
|
CurrentScope->Scope = NewScope;
|
|
|
|
CurrentScope->Type = Type;
|
|
|
|
|
|
|
|
if (CurrentScope->Scope == Root)
|
|
|
|
{
|
|
|
|
NsCurrentSize = NsRootSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NsCurrentSize = TABLSIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Scope stack overflow */
|
|
|
|
|
|
|
|
REPORT_ERROR (&KDT[2]);
|
|
|
|
}
|
2005-06-29 20:55:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
*
|
2005-06-29 21:14:33 +04:00
|
|
|
* FUNCTION: NsPushMethodScope
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
2005-06-29 21:14:33 +04:00
|
|
|
* PARAMETERS: NsHandle NewScope, name to be made current
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
|
|
|
* DESCRIPTION: Push the current scope on the scope stack, and make the
|
2005-06-29 21:14:33 +04:00
|
|
|
* passed nte current.
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
void
|
|
|
|
NsPushMethodScope (NsHandle NewScope)
|
2005-06-29 20:55:00 +04:00
|
|
|
{
|
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
FUNCTION_TRACE ("NsPushMethodScope");
|
2005-06-29 20:55:00 +04:00
|
|
|
|
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
if (!NewScope ||
|
|
|
|
(nte *) 0 == ((nte *) NewScope)->ChildScope)
|
2005-06-29 20:55:00 +04:00
|
|
|
{
|
2005-06-29 21:14:33 +04:00
|
|
|
/* NewScope or NewScope->ChildScope invalid */
|
2005-06-29 21:13:08 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
REPORT_ERROR (&KDT[3]);
|
2005-06-29 20:55:00 +04:00
|
|
|
}
|
|
|
|
|
2005-06-29 21:14:09 +04:00
|
|
|
else
|
|
|
|
{
|
2005-06-29 21:14:33 +04:00
|
|
|
if (CurrentScope < &ScopeStack[MAXNEST-1]) /* check for overflow */
|
|
|
|
{
|
|
|
|
NsPushCurrentScope (((nte *) NewScope)->ChildScope, Method);
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* scope stack overflow */
|
|
|
|
|
|
|
|
REPORT_ERROR (&KDT[4]);
|
|
|
|
}
|
2005-06-29 21:14:09 +04:00
|
|
|
}
|
2005-06-29 20:59:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
*
|
2005-06-29 21:14:33 +04:00
|
|
|
* FUNCTION: NsPopCurrent
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
2005-06-29 21:14:33 +04:00
|
|
|
* PARAMETERS: NsType Type The type of frame to be found
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
2005-06-29 21:01:41 +04:00
|
|
|
* DESCRIPTION: Pop the scope stack until a frame of the requested type
|
|
|
|
* is found.
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
2005-06-29 21:01:41 +04:00
|
|
|
* RETURN: Count of frames popped. If no frame of the requested type
|
|
|
|
* was found, the count is returned as a negative number and
|
|
|
|
* the scope stack is emptied (which sets the current scope
|
|
|
|
* to the root). If the scope stack was empty at entry, the
|
|
|
|
* function is a no-op and returns 0.
|
2005-06-29 20:55:00 +04:00
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
INT32
|
|
|
|
NsPopCurrent (NsType Type)
|
2005-06-29 20:55:00 +04:00
|
|
|
{
|
2005-06-29 21:14:33 +04:00
|
|
|
INT32 Count = 0;
|
2005-06-29 20:56:40 +04:00
|
|
|
|
2005-06-29 20:55:00 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
FUNCTION_TRACE ("NsPopCurrent");
|
2005-06-29 20:59:45 +04:00
|
|
|
|
2005-06-29 21:13:36 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
if (OUTRANGE (Type, NsTypeNames) || BadType == NsTypeNames[Type])
|
2005-06-29 20:56:40 +04:00
|
|
|
{
|
2005-06-29 21:14:33 +04:00
|
|
|
/* type code out of range */
|
2005-06-29 20:59:02 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
REPORT_WARNING (&KDT[5]);
|
|
|
|
}
|
2005-06-29 21:14:09 +04:00
|
|
|
|
2005-06-29 21:14:34 +04:00
|
|
|
DEBUG_PRINT (TRACE_EXEC, ("Popping Scope till type (%d) is found\n", Type));
|
2005-06-29 21:14:09 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
while (CurrentScope > &ScopeStack[0])
|
2005-06-29 21:14:09 +04:00
|
|
|
{
|
2005-06-29 21:14:33 +04:00
|
|
|
CurrentScope--;
|
|
|
|
|
|
|
|
if (Root == CurrentScope->Scope)
|
|
|
|
{
|
|
|
|
NsCurrentSize = NsRootSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NsCurrentSize = TABLSIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Count++;
|
|
|
|
|
2005-06-29 21:00:19 +04:00
|
|
|
|
2005-06-29 21:14:34 +04:00
|
|
|
DEBUG_PRINT (TRACE_EXEC, ("Popped %d\n", (CurrentScope+1)->Type));
|
2005-06-29 20:59:02 +04:00
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
if ((Any == Type) || (Type == (CurrentScope + 1)->Type))
|
|
|
|
{
|
2005-06-29 21:14:34 +04:00
|
|
|
DEBUG_PRINT (TRACE_EXEC, ("Found %d\n", Type));
|
2005-06-29 21:14:33 +04:00
|
|
|
return Count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-29 21:14:34 +04:00
|
|
|
DEBUG_PRINT (TRACE_EXEC,("%d Not Found\n", Type));
|
2005-06-29 21:14:33 +04:00
|
|
|
return -Count;
|
2005-06-29 20:55:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-29 21:14:33 +04:00
|
|
|
|