glsl2: Move the compiler to the subdirectory it will live in in Mesa.
This commit is contained in:
11
src/glsl/glcpp/.gitignore
vendored
Normal file
11
src/glsl/glcpp/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
glcpp
|
||||
glcpp-lex.c
|
||||
glcpp-parse.c
|
||||
glcpp-parse.h
|
||||
glcpp-parse.output
|
||||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
.libs
|
||||
*~
|
||||
tests/*.out
|
46
src/glsl/glcpp/Makefile.am
Normal file
46
src/glsl/glcpp/Makefile.am
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright © 2010 Intel Corporation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
# license, and/or sell copies of the Software, and to permit persons to whom
|
||||
# the Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice (including the next
|
||||
# paragraph) shall be included in all copies or substantial portions of the
|
||||
# Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
noinst_LTLIBRARIES = libglcpp.la
|
||||
libglcpp_la_SOURCES = \
|
||||
glcpp-lex.l \
|
||||
glcpp-parse.y \
|
||||
glcpp.h \
|
||||
hash_table.c \
|
||||
pp.c \
|
||||
xtalloc.c
|
||||
|
||||
BUILT_SOURCES = glcpp-parse.h glcpp-parse.c glcpp-lex.c
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
glcpp-parse.h: glcpp-parse.c
|
||||
|
||||
bin_PROGRAMS = glcpp
|
||||
glcpp_LDADD = libglcpp.la
|
||||
glcpp_LDFLAGS = @LDFLAGS@ $(talloc_LIBS)
|
||||
glcpp_SOURCES = glcpp.c
|
||||
|
||||
.l.c:
|
||||
$(LEXCOMPILE) --outfile="$@" $<
|
||||
|
||||
test: glcpp
|
||||
@(cd tests; ./glcpp-test)
|
30
src/glsl/glcpp/README
Normal file
30
src/glsl/glcpp/README
Normal file
@@ -0,0 +1,30 @@
|
||||
glcpp -- GLSL "C" preprocessor
|
||||
|
||||
This is a simple preprocessor designed to provide the preprocessing
|
||||
needs of the GLSL language. The requirements for this preprocessor are
|
||||
specified in the GLSL 1.30 specification availble from:
|
||||
|
||||
http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.30.08.pdf
|
||||
|
||||
This specification is not precise on some semantics, (for example,
|
||||
#define and #if), defining these merely "as is standard for C++
|
||||
preprocessors". To fill in these details, I've been using the C99
|
||||
standard (for which I had a convenient copy) as available from:
|
||||
|
||||
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
|
||||
|
||||
Known limitations
|
||||
-----------------
|
||||
Macro invocations cannot include embedded newlines.
|
||||
|
||||
The __LINE__, __FILE__, and __VERSION__ macros are not yet supported.
|
||||
|
||||
The argument of the 'defined' operator cannot yet include enclosing
|
||||
parentheses.
|
||||
|
||||
The #error, #pragma, #extension, #version, and #line macros are not
|
||||
yet supported.
|
||||
|
||||
A file that ends with a function-like macro name as the last
|
||||
non-whitespace token will result in a parse error, (where it should be
|
||||
passed through as is).
|
257
src/glsl/glcpp/glcpp-lex.l
Normal file
257
src/glsl/glcpp/glcpp-lex.l
Normal file
@@ -0,0 +1,257 @@
|
||||
%{
|
||||
/*
|
||||
* Copyright © 2010 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glcpp.h"
|
||||
#include "glcpp-parse.h"
|
||||
|
||||
#define YY_USER_ACTION \
|
||||
do { \
|
||||
yylloc->source = 0; \
|
||||
yylloc->first_column = yycolumn + 1; \
|
||||
yylloc->first_line = yylineno; \
|
||||
yycolumn += yyleng; \
|
||||
} while(0);
|
||||
%}
|
||||
|
||||
%option bison-bridge bison-locations reentrant noyywrap
|
||||
%option extra-type="glcpp_parser_t *"
|
||||
%option prefix="glcpp_"
|
||||
%option stack
|
||||
|
||||
%x DONE COMMENT
|
||||
|
||||
SPACE [[:space:]]
|
||||
NONSPACE [^[:space:]]
|
||||
NEWLINE [\n]
|
||||
HSPACE [ \t]
|
||||
HASH ^{HSPACE}*#{HSPACE}*
|
||||
IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*
|
||||
PUNCTUATION [][(){}.&*~!/%<>^|;,=+-]
|
||||
OTHER [^][(){}.&*~!/%<>^|;,=#[:space:]+-]+
|
||||
|
||||
DECIMAL_INTEGER [1-9][0-9]*[uU]?
|
||||
OCTAL_INTEGER 0[0-7]*[uU]?
|
||||
HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
||||
|
||||
%%
|
||||
|
||||
/* Single-line comments */
|
||||
"//"[^\n]*\n {
|
||||
yylineno++;
|
||||
yycolumn = 0;
|
||||
return NEWLINE;
|
||||
}
|
||||
|
||||
/* Multi-line comments */
|
||||
"/*" { yy_push_state(COMMENT, yyscanner); }
|
||||
<COMMENT>[^*\n]*
|
||||
<COMMENT>[^*\n]*\n { yylineno++; yycolumn = 0; }
|
||||
<COMMENT>"*"+[^*/\n]*
|
||||
<COMMENT>"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; }
|
||||
<COMMENT>"*"+"/" {
|
||||
yy_pop_state(yyscanner);
|
||||
if (yyextra->space_tokens)
|
||||
return SPACE;
|
||||
}
|
||||
|
||||
/* glcpp doesn't handle #extension, #version, or #pragma directives.
|
||||
* Simply pass them through to the main compiler's lexer/parser. */
|
||||
{HASH}(extension|version|pragma)[^\n]+ {
|
||||
yylval->str = xtalloc_strdup (yyextra, yytext);
|
||||
yylineno++;
|
||||
yycolumn = 0;
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
{HASH}ifdef/.*\n {
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_IFDEF;
|
||||
}
|
||||
|
||||
{HASH}ifndef/.*\n {
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_IFNDEF;
|
||||
}
|
||||
|
||||
{HASH}if{HSPACE}/.*\n {
|
||||
yyextra->lexing_if = 1;
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_IF;
|
||||
}
|
||||
|
||||
{HASH}elif/.*\n {
|
||||
yyextra->lexing_if = 1;
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_ELIF;
|
||||
}
|
||||
|
||||
{HASH}else/.*\n {
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_ELSE;
|
||||
}
|
||||
|
||||
{HASH}endif/.*\n {
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_ENDIF;
|
||||
}
|
||||
|
||||
/* When skipping (due to an #if 0 or similar) consume anything
|
||||
* up to a newline. We do this less priroty than any
|
||||
* #if-related directive (#if, #elif, #else, #endif), but with
|
||||
* more priority than any other directive or token to avoid
|
||||
* any side-effects from skipped content.
|
||||
*
|
||||
* We use the lexing_if flag to avoid skipping any part of an
|
||||
* if conditional expression. */
|
||||
[^\n]+/\n {
|
||||
/* Since this rule always matches, YY_USER_ACTION gets called for it,
|
||||
* wrongly incrementing yycolumn. We undo that effect here. */
|
||||
yycolumn -= yyleng;
|
||||
if (yyextra->lexing_if ||
|
||||
yyextra->skip_stack == NULL ||
|
||||
yyextra->skip_stack->type == SKIP_NO_SKIP)
|
||||
{
|
||||
REJECT;
|
||||
}
|
||||
}
|
||||
|
||||
{HASH}define{HSPACE}+/{IDENTIFIER}"(" {
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_DEFINE_FUNC;
|
||||
}
|
||||
|
||||
{HASH}define {
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_DEFINE_OBJ;
|
||||
}
|
||||
|
||||
{HASH}undef {
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_UNDEF;
|
||||
}
|
||||
|
||||
{HASH} {
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH;
|
||||
}
|
||||
|
||||
{DECIMAL_INTEGER} {
|
||||
yylval->str = xtalloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
|
||||
{OCTAL_INTEGER} {
|
||||
yylval->str = xtalloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
|
||||
{HEXADECIMAL_INTEGER} {
|
||||
yylval->str = xtalloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
|
||||
"<<" {
|
||||
return LEFT_SHIFT;
|
||||
}
|
||||
|
||||
">>" {
|
||||
return RIGHT_SHIFT;
|
||||
}
|
||||
|
||||
"<=" {
|
||||
return LESS_OR_EQUAL;
|
||||
}
|
||||
|
||||
">=" {
|
||||
return GREATER_OR_EQUAL;
|
||||
}
|
||||
|
||||
"==" {
|
||||
return EQUAL;
|
||||
}
|
||||
|
||||
"!=" {
|
||||
return NOT_EQUAL;
|
||||
}
|
||||
|
||||
"&&" {
|
||||
return AND;
|
||||
}
|
||||
|
||||
"||" {
|
||||
return OR;
|
||||
}
|
||||
|
||||
"##" {
|
||||
return PASTE;
|
||||
}
|
||||
|
||||
"defined" {
|
||||
return DEFINED;
|
||||
}
|
||||
|
||||
{IDENTIFIER} {
|
||||
yylval->str = xtalloc_strdup (yyextra, yytext);
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
{PUNCTUATION} {
|
||||
return yytext[0];
|
||||
}
|
||||
|
||||
{OTHER}+ {
|
||||
yylval->str = xtalloc_strdup (yyextra, yytext);
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
{HSPACE}+ {
|
||||
if (yyextra->space_tokens) {
|
||||
return SPACE;
|
||||
}
|
||||
}
|
||||
|
||||
\n {
|
||||
yyextra->lexing_if = 0;
|
||||
yylineno++;
|
||||
yycolumn = 0;
|
||||
return NEWLINE;
|
||||
}
|
||||
|
||||
/* Handle missing newline at EOF. */
|
||||
<INITIAL><<EOF>> {
|
||||
BEGIN DONE; /* Don't keep matching this rule forever. */
|
||||
yyextra->lexing_if = 0;
|
||||
return NEWLINE;
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
void
|
||||
glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader)
|
||||
{
|
||||
yy_scan_string(shader, parser->scanner);
|
||||
}
|
1611
src/glsl/glcpp/glcpp-parse.y
Normal file
1611
src/glsl/glcpp/glcpp-parse.y
Normal file
File diff suppressed because it is too large
Load Diff
88
src/glsl/glcpp/glcpp.c
Normal file
88
src/glsl/glcpp/glcpp.c
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright © 2010 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "glcpp.h"
|
||||
|
||||
extern int yydebug;
|
||||
|
||||
static char *
|
||||
load_text_file(void *ctx, const char *file_name)
|
||||
{
|
||||
char *text = NULL;
|
||||
struct stat st;
|
||||
ssize_t total_read = 0;
|
||||
int fd = file_name == NULL ? STDIN_FILENO : open(file_name, O_RDONLY);
|
||||
|
||||
if (fd < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fstat(fd, & st) == 0) {
|
||||
text = (char *) talloc_size(ctx, st.st_size + 1);
|
||||
if (text != NULL) {
|
||||
do {
|
||||
ssize_t bytes = read(fd, text + total_read,
|
||||
st.st_size - total_read);
|
||||
if (bytes < 0) {
|
||||
text = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (bytes == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
total_read += bytes;
|
||||
} while (total_read < st.st_size);
|
||||
|
||||
text[total_read] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
int
|
||||
preprocess(void *talloc_ctx, const char **shader, char **info_log);
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
void *ctx = talloc(NULL, void*);
|
||||
const char *shader = load_text_file(ctx, NULL);
|
||||
char *info_log = talloc_strdup(ctx, "");
|
||||
int ret = preprocess(ctx, &shader, &info_log);
|
||||
|
||||
printf("%s", shader);
|
||||
fprintf(stderr, "%s", info_log);
|
||||
|
||||
talloc_free(ctx);
|
||||
|
||||
return ret;
|
||||
}
|
224
src/glsl/glcpp/glcpp.h
Normal file
224
src/glsl/glcpp/glcpp.h
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright © 2010 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GLCPP_H
|
||||
#define GLCPP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <talloc.h>
|
||||
|
||||
#include "hash_table.h"
|
||||
|
||||
#define yyscan_t void*
|
||||
|
||||
/* Some data types used for parser values. */
|
||||
|
||||
typedef struct string_node {
|
||||
const char *str;
|
||||
struct string_node *next;
|
||||
} string_node_t;
|
||||
|
||||
typedef struct string_list {
|
||||
string_node_t *head;
|
||||
string_node_t *tail;
|
||||
} string_list_t;
|
||||
|
||||
typedef struct token token_t;
|
||||
typedef struct token_list token_list_t;
|
||||
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
intmax_t ival;
|
||||
char *str;
|
||||
string_list_t *string_list;
|
||||
token_t *token;
|
||||
token_list_t *token_list;
|
||||
} YYSTYPE;
|
||||
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
|
||||
typedef struct YYLTYPE {
|
||||
int first_line;
|
||||
int first_column;
|
||||
int last_line;
|
||||
int last_column;
|
||||
unsigned source;
|
||||
} YYLTYPE;
|
||||
# define YYLTYPE_IS_DECLARED 1
|
||||
# define YYLTYPE_IS_TRIVIAL 1
|
||||
|
||||
struct token {
|
||||
int type;
|
||||
YYSTYPE value;
|
||||
YYLTYPE location;
|
||||
};
|
||||
|
||||
typedef struct token_node {
|
||||
token_t *token;
|
||||
struct token_node *next;
|
||||
} token_node_t;
|
||||
|
||||
struct token_list {
|
||||
token_node_t *head;
|
||||
token_node_t *tail;
|
||||
token_node_t *non_space_tail;
|
||||
};
|
||||
|
||||
typedef struct argument_node {
|
||||
token_list_t *argument;
|
||||
struct argument_node *next;
|
||||
} argument_node_t;
|
||||
|
||||
typedef struct argument_list {
|
||||
argument_node_t *head;
|
||||
argument_node_t *tail;
|
||||
} argument_list_t;
|
||||
|
||||
typedef struct glcpp_parser glcpp_parser_t;
|
||||
|
||||
typedef enum {
|
||||
TOKEN_CLASS_IDENTIFIER,
|
||||
TOKEN_CLASS_IDENTIFIER_FINALIZED,
|
||||
TOKEN_CLASS_FUNC_MACRO,
|
||||
TOKEN_CLASS_OBJ_MACRO
|
||||
} token_class_t;
|
||||
|
||||
token_class_t
|
||||
glcpp_parser_classify_token (glcpp_parser_t *parser,
|
||||
const char *identifier,
|
||||
int *parameter_index);
|
||||
|
||||
typedef struct {
|
||||
int is_function;
|
||||
string_list_t *parameters;
|
||||
const char *identifier;
|
||||
token_list_t *replacements;
|
||||
} macro_t;
|
||||
|
||||
typedef struct expansion_node {
|
||||
macro_t *macro;
|
||||
token_node_t *replacements;
|
||||
struct expansion_node *next;
|
||||
} expansion_node_t;
|
||||
|
||||
typedef enum skip_type {
|
||||
SKIP_NO_SKIP,
|
||||
SKIP_TO_ELSE,
|
||||
SKIP_TO_ENDIF
|
||||
} skip_type_t;
|
||||
|
||||
typedef struct skip_node {
|
||||
skip_type_t type;
|
||||
YYLTYPE loc; /* location of the initial #if/#elif/... */
|
||||
struct skip_node *next;
|
||||
} skip_node_t;
|
||||
|
||||
typedef struct active_list {
|
||||
const char *identifier;
|
||||
token_node_t *marker;
|
||||
struct active_list *next;
|
||||
} active_list_t;
|
||||
|
||||
struct glcpp_parser {
|
||||
yyscan_t scanner;
|
||||
struct hash_table *defines;
|
||||
active_list_t *active;
|
||||
int lexing_if;
|
||||
int space_tokens;
|
||||
int newline_as_space;
|
||||
int in_control_line;
|
||||
int paren_count;
|
||||
skip_node_t *skip_stack;
|
||||
token_list_t *lex_from_list;
|
||||
token_node_t *lex_from_node;
|
||||
char *output;
|
||||
char *info_log;
|
||||
int error;
|
||||
};
|
||||
|
||||
glcpp_parser_t *
|
||||
glcpp_parser_create (void);
|
||||
|
||||
int
|
||||
glcpp_parser_parse (glcpp_parser_t *parser);
|
||||
|
||||
void
|
||||
glcpp_parser_destroy (glcpp_parser_t *parser);
|
||||
|
||||
int
|
||||
preprocess(void *talloc_ctx, const char **shader, char **info_log);
|
||||
|
||||
/* Functions for writing to the info log */
|
||||
|
||||
void
|
||||
glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...);
|
||||
|
||||
void
|
||||
glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...);
|
||||
|
||||
/* Generated by glcpp-lex.l to glcpp-lex.c */
|
||||
|
||||
int
|
||||
glcpp_lex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner);
|
||||
|
||||
void
|
||||
glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader);
|
||||
|
||||
int
|
||||
glcpp_lex (YYSTYPE *lvalp, YYLTYPE *llocp, yyscan_t scanner);
|
||||
|
||||
int
|
||||
glcpp_lex_destroy (yyscan_t scanner);
|
||||
|
||||
/* Generated by glcpp-parse.y to glcpp-parse.c */
|
||||
|
||||
int
|
||||
yyparse (glcpp_parser_t *parser);
|
||||
|
||||
/* xtalloc - wrappers around talloc to check for out-of-memory */
|
||||
|
||||
#define xtalloc(ctx, type) (type *)xtalloc_named_const(ctx, sizeof(type), #type)
|
||||
|
||||
#define xtalloc_size(ctx, size) xtalloc_named_const(ctx, size, __location__)
|
||||
|
||||
void *
|
||||
xtalloc_named_const (const void *context, size_t size, const char *name);
|
||||
|
||||
char *
|
||||
xtalloc_strdup (const void *t, const char *p);
|
||||
|
||||
char *
|
||||
xtalloc_strndup (const void *t, const char *p, size_t n);
|
||||
|
||||
char *
|
||||
xtalloc_asprintf (const void *t, const char *fmt, ...);
|
||||
|
||||
void *
|
||||
_xtalloc_reference_loc (const void *context,
|
||||
const void *ptr, const char *location);
|
||||
|
||||
#define xtalloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_xtalloc_reference_loc((ctx),(ptr), __location__)
|
||||
|
||||
#endif
|
159
src/glsl/glcpp/hash_table.c
Normal file
159
src/glsl/glcpp/hash_table.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright © 2008 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file hash_table.c
|
||||
* \brief Implementation of a generic, opaque hash table data type.
|
||||
*
|
||||
* \author Ian Romanick <ian.d.romanick@intel.com>
|
||||
*/
|
||||
|
||||
#include "main/imports.h"
|
||||
#include "main/simple_list.h"
|
||||
#include "hash_table.h"
|
||||
|
||||
struct node {
|
||||
struct node *next;
|
||||
struct node *prev;
|
||||
};
|
||||
|
||||
struct hash_table {
|
||||
hash_func_t hash;
|
||||
hash_compare_func_t compare;
|
||||
|
||||
unsigned num_buckets;
|
||||
struct node buckets[1];
|
||||
};
|
||||
|
||||
|
||||
struct hash_node {
|
||||
struct node link;
|
||||
const void *key;
|
||||
void *data;
|
||||
};
|
||||
|
||||
|
||||
struct hash_table *
|
||||
hash_table_ctor(unsigned num_buckets, hash_func_t hash,
|
||||
hash_compare_func_t compare)
|
||||
{
|
||||
struct hash_table *ht;
|
||||
unsigned i;
|
||||
|
||||
|
||||
if (num_buckets < 16) {
|
||||
num_buckets = 16;
|
||||
}
|
||||
|
||||
ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1)
|
||||
* sizeof(ht->buckets[0])));
|
||||
if (ht != NULL) {
|
||||
ht->hash = hash;
|
||||
ht->compare = compare;
|
||||
ht->num_buckets = num_buckets;
|
||||
|
||||
for (i = 0; i < num_buckets; i++) {
|
||||
make_empty_list(& ht->buckets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return ht;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
hash_table_dtor(struct hash_table *ht)
|
||||
{
|
||||
hash_table_clear(ht);
|
||||
_mesa_free(ht);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
hash_table_clear(struct hash_table *ht)
|
||||
{
|
||||
struct node *node;
|
||||
struct node *temp;
|
||||
unsigned i;
|
||||
|
||||
|
||||
for (i = 0; i < ht->num_buckets; i++) {
|
||||
foreach_s(node, temp, & ht->buckets[i]) {
|
||||
remove_from_list(node);
|
||||
_mesa_free(node);
|
||||
}
|
||||
|
||||
assert(is_empty_list(& ht->buckets[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
hash_table_find(struct hash_table *ht, const void *key)
|
||||
{
|
||||
const unsigned hash_value = (*ht->hash)(key);
|
||||
const unsigned bucket = hash_value % ht->num_buckets;
|
||||
struct node *node;
|
||||
|
||||
foreach(node, & ht->buckets[bucket]) {
|
||||
struct hash_node *hn = (struct hash_node *) node;
|
||||
|
||||
if ((*ht->compare)(hn->key, key) == 0) {
|
||||
return hn->data;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
hash_table_insert(struct hash_table *ht, void *data, const void *key)
|
||||
{
|
||||
const unsigned hash_value = (*ht->hash)(key);
|
||||
const unsigned bucket = hash_value % ht->num_buckets;
|
||||
struct hash_node *node;
|
||||
|
||||
node = _mesa_calloc(sizeof(*node));
|
||||
|
||||
node->data = data;
|
||||
node->key = key;
|
||||
|
||||
insert_at_head(& ht->buckets[bucket], & node->link);
|
||||
}
|
||||
|
||||
|
||||
unsigned
|
||||
hash_table_string_hash(const void *key)
|
||||
{
|
||||
const char *str = (const char *) key;
|
||||
unsigned hash = 5381;
|
||||
|
||||
|
||||
while (*str != '\0') {
|
||||
hash = (hash * 33) + *str;
|
||||
str++;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
125
src/glsl/glcpp/hash_table.h
Normal file
125
src/glsl/glcpp/hash_table.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright © 2008 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file hash_table.h
|
||||
* \brief Implementation of a generic, opaque hash table data type.
|
||||
*
|
||||
* \author Ian Romanick <ian.d.romanick@intel.com>
|
||||
*/
|
||||
|
||||
#ifndef HASH_TABLE_H
|
||||
#define HASH_TABLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct hash_table;
|
||||
|
||||
typedef unsigned (*hash_func_t)(const void *key);
|
||||
typedef int (*hash_compare_func_t)(const void *key1, const void *key2);
|
||||
|
||||
/**
|
||||
* Hash table constructor
|
||||
*
|
||||
* Creates a hash table with the specified number of buckets. The supplied
|
||||
* \c hash and \c compare routines are used when adding elements to the table
|
||||
* and when searching for elements in the table.
|
||||
*
|
||||
* \param num_buckets Number of buckets (bins) in the hash table.
|
||||
* \param hash Function used to compute hash value of input keys.
|
||||
* \param compare Function used to compare keys.
|
||||
*/
|
||||
extern struct hash_table *hash_table_ctor(unsigned num_buckets,
|
||||
hash_func_t hash, hash_compare_func_t compare);
|
||||
|
||||
|
||||
/**
|
||||
* Release all memory associated with a hash table
|
||||
*
|
||||
* \warning
|
||||
* This function cannot release memory occupied either by keys or data.
|
||||
*/
|
||||
extern void hash_table_dtor(struct hash_table *ht);
|
||||
|
||||
|
||||
/**
|
||||
* Flush all entries from a hash table
|
||||
*
|
||||
* \param ht Table to be cleared of its entries.
|
||||
*/
|
||||
extern void hash_table_clear(struct hash_table *ht);
|
||||
|
||||
|
||||
/**
|
||||
* Search a hash table for a specific element
|
||||
*
|
||||
* \param ht Table to be searched
|
||||
* \param key Key of the desired element
|
||||
*
|
||||
* \return
|
||||
* The \c data value supplied to \c hash_table_insert when the element with
|
||||
* the matching key was added. If no matching key exists in the table,
|
||||
* \c NULL is returned.
|
||||
*/
|
||||
extern void *hash_table_find(struct hash_table *ht, const void *key);
|
||||
|
||||
|
||||
/**
|
||||
* Add an element to a hash table
|
||||
*/
|
||||
extern void hash_table_insert(struct hash_table *ht, void *data,
|
||||
const void *key);
|
||||
|
||||
|
||||
/**
|
||||
* Compute hash value of a string
|
||||
*
|
||||
* Computes the hash value of a string using the DJB2 algorithm developed by
|
||||
* Professor Daniel J. Bernstein. It was published on comp.lang.c once upon
|
||||
* a time. I was unable to find the original posting in the archives.
|
||||
*
|
||||
* \param key Pointer to a NUL terminated string to be hashed.
|
||||
*
|
||||
* \sa hash_table_string_compare
|
||||
*/
|
||||
extern unsigned hash_table_string_hash(const void *key);
|
||||
|
||||
|
||||
/**
|
||||
* Compare two strings used as keys
|
||||
*
|
||||
* This is just a macro wrapper around \c strcmp.
|
||||
*
|
||||
* \sa hash_table_string_hash
|
||||
*/
|
||||
#define hash_table_string_compare ((hash_compare_func_t) strcmp)
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HASH_TABLE_H */
|
6
src/glsl/glcpp/main/imports.h
Normal file
6
src/glsl/glcpp/main/imports.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define _mesa_malloc(x) malloc(x)
|
||||
#define _mesa_free(x) free(x)
|
||||
#define _mesa_calloc(x) calloc(1,x)
|
235
src/glsl/glcpp/main/simple_list.h
Normal file
235
src/glsl/glcpp/main/simple_list.h
Normal file
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* \file simple_list.h
|
||||
* Simple macros for type-safe, intrusive lists.
|
||||
*
|
||||
* Intended to work with a list sentinal which is created as an empty
|
||||
* list. Insert & delete are O(1).
|
||||
*
|
||||
* \author
|
||||
* (C) 1997, Keith Whitwell
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SIMPLE_LIST_H
|
||||
#define _SIMPLE_LIST_H
|
||||
|
||||
struct simple_node {
|
||||
struct simple_node *next;
|
||||
struct simple_node *prev;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove an element from list.
|
||||
*
|
||||
* \param elem element to remove.
|
||||
*/
|
||||
#define remove_from_list(elem) \
|
||||
do { \
|
||||
(elem)->next->prev = (elem)->prev; \
|
||||
(elem)->prev->next = (elem)->next; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Insert an element to the list head.
|
||||
*
|
||||
* \param list list.
|
||||
* \param elem element to insert.
|
||||
*/
|
||||
#define insert_at_head(list, elem) \
|
||||
do { \
|
||||
(elem)->prev = list; \
|
||||
(elem)->next = (list)->next; \
|
||||
(list)->next->prev = elem; \
|
||||
(list)->next = elem; \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Insert an element to the list tail.
|
||||
*
|
||||
* \param list list.
|
||||
* \param elem element to insert.
|
||||
*/
|
||||
#define insert_at_tail(list, elem) \
|
||||
do { \
|
||||
(elem)->next = list; \
|
||||
(elem)->prev = (list)->prev; \
|
||||
(list)->prev->next = elem; \
|
||||
(list)->prev = elem; \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Move an element to the list head.
|
||||
*
|
||||
* \param list list.
|
||||
* \param elem element to move.
|
||||
*/
|
||||
#define move_to_head(list, elem) \
|
||||
do { \
|
||||
remove_from_list(elem); \
|
||||
insert_at_head(list, elem); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Move an element to the list tail.
|
||||
*
|
||||
* \param list list.
|
||||
* \param elem element to move.
|
||||
*/
|
||||
#define move_to_tail(list, elem) \
|
||||
do { \
|
||||
remove_from_list(elem); \
|
||||
insert_at_tail(list, elem); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Consatinate a cyclic list to a list
|
||||
*
|
||||
* Appends the sequence of nodes starting with \c tail to the list \c head.
|
||||
* A "cyclic list" is a list that does not have a sentinal node. This means
|
||||
* that the data pointed to by \c tail is an actual node, not a dataless
|
||||
* sentinal. Note that if \c tail constist of a single node, this macro
|
||||
* behaves identically to \c insert_at_tail
|
||||
*
|
||||
* \param head Head of the list to be appended to. This may or may not
|
||||
* be a cyclic list.
|
||||
* \param tail Head of the cyclic list to be appended to \c head.
|
||||
* \param temp Temporary \c simple_list used by the macro
|
||||
*
|
||||
* \sa insert_at_tail
|
||||
*/
|
||||
#define concat_list_and_cycle(head, tail, temp) \
|
||||
do { \
|
||||
(head)->prev->next = (tail); \
|
||||
(tail)->prev->next = (head); \
|
||||
(temp) = (head)->prev; \
|
||||
(head)->prev = (tail)->prev; \
|
||||
(tail)->prev = (temp); \
|
||||
} while (0)
|
||||
|
||||
#define concat_list(head, next_list) \
|
||||
do { \
|
||||
(next_list)->next->prev = (head)->prev; \
|
||||
(next_list)->prev->next = (head); \
|
||||
(head)->prev->next = (next_list)->next; \
|
||||
(head)->prev = (next_list)->prev; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Make a empty list empty.
|
||||
*
|
||||
* \param sentinal list (sentinal element).
|
||||
*/
|
||||
#define make_empty_list(sentinal) \
|
||||
do { \
|
||||
(sentinal)->next = sentinal; \
|
||||
(sentinal)->prev = sentinal; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Get list first element.
|
||||
*
|
||||
* \param list list.
|
||||
*
|
||||
* \return pointer to first element.
|
||||
*/
|
||||
#define first_elem(list) ((list)->next)
|
||||
|
||||
/**
|
||||
* Get list last element.
|
||||
*
|
||||
* \param list list.
|
||||
*
|
||||
* \return pointer to last element.
|
||||
*/
|
||||
#define last_elem(list) ((list)->prev)
|
||||
|
||||
/**
|
||||
* Get next element.
|
||||
*
|
||||
* \param elem element.
|
||||
*
|
||||
* \return pointer to next element.
|
||||
*/
|
||||
#define next_elem(elem) ((elem)->next)
|
||||
|
||||
/**
|
||||
* Get previous element.
|
||||
*
|
||||
* \param elem element.
|
||||
*
|
||||
* \return pointer to previous element.
|
||||
*/
|
||||
#define prev_elem(elem) ((elem)->prev)
|
||||
|
||||
/**
|
||||
* Test whether element is at end of the list.
|
||||
*
|
||||
* \param list list.
|
||||
* \param elem element.
|
||||
*
|
||||
* \return non-zero if element is at end of list, or zero otherwise.
|
||||
*/
|
||||
#define at_end(list, elem) ((elem) == (list))
|
||||
|
||||
/**
|
||||
* Test if a list is empty.
|
||||
*
|
||||
* \param list list.
|
||||
*
|
||||
* \return non-zero if list empty, or zero otherwise.
|
||||
*/
|
||||
#define is_empty_list(list) ((list)->next == (list))
|
||||
|
||||
/**
|
||||
* Walk through the elements of a list.
|
||||
*
|
||||
* \param ptr pointer to the current element.
|
||||
* \param list list.
|
||||
*
|
||||
* \note It should be followed by a { } block or a single statement, as in a \c
|
||||
* for loop.
|
||||
*/
|
||||
#define foreach(ptr, list) \
|
||||
for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next )
|
||||
|
||||
/**
|
||||
* Walk through the elements of a list.
|
||||
*
|
||||
* Same as #foreach but lets you unlink the current value during a list
|
||||
* traversal. Useful for freeing a list, element by element.
|
||||
*
|
||||
* \param ptr pointer to the current element.
|
||||
* \param t temporary pointer.
|
||||
* \param list list.
|
||||
*
|
||||
* \note It should be followed by a { } block or a single statement, as in a \c
|
||||
* for loop.
|
||||
*/
|
||||
#define foreach_s(ptr, t, list) \
|
||||
for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next)
|
||||
|
||||
#endif
|
155
src/glsl/glcpp/pp.c
Normal file
155
src/glsl/glcpp/pp.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright © 2010 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include "glcpp.h"
|
||||
|
||||
void
|
||||
glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
|
||||
{
|
||||
parser->error = 1;
|
||||
parser->info_log = talloc_asprintf_append(parser->info_log,
|
||||
"%u:%u(%u): "
|
||||
"preprocessor error: ",
|
||||
locp->source,
|
||||
locp->first_line,
|
||||
locp->first_column);
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
|
||||
va_end(ap);
|
||||
parser->info_log = talloc_strdup_append(parser->info_log, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
|
||||
{
|
||||
parser->info_log = talloc_asprintf_append(parser->info_log,
|
||||
"%u:%u(%u): "
|
||||
"preprocessor warning: ",
|
||||
locp->source,
|
||||
locp->first_line,
|
||||
locp->first_column);
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
|
||||
va_end(ap);
|
||||
parser->info_log = talloc_strdup_append(parser->info_log, "\n");
|
||||
}
|
||||
|
||||
/* Searches backwards for '^ *#' from a given starting point. */
|
||||
static int
|
||||
in_directive(const char *shader, const char *ptr)
|
||||
{
|
||||
assert(ptr >= shader);
|
||||
|
||||
/* Search backwards for '#'. If we find a \n first, it doesn't count */
|
||||
for (; ptr >= shader && *ptr != '#'; ptr--) {
|
||||
if (*ptr == '\n')
|
||||
return 0;
|
||||
}
|
||||
if (ptr >= shader) {
|
||||
/* Found '#'...look for spaces preceded by a newline */
|
||||
for (ptr--; ptr >= shader && isblank(*ptr); ptr--);
|
||||
// FIXME: I don't think the '\n' case can happen
|
||||
if (ptr < shader || *ptr == '\n')
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Remove any line continuation characters in preprocessing directives.
|
||||
* However, ignore any in GLSL code, as "There is no line continuation
|
||||
* character" (1.30 page 9) in GLSL.
|
||||
*/
|
||||
static char *
|
||||
remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
|
||||
{
|
||||
int in_continued_line = 0;
|
||||
int extra_newlines = 0;
|
||||
char *clean = talloc_strdup(ctx, "");
|
||||
const char *search_start = shader;
|
||||
const char *newline;
|
||||
while ((newline = strchr(search_start, '\n')) != NULL) {
|
||||
const char *backslash = NULL;
|
||||
/* Find the preceding '\', if it exists */
|
||||
if (newline[-1] == '\\') {
|
||||
backslash = newline - 1;
|
||||
} else if (newline[-1] == '\r' && newline[-2] == '\\') {
|
||||
backslash = newline - 2;
|
||||
}
|
||||
/* Double backslashes don't count (the backslash is escaped) */
|
||||
if (backslash != NULL && backslash[-1] == '\\') {
|
||||
backslash = NULL;
|
||||
}
|
||||
|
||||
if (backslash != NULL) {
|
||||
/* We found a line continuation, but do we care? */
|
||||
if (!in_continued_line) {
|
||||
if (in_directive(shader, backslash)) {
|
||||
in_continued_line = 1;
|
||||
extra_newlines = 0;
|
||||
}
|
||||
}
|
||||
if (in_continued_line) {
|
||||
/* Copy everything before the \ */
|
||||
clean = talloc_strndup_append(clean, shader, backslash - shader);
|
||||
shader = newline + 1;
|
||||
extra_newlines++;
|
||||
}
|
||||
} else if (in_continued_line) {
|
||||
/* Copy everything up to and including the \n */
|
||||
clean = talloc_strndup_append(clean, shader, newline - shader + 1);
|
||||
shader = newline + 1;
|
||||
/* Output extra newlines to make line numbers match */
|
||||
for (; extra_newlines > 0; extra_newlines--)
|
||||
clean = talloc_strdup_append(clean, "\n");
|
||||
in_continued_line = 0;
|
||||
}
|
||||
search_start = newline + 1;
|
||||
}
|
||||
clean = talloc_strdup_append(clean, shader);
|
||||
return clean;
|
||||
}
|
||||
|
||||
extern int
|
||||
preprocess(void *talloc_ctx, const char **shader, char **info_log)
|
||||
{
|
||||
int errors;
|
||||
glcpp_parser_t *parser = glcpp_parser_create ();
|
||||
*shader = remove_line_continuations(parser, *shader);
|
||||
|
||||
glcpp_lex_set_source_string (parser, *shader);
|
||||
|
||||
glcpp_parser_parse (parser);
|
||||
|
||||
*info_log = talloc_strdup_append(*info_log, parser->info_log);
|
||||
|
||||
talloc_steal(talloc_ctx, parser->output);
|
||||
*shader = parser->output;
|
||||
|
||||
errors = parser->error;
|
||||
glcpp_parser_destroy (parser);
|
||||
return errors;
|
||||
}
|
1
src/glsl/glcpp/tests/000-content-with-spaces.c
Normal file
1
src/glsl/glcpp/tests/000-content-with-spaces.c
Normal file
@@ -0,0 +1 @@
|
||||
this is four tokens
|
2
src/glsl/glcpp/tests/000-content-with-spaces.c.expected
Normal file
2
src/glsl/glcpp/tests/000-content-with-spaces.c.expected
Normal file
@@ -0,0 +1,2 @@
|
||||
this is four tokens
|
||||
|
2
src/glsl/glcpp/tests/001-define.c
Normal file
2
src/glsl/glcpp/tests/001-define.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo 1
|
||||
foo
|
3
src/glsl/glcpp/tests/001-define.c.expected
Normal file
3
src/glsl/glcpp/tests/001-define.c.expected
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
1
|
||||
|
3
src/glsl/glcpp/tests/002-define-chain.c
Normal file
3
src/glsl/glcpp/tests/002-define-chain.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define foo 1
|
||||
#define bar foo
|
||||
bar
|
4
src/glsl/glcpp/tests/002-define-chain.c.expected
Normal file
4
src/glsl/glcpp/tests/002-define-chain.c.expected
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
1
|
||||
|
3
src/glsl/glcpp/tests/003-define-chain-reverse.c
Normal file
3
src/glsl/glcpp/tests/003-define-chain-reverse.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define bar foo
|
||||
#define foo 1
|
||||
bar
|
4
src/glsl/glcpp/tests/003-define-chain-reverse.c.expected
Normal file
4
src/glsl/glcpp/tests/003-define-chain-reverse.c.expected
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
1
|
||||
|
6
src/glsl/glcpp/tests/004-define-recursive.c
Normal file
6
src/glsl/glcpp/tests/004-define-recursive.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#define foo bar
|
||||
#define bar baz
|
||||
#define baz foo
|
||||
foo
|
||||
bar
|
||||
baz
|
7
src/glsl/glcpp/tests/004-define-recursive.c.expected
Normal file
7
src/glsl/glcpp/tests/004-define-recursive.c.expected
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
|
||||
foo
|
||||
bar
|
||||
baz
|
||||
|
3
src/glsl/glcpp/tests/005-define-composite-chain.c
Normal file
3
src/glsl/glcpp/tests/005-define-composite-chain.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define foo 1
|
||||
#define bar a foo
|
||||
bar
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
a 1
|
||||
|
@@ -0,0 +1,3 @@
|
||||
#define bar a foo
|
||||
#define foo 1
|
||||
bar
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
a 1
|
||||
|
6
src/glsl/glcpp/tests/007-define-composite-recursive.c
Normal file
6
src/glsl/glcpp/tests/007-define-composite-recursive.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#define foo a bar
|
||||
#define bar b baz
|
||||
#define baz c foo
|
||||
foo
|
||||
bar
|
||||
baz
|
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
|
||||
a b c foo
|
||||
b c a bar
|
||||
c a b baz
|
||||
|
2
src/glsl/glcpp/tests/008-define-empty.c
Normal file
2
src/glsl/glcpp/tests/008-define-empty.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo
|
||||
foo
|
3
src/glsl/glcpp/tests/008-define-empty.c.expected
Normal file
3
src/glsl/glcpp/tests/008-define-empty.c.expected
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
|
4
src/glsl/glcpp/tests/009-undef.c
Normal file
4
src/glsl/glcpp/tests/009-undef.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#define foo 1
|
||||
foo
|
||||
#undef foo
|
||||
foo
|
5
src/glsl/glcpp/tests/009-undef.c.expected
Normal file
5
src/glsl/glcpp/tests/009-undef.c.expected
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
1
|
||||
|
||||
foo
|
||||
|
6
src/glsl/glcpp/tests/010-undef-re-define.c
Normal file
6
src/glsl/glcpp/tests/010-undef-re-define.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#define foo 1
|
||||
foo
|
||||
#undef foo
|
||||
foo
|
||||
#define foo 2
|
||||
foo
|
7
src/glsl/glcpp/tests/010-undef-re-define.c.expected
Normal file
7
src/glsl/glcpp/tests/010-undef-re-define.c.expected
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
1
|
||||
|
||||
foo
|
||||
|
||||
2
|
||||
|
2
src/glsl/glcpp/tests/011-define-func-empty.c
Normal file
2
src/glsl/glcpp/tests/011-define-func-empty.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo()
|
||||
foo()
|
3
src/glsl/glcpp/tests/011-define-func-empty.c.expected
Normal file
3
src/glsl/glcpp/tests/011-define-func-empty.c.expected
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
|
2
src/glsl/glcpp/tests/012-define-func-no-args.c
Normal file
2
src/glsl/glcpp/tests/012-define-func-no-args.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo() bar
|
||||
foo()
|
3
src/glsl/glcpp/tests/012-define-func-no-args.c.expected
Normal file
3
src/glsl/glcpp/tests/012-define-func-no-args.c.expected
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
bar
|
||||
|
2
src/glsl/glcpp/tests/013-define-func-1-arg-unused.c
Normal file
2
src/glsl/glcpp/tests/013-define-func-1-arg-unused.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(x) 1
|
||||
foo(bar)
|
@@ -0,0 +1,3 @@
|
||||
|
||||
1
|
||||
|
2
src/glsl/glcpp/tests/014-define-func-2-arg-unused.c
Normal file
2
src/glsl/glcpp/tests/014-define-func-2-arg-unused.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(x,y) 1
|
||||
foo(bar,baz)
|
@@ -0,0 +1,3 @@
|
||||
|
||||
1
|
||||
|
4
src/glsl/glcpp/tests/015-define-object-with-parens.c
Normal file
4
src/glsl/glcpp/tests/015-define-object-with-parens.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#define foo ()1
|
||||
foo()
|
||||
#define bar ()2
|
||||
bar()
|
@@ -0,0 +1,5 @@
|
||||
|
||||
()1()
|
||||
|
||||
()2()
|
||||
|
2
src/glsl/glcpp/tests/016-define-func-1-arg.c
Normal file
2
src/glsl/glcpp/tests/016-define-func-1-arg.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(x) ((x)+1)
|
||||
foo(bar)
|
3
src/glsl/glcpp/tests/016-define-func-1-arg.c.expected
Normal file
3
src/glsl/glcpp/tests/016-define-func-1-arg.c.expected
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
((bar)+1)
|
||||
|
2
src/glsl/glcpp/tests/017-define-func-2-args.c
Normal file
2
src/glsl/glcpp/tests/017-define-func-2-args.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(x,y) ((x)*(y))
|
||||
foo(bar,baz)
|
3
src/glsl/glcpp/tests/017-define-func-2-args.c.expected
Normal file
3
src/glsl/glcpp/tests/017-define-func-2-args.c.expected
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
((bar)*(baz))
|
||||
|
@@ -0,0 +1,3 @@
|
||||
#define x 0
|
||||
#define foo(x) x
|
||||
foo(1)
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
1
|
||||
|
2
src/glsl/glcpp/tests/019-define-func-1-arg-multi.c
Normal file
2
src/glsl/glcpp/tests/019-define-func-1-arg-multi.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(x) (x)
|
||||
foo(this is more than one word)
|
@@ -0,0 +1,3 @@
|
||||
|
||||
(this is more than one word)
|
||||
|
2
src/glsl/glcpp/tests/020-define-func-2-arg-multi.c
Normal file
2
src/glsl/glcpp/tests/020-define-func-2-arg-multi.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(x,y) x,two fish,red fish,y
|
||||
foo(one fish, blue fish)
|
@@ -0,0 +1,3 @@
|
||||
|
||||
one fish,two fish,red fish,blue fish
|
||||
|
3
src/glsl/glcpp/tests/021-define-func-compose.c
Normal file
3
src/glsl/glcpp/tests/021-define-func-compose.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define bar(x) (1+(x))
|
||||
#define foo(y) (2*(y))
|
||||
foo(bar(3))
|
4
src/glsl/glcpp/tests/021-define-func-compose.c.expected
Normal file
4
src/glsl/glcpp/tests/021-define-func-compose.c.expected
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
(2*((1+(3))))
|
||||
|
2
src/glsl/glcpp/tests/022-define-func-arg-with-parens.c
Normal file
2
src/glsl/glcpp/tests/022-define-func-arg-with-parens.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(x) (x)
|
||||
foo(argument(including parens)for the win)
|
@@ -0,0 +1,3 @@
|
||||
|
||||
(argument(including parens)for the win)
|
||||
|
8
src/glsl/glcpp/tests/023-define-extra-whitespace.c
Normal file
8
src/glsl/glcpp/tests/023-define-extra-whitespace.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#define noargs() 1
|
||||
# define onearg(foo) foo
|
||||
# define twoargs( x , y ) x y
|
||||
# define threeargs( a , b , c ) a b c
|
||||
noargs ( )
|
||||
onearg ( 2 )
|
||||
twoargs ( 3 , 4 )
|
||||
threeargs ( 5 , 6 , 7 )
|
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
|
||||
|
||||
1
|
||||
2
|
||||
3 4
|
||||
5 6 7
|
||||
|
@@ -0,0 +1,3 @@
|
||||
#define foo foo
|
||||
#define bar foo
|
||||
bar
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
foo
|
||||
|
2
src/glsl/glcpp/tests/025-func-macro-as-non-macro.c
Normal file
2
src/glsl/glcpp/tests/025-func-macro-as-non-macro.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(bar) bar
|
||||
foo bar
|
@@ -0,0 +1,3 @@
|
||||
|
||||
foo bar
|
||||
|
6
src/glsl/glcpp/tests/026-define-func-extra-newlines.c
Normal file
6
src/glsl/glcpp/tests/026-define-func-extra-newlines.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#define foo(a) bar
|
||||
|
||||
foo
|
||||
(
|
||||
1
|
||||
)
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
bar
|
||||
|
3
src/glsl/glcpp/tests/027-define-chain-obj-to-func.c
Normal file
3
src/glsl/glcpp/tests/027-define-chain-obj-to-func.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define failure() success
|
||||
#define foo failure()
|
||||
foo
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
success
|
||||
|
3
src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c
Normal file
3
src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define success() failure
|
||||
#define foo success
|
||||
foo
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
success
|
||||
|
@@ -0,0 +1,3 @@
|
||||
#define bar(failure) failure
|
||||
#define foo bar(success)
|
||||
foo
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
success
|
||||
|
@@ -0,0 +1,4 @@
|
||||
#define baz(failure) failure
|
||||
#define bar(failure) failure
|
||||
#define foo bar(baz(success))
|
||||
foo
|
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
|
||||
success
|
||||
|
@@ -0,0 +1,4 @@
|
||||
#define baz(failure) failure
|
||||
#define bar(failure) failure
|
||||
#define foo() bar(baz(success))
|
||||
foo()
|
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
|
||||
success
|
||||
|
2
src/glsl/glcpp/tests/032-define-func-self-recurse.c
Normal file
2
src/glsl/glcpp/tests/032-define-func-self-recurse.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(a) foo(2*(a))
|
||||
foo(3)
|
@@ -0,0 +1,3 @@
|
||||
|
||||
foo(2*(3))
|
||||
|
2
src/glsl/glcpp/tests/033-define-func-self-compose.c
Normal file
2
src/glsl/glcpp/tests/033-define-func-self-compose.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(a) foo(2*(a))
|
||||
foo(foo(3))
|
@@ -0,0 +1,3 @@
|
||||
|
||||
foo(2*(foo(2*(3))))
|
||||
|
@@ -0,0 +1,2 @@
|
||||
#define foo(bar) bar
|
||||
foo(foo)
|
@@ -0,0 +1,3 @@
|
||||
|
||||
foo
|
||||
|
@@ -0,0 +1,2 @@
|
||||
#define foo(bar) bar
|
||||
foo(1+foo)
|
@@ -0,0 +1,3 @@
|
||||
|
||||
1+foo
|
||||
|
@@ -0,0 +1,3 @@
|
||||
#define bar success
|
||||
#define foo(x) x
|
||||
foo(more bar)
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
more success
|
||||
|
3
src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c
Normal file
3
src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define expand(x) expand(x once)
|
||||
#define foo(x) x
|
||||
foo(expand(just))
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
expand(just once)
|
||||
|
2
src/glsl/glcpp/tests/038-func-arg-with-commas.c
Normal file
2
src/glsl/glcpp/tests/038-func-arg-with-commas.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define foo(x) success
|
||||
foo(argument (with,embedded , commas) -- tricky)
|
3
src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected
Normal file
3
src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
success
|
||||
|
3
src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c
Normal file
3
src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define foo(a) (a)
|
||||
#define bar two,words
|
||||
foo(bar)
|
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
(two,words)
|
||||
|
2
src/glsl/glcpp/tests/040-token-pasting.c
Normal file
2
src/glsl/glcpp/tests/040-token-pasting.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define paste(a,b) a ## b
|
||||
paste(one , token)
|
3
src/glsl/glcpp/tests/040-token-pasting.c.expected
Normal file
3
src/glsl/glcpp/tests/040-token-pasting.c.expected
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
onetoken
|
||||
|
5
src/glsl/glcpp/tests/041-if-0.c
Normal file
5
src/glsl/glcpp/tests/041-if-0.c
Normal file
@@ -0,0 +1,5 @@
|
||||
success_1
|
||||
#if 0
|
||||
failure
|
||||
#endif
|
||||
success_2
|
6
src/glsl/glcpp/tests/041-if-0.c.expected
Normal file
6
src/glsl/glcpp/tests/041-if-0.c.expected
Normal file
@@ -0,0 +1,6 @@
|
||||
success_1
|
||||
|
||||
|
||||
|
||||
success_2
|
||||
|
5
src/glsl/glcpp/tests/042-if-1.c
Normal file
5
src/glsl/glcpp/tests/042-if-1.c
Normal file
@@ -0,0 +1,5 @@
|
||||
success_1
|
||||
#if 1
|
||||
success_2
|
||||
#endif
|
||||
success_3
|
6
src/glsl/glcpp/tests/042-if-1.c.expected
Normal file
6
src/glsl/glcpp/tests/042-if-1.c.expected
Normal file
@@ -0,0 +1,6 @@
|
||||
success_1
|
||||
|
||||
success_2
|
||||
|
||||
success_3
|
||||
|
7
src/glsl/glcpp/tests/043-if-0-else.c
Normal file
7
src/glsl/glcpp/tests/043-if-0-else.c
Normal file
@@ -0,0 +1,7 @@
|
||||
success_1
|
||||
#if 0
|
||||
failure
|
||||
#else
|
||||
success_2
|
||||
#endif
|
||||
success_3
|
8
src/glsl/glcpp/tests/043-if-0-else.c.expected
Normal file
8
src/glsl/glcpp/tests/043-if-0-else.c.expected
Normal file
@@ -0,0 +1,8 @@
|
||||
success_1
|
||||
|
||||
|
||||
|
||||
success_2
|
||||
|
||||
success_3
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user