Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/compiler/glsl/glsl_symbol_table.h
4545 views
1
/* -*- c++ -*- */
2
/*
3
* Copyright © 2010 Intel Corporation
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining a
6
* copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation
8
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
* and/or sell copies of the Software, and to permit persons to whom the
10
* Software is furnished to do so, subject to the following conditions:
11
*
12
* The above copyright notice and this permission notice (including the next
13
* paragraph) shall be included in all copies or substantial portions of the
14
* Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
* DEALINGS IN THE SOFTWARE.
23
*/
24
25
#ifndef GLSL_SYMBOL_TABLE
26
#define GLSL_SYMBOL_TABLE
27
28
#include <new>
29
30
#include "program/symbol_table.h"
31
#include "ir.h"
32
33
class symbol_table_entry;
34
struct glsl_type;
35
36
/**
37
* Facade class for _mesa_symbol_table
38
*
39
* Wraps the existing \c _mesa_symbol_table data structure to enforce some
40
* type safe and some symbol table invariants.
41
*/
42
struct glsl_symbol_table {
43
DECLARE_RALLOC_CXX_OPERATORS(glsl_symbol_table)
44
45
glsl_symbol_table();
46
~glsl_symbol_table();
47
48
/* In 1.10, functions and variables have separate namespaces. */
49
bool separate_function_namespace;
50
51
void push_scope();
52
void pop_scope();
53
54
/**
55
* Determine whether a name was declared at the current scope
56
*/
57
bool name_declared_this_scope(const char *name);
58
59
/**
60
* \name Methods to add symbols to the table
61
*
62
* There is some temptation to rename all these functions to \c add_symbol
63
* or similar. However, this breaks symmetry with the getter functions and
64
* reduces the clarity of the intention of code that uses these methods.
65
*/
66
/*@{*/
67
bool add_variable(ir_variable *v);
68
bool add_type(const char *name, const glsl_type *t);
69
bool add_function(ir_function *f);
70
bool add_interface(const char *name, const glsl_type *i,
71
enum ir_variable_mode mode);
72
bool add_default_precision_qualifier(const char *type_name, int precision);
73
/*@}*/
74
75
/**
76
* Add an function at global scope without checking for scoping conflicts.
77
*/
78
void add_global_function(ir_function *f);
79
80
/**
81
* \name Methods to get symbols from the table
82
*/
83
/*@{*/
84
ir_variable *get_variable(const char *name);
85
const glsl_type *get_type(const char *name);
86
ir_function *get_function(const char *name);
87
const glsl_type *get_interface(const char *name,
88
enum ir_variable_mode mode);
89
int get_default_precision_qualifier(const char *type_name);
90
/*@}*/
91
92
/**
93
* Disable a previously-added variable so that it no longer appears to be
94
* in the symbol table. This is necessary when gl_PerVertex is redeclared,
95
* to ensure that previously-available built-in variables are no longer
96
* available.
97
*/
98
void disable_variable(const char *name);
99
100
/**
101
* Replaces the variable in the entry by the new variable.
102
*/
103
void replace_variable(const char *name, ir_variable *v);
104
105
private:
106
symbol_table_entry *get_entry(const char *name);
107
108
struct _mesa_symbol_table *table;
109
void *mem_ctx;
110
void *linalloc;
111
};
112
113
#endif /* GLSL_SYMBOL_TABLE */
114
115