1a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block/****************************************************************************\ 2a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockCopyright (c) 2002, NVIDIA Corporation. 3a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 4a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockNVIDIA Corporation("NVIDIA") supplies this software to you in 5a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockconsideration of your agreement to the following terms, and your use, 6a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockinstallation, modification or redistribution of this NVIDIA software 7a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockconstitutes acceptance of these terms. If you do not agree with these 8a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockterms, please do not use, install, modify or redistribute this NVIDIA 9a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocksoftware. 10a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 11a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockIn consideration of your agreement to abide by the following terms, and 12a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocksubject to these terms, NVIDIA grants you a personal, non-exclusive 13a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocklicense, under NVIDIA's copyrights in this original NVIDIA software (the 14a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block"NVIDIA Software"), to use, reproduce, modify and redistribute the 15a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockNVIDIA Software, with or without modifications, in source and/or binary 16a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockforms; provided that if you redistribute the NVIDIA Software, you must 17a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockretain the copyright notice of NVIDIA, this notice and the following 18a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocktext and disclaimers in all such redistributions of the NVIDIA Software. 19a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockNeither the name, trademarks, service marks nor logos of NVIDIA 20a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockCorporation may be used to endorse or promote products derived from the 21a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockNVIDIA Software without specific prior written permission from NVIDIA. 22a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockExcept as expressly stated in this notice, no other rights or licenses 23a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockexpress or implied, are granted by NVIDIA herein, including but not 24a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocklimited to any patent rights that may be infringed by your derivative 25a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockworks or by other works in which the NVIDIA Software may be 26a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockincorporated. No hardware is licensed hereunder. 27a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 28a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockTHE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT 29a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockWARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, 30a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockINCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, 31a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockNON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 32a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER 33a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockPRODUCTS. 34a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 35a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockIN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, 36a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockINCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 37a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockTO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 38a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY 39a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockOUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE 40a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockNVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, 41a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockTORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF 42a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockNVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block\****************************************************************************/ 44a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// 45a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// symbols.h 46a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// 47a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 48a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#if !defined(__SYMBOLS_H) 49a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#define __SYMBOLS_H 1 50a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 51a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#include "compiler/preprocessor/memory.h" 52a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 53a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocktypedef enum symbolkind { 54a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block MACRO_S 55a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block} symbolkind; 56a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 57a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Typedefs for things defined here in "symbols.h": 58a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 59a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocktypedef struct Scope_Rec Scope; 60a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocktypedef struct Symbol_Rec Symbol; 61a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 62a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocktypedef struct SymbolList_Rec { 63a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block struct SymbolList_Rec *next; 64a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Symbol *symb; 65a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block} SymbolList; 66a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 67a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockstruct Scope_Rec { 68a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Scope *next, *prev; // doubly-linked list of all scopes 69a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Scope *parent; 70a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Scope *funScope; // Points to base scope of enclosing function 71a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block MemoryPool *pool; // pool used for allocation in this scope 72a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Symbol *symbols; 73a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 74a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block int level; // 0 = super globals, 1 = globals, etc. 75a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 76a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block // Only used at global scope (level 1): 77a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block SymbolList *programs; // List of programs for this compilation. 78a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block}; 79a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 80a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 81a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Symbol table is a simple binary tree. 82a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 83a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#include "compiler/preprocessor/cpp.h" // to get MacroSymbol def 84a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 85a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockstruct Symbol_Rec { 86a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Symbol *left, *right; 87a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Symbol *next; 88a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block int name; // Name atom 89a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block SourceLoc loc; 90a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block symbolkind kind; 91a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block union { 92a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block MacroSymbol mac; 93a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block } details; 94a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block}; 95a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 96a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockextern Scope *CurrentScope; 97a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockextern Scope *GlobalScope; 98a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockextern Scope *ScopeList; 99a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 100a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockScope *NewScopeInPool(MemoryPool *); 101a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#define NewScope() NewScopeInPool(CurrentScope->pool) 102a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockvoid PushScope(Scope *fScope); 103a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockScope *PopScope(void); 104a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockSymbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind); 105a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockSymbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind); 106a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockSymbol *LookUpLocalSymbol(Scope *fScope, int atom); 107a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve BlockSymbol *LookUpSymbol(Scope *fScope, int atom); 108a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockvoid CPPErrorToInfoLog(char *); 109a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 110a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 111a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#endif // !defined(__SYMBOLS_H) 112a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 113