nvfx: expose GLSL
[mesa/mesa-lb.git] / src / glsl / pp / sl_pp_error.c
blobb628e37ce83b1296617858e34171a23432fe16f6
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include <stdlib.h>
29 #include <string.h>
30 #include "sl_pp_context.h"
31 #include "sl_pp_process.h"
32 #include "sl_pp_public.h"
35 void
36 sl_pp_process_error(struct sl_pp_context *context,
37 const struct sl_pp_token_info *input,
38 unsigned int first,
39 unsigned int last)
41 unsigned int out_len = 0;
42 unsigned int i;
44 for (i = first; i < last; i++) {
45 const char *s = NULL;
46 char buf[2];
48 switch (input[i].token) {
49 case SL_PP_WHITESPACE:
50 s = " ";
51 break;
53 case SL_PP_NEWLINE:
54 s = "\n";
55 break;
57 case SL_PP_HASH:
58 s = "#";
59 break;
61 case SL_PP_COMMA:
62 s = ",";
63 break;
65 case SL_PP_SEMICOLON:
66 s = ";";
67 break;
69 case SL_PP_LBRACE:
70 s = "{";
71 break;
73 case SL_PP_RBRACE:
74 s = "}";
75 break;
77 case SL_PP_LPAREN:
78 s = "(";
79 break;
81 case SL_PP_RPAREN:
82 s = ")";
83 break;
85 case SL_PP_LBRACKET:
86 s = "[";
87 break;
89 case SL_PP_RBRACKET:
90 s = "]";
91 break;
93 case SL_PP_DOT:
94 s = ".";
95 break;
97 case SL_PP_INCREMENT:
98 s = "++";
99 break;
101 case SL_PP_ADDASSIGN:
102 s = "+=";
103 break;
105 case SL_PP_PLUS:
106 s = "+";
107 break;
109 case SL_PP_DECREMENT:
110 s = "--";
111 break;
113 case SL_PP_SUBASSIGN:
114 s = "-=";
115 break;
117 case SL_PP_MINUS:
118 s = "-";
119 break;
121 case SL_PP_BITNOT:
122 s = "~";
123 break;
125 case SL_PP_NOTEQUAL:
126 s = "!=";
127 break;
129 case SL_PP_NOT:
130 s = "!";
131 break;
133 case SL_PP_MULASSIGN:
134 s = "*=";
135 break;
137 case SL_PP_STAR:
138 s = "*";
139 break;
141 case SL_PP_DIVASSIGN:
142 s = "/=";
143 break;
145 case SL_PP_SLASH:
146 s = "/";
147 break;
149 case SL_PP_MODASSIGN:
150 s = "%=";
151 break;
153 case SL_PP_MODULO:
154 s = "%";
155 break;
157 case SL_PP_LSHIFTASSIGN:
158 s = "<<=";
159 break;
161 case SL_PP_LSHIFT:
162 s = "<<";
163 break;
165 case SL_PP_LESSEQUAL:
166 s = "<=";
167 break;
169 case SL_PP_LESS:
170 s = "<";
171 break;
173 case SL_PP_RSHIFTASSIGN:
174 s = ">>=";
175 break;
177 case SL_PP_RSHIFT:
178 s = ">>";
179 break;
181 case SL_PP_GREATEREQUAL:
182 s = ">=";
183 break;
185 case SL_PP_GREATER:
186 s = ">";
187 break;
189 case SL_PP_EQUAL:
190 s = "==";
191 break;
193 case SL_PP_ASSIGN:
194 s = "=";
195 break;
197 case SL_PP_AND:
198 s = "&&";
199 break;
201 case SL_PP_BITANDASSIGN:
202 s = "&=";
203 break;
205 case SL_PP_BITAND:
206 s = "&";
207 break;
209 case SL_PP_XOR:
210 s = "^^";
211 break;
213 case SL_PP_BITXORASSIGN:
214 s = "^=";
215 break;
217 case SL_PP_BITXOR:
218 s = "^";
219 break;
221 case SL_PP_OR:
222 s = "||";
223 break;
225 case SL_PP_BITORASSIGN:
226 s = "|=";
227 break;
229 case SL_PP_BITOR:
230 s = "|";
231 break;
233 case SL_PP_QUESTION:
234 s = "?";
235 break;
237 case SL_PP_COLON:
238 s = ":";
239 break;
241 case SL_PP_IDENTIFIER:
242 s = sl_pp_context_cstr(context, input[i].data.identifier);
243 break;
245 case SL_PP_UINT:
246 s = sl_pp_context_cstr(context, input[i].data._uint);
247 break;
249 case SL_PP_FLOAT:
250 s = sl_pp_context_cstr(context, input[i].data._float);
251 break;
253 case SL_PP_OTHER:
254 buf[0] = input[i].data.other;
255 buf[1] = '\0';
256 s = buf;
257 break;
259 default:
260 strcpy(context->error_msg, "internal error");
261 return;
264 while (*s != '\0' && out_len < sizeof(context->error_msg) - 1) {
265 context->error_msg[out_len++] = *s++;
269 context->error_msg[out_len] = '\0';