1 /****************************************************************************
2     Copyright (C) 1987-2015 by Jeffery P. Hansen
3 
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License along
15     with this program; if not, write to the Free Software Foundation, Inc.,
16     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 ****************************************************************************/
18 #ifndef __error_h
19 #define __error_h
20 
21 /*****************************************************************************
22  * placemode_t - Type of place reporting
23  *****************************************************************************/
24 typedef enum {
25   PM_FILE = 0x1,
26   PM_LINE = 0x2,
27   PM_MODULE = 0x4,
28   PM_MODLINE = 0x8,
29   PM_PRETTY = 0x10
30 } placemode_t;
31 
32 typedef enum {
33   ERR_OK,
34   WRN_INPORT,
35   WRN_OUTPORT,
36   WRN_FLOATNET,
37   ERR_MEMADDR,
38   ERR_MEMBITS,
39   ERR_BADARRAYUSG,
40   ERR_BADARRAYLHS,
41   ERR_BADCLOSE,
42   ERR_BADAUTORNG,
43   ERR_BADGATERNG,
44   ERR_DIVZERO,
45   ERR_BADEDGEEVENT,
46   ERR_ASGNEVENT,
47   ERR_PROTTASK,
48   ERR_NEEDIDENT,
49   ERR_BADOP,
50   ERR_NOREAD,
51   ERR_MEMFILE,
52   ERR_WRONGMOD,
53   ERR_NOTPARM,
54   ERR_BADADDR,
55   ERR_BADADDRSPEC,
56   ERR_BADCHAR,
57   ERR_BADEVENT,
58   ERR_BADCONSTOP,
59   ERR_BADXOP,
60   ERR_NETREDEF,
61   ERR_BADINOUT,
62   ERR_MODUNDEF,
63   ERR_BADASGNLHS,
64   ERR_BADLHS,
65   ERR_BADOUT,
66   ERR_NOTREG,
67   ERR_PORTMIX,
68   ERR_REPCASE,
69   ERR_NOMEM,
70   ERR_BADCMD,
71   ERR_CMDNOTNET,
72   ERR_MEMNONBLK,
73   ERR_NOTPPORT,
74   ERR_REDEFP,
75   ERR_PORTNOTDEF,
76   ERR_NOCONN,
77   ERR_MULTCONN,
78   ERR_PORTCOUNT,
79   ERR_BADPRTRANGE,
80   ERR_BADARRAYRNG,
81   ERR_LHSNOTREG,
82   ERR_CMDMODREDEF,
83   ERR_REDEF,
84   ERR_PROTTASKSTOP,
85   ERR_NOTMEM,
86   ERR_CMDNOTMEM,
87   ERR_SYNTAX,
88   ERR_BADHIER,
89   ERR_TOOFEWPP,
90   ERR_OPENTOOMANY,
91   ERR_TOOMANYPP,
92   ERR_NOTOP,
93   ERR_BADOPEN,
94   ERR_CMDNOMOD,
95   ERR_BADEVENTNET,
96   ERR_NOTASK,
97   ERR_NOTDEF,
98   ERR_BADRANGE,
99   ERR_GATEUNIMP,
100   ERR_USAGE,
101   ERR_CLSDWRITE,
102   ERR_PRIMPTCOUNT,
103   ERR_CMDARGS,
104   ERR_YYERROR,
105   ERR_TASKARGS,
106   ERR_BADSTART,
107   ERR_BADSTOP,
108   ERR_TIMING,
109   ERR_SPECTASKUSG,
110   ERR_BADSPECTASK,
111   ERR_NEEDEDGE,
112   ERR_NOIFDEF,
113   ERR_BADSPECLVAL,
114   WRN_DIRECTCONN,
115   ERR_PATHDMEM,
116   ERR_PATHDINOUT,
117   ERR_PATHDLOOP,
118   ERR_PATHDREASSGN,
119   ERR_PATHDNOTIN,
120   ERR_PATHDCOND,
121   ERR_TASKREDEF,
122   ERR_TASKASFUNC,
123   ERR_FUNCASTASK,
124   ERR_TASKBADTYPE,
125   ERR_TASKBADPORT,
126   ERR_TIMESCALEU,
127   ERR_TIMESCALEN,
128   ERR_TIMESCALES,
129   ERR_TIMESCALEX,
130   ERR_TIMESCALEAN,
131   ERR_PARAMMIX,
132   ERR_BADPORTTYPE,
133   ERR_BADVALUE,
134   ERR_NONEXPCTL,
135   ERR_NONSTATCTL,
136   ERR_MODREDEF,
137   ERR_IE_NONET,
138   ERR_IE_NOOP,
139   ERR_IE_BADEXP,
140   ERR_IE_BADVAR,
141   ERR_IE_BADSTATE,
142   ERR_IE_RETURN,
143   ERR_IE_TASK,
144   ERR_IE_UNIMP,
145   ERR_UNKNOWN,
146 } errorcode_t;
147 
148 typedef struct ErrorDescriptor_str {
149   errorcode_t	ed_code;		/* Error code number */
150   int		ed_level;		/* Error level */
151   char		*ed_tag;		/* Message tag for error */
152   char		*ed_text;		/* Default text of error */
153   int		ed_numArgs;		/* Number of arguments */
154 } ErrorDescriptor;
155 
156 /*****************************************************************************
157  *
158  * Place - A "Place" is used to represent a place in a source file with
159  * information about the line number,
160  *
161  *****************************************************************************/
162 typedef struct Place_str {
163   char		*p_fileName;		/* Name of file */
164   char		*p_moduleName;		/* Name of module */
165   int		p_mtag;			/* non-zero if in tagged module */
166   ModuleItem	*p_mitem;		/* Module item if appropriate */
167   int		p_lineNo;		/* Line number within file */
168   int		p_modLineNo;		/* Line number within module */
169 } Place;
170 
171 /*****************************************************************************
172  * Place member functions
173  *****************************************************************************/
174 void Place_init(Place *p, const char *fileName);
175 void Place_copy(Place *p, Place *srcP);
176 void Place_incLineno(Place *p, int delta);
177 void Place_startModule(Place *p, const char *modName);
178 void Place_endModule(Place *p);
179 void Place_startMTag(Place *p, const char *modName);
180 void Place_endMTag(Place *p);
181 char *Place_report(Place *p, const char *etype, const char *netName,char *buf);
182 void Place_setMode(placemode_t);
183 void Place_setCurrent(Place*);
184 void Place_resetModLine(Place*);
185 Place *Place_getCurrent();
186 
187 /*****************************************************************************
188  * Error reporting functions
189  *****************************************************************************/
190 void errorCmd(errorcode_t,...);
191 void errorRun(errorcode_t,...);
192 void errorFile(Place*,errorcode_t,...);
193 void errorModule(ModuleDecl*,Place*,errorcode_t,...);
194 void errorNet(ModuleDecl *,const char *,Place*,errorcode_t,...);
195 //void errorNet(ModuleDecl*,NetDecl*,Place*,errorcode_t,...);
196 
197 void dumpErrorMessages();
198 void initErrorMessages();
199 void flushErrors();
200 
201 #endif
202