]> git.sur5r.net Git - cc65/blob - src/ca65/dbginfo.c
Move all attributes and other information that is attached to a token into a
[cc65] / src / ca65 / dbginfo.c
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 dbginfo.c                                 */
4 /*                                                                           */
5 /*                         Handle the .dbg commands                          */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2000-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 #include <string.h>
37
38 /* common */
39 #include "strbuf.h"
40
41 /* ca65 */
42 #include "error.h"
43 #include "expr.h"
44 #include "filetab.h"
45 #include "lineinfo.h"
46 #include "nexttok.h"
47 #include "dbginfo.h"
48
49
50
51 /*****************************************************************************/
52 /*                                   Code                                    */
53 /*****************************************************************************/
54
55
56
57 void DbgInfoFile (void)
58 /* Parse and handle FILE subcommand of the .dbg pseudo instruction */
59 {
60     StrBuf Name = STATIC_STRBUF_INITIALIZER;
61     unsigned long Size;
62     unsigned long MTime;
63
64     /* Parameters are separated by a comma */
65     ConsumeComma ();
66
67     /* Name */
68     if (CurTok.Tok != TOK_STRCON) {
69         ErrorSkip ("String constant expected");
70         return;
71     }
72     SB_Copy (&Name, &CurTok.SVal);
73     NextTok ();
74
75     /* Comma expected */
76     ConsumeComma ();
77
78     /* Size */
79     Size = ConstExpression ();
80
81     /* Comma expected */
82     ConsumeComma ();
83
84     /* MTime */
85     MTime = ConstExpression ();
86
87     /* Insert the file into the table */
88     AddFile (&Name, FT_DBGINFO, Size, MTime);
89
90     /* Free memory used for Name */
91     SB_Done (&Name);
92 }
93
94
95
96 void DbgInfoLine (void)
97 /* Parse and handle LINE subcommand of the .dbg pseudo instruction */
98 {
99     unsigned Index;
100     long LineNum;
101
102     /* If a parameters follow, this is actual line info. If no parameters
103      * follow, the last line info is terminated.
104      */
105     if (CurTok.Tok == TOK_SEP) {
106         ClearLineInfo ();
107         return;
108     }
109
110     /* Parameters are separated by a comma */
111     ConsumeComma ();
112
113     /* The name of the file follows */
114     if (CurTok.Tok != TOK_STRCON) {
115         ErrorSkip ("String constant expected");
116         return;
117     }
118
119     /* Get the index in the file table for the name */
120     Index = GetFileIndex (&CurTok.SVal);
121
122     /* Skip the name */
123     NextTok ();
124
125     /* Comma expected */
126     ConsumeComma ();
127
128     /* Line number */
129     LineNum = ConstExpression ();
130     if (LineNum < 0) {
131         ErrorSkip ("Line number is out of valid range");
132         return;
133     }
134
135     /* Remember the line info */
136     GenLineInfo (Index, LineNum);
137 }
138
139
140
141 void DbgInfoSym (void)
142 /* Parse and handle SYM subcommand of the .dbg pseudo instruction */
143 {
144     ErrorSkip ("Not implemented");
145 }
146
147
148
149
150