2000-05-28 13:40:48 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* */
|
|
|
|
|
/* symtab.h */
|
|
|
|
|
/* */
|
|
|
|
|
/* Symbol table for the ca65 macroassembler */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
2003-03-07 11:33:14 +00:00
|
|
|
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
2003-11-11 13:57:30 +00:00
|
|
|
|
/* R<>merstra<72>e 52 */
|
2003-03-07 11:33:14 +00:00
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
|
/* EMail: uz@cc65.org */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
|
/* */
|
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
|
/* */
|
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
|
/* distribution. */
|
|
|
|
|
/* */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SYMTAB_H
|
|
|
|
|
#define SYMTAB_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2000-08-02 14:12:36 +00:00
|
|
|
|
/* common */
|
|
|
|
|
#include "exprdefs.h"
|
2000-10-30 19:30:26 +00:00
|
|
|
|
|
2000-08-02 14:12:36 +00:00
|
|
|
|
/* ca65 */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
#include "symentry.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-11-22 01:45:00 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Data */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-11-11 13:57:30 +00:00
|
|
|
|
/* Symbol table flags */
|
2003-11-08 17:20:21 +00:00
|
|
|
|
#define ST_NONE 0x00 /* No flags */
|
|
|
|
|
#define ST_DEFINED 0x01 /* Scope has been defined */
|
|
|
|
|
|
2003-11-06 11:22:31 +00:00
|
|
|
|
/* A symbol table */
|
|
|
|
|
typedef struct SymTable SymTable;
|
|
|
|
|
struct SymTable {
|
|
|
|
|
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 */
|
2003-11-08 17:20:21 +00:00
|
|
|
|
unsigned short Flags; /* Symbol table flags */
|
2003-11-07 19:28:37 +00:00
|
|
|
|
unsigned char AddrSize; /* Address size */
|
|
|
|
|
unsigned char Type; /* Type of the scope */
|
2003-11-06 11:22:31 +00:00
|
|
|
|
unsigned Level; /* Lexical level */
|
|
|
|
|
unsigned TableSlots; /* Number of hash table slots */
|
|
|
|
|
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 */
|
2003-10-17 00:38:21 +00:00
|
|
|
|
|
2002-11-22 01:45:00 +00:00
|
|
|
|
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/*****************************************************************************/
|
2001-09-08 21:08:20 +00:00
|
|
|
|
/* Code */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-11-07 19:28:37 +00:00
|
|
|
|
void SymEnterLevel (const char* ScopeName, unsigned AddrSize);
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/* Enter a new lexical level */
|
|
|
|
|
|
|
|
|
|
void SymLeaveLevel (void);
|
|
|
|
|
/* Leave the current lexical level */
|
|
|
|
|
|
2003-11-07 19:28:37 +00:00
|
|
|
|
SymTable* SymFindScope (SymTable* Parent, const char* Name, int AllocNew);
|
2003-11-06 11:22:31 +00:00
|
|
|
|
/* Find a scope in the given enclosing scope */
|
2003-03-17 10:14:43 +00:00
|
|
|
|
|
2003-11-06 11:22:31 +00:00
|
|
|
|
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.
|
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
2000-11-20 15:22:57 +00:00
|
|
|
|
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.
|
2000-10-30 19:30:26 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
int SymIsZP (SymEntry* Sym);
|
|
|
|
|
/* Return true if the symbol is explicitly marked as zeropage symbol */
|
|
|
|
|
|
|
|
|
|
void SymCheck (void);
|
|
|
|
|
/* Run through all symbols and check for anomalies and errors */
|
|
|
|
|
|
|
|
|
|
void SymDump (FILE* F);
|
|
|
|
|
/* Dump the symbol table */
|
|
|
|
|
|
|
|
|
|
void WriteImports (void);
|
|
|
|
|
/* Write the imports list to the object file */
|
|
|
|
|
|
|
|
|
|
void WriteExports (void);
|
|
|
|
|
/* Write the exports list to the object file */
|
|
|
|
|
|
|
|
|
|
void WriteDbgSyms (void);
|
|
|
|
|
/* Write a list of all symbols to the object file */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* End of symtab.h */
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-10-30 19:30:26 +00:00
|
|
|
|
|