mirror of
https://github.com/cc65/cc65.git
synced 2025-08-09 13:25:06 +00:00
Renamed struct Segments to SegContext as well as some related functions.
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct Segments* CurrentFunctionSegment;
|
static struct SegContext* CurrentFunctionSegment;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ static struct Segments* CurrentFunctionSegment;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UseLabelPoolFromSegments (struct Segments* Seg)
|
void UseLabelPoolFromSegments (struct SegContext* Seg)
|
||||||
/* Use the info in segments for generating new label numbers */
|
/* Use the info in segments for generating new label numbers */
|
||||||
{
|
{
|
||||||
CurrentFunctionSegment = Seg;
|
CurrentFunctionSegment = Seg;
|
||||||
|
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Segments;
|
struct SegContext;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ struct Segments;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UseLabelPoolFromSegments (struct Segments* Seg);
|
void UseLabelPoolFromSegments (struct SegContext* Seg);
|
||||||
/* Use the info in segments for generating new label numbers */
|
/* Use the info in segments for generating new label numbers */
|
||||||
|
|
||||||
unsigned GetLocalLabel (void);
|
unsigned GetLocalLabel (void);
|
||||||
|
@@ -547,7 +547,7 @@ void NewFunc (SymEntry* Func, FuncDesc* D)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate code and data segments for this function */
|
/* Allocate code and data segments for this function */
|
||||||
Func->V.F.Seg = PushSegments (Func);
|
Func->V.F.Seg = PushSegContext (Func);
|
||||||
|
|
||||||
/* Use the info in the segments for generating new local labels */
|
/* Use the info in the segments for generating new local labels */
|
||||||
UseLabelPoolFromSegments (Func->V.F.Seg);
|
UseLabelPoolFromSegments (Func->V.F.Seg);
|
||||||
@@ -696,7 +696,7 @@ void NewFunc (SymEntry* Func, FuncDesc* D)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Switch back to the old segments */
|
/* Switch back to the old segments */
|
||||||
PopSegments ();
|
PopSegContext ();
|
||||||
|
|
||||||
/* Reset the current function pointer */
|
/* Reset the current function pointer */
|
||||||
FreeFunction (CurrentFunc);
|
FreeFunction (CurrentFunc);
|
||||||
|
@@ -69,11 +69,11 @@ typedef struct {
|
|||||||
} SegAddrSize_t;
|
} SegAddrSize_t;
|
||||||
|
|
||||||
|
|
||||||
/* Pointer to the current segment list. Output goes here. */
|
/* Pointer to the current segment context. Output goes here. */
|
||||||
Segments* CS = 0;
|
SegContext* CS = 0;
|
||||||
|
|
||||||
/* Pointer to the global segment list */
|
/* Pointer to the global segment context */
|
||||||
Segments* GS = 0;
|
SegContext* GS = 0;
|
||||||
|
|
||||||
/* Actual names for the segments */
|
/* Actual names for the segments */
|
||||||
static StrStack SegmentNames[SEG_COUNT];
|
static StrStack SegmentNames[SEG_COUNT];
|
||||||
@@ -86,12 +86,12 @@ static Collection SegmentAddrSizes;
|
|||||||
** maximum stack depth is 2, so there is not really a need for a better
|
** maximum stack depth is 2, so there is not really a need for a better
|
||||||
** implementation.
|
** implementation.
|
||||||
*/
|
*/
|
||||||
static Collection SegmentStack = STATIC_COLLECTION_INITIALIZER;
|
static Collection SegContextStack = STATIC_COLLECTION_INITIALIZER;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Segment name and address size */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
@@ -226,11 +226,17 @@ const char* GetSegName (segment_t Seg)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Segments* NewSegments (SymEntry* Func)
|
/*****************************************************************************/
|
||||||
/* Initialize a Segments structure (set all fields to NULL) */
|
/* Segment context */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static SegContext* NewSegContext (SymEntry* Func)
|
||||||
|
/* Initialize a SegContext structure (set all fields to NULL) */
|
||||||
{
|
{
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
Segments* S = xmalloc (sizeof (Segments));
|
SegContext* S = xmalloc (sizeof (SegContext));
|
||||||
|
|
||||||
/* Initialize the fields */
|
/* Initialize the fields */
|
||||||
S->Text = NewTextSeg (Func);
|
S->Text = NewTextSeg (Func);
|
||||||
@@ -248,14 +254,14 @@ static Segments* NewSegments (SymEntry* Func)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Segments* PushSegments (SymEntry* Func)
|
SegContext* PushSegContext (SymEntry* Func)
|
||||||
/* Make the new segment list current but remember the old one */
|
/* Make the new segment context current but remember the old one */
|
||||||
{
|
{
|
||||||
/* Push the current pointer onto the stack */
|
/* Push the current pointer onto the stack */
|
||||||
CollAppend (&SegmentStack, CS);
|
CollAppend (&SegContextStack, CS);
|
||||||
|
|
||||||
/* Create a new Segments structure */
|
/* Create a new SegContext structure */
|
||||||
CS = NewSegments (Func);
|
CS = NewSegContext (Func);
|
||||||
|
|
||||||
/* Return the new struct */
|
/* Return the new struct */
|
||||||
return CS;
|
return CS;
|
||||||
@@ -263,14 +269,14 @@ Segments* PushSegments (SymEntry* Func)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PopSegments (void)
|
void PopSegContext (void)
|
||||||
/* Pop the old segment list (make it current) */
|
/* Pop the old segment context (make it current) */
|
||||||
{
|
{
|
||||||
/* Must have something on the stack */
|
/* Must have something on the stack */
|
||||||
PRECONDITION (CollCount (&SegmentStack) > 0);
|
PRECONDITION (CollCount (&SegContextStack) > 0);
|
||||||
|
|
||||||
/* Pop the last segment and set it as current */
|
/* Pop the last segment and set it as current */
|
||||||
CS = CollPop (&SegmentStack);
|
CS = CollPop (&SegContextStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -278,13 +284,13 @@ void PopSegments (void)
|
|||||||
void CreateGlobalSegments (void)
|
void CreateGlobalSegments (void)
|
||||||
/* Create the global segments and remember them in GS */
|
/* Create the global segments and remember them in GS */
|
||||||
{
|
{
|
||||||
GS = PushSegments (0);
|
GS = PushSegContext (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UseDataSeg (segment_t DSeg)
|
void UseDataSeg (segment_t DSeg)
|
||||||
/* For the current segment list, use the data segment DSeg */
|
/* For the current segment context, use the data segment DSeg */
|
||||||
{
|
{
|
||||||
/* Check the input */
|
/* Check the input */
|
||||||
PRECONDITION (CS && DSeg != SEG_CODE);
|
PRECONDITION (CS && DSeg != SEG_CODE);
|
||||||
@@ -372,7 +378,7 @@ void RemoveGlobalCode (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void OutputSegments (const Segments* S)
|
void OutputSegments (const SegContext* S)
|
||||||
/* Output the given segments to the output file */
|
/* Output the given segments to the output file */
|
||||||
{
|
{
|
||||||
/* Output the function prologue if the segments came from a function */
|
/* Output the function prologue if the segments came from a function */
|
||||||
|
@@ -78,8 +78,8 @@ typedef enum segment_t {
|
|||||||
} segment_t;
|
} segment_t;
|
||||||
|
|
||||||
/* A list of all segments used when generating code */
|
/* A list of all segments used when generating code */
|
||||||
typedef struct Segments Segments;
|
typedef struct SegContext SegContext;
|
||||||
struct Segments {
|
struct SegContext {
|
||||||
struct TextSeg* Text; /* Text segment */
|
struct TextSeg* Text; /* Text segment */
|
||||||
struct CodeSeg* Code; /* Code segment */
|
struct CodeSeg* Code; /* Code segment */
|
||||||
struct DataSeg* Data; /* Data segment */
|
struct DataSeg* Data; /* Data segment */
|
||||||
@@ -90,11 +90,11 @@ struct Segments {
|
|||||||
unsigned NextDataLabel; /* Number to generate unique data labels */
|
unsigned NextDataLabel; /* Number to generate unique data labels */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Pointer to the current segment list. Output goes here. */
|
/* Pointer to the current segment context. Output goes here. */
|
||||||
extern Segments* CS;
|
extern SegContext* CS;
|
||||||
|
|
||||||
/* Pointer to the global segment list */
|
/* Pointer to the global segment context */
|
||||||
extern Segments* GS;
|
extern SegContext* GS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -132,17 +132,17 @@ void PopSegName (segment_t Seg);
|
|||||||
const char* GetSegName (segment_t Seg);
|
const char* GetSegName (segment_t Seg);
|
||||||
/* Get the name of the given segment */
|
/* Get the name of the given segment */
|
||||||
|
|
||||||
Segments* PushSegments (struct SymEntry* Func);
|
SegContext* PushSegContext (struct SymEntry* Func);
|
||||||
/* Make the new segment list current but remember the old one */
|
/* Make the new segment context current but remember the old one */
|
||||||
|
|
||||||
void PopSegments (void);
|
void PopSegContext (void);
|
||||||
/* Pop the old segment list (make it current) */
|
/* Pop the old segment context (make it current) */
|
||||||
|
|
||||||
void CreateGlobalSegments (void);
|
void CreateGlobalSegments (void);
|
||||||
/* Create the global segments and remember them in GS */
|
/* Create the global segments and remember them in GS */
|
||||||
|
|
||||||
void UseDataSeg (segment_t DSeg);
|
void UseDataSeg (segment_t DSeg);
|
||||||
/* For the current segment list, use the data segment DSeg */
|
/* For the current segment context, use the data segment DSeg */
|
||||||
|
|
||||||
struct DataSeg* GetDataSeg (void);
|
struct DataSeg* GetDataSeg (void);
|
||||||
/* Return the current data segment */
|
/* Return the current data segment */
|
||||||
@@ -165,7 +165,7 @@ int HaveGlobalCode (void);
|
|||||||
void RemoveGlobalCode (void);
|
void RemoveGlobalCode (void);
|
||||||
/* Remove all code from the global code segment. Used for error recovery. */
|
/* Remove all code from the global code segment. Used for error recovery. */
|
||||||
|
|
||||||
void OutputSegments (const Segments* S);
|
void OutputSegments (const SegContext* S);
|
||||||
/* Output the given segments to the output file */
|
/* Output the given segments to the output file */
|
||||||
|
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Segments;
|
struct SegContext;
|
||||||
struct LiteralPool;
|
struct LiteralPool;
|
||||||
struct CodeEntry;
|
struct CodeEntry;
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ struct SymEntry {
|
|||||||
|
|
||||||
/* Data for functions */
|
/* Data for functions */
|
||||||
struct {
|
struct {
|
||||||
struct Segments* Seg; /* Segments for this function */
|
struct SegContext* Seg; /* SegContext for this function */
|
||||||
struct LiteralPool* LitPool; /* Literal pool for this function */
|
struct LiteralPool* LitPool; /* Literal pool for this function */
|
||||||
} F;
|
} F;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user