2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* symtab.h */
|
|
|
|
/* */
|
|
|
|
/* Symbol table for the ca65 macroassembler */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* (C) 1998 Ullrich von Bassewitz */
|
|
|
|
/* Wacholderweg 14 */
|
|
|
|
/* D-70597 Stuttgart */
|
|
|
|
/* EMail: uz@musoftware.de */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* 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 */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Scope identifiers */
|
|
|
|
#define SCOPE_ANY 0
|
|
|
|
#define SCOPE_GLOBAL 1
|
|
|
|
#define SCOPE_LOCAL 2
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SymEnterLevel (void);
|
|
|
|
/* Enter a new lexical level */
|
|
|
|
|
|
|
|
void SymLeaveLevel (void);
|
|
|
|
/* Leave the current lexical level */
|
|
|
|
|
2001-09-08 21:08:20 +00:00
|
|
|
void SymDef (const char* Name, ExprNode* Expr, int ZP, int Label);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Define a new symbol */
|
|
|
|
|
2002-11-22 01:45:00 +00:00
|
|
|
SymEntry* SymRef (const char* Name, int Scope);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Search for the symbol and return it */
|
|
|
|
|
2002-11-22 01:45:00 +00:00
|
|
|
int SymIsDef (const char* Name, int Scope);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Return true if the given symbol is already defined */
|
|
|
|
|
2002-11-22 01:45:00 +00:00
|
|
|
int SymIsRef (const char* Name, int Scope);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Return true if the given symbol has been referenced */
|
|
|
|
|
|
|
|
void SymImport (const char* Name, int ZP);
|
|
|
|
/* Mark the given symbol as an imported symbol */
|
|
|
|
|
|
|
|
void SymExport (const char* Name, int ZP);
|
|
|
|
/* Mark the given symbol as an exported symbol */
|
|
|
|
|
|
|
|
void SymGlobal (const char* Name, int ZP);
|
|
|
|
/* Mark the given symbol as a global symbol, that is, as a symbol that is
|
|
|
|
* either imported or exported.
|
|
|
|
*/
|
|
|
|
|
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 SymIsConst (SymEntry* Sym);
|
|
|
|
/* Return true if the given symbol has a constant value */
|
|
|
|
|
|
|
|
int SymIsZP (SymEntry* Sym);
|
|
|
|
/* Return true if the symbol is explicitly marked as zeropage symbol */
|
|
|
|
|
|
|
|
int SymIsImport (SymEntry* Sym);
|
|
|
|
/* Return true if the given symbol is marked as import */
|
|
|
|
|
|
|
|
int SymHasExpr (SymEntry* Sym);
|
|
|
|
/* Return true if the given symbol has an associated expression */
|
|
|
|
|
|
|
|
void SymMarkUser (SymEntry* Sym);
|
|
|
|
/* Set a user mark on the specified symbol */
|
|
|
|
|
|
|
|
void SymUnmarkUser (SymEntry* Sym);
|
|
|
|
/* Remove a user mark from the specified symbol */
|
|
|
|
|
|
|
|
int SymHasUserMark (SymEntry* Sym);
|
|
|
|
/* Return the state of the user mark for the specified symbol */
|
|
|
|
|
|
|
|
long GetSymVal (SymEntry* Sym);
|
|
|
|
/* Return the symbol value */
|
|
|
|
|
|
|
|
ExprNode* GetSymExpr (SymEntry* Sym);
|
|
|
|
/* Get the expression for a non-const symbol */
|
|
|
|
|
|
|
|
const char* GetSymName (SymEntry* Sym);
|
|
|
|
/* Return the name of the symbol */
|
|
|
|
|
|
|
|
unsigned GetSymIndex (SymEntry* Sym);
|
|
|
|
/* Return the symbol index for the given symbol */
|
|
|
|
|
|
|
|
const FilePos* GetSymPos (SymEntry* Sym);
|
|
|
|
/* Return the position of first occurence in the source for the given 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
|
|
|
|