diff options
author | Kenneth Graunke <[email protected]> | 2010-09-05 01:27:02 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2010-09-07 17:30:37 -0700 |
commit | 7dcfc44b72f00ba5a38cb02123c80113440f0de9 (patch) | |
tree | cb119dea4be95f12bab48bddf6f21cfd9ed9592b | |
parent | 719caa403ecc3345b86708f8172600d80132d6cb (diff) |
glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.
Also define it if #version 100 is encountered.
-rw-r--r-- | src/glsl/glcpp/glcpp-parse.c | 445 | ||||
-rw-r--r-- | src/glsl/glcpp/glcpp-parse.h | 7 | ||||
-rw-r--r-- | src/glsl/glcpp/glcpp-parse.y | 9 | ||||
-rw-r--r-- | src/glsl/glcpp/glcpp.c | 3 | ||||
-rw-r--r-- | src/glsl/glcpp/glcpp.h | 4 | ||||
-rw-r--r-- | src/glsl/glcpp/pp.c | 4 | ||||
-rw-r--r-- | src/glsl/glsl_parser_extras.h | 2 | ||||
-rw-r--r-- | src/glsl/main.cpp | 2 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 2 |
9 files changed, 250 insertions, 228 deletions
diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 91eb0bf9720..96784594d47 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.4.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -101,6 +100,7 @@ #include "glcpp.h" #include "main/core.h" /* for struct gl_extensions */ +#include "main/mtypes.h" /* for gl_api enum */ #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) #define glcpp_printf(stream, fmt, args, ...) \ @@ -357,7 +357,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -632,17 +632,17 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 187, 187, 189, 193, 196, 201, 202, 206, 209, - 215, 218, 221, 224, 232, 251, 261, 266, 271, 290, - 305, 308, 311, 320, 324, 333, 338, 339, 342, 345, - 348, 351, 354, 357, 360, 363, 366, 369, 372, 375, - 378, 381, 384, 387, 390, 393, 396, 399, 402, 405, - 411, 416, 424, 425, 429, 435, 436, 439, 441, 448, - 452, 456, 461, 467, 475, 481, 489, 493, 497, 501, - 505, 512, 513, 514, 515, 516, 517, 518, 519, 520, - 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, - 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, - 541, 542 + 0, 188, 188, 190, 194, 197, 202, 203, 207, 210, + 216, 219, 222, 225, 233, 252, 262, 267, 272, 291, + 306, 309, 312, 324, 328, 337, 342, 343, 346, 349, + 352, 355, 358, 361, 364, 367, 370, 373, 376, 379, + 382, 385, 388, 391, 394, 397, 400, 403, 406, 409, + 415, 420, 428, 429, 433, 439, 440, 443, 445, 452, + 456, 460, 465, 471, 479, 485, 493, 497, 501, 505, + 509, 516, 517, 518, 519, 520, 521, 522, 523, 524, + 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, + 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, + 545, 546 }; #endif @@ -945,9 +945,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -1004,7 +1013,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1546,7 +1555,7 @@ YYLTYPE yylloc; YYLTYPE *yylsp; /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; + YYLTYPE yyerror_range[3]; YYSIZE_T yystacksize; @@ -1593,7 +1602,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if YYLTYPE_IS_TRIVIAL +#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -1601,8 +1610,8 @@ YYLTYPE yylloc; /* User initialization code. */ -/* Line 1242 of yacc.c */ -#line 154 "glcpp/glcpp-parse.y" +/* Line 1251 of yacc.c */ +#line 155 "glcpp/glcpp-parse.y" { yylloc.first_line = 1; yylloc.first_column = 1; @@ -1611,8 +1620,8 @@ YYLTYPE yylloc; yylloc.source = 0; } -/* Line 1242 of yacc.c */ -#line 1616 "glcpp/glcpp-parse.c" +/* Line 1251 of yacc.c */ +#line 1625 "glcpp/glcpp-parse.c" yylsp[0] = yylloc; goto yysetstate; @@ -1799,8 +1808,8 @@ yyreduce: { case 4: -/* Line 1455 of yacc.c */ -#line 193 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 194 "glcpp/glcpp-parse.y" { glcpp_print(parser->output, "\n"); ;} @@ -1808,8 +1817,8 @@ yyreduce: case 5: -/* Line 1455 of yacc.c */ -#line 196 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 197 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); glcpp_print(parser->output, "\n"); @@ -1819,8 +1828,8 @@ yyreduce: case 8: -/* Line 1455 of yacc.c */ -#line 206 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 207 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); ;} @@ -1828,8 +1837,8 @@ yyreduce: case 9: -/* Line 1455 of yacc.c */ -#line 209 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 210 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); ;} @@ -1837,8 +1846,8 @@ yyreduce: case 10: -/* Line 1455 of yacc.c */ -#line 215 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 216 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); ;} @@ -1846,8 +1855,8 @@ yyreduce: case 11: -/* Line 1455 of yacc.c */ -#line 218 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 219 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); ;} @@ -1855,8 +1864,8 @@ yyreduce: case 12: -/* Line 1455 of yacc.c */ -#line 221 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 222 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); ;} @@ -1864,8 +1873,8 @@ yyreduce: case 13: -/* Line 1455 of yacc.c */ -#line 224 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 225 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); if (macro) { @@ -1878,8 +1887,8 @@ yyreduce: case 14: -/* Line 1455 of yacc.c */ -#line 232 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 233 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'if' expression if * we are not skipping. When we are skipping, we @@ -1903,8 +1912,8 @@ yyreduce: case 15: -/* Line 1455 of yacc.c */ -#line 251 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 252 "glcpp/glcpp-parse.y" { /* #if without an expression is only an error if we * are not skipping */ @@ -1919,8 +1928,8 @@ yyreduce: case 16: -/* Line 1455 of yacc.c */ -#line 261 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 262 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1930,8 +1939,8 @@ yyreduce: case 17: -/* Line 1455 of yacc.c */ -#line 266 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 267 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1941,8 +1950,8 @@ yyreduce: case 18: -/* Line 1455 of yacc.c */ -#line 271 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 272 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'elif' expression * if we are not skipping. When we are skipping, we @@ -1966,8 +1975,8 @@ yyreduce: case 19: -/* Line 1455 of yacc.c */ -#line 290 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 291 "glcpp/glcpp-parse.y" { /* #elif without an expression is an error unless we * are skipping. */ @@ -1987,8 +1996,8 @@ yyreduce: case 20: -/* Line 1455 of yacc.c */ -#line 305 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 306 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} @@ -1996,8 +2005,8 @@ yyreduce: case 21: -/* Line 1455 of yacc.c */ -#line 308 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 309 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} @@ -2005,9 +2014,12 @@ yyreduce: case 22: -/* Line 1455 of yacc.c */ -#line 311 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 312 "glcpp/glcpp-parse.y" { + if ((yyvsp[(2) - (3)].ival) == 100) + add_builtin_define (parser, "GL_ES", 1); + macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { hash_table_remove (parser->defines, "__VERSION__"); @@ -2020,8 +2032,8 @@ yyreduce: case 24: -/* Line 1455 of yacc.c */ -#line 324 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 328 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -2035,8 +2047,8 @@ yyreduce: case 25: -/* Line 1455 of yacc.c */ -#line 333 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 337 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} @@ -2044,8 +2056,8 @@ yyreduce: case 27: -/* Line 1455 of yacc.c */ -#line 339 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 343 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} @@ -2053,8 +2065,8 @@ yyreduce: case 28: -/* Line 1455 of yacc.c */ -#line 342 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 346 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} @@ -2062,8 +2074,8 @@ yyreduce: case 29: -/* Line 1455 of yacc.c */ -#line 345 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 349 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} @@ -2071,8 +2083,8 @@ yyreduce: case 30: -/* Line 1455 of yacc.c */ -#line 348 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 352 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} @@ -2080,8 +2092,8 @@ yyreduce: case 31: -/* Line 1455 of yacc.c */ -#line 351 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 355 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} @@ -2089,8 +2101,8 @@ yyreduce: case 32: -/* Line 1455 of yacc.c */ -#line 354 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 358 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} @@ -2098,8 +2110,8 @@ yyreduce: case 33: -/* Line 1455 of yacc.c */ -#line 357 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 361 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} @@ -2107,8 +2119,8 @@ yyreduce: case 34: -/* Line 1455 of yacc.c */ -#line 360 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 364 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} @@ -2116,8 +2128,8 @@ yyreduce: case 35: -/* Line 1455 of yacc.c */ -#line 363 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 367 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} @@ -2125,8 +2137,8 @@ yyreduce: case 36: -/* Line 1455 of yacc.c */ -#line 366 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 370 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} @@ -2134,8 +2146,8 @@ yyreduce: case 37: -/* Line 1455 of yacc.c */ -#line 369 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 373 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} @@ -2143,8 +2155,8 @@ yyreduce: case 38: -/* Line 1455 of yacc.c */ -#line 372 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 376 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} @@ -2152,8 +2164,8 @@ yyreduce: case 39: -/* Line 1455 of yacc.c */ -#line 375 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 379 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} @@ -2161,8 +2173,8 @@ yyreduce: case 40: -/* Line 1455 of yacc.c */ -#line 378 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 382 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} @@ -2170,8 +2182,8 @@ yyreduce: case 41: -/* Line 1455 of yacc.c */ -#line 381 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 385 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} @@ -2179,8 +2191,8 @@ yyreduce: case 42: -/* Line 1455 of yacc.c */ -#line 384 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 388 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} @@ -2188,8 +2200,8 @@ yyreduce: case 43: -/* Line 1455 of yacc.c */ -#line 387 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 391 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); ;} @@ -2197,8 +2209,8 @@ yyreduce: case 44: -/* Line 1455 of yacc.c */ -#line 390 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 394 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} @@ -2206,8 +2218,8 @@ yyreduce: case 45: -/* Line 1455 of yacc.c */ -#line 393 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 397 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} @@ -2215,8 +2227,8 @@ yyreduce: case 46: -/* Line 1455 of yacc.c */ -#line 396 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 400 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} @@ -2224,8 +2236,8 @@ yyreduce: case 47: -/* Line 1455 of yacc.c */ -#line 399 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 403 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} @@ -2233,8 +2245,8 @@ yyreduce: case 48: -/* Line 1455 of yacc.c */ -#line 402 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 406 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} @@ -2242,8 +2254,8 @@ yyreduce: case 49: -/* Line 1455 of yacc.c */ -#line 405 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 409 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} @@ -2251,8 +2263,8 @@ yyreduce: case 50: -/* Line 1455 of yacc.c */ -#line 411 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 415 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); @@ -2262,8 +2274,8 @@ yyreduce: case 51: -/* Line 1455 of yacc.c */ -#line 416 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 420 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); @@ -2273,15 +2285,15 @@ yyreduce: case 52: -/* Line 1455 of yacc.c */ -#line 424 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 428 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 54: -/* Line 1455 of yacc.c */ -#line 429 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 433 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} @@ -2289,15 +2301,15 @@ yyreduce: case 55: -/* Line 1455 of yacc.c */ -#line 435 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 439 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 58: -/* Line 1455 of yacc.c */ -#line 441 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 445 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} @@ -2305,8 +2317,8 @@ yyreduce: case 59: -/* Line 1455 of yacc.c */ -#line 448 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 452 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2315,8 +2327,8 @@ yyreduce: case 60: -/* Line 1455 of yacc.c */ -#line 452 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 456 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2325,8 +2337,8 @@ yyreduce: case 62: -/* Line 1455 of yacc.c */ -#line 461 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 465 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2337,8 +2349,8 @@ yyreduce: case 63: -/* Line 1455 of yacc.c */ -#line 467 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 471 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2348,8 +2360,8 @@ yyreduce: case 64: -/* Line 1455 of yacc.c */ -#line 475 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 479 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2360,8 +2372,8 @@ yyreduce: case 65: -/* Line 1455 of yacc.c */ -#line 481 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 485 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2371,8 +2383,8 @@ yyreduce: case 66: -/* Line 1455 of yacc.c */ -#line 489 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 493 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2381,8 +2393,8 @@ yyreduce: case 67: -/* Line 1455 of yacc.c */ -#line 493 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 497 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2391,8 +2403,8 @@ yyreduce: case 68: -/* Line 1455 of yacc.c */ -#line 497 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 501 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; @@ -2401,8 +2413,8 @@ yyreduce: case 69: -/* Line 1455 of yacc.c */ -#line 501 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 505 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2411,8 +2423,8 @@ yyreduce: case 70: -/* Line 1455 of yacc.c */ -#line 505 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 509 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; @@ -2421,225 +2433,225 @@ yyreduce: case 71: -/* Line 1455 of yacc.c */ -#line 512 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 516 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 72: -/* Line 1455 of yacc.c */ -#line 513 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 517 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 73: -/* Line 1455 of yacc.c */ -#line 514 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 518 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 74: -/* Line 1455 of yacc.c */ -#line 515 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 519 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 75: -/* Line 1455 of yacc.c */ -#line 516 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 520 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 76: -/* Line 1455 of yacc.c */ -#line 517 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 521 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 77: -/* Line 1455 of yacc.c */ -#line 518 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 522 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 78: -/* Line 1455 of yacc.c */ -#line 519 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 523 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 79: -/* Line 1455 of yacc.c */ -#line 520 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 524 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 80: -/* Line 1455 of yacc.c */ -#line 521 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 525 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 81: -/* Line 1455 of yacc.c */ -#line 522 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 526 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 82: -/* Line 1455 of yacc.c */ -#line 523 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 527 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 83: -/* Line 1455 of yacc.c */ -#line 524 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 528 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 84: -/* Line 1455 of yacc.c */ -#line 525 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 529 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 85: -/* Line 1455 of yacc.c */ -#line 526 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 530 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 86: -/* Line 1455 of yacc.c */ -#line 527 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 531 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 87: -/* Line 1455 of yacc.c */ -#line 528 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 532 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 88: -/* Line 1455 of yacc.c */ -#line 529 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 533 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 89: -/* Line 1455 of yacc.c */ -#line 530 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 534 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 90: -/* Line 1455 of yacc.c */ -#line 531 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 535 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 91: -/* Line 1455 of yacc.c */ -#line 532 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 536 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 92: -/* Line 1455 of yacc.c */ -#line 533 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 537 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 93: -/* Line 1455 of yacc.c */ -#line 534 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 538 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 94: -/* Line 1455 of yacc.c */ -#line 535 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 539 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 95: -/* Line 1455 of yacc.c */ -#line 536 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 540 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 96: -/* Line 1455 of yacc.c */ -#line 537 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 541 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 97: -/* Line 1455 of yacc.c */ -#line 538 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 542 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 98: -/* Line 1455 of yacc.c */ -#line 539 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 543 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 99: -/* Line 1455 of yacc.c */ -#line 540 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 544 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 100: -/* Line 1455 of yacc.c */ -#line 541 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 545 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 101: -/* Line 1455 of yacc.c */ -#line 542 "glcpp/glcpp-parse.y" +/* Line 1464 of yacc.c */ +#line 546 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; -/* Line 1455 of yacc.c */ -#line 2643 "glcpp/glcpp-parse.c" +/* Line 1464 of yacc.c */ +#line 2655 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2711,7 +2723,7 @@ yyerrlab: #endif } - yyerror_range[0] = yylloc; + yyerror_range[1] = yylloc; if (yyerrstatus == 3) { @@ -2748,7 +2760,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[0] = yylsp[1-yylen]; + yyerror_range[1] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -2782,7 +2794,7 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - yyerror_range[0] = *yylsp; + yyerror_range[1] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp, parser); YYPOPSTACK (1); @@ -2792,10 +2804,10 @@ yyerrlab1: *++yyvsp = yylval; - yyerror_range[1] = yylloc; + yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + YYLLOC_DEFAULT (yyloc, yyerror_range, 2); *++yylsp = yyloc; /* Shift the error token. */ @@ -2857,8 +2869,8 @@ yyreturn: -/* Line 1675 of yacc.c */ -#line 545 "glcpp/glcpp-parse.y" +/* Line 1684 of yacc.c */ +#line 549 "glcpp/glcpp-parse.y" string_list_t * @@ -3365,7 +3377,7 @@ static void add_builtin_define(glcpp_parser_t *parser, } glcpp_parser_t * -glcpp_parser_create (const struct gl_extensions *extensions) +glcpp_parser_create (const struct gl_extensions *extensions, int api) { glcpp_parser_t *parser; int language_version; @@ -3395,6 +3407,9 @@ glcpp_parser_create (const struct gl_extensions *extensions) add_builtin_define(parser, "GL_ARB_draw_buffers", 1); add_builtin_define(parser, "GL_ARB_texture_rectangle", 1); + if (api == API_OPENGLES2) + add_builtin_define(parser, "GL_ES", 1); + if (extensions != NULL) { if (extensions->EXT_texture_array) { add_builtin_define(parser, "GL_EXT_texture_array", 1); diff --git a/src/glsl/glcpp/glcpp-parse.h b/src/glsl/glcpp/glcpp-parse.h index 50758930e9c..40556854f38 100644 --- a/src/glsl/glcpp/glcpp-parse.h +++ b/src/glsl/glcpp/glcpp-parse.h @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 3c28edf688b..4463a977778 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -30,6 +30,7 @@ #include "glcpp.h" #include "main/core.h" /* for struct gl_extensions */ +#include "main/mtypes.h" /* for gl_api enum */ #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) #define glcpp_printf(stream, fmt, args, ...) \ @@ -309,6 +310,9 @@ control_line: _glcpp_parser_skip_stack_pop (parser, & @1); } | HASH_VERSION integer_constant NEWLINE { + if ($2 == 100) + add_builtin_define (parser, "GL_ES", 1); + macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { hash_table_remove (parser->defines, "__VERSION__"); @@ -1048,7 +1052,7 @@ static void add_builtin_define(glcpp_parser_t *parser, } glcpp_parser_t * -glcpp_parser_create (const struct gl_extensions *extensions) +glcpp_parser_create (const struct gl_extensions *extensions, int api) { glcpp_parser_t *parser; int language_version; @@ -1078,6 +1082,9 @@ glcpp_parser_create (const struct gl_extensions *extensions) add_builtin_define(parser, "GL_ARB_draw_buffers", 1); add_builtin_define(parser, "GL_ARB_texture_rectangle", 1); + if (api == API_OPENGLES2) + add_builtin_define(parser, "GL_ES", 1); + if (extensions != NULL) { if (extensions->EXT_texture_array) { add_builtin_define(parser, "GL_EXT_texture_array", 1); diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c index 56714936bbc..8d1ced571b4 100644 --- a/src/glsl/glcpp/glcpp.c +++ b/src/glsl/glcpp/glcpp.c @@ -28,6 +28,7 @@ #include <string.h> #include <errno.h> #include "glcpp.h" +#include "main/mtypes.h" extern int yydebug; @@ -111,7 +112,7 @@ main (int argc, char *argv[]) if (shader == NULL) return 1; - ret = preprocess(ctx, &shader, &info_log, NULL); + ret = preprocess(ctx, &shader, &info_log, NULL, API_OPENGL); printf("%s", shader); fprintf(stderr, "%s", info_log); diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 0bebdb9ae8c..7125d325dff 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -180,7 +180,7 @@ struct glcpp_parser { struct gl_extensions; glcpp_parser_t * -glcpp_parser_create (const struct gl_extensions *extensions); +glcpp_parser_create (const struct gl_extensions *extensions, int api); int glcpp_parser_parse (glcpp_parser_t *parser); @@ -190,7 +190,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser); int preprocess(void *talloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions); + const struct gl_extensions *extensions, int api); /* Functions for writing to the info log */ diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index a1d00c4193b..e1a3a88a3e5 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -143,10 +143,10 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader) int preprocess(void *talloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions) + const struct gl_extensions *extensions, int api) { int errors; - glcpp_parser_t *parser = glcpp_parser_create (extensions); + glcpp_parser_t *parser = glcpp_parser_create (extensions, api); *shader = remove_line_continuations(parser, *shader); glcpp_lex_set_source_string (parser, *shader); diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index f0977f929a2..ddc2138b765 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -223,7 +223,7 @@ extern "C" { #endif extern int preprocess(void *ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions); + const struct gl_extensions *extensions, int api); extern void _mesa_destroy_shader_compiler(); extern void _mesa_destroy_shader_compiler_caches(); diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 30f11a5a440..2323a204da1 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -130,7 +130,7 @@ compile_shader(struct gl_shader *shader) const char *source = shader->Source; state->error = preprocess(state, &source, &state->info_log, - state->extensions); + state->extensions, API_OPENGL); if (!state->error) { _mesa_glsl_lexer_ctor(state, source); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 960d5c7cece..cb4fbb60c1c 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2769,7 +2769,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) } state->error = preprocess(state, &source, &state->info_log, - &ctx->Extensions); + &ctx->Extensions, ctx->API); if (ctx->Shader.Flags & GLSL_DUMP) { printf("GLSL source for shader %d:\n", shader->Name); |