xref: /netbsd-src/sys/external/bsd/acpica/dist/compiler/aslsupport.y (revision 046a29855e04359424fd074e8313af6b6be8cfb6)
1460301d4Schristos NoEcho('
2460301d4Schristos /******************************************************************************
3460301d4Schristos  *
4460301d4Schristos  * Module Name: aslsupport.y - Bison/Yacc C support functions
5460301d4Schristos  *
6460301d4Schristos  *****************************************************************************/
7460301d4Schristos 
8460301d4Schristos /*
9*046a2985Schristos  * Copyright (C) 2000 - 2023, Intel Corp.
10460301d4Schristos  * All rights reserved.
11460301d4Schristos  *
12460301d4Schristos  * Redistribution and use in source and binary forms, with or without
13460301d4Schristos  * modification, are permitted provided that the following conditions
14460301d4Schristos  * are met:
15460301d4Schristos  * 1. Redistributions of source code must retain the above copyright
16460301d4Schristos  *    notice, this list of conditions, and the following disclaimer,
17460301d4Schristos  *    without modification.
18460301d4Schristos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19460301d4Schristos  *    substantially similar to the "NO WARRANTY" disclaimer below
20460301d4Schristos  *    ("Disclaimer") and any redistribution must be conditioned upon
21460301d4Schristos  *    including a substantially similar Disclaimer requirement for further
22460301d4Schristos  *    binary redistribution.
23460301d4Schristos  * 3. Neither the names of the above-listed copyright holders nor the names
24460301d4Schristos  *    of any contributors may be used to endorse or promote products derived
25460301d4Schristos  *    from this software without specific prior written permission.
26460301d4Schristos  *
27460301d4Schristos  * Alternatively, this software may be distributed under the terms of the
28460301d4Schristos  * GNU General Public License ("GPL") version 2 as published by the Free
29460301d4Schristos  * Software Foundation.
30460301d4Schristos  *
31460301d4Schristos  * NO WARRANTY
32460301d4Schristos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33460301d4Schristos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3446a330b4Schristos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
35460301d4Schristos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36460301d4Schristos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37460301d4Schristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38460301d4Schristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39460301d4Schristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40460301d4Schristos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41460301d4Schristos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42460301d4Schristos  * POSSIBILITY OF SUCH DAMAGES.
43460301d4Schristos  */
44460301d4Schristos 
45460301d4Schristos ')
46460301d4Schristos 
47460301d4Schristos /******************************************************************************
48460301d4Schristos  *
49460301d4Schristos  * Local support functions
50460301d4Schristos  *
51460301d4Schristos  *****************************************************************************/
52460301d4Schristos 
53460301d4Schristos /*! [Begin] no source code translation */
54460301d4Schristos int
55460301d4Schristos AslCompilerwrap(void)
56460301d4Schristos {
57460301d4Schristos   return (1);
58460301d4Schristos }
59460301d4Schristos /*! [End] no source code translation !*/
60460301d4Schristos 
61460301d4Schristos 
62460301d4Schristos void *
63460301d4Schristos AslLocalAllocate (
64460301d4Schristos     unsigned int        Size)
65460301d4Schristos {
66460301d4Schristos     void                *Mem;
67460301d4Schristos 
68460301d4Schristos 
69460301d4Schristos     DbgPrint (ASL_PARSE_OUTPUT,
70460301d4Schristos         "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size);
71460301d4Schristos 
72460301d4Schristos     Mem = ACPI_ALLOCATE_ZEROED (Size);
73460301d4Schristos     if (!Mem)
74460301d4Schristos     {
75460301d4Schristos         AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,
764c4e8184Schristos             AslGbl_CurrentLineNumber, AslGbl_LogicalLineNumber,
774c4e8184Schristos             AslGbl_InputByteCount, AslGbl_CurrentColumn,
784c4e8184Schristos             AslGbl_Files[ASL_FILE_INPUT].Filename, NULL);
79460301d4Schristos         exit (1);
80460301d4Schristos     }
81460301d4Schristos 
82460301d4Schristos     return (Mem);
83460301d4Schristos }
84460301d4Schristos 
85460301d4Schristos ACPI_PARSE_OBJECT *
86460301d4Schristos AslDoError (
87460301d4Schristos     void)
88460301d4Schristos {
89460301d4Schristos 
9089b8eb6cSchristos     return (TrCreateLeafOp (PARSEOP_ERRORNODE));
91460301d4Schristos }
92460301d4Schristos 
93460301d4Schristos 
94460301d4Schristos /*******************************************************************************
95460301d4Schristos  *
96460301d4Schristos  * FUNCTION:    UtGetOpName
97460301d4Schristos  *
98460301d4Schristos  * PARAMETERS:  ParseOpcode         - Parser keyword ID
99460301d4Schristos  *
100460301d4Schristos  * RETURN:      Pointer to the opcode name
101460301d4Schristos  *
102460301d4Schristos  * DESCRIPTION: Get the ascii name of the parse opcode
103460301d4Schristos  *
104460301d4Schristos  ******************************************************************************/
105460301d4Schristos 
106460301d4Schristos char *
107460301d4Schristos UtGetOpName (
108460301d4Schristos     UINT32                  ParseOpcode)
109460301d4Schristos {
110460301d4Schristos #ifdef ASL_YYTNAME_START
111460301d4Schristos     /*
112460301d4Schristos      * First entries (ASL_YYTNAME_START) in yytname are special reserved names.
113460301d4Schristos      * Ignore first 8 characters of the name
114460301d4Schristos      */
115460301d4Schristos     return ((char *) yytname
116460301d4Schristos         [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8);
117460301d4Schristos #else
118460301d4Schristos     return ("[Unknown parser generator]");
119460301d4Schristos #endif
120460301d4Schristos }
121