]> git.sur5r.net Git - cc65/blobdiff - src/ca65/symtab.h
Finished implemenation of commands to delete macros. Added the new commands to
[cc65] / src / ca65 / symtab.h
index 5873842678d749235923b29fb6e1d090b451fa79..9761da025af069522ff4a945a2e2e37d41e01791 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -45,6 +45,7 @@
 #include "inline.h"
 
 /* ca65 */
+#include "segrange.h"
 #include "symentry.h"
 
 
 #define ST_DEFINED      0x01            /* Scope has been defined */
 
 /* Symbol table types */
-#define ST_GLOBAL       0x00            /* Root level */
-#define ST_PROC         0x01            /* .PROC */
-#define ST_SCOPE        0x02            /* .SCOPE */
-#define ST_STRUCT       0x03            /* .STRUCT */
-#define ST_UNION        0x04            /* .UNION */
-#define ST_UNDEF        0xFF
+enum {
+    ST_GLOBAL,                          /* Root level */
+    ST_PROC,                            /* .PROC */
+    ST_SCOPE,                           /* .SCOPE */
+    ST_SCOPE_HAS_DATA = ST_SCOPE,       /* Last scope that contains data */
+    ST_STRUCT,                          /* .STRUCT/.UNION */
+    ST_ENUM,                            /* .ENUM */
+    ST_UNDEF    = 0xFF
+};
 
 /* A symbol table */
 typedef struct SymTable SymTable;
-struct SymTable {
+struct SymTable {                                     
+    SymTable*           Next;           /* Pointer to next table in list */
     SymTable*           Left;           /* Pointer to smaller entry */
     SymTable*           Right;          /* Pointer to greater entry */
     SymTable*                  Parent;         /* Link to enclosing scope if any */
     SymTable*           Childs;         /* Pointer to child scopes */
+    Collection          SegRanges;      /* Segment ranges for this scope */
+    unsigned            Id;             /* Scope id */
     unsigned short      Flags;          /* Symbol table flags */
-    unsigned char      AddrSize;       /* Address size */
+    unsigned char      AddrSize;       /* Address size */
     unsigned char       Type;           /* Type of the scope */
     unsigned            Level;          /* Lexical level */
     unsigned                   TableSlots;     /* Number of hash table slots */
-    unsigned                   TableEntries;   /* Number of entries in the table */
+    unsigned                   TableEntries;   /* Number of entries in the table */
     unsigned            Name;           /* Name of the scope */
     SymEntry*                  Table[1];       /* Dynamic allocation */
 };
 
 /* Symbol tables */
-SymTable*              CurrentScope;   /* Pointer to current symbol table */
-SymTable*      RootScope;      /* Root symbol table */
+extern SymTable*        CurrentScope;   /* Pointer to current symbol table */
+extern SymTable*       RootScope;      /* Root symbol table */
 
 
 
@@ -96,29 +103,38 @@ SymTable*  RootScope;      /* Root symbol table */
 
 
 
-void SymEnterLevel (const char* ScopeName, unsigned char Type, unsigned char AddrSize);
+void SymEnterLevel (const StrBuf* ScopeName, unsigned char Type, unsigned char AddrSize);
 /* Enter a new lexical level */
 
 void SymLeaveLevel (void);
 /* Leave the current lexical level */
 
-SymTable* SymFindScope (SymTable* Parent, const char* Name, int AllocNew);
+SymTable* SymFindScope (SymTable* Parent, const StrBuf* Name, int AllocNew);
 /* Find a scope in the given enclosing scope */
 
-SymTable* SymFindAnyScope (SymTable* Parent, const char* Name);
+SymTable* SymFindAnyScope (SymTable* Parent, const StrBuf* Name);
 /* Find a scope in the given or any of its parent scopes. The function will
  * never create a new symbol, since this can only be done in one specific
  * scope.
  */
 
-SymEntry* SymFind (SymTable* Scope, const char* Name, int AllocNew);
+SymEntry* SymFindLocal (SymEntry* Parent, const StrBuf* StrBuf, int AllocNew);
+/* Find a cheap local symbol. If AllocNew is given and the entry is not
+ * found, create a new one. Return the entry found, or the new entry created,
+ * or - in case AllocNew is zero - return 0.
+ */
+
+SymEntry* SymFind (SymTable* Scope, const StrBuf* Name, int AllocNew);
 /* Find a new symbol table entry in the given table. If AllocNew is given and
  * the entry is not found, create a new one. Return the entry found, or the
  * new entry created, or - in case AllocNew is zero - return 0.
  */
 
-int SymIsZP (SymEntry* Sym);
-/* Return true if the symbol is explicitly marked as zeropage symbol */
+SymEntry* SymFindAny (SymTable* Scope, const StrBuf* Name);
+/* Find a symbol in the given or any of its parent scopes. The function will
+ * never create a new symbol, since this can only be done in one specific
+ * scope.
+ */
 
 #if defined(HAVE_INLINE)
 INLINE unsigned char GetSymTabType (const SymTable* S)
@@ -148,6 +164,9 @@ void WriteExports (void);
 void WriteDbgSyms (void);
 /* Write a list of all symbols to the object file */
 
+void WriteScopes (void);
+/* Write the scope table to the object file */
+
 
 
 /* End of symtab.h */
@@ -156,4 +175,3 @@ void WriteDbgSyms (void);
 
 
 
-