]> git.sur5r.net Git - cc65/blobdiff - src/ca65/symtab.h
Allow conditional directives within .STRUCT7:UNION and .ENUM
[cc65] / src / ca65 / symtab.h
index fc28def444fb176b7737d7efbe67adb7831addd8..20aa2a354f2b4ccf22f18901829f05bd1721d5ce 100644 (file)
@@ -42,6 +42,7 @@
 
 /* common */
 #include "exprdefs.h"
+#include "inline.h"
 
 /* ca65 */
 #include "symentry.h"
 #define ST_NONE         0x00            /* No flags */
 #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/.UNION */
+#define ST_ENUM         0x04            /* .ENUM */
+#define ST_UNDEF        0xFF
+
 /* A symbol table */
 typedef struct SymTable SymTable;
 struct SymTable {
@@ -87,7 +96,7 @@ SymTable*     RootScope;      /* Root symbol table */
 
 
 
-void SymEnterLevel (const char* ScopeName, unsigned AddrSize);
+void SymEnterLevel (const char* ScopeName, unsigned char Type, unsigned char AddrSize);
 /* Enter a new lexical level */
 
 void SymLeaveLevel (void);
@@ -96,20 +105,34 @@ void SymLeaveLevel (void);
 SymTable* SymFindScope (SymTable* Parent, const char* Name, int AllocNew);
 /* Find a scope in the given enclosing scope */
 
+SymTable* SymFindAnyScope (SymTable* Parent, const char* 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);
 /* 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.
  */
 
-void SymConDes (const char* Name, unsigned Type, unsigned Prio);
-/* Mark the given symbol as a module constructor/destructor. This will also
- * mark the symbol as an export. Initializers may never be zero page symbols.
- */
-
 int SymIsZP (SymEntry* Sym);
 /* Return true if the symbol is explicitly marked as zeropage symbol */
 
+#if defined(HAVE_INLINE)
+INLINE unsigned char GetSymTabType (const SymTable* S)
+/* Return the type of the given symbol table */
+{
+    return S->Type;
+}
+#else
+#  define GetSymTabType(S)      ((S)->Type)
+#endif
+
+unsigned char GetCurrentSymTabType ();
+/* Return the type of the current symbol table */
+
 void SymCheck (void);
 /* Run through all symbols and check for anomalies and errors */