Support for #line directive (not complete)

date	2002.03.28.22.05.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 16:11:33 +00:00
parent 191ea7a626
commit 9046454f8b
2 changed files with 56 additions and 100 deletions

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: asltransform - Parse tree transforms
* $Revision: 1.6 $
* $Revision: 1.11 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* All rights reserved.
*
* 2. License
@ -120,20 +120,19 @@
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
MODULE_NAME ("asltransform")
ACPI_MODULE_NAME ("asltransform")
/*******************************************************************************
*
* FUNCTION: TrAmlGetNextTempName
*
* PARAMETERS:
* PARAMETERS: NamePath - Where a pointer to the temp name is returned
*
* RETURN: None
* RETURN: A pointer to the second character of the name
*
* DESCRIPTION: +
* DESCRIPTION: Generate an ACPI name of the form _Txx. These names are
* reserved for use by the ASL compiler.
*
******************************************************************************/
@ -171,11 +170,12 @@ TrAmlGetNextTempName (
*
* FUNCTION: TrAmlInitLineNumbers
*
* PARAMETERS:
* PARAMETERS: Node - Node to be initialized
* Neighbor - Node used for initialization values
*
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Initialized the various line numbers for a parse node.
*
******************************************************************************/
@ -197,11 +197,12 @@ TrAmlInitLineNumbers (
*
* FUNCTION: TrAmlInitNode
*
* PARAMETERS:
* PARAMETERS: Node - Node to be initialized
* ParseOpcode - Opcode for this node
*
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Initialize a node with the parse opcode and opcode name.
*
******************************************************************************/
@ -213,20 +214,19 @@ TrAmlInitNode (
Node->ParseOpcode = ParseOpcode;
strncpy (Node->ParseOpName, UtGetOpName (ParseOpcode), 12);
}
/*******************************************************************************
*
* FUNCTION: TrAmlSetSubtreeParent
*
* PARAMETERS:
* PARAMETERS: Node - First node in a list of peer nodes
* Parent - Parent of the subtree
*
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Set the parent for all peer nodes in a subtree
*
******************************************************************************/
@ -237,6 +237,7 @@ TrAmlSetSubtreeParent (
{
ASL_PARSE_NODE *Next;
Next = Node;
while (Next)
{
@ -246,16 +247,16 @@ TrAmlSetSubtreeParent (
}
/*******************************************************************************
*
* FUNCTION: TrAmlInsertPeer
*
* PARAMETERS:
* PARAMETERS: Node - First node in a list of peer nodes
* NewPeer - Peer node to insert
*
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Insert a new peer node into a list of peers.
*
******************************************************************************/
@ -270,7 +271,6 @@ TrAmlInsertPeer (
}
/*******************************************************************************
*
* FUNCTION: TrAmlTransformWalk
@ -291,14 +291,11 @@ TrAmlTransformWalk (
void *Context)
{
TrTransformSubtree (Node);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: TrTransformSubtree
@ -318,13 +315,11 @@ TrTransformSubtree (
ASL_PARSE_NODE *Node)
{
if (Node->AmlOpcode == AML_RAW_DATA_BYTE)
{
return;
}
switch (Node->ParseOpcode)
{
case DEFINITIONBLOCK:
@ -370,8 +365,6 @@ TrDoDefinitionBlock (
Next = Next->Peer;
}
Gbl_FirstLevelInsertionNode = Next;
}
@ -395,7 +388,6 @@ TrDoElseif (
ASL_PARSE_NODE *IfNode;
/* Change the ELSEIF into an ELSE */
TrAmlInitNode (Node, ELSE);
@ -406,7 +398,6 @@ TrDoElseif (
IfNode->Parent = Node;
TrAmlInitLineNumbers (IfNode, Node);
/* Insert the the IF node first in the ELSE child list */
IfNode->Child = Node->Child;
@ -425,7 +416,8 @@ TrDoElseif (
* RETURN: None
*
*
* DESCRIPTION: Translate switch to if/else pairs
* DESCRIPTION: Translate ASL SWITCH statement to if/else pairs. There is
* no actual AML opcode for SWITCH -- it must be simulated.
*
******************************************************************************/
@ -483,19 +475,18 @@ TrDoSwitch (
CaseBlock = Case->Child->Peer;
Conditional->Child->Peer = NULL;
/*
/*
* change Case() to: If (PredicateValue == CaseValue) {...}
* Case->Child is the case value
* Case->Child->Peer is the beginning of the case block
*/
NewNode = TrCreateValuedLeafNode (NAMESTRING,
NewNode = TrCreateValuedLeafNode (NAMESTRING,
ACPI_TO_INTEGER (PredicateValuePath));
Predicate = Case->Child;
Predicate->Peer = NewNode;
TrAmlInitLineNumbers (NewNode, Predicate);
NewNode2 = TrCreateLeafNode (LEQUAL);
NewNode2->Parent = Conditional;
NewNode2->Child = Predicate;
@ -527,8 +518,8 @@ TrDoSwitch (
}
else
{
/*
* The IF is a child of previous IF/ELSE. It
/*
* The IF is a child of previous IF/ELSE. It
* is therefore without peer.
*/
CurrentParentNode->Child = Conditional;
@ -536,7 +527,6 @@ TrDoSwitch (
Conditional->Peer = NULL;
}
}
else if (Next->ParseOpcode == DEFAULT)
{
if (Default)
@ -548,15 +538,14 @@ TrDoSwitch (
Default = Next;
}
else
{
/* Unkown peer opcode */
printf ("Unknown switch opcode\n");
printf ("Unknown parse opcode for switch statement: %s (%d)\n",
Next->ParseOpName, Next->ParseOpcode);
}
}
/*
* Add the default at the end of the if/else construct
*/
@ -578,12 +567,12 @@ TrDoSwitch (
}
/*
* Add a NAME node for the temp integer
* Add a NAME node for the temp integer
*/
NewNode = TrCreateLeafNode (NAME);
NewNode->Parent = Gbl_FirstLevelInsertionNode->Parent;
NewNode2 = TrCreateValuedLeafNode (NAMESTRING,
NewNode2 = TrCreateValuedLeafNode (NAMESTRING,
ACPI_TO_INTEGER (PredicateValueName));
NewNode->Child = NewNode2;
NewNode2->Peer = TrCreateValuedLeafNode (INTEGER, 0);
@ -597,7 +586,6 @@ TrDoSwitch (
TrAmlInitLineNumbers (NewNode2, Gbl_FirstLevelInsertionNode);
TrAmlInitLineNumbers (NewNode2->Peer, Gbl_FirstLevelInsertionNode);
/*
* Change the SWITCH node to a STORE (predicate value, _Txx)
*/
@ -606,11 +594,10 @@ TrDoSwitch (
Predicate = StartNode->Child;
Predicate->Child = NULL;
NewNode = TrCreateValuedLeafNode (NAMESTRING,
NewNode = TrCreateValuedLeafNode (NAMESTRING,
ACPI_TO_INTEGER (PredicateValuePath));
NewNode->Parent = StartNode;
Predicate->Peer = NewNode;
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: asltree - parse tree management
* $Revision: 1.32 $
* $Revision: 1.41 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* All rights reserved.
*
* 2. License
@ -120,7 +120,7 @@
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
MODULE_NAME ("asltree")
ACPI_MODULE_NAME ("asltree")
/*******************************************************************************
@ -243,12 +243,10 @@ TrUpdateNode (
Node->ParseOpcode = (UINT16) ParseOpcode;
strncpy (Node->ParseOpName, UtGetOpName (ParseOpcode), 12);
/*
* For the BYTE, WORD, and DWORD constants, make sure that the integer
* that was passed in will actually fit into the data type
*/
switch (ParseOpcode)
{
case BYTECONST:
@ -264,7 +262,6 @@ TrUpdateNode (
break;
}
return Node;
}
@ -288,7 +285,6 @@ TrSetNodeFlags (
UINT32 Flags)
{
DbgPrint (ASL_PARSE_OUTPUT,
"\nSetNodeFlags: Node %p, %d\n\n", Node, Flags);
@ -298,7 +294,6 @@ TrSetNodeFlags (
}
Node->Flags |= Flags;
return Node;
}
@ -330,7 +325,6 @@ TrSetEndLineNumber (
Node->EndLine = Gbl_CurrentLineNumber;
Node->EndLogicalLine = Gbl_LogicalLineNumber;
}
@ -389,8 +383,9 @@ TrCreateValuedLeafNode (
Node = TrAllocateNode (ParseOpcode);
DbgPrint (ASL_PARSE_OUTPUT,
"\nCreateValuedLeafNode Line %d NewNode %p Op %s Value %lX ",
Node->LineNumber, Node, UtGetOpName(ParseOpcode), Value);
"\nCreateValuedLeafNode Line %d NewNode %p Op %s Value %8.8X%8.8X ",
Node->LineNumber, Node, UtGetOpName(ParseOpcode),
ACPI_HIDWORD (Value), ACPI_LODWORD (Value));
Node->Value.Integer = Value;
switch (ParseOpcode)
@ -424,7 +419,6 @@ TrCreateValuedLeafNode (
}
DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
return Node;
}
@ -487,7 +481,6 @@ TrCreateNode (
break;
}
/* Link the new node to its children */
PrevChild = NULL;
@ -499,14 +492,12 @@ TrCreateNode (
Child = va_arg (ap, ASL_PARSE_NODE *);
DbgPrint (ASL_PARSE_OUTPUT, "%p, ", Child);
/*
* If child is NULL, this means that an optional argument
* was omitted. We must create a placeholder with a special
* opcode (DEFAULT_ARG) so that the code generator will know
* that it must emit the correct default for this argument
*/
if (!Child)
{
Child = TrAllocateNode (DEFAULT_ARG);
@ -520,7 +511,6 @@ TrCreateNode (
Node->Child = Child;
}
/* Point all children to parent */
Child->Parent = Node;
@ -536,7 +526,6 @@ TrCreateNode (
* This child might be a list, point all nodes in the list
* to the same parent
*/
while (Child->Peer)
{
Child = Child->Peer;
@ -548,8 +537,6 @@ TrCreateNode (
va_end(ap);
DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
return Node;
}
@ -588,8 +575,8 @@ TrLinkChildren (
TrSetEndLineNumber (Node);
DbgPrint (ASL_PARSE_OUTPUT,
"\nLinkChildren Line %d NewParent %p Child %d Op %s ",
Node->LineNumber,
"\nLinkChildren Line [%d to %d] NewParent %p Child %d Op %s ",
Node->LineNumber, Node->EndLine,
Node, NumChildren, UtGetOpName(Node->ParseOpcode));
RootNode = Node;
@ -608,7 +595,6 @@ TrLinkChildren (
break;
}
/* Link the new node to it's children */
PrevChild = NULL;
@ -616,8 +602,14 @@ TrLinkChildren (
for (i = 0; i < NumChildren; i++)
{
Child = va_arg (ap, ASL_PARSE_NODE *);
DbgPrint (ASL_PARSE_OUTPUT, "%p, ", Child);
if ((Child == PrevChild) && (Child != NULL))
{
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Child, "Child node list invalid");
return Node;
}
DbgPrint (ASL_PARSE_OUTPUT, "%p, ", Child);
/*
* If child is NULL, this means that an optional argument
@ -625,7 +617,6 @@ TrLinkChildren (
* opcode (DEFAULT_ARG) so that the code generator will know
* that it must emit the correct default for this argument
*/
if (!Child)
{
Child = TrAllocateNode (DEFAULT_ARG);
@ -639,7 +630,6 @@ TrLinkChildren (
Node->Child = Child;
}
/* Point all children to parent */
Child->Parent = Node;
@ -655,20 +645,16 @@ TrLinkChildren (
* This child might be a list, point all nodes in the list
* to the same parent
*/
while (Child->Peer)
{
Child = Child->Peer;
Child->Parent = Node;
}
PrevChild = Child;
}
va_end(ap);
DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
return Node;
}
@ -718,12 +704,11 @@ TrLinkPeerNode (
return Node2;
}
if (Node1 == Node2)
{
DbgPrint (ASL_DEBUG_OUTPUT,
"\n\n************* Internal error, linking node to itself %p\n\n\n", Node1);
printf ("Internal error, linking node to itself\n");
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Node1, "Linking node to itself");
return Node1;
}
@ -734,7 +719,6 @@ TrLinkPeerNode (
* so we must walk to the end of the list and attach the new
* peer at the end
*/
Next = Node1;
while (Next->Peer)
{
@ -742,7 +726,6 @@ TrLinkPeerNode (
}
Next->Peer = Node2;
return Node1;
}
@ -775,7 +758,6 @@ TrLinkPeerNodes (
DbgPrint (ASL_PARSE_OUTPUT,
"\nLinkPeerNodes: (%d) ", NumPeers);
va_start (ap, NumPeers);
This = va_arg (ap, ASL_PARSE_NODE *);
Start = This;
@ -806,7 +788,6 @@ TrLinkPeerNodes (
This = Next;
}
DbgPrint (ASL_PARSE_OUTPUT,"\n\n");
return (Start);
}
@ -855,7 +836,6 @@ TrLinkChildNode (
}
return Node1;
}
@ -891,7 +871,6 @@ TrWalkParseTree (
return;
}
Level = 0;
NodePreviouslyVisited = FALSE;
@ -901,7 +880,6 @@ TrWalkParseTree (
while (Node)
{
if (!NodePreviouslyVisited)
{
/*
@ -926,11 +904,10 @@ TrWalkParseTree (
Node = Node->Peer;
NodePreviouslyVisited = FALSE;
}
/* No children or peers, re-visit parent */
else
{
/* No children or peers, re-visit parent */
if (Level != 0 )
{
Level--;
@ -939,7 +916,6 @@ TrWalkParseTree (
NodePreviouslyVisited = TRUE;
}
}
break;
@ -947,7 +923,6 @@ TrWalkParseTree (
while (Node)
{
/* Visit leaf node (no children) or parent node on return trip */
if ((!Node->Child) ||
@ -959,11 +934,10 @@ TrWalkParseTree (
*/
AscendingCallback (Node, Level, Context);
}
/* Visit children first, once */
else
{
/* Visit children first, once */
Level++;
Node = Node->Child;
continue;
@ -976,11 +950,10 @@ TrWalkParseTree (
Node = Node->Peer;
NodePreviouslyVisited = FALSE;
}
/* No children or peers, re-visit parent */
else
{
/* No children or peers, re-visit parent */
if (Level != 0 )
{
Level--;
@ -989,19 +962,17 @@ TrWalkParseTree (
NodePreviouslyVisited = TRUE;
}
}
break;
case ASL_WALK_VISIT_TWICE:
while (Node)
{
if (NodePreviouslyVisited)
{
AscendingCallback (Node, Level, Context);
}
else
{
/*
@ -1026,11 +997,10 @@ TrWalkParseTree (
Node = Node->Peer;
NodePreviouslyVisited = FALSE;
}
/* No children or peers, re-visit parent */
else
{
/* No children or peers, re-visit parent */
if (Level != 0 )
{
Level--;
@ -1039,7 +1009,6 @@ TrWalkParseTree (
NodePreviouslyVisited = TRUE;
}
}
break;
}
}