ReactOS 0.4.17-dev-934-g091855f
preproc.h
Go to the documentation of this file.
1/*
2 * HLSL preprocessor
3 *
4 * Copyright 2020 Zebediah Figura for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#ifndef __VKD3D_SHADER_PREPROC_H
22#define __VKD3D_SHADER_PREPROC_H
23
25#include "wine/rbtree.h"
26
28{
29 /* Are we currently in a "true" block? */
31 /* Have we seen a "true" block in this #if..#endif yet? */
33 /* Have we seen an #else yet? */
35};
36
38{
41};
42
44{
47 char *filename;
48
51};
52
54{
57};
58
60{
62 const struct preproc_text *text;
64 /* Back-pointer to the macro, if this expansion a macro body. This is
65 * necessary so that argument tokens can be correctly replaced. */
67};
68
70{
72 char *name;
73
74 char **arg_names;
75 size_t arg_count;
76
78};
79
81{
83 void *scanner;
84
87
90
93
95
96 /* It's possible to parse as many as two function-like macros at once: one
97 * in the main text, and another inside of #if directives. E.g.
98 *
99 * func1(
100 * #if func2(...)
101 * #endif
102 * )
103 *
104 * It's not possible to parse more than two, however. In the case of nested
105 * calls like "func1(func2(...))", we store everything inside the outer
106 * parentheses as unparsed text, and then parse it once the argument is
107 * actually invoked.
108 */
110 {
112 size_t arg_count;
113 enum
114 {
119 unsigned int paren_depth;
122
124
126
130
131 bool error;
132};
133
134bool preproc_add_macro(struct preproc_ctx *ctx, const struct vkd3d_shader_location *loc, char *name, char **arg_names,
135 size_t arg_count, const struct vkd3d_shader_location *body_loc, struct vkd3d_string_buffer *body);
140void preproc_warning(struct preproc_ctx *ctx, const struct vkd3d_shader_location *loc,
141 enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(4, 5);
142
144{
145 VKD3D_ASSERT(ctx->file_count);
146 return &ctx->file_stack[ctx->file_count - 1];
147}
148
149#endif
GLuint buffer
Definition: glext.h:5915
const char * filename
Definition: ioapi.h:137
#define error(str)
Definition: mkdosfs.c:1605
#define inline
Definition: compat.h:23
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition: md5.c:100
bool preproc_add_macro(struct preproc_ctx *ctx, const struct vkd3d_shader_location *loc, char *name, char **arg_names, size_t arg_count, const struct vkd3d_shader_location *body_loc, struct vkd3d_string_buffer *body)
void preproc_close_include(struct preproc_ctx *ctx, const struct vkd3d_shader_code *code)
void preproc_free_macro(struct preproc_macro *macro)
void static struct preproc_file * preproc_get_top_file(struct preproc_ctx *ctx)
Definition: preproc.h:143
bool preproc_push_include(struct preproc_ctx *ctx, char *filename, const struct vkd3d_shader_code *code)
struct preproc_macro * preproc_find_macro(struct preproc_ctx *ctx, const char *name)
void preproc_warning(struct preproc_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *format,...) VKD3D_PRINTF_FUNC(4
Definition: inflate.c:139
Definition: name.c:39
void * lexer_buffer
Definition: preproc.h:39
struct preproc_text * arg_values
Definition: preproc.h:120
struct preproc_macro * macro
Definition: preproc.h:111
enum preproc_ctx::preproc_func_state::@6007 state
bool last_was_eof
Definition: preproc.h:128
struct preproc_file * file_stack
Definition: preproc.h:88
struct preproc_ctx::preproc_func_state text_func
struct vkd3d_shader_message_context * message_context
Definition: preproc.h:85
size_t expansion_stack_size
Definition: preproc.h:92
struct rb_tree macros
Definition: preproc.h:94
void * scanner
Definition: preproc.h:83
const struct vkd3d_shader_preprocess_info * preprocess_info
Definition: preproc.h:82
bool last_was_newline
Definition: preproc.h:127
size_t file_count
Definition: preproc.h:89
bool error
Definition: preproc.h:131
int lookahead_token
Definition: preproc.h:125
struct preproc_expansion * expansion_stack
Definition: preproc.h:91
size_t file_stack_size
Definition: preproc.h:89
bool last_was_defined
Definition: preproc.h:129
size_t expansion_count
Definition: preproc.h:92
int current_directive
Definition: preproc.h:123
struct preproc_ctx::preproc_func_state directive_func
struct preproc_macro * macro
Definition: preproc.h:66
const struct preproc_text * text
Definition: preproc.h:62
struct preproc_text * arg_values
Definition: preproc.h:63
char * filename
Definition: preproc.h:47
size_t if_stack_size
Definition: preproc.h:50
struct preproc_if_state * if_stack
Definition: preproc.h:49
size_t if_count
Definition: preproc.h:50
bool current_true
Definition: preproc.h:30
bool seen_true
Definition: preproc.h:32
bool seen_else
Definition: preproc.h:34
size_t arg_count
Definition: preproc.h:75
struct preproc_text body
Definition: preproc.h:77
struct rb_entry entry
Definition: preproc.h:71
char * name
Definition: preproc.h:72
char ** arg_names
Definition: preproc.h:74
struct vkd3d_string_buffer text
Definition: preproc.h:55
Definition: rbtree.h:30
Definition: rbtree.h:40
#define VKD3D_PRINTF_FUNC(fmt, args)
Definition: vkd3d_common.h:114
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49
vkd3d_shader_error