acc/symbol.h
Randy Heit c447410ad8 Don't convert string constants to numbers for #define
- Fixed: You could not #define a string for use in a library, because it
  was converted to a number at definition time and not at use time. This
  is no longer the case. Symbolic constants now store the string in its
  original form, and they now expand into the string when encountered
  instead of their string table index.
2014-07-21 23:32:57 -05:00

130 lines
2.5 KiB
C

//**************************************************************************
//**
//** symbol.h
//**
//**************************************************************************
#ifndef __SYMBOL_H__
#define __SYMBOL_H__
// HEADER FILES ------------------------------------------------------------
#include "common.h"
#include "pcode.h"
// MACROS ------------------------------------------------------------------
#define MAX_ARRAY_DIMS 8
// TYPES -------------------------------------------------------------------
typedef enum
{
SY_DUMMY,
SY_LABEL,
SY_SCRIPTVAR,
SY_SCRIPTALIAS,
SY_MAPVAR,
SY_WORLDVAR,
SY_GLOBALVAR,
SY_MAPARRAY,
SY_WORLDARRAY,
SY_GLOBALARRAY,
SY_SPECIAL,
SY_CONSTANT,
SY_INTERNFUNC,
SY_SCRIPTFUNC
} symbolType_t;
typedef struct
{
U_BYTE index;
} symVar_t;
typedef struct
{
U_BYTE index;
int dimensions[MAX_ARRAY_DIMS];
int ndim;
int size;
} symArray_t;
typedef struct
{
int address;
} symLabel_t;
typedef struct
{
int value;
int argCount;
} symSpecial_t;
typedef struct
{
int value;
char *strValue;
int fileDepth;
} symConstant_t;
typedef struct
{
pcd_t directCommand;
pcd_t stackCommand;
int argCount;
int optMask;
int outMask;
boolean hasReturnValue;
boolean latent;
} symInternFunc_t;
typedef struct
{
int address;
int argCount;
int varCount;
int funcNumber;
boolean hasReturnValue;
int sourceLine;
char *sourceName;
boolean predefined;
} symScriptFunc_t;
typedef struct symbolNode_s
{
struct symbolNode_s *left;
struct symbolNode_s *right;
char *name;
symbolType_t type;
boolean unused;
boolean imported;
union
{
symVar_t var;
symArray_t array;
symLabel_t label;
symSpecial_t special;
symConstant_t constant;
symInternFunc_t internFunc;
symScriptFunc_t scriptFunc;
} info;
} symbolNode_t;
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
void SY_Init(void);
symbolNode_t *SY_Find(char *name);
symbolNode_t *SY_FindLocal(char *name);
symbolNode_t *SY_FindGlobal(char *name);
symbolNode_t *SY_InsertLocal(char *name, symbolType_t type);
symbolNode_t *SY_InsertGlobal(char *name, symbolType_t type);
symbolNode_t *SY_InsertGlobalUnique(char *name, symbolType_t type);
void SY_FreeLocals(void);
void SY_FreeGlobals(void);
void SY_FreeConstants(int depth);
void SY_ClearShared(void);
// PUBLIC DATA DECLARATIONS ------------------------------------------------
#endif