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