]> git.sur5r.net Git - cc65/blob - src/ca65/span.h
Fixed _textcolor definition.
[cc65] / src / ca65 / span.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  span.h                                   */
4 /*                                                                           */
5 /*                      A span of data within a segment                      */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2003-2011, Ullrich von Bassewitz                                      */
10 /*                Roemerstrasse 52                                           */
11 /*                D-70794 Filderstadt                                        */
12 /* EMail:         uz@cc65.org                                                */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef SPAN_H
37 #define SPAN_H
38
39
40
41 /* common */
42 #include "coll.h"
43 #include "gentype.h"
44 #include "hashtab.h"
45 #include "inline.h"
46 #include "strbuf.h"
47
48
49
50 /*****************************************************************************/
51 /*                                   Data                                    */
52 /*****************************************************************************/
53
54
55
56 /* Forwards */
57 struct Segment;
58
59 /* Span definition */
60 typedef struct Span Span;
61 struct Span{
62     HashNode        Node;               /* Node for hash table */
63     unsigned        Id;                 /* Id of span */
64     struct Segment* Seg;                /* Pointer to segment */
65     unsigned        Start;              /* Start of range */
66     unsigned        End;                /* End of range */
67     unsigned        Type;               /* Type of data in span */
68 };
69
70
71
72 /*****************************************************************************/
73 /*                                   Code                                    */
74 /*****************************************************************************/
75
76
77
78 #if defined(HAVE_INLINE)
79 INLINE unsigned long GetSpanSize (const Span* R)
80 /* Return the span size in bytes */
81 {
82     return (R->End - R->Start);
83 }
84 #else
85 #  define GetSpanSize(R)   ((R)->End - (R)->Start)
86 #endif
87
88 void SetSpanType (Span* S, const StrBuf* Type);
89 /* Set the generic type of the span to Type */
90
91 Span* OpenSpan (void);
92 /* Open a span for the active segment and return it. */
93
94 Span* CloseSpan (Span* S);
95 /* Close the given span. Be sure to replace the passed span by the one
96 ** returned, since the span will get deleted if it is empty or may be
97 ** replaced if a duplicate exists.
98 */
99
100 void OpenSpanList (Collection* Spans);
101 /* Open a list of spans for all existing segments to the given collection of
102 ** spans. The currently active segment will be inserted first with all others
103 ** following.
104 */
105
106 void CloseSpanList (Collection* Spans);
107 /* Close all open spans by setting PC to the current PC for the segment. */
108
109 void WriteSpanList (const Collection* Spans);
110 /* Write a list of spans to the output file */
111
112 void WriteSpans (void);
113 /* Write all spans to the object file */
114
115
116
117 /* End of span.h */
118
119 #endif