mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
Use glsl_symbol_table instead of using _mesa_symbol_table directly
This commit is contained in:
parent
82de85e264
commit
8bde4cec6b
6 changed files with 32 additions and 41 deletions
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include "symbol_table.h"
|
||||
#include "glsl_symbol_table.h"
|
||||
#include "ast.h"
|
||||
#include "glsl_types.h"
|
||||
#include "ir.h"
|
||||
|
|
@ -32,8 +32,7 @@ match_function_by_name(exec_list *instructions, const char *name,
|
|||
YYLTYPE *loc, simple_node *parameters,
|
||||
struct _mesa_glsl_parse_state *state)
|
||||
{
|
||||
ir_function *f = (ir_function *)
|
||||
_mesa_symbol_table_find_symbol(state->symbols, 0, name);
|
||||
ir_function *f = state->symbols->get_function(name);
|
||||
|
||||
if (f == NULL) {
|
||||
_mesa_glsl_error(loc, state, "function `%s' undeclared", name);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
#include "main/imports.h"
|
||||
#include "symbol_table.h"
|
||||
#include "glsl_symbol_table.h"
|
||||
#include "glsl_parser_extras.h"
|
||||
#include "ast.h"
|
||||
#include "glsl_types.h"
|
||||
|
|
@ -208,8 +208,7 @@ arithmetic_result_type(const struct glsl_type *type_a,
|
|||
type_name[6] = '\0';
|
||||
}
|
||||
|
||||
t = (glsl_type *)
|
||||
_mesa_symbol_table_find_symbol(state->symbols, 0, type_name);
|
||||
t = state->symbols->get_type(type_name);
|
||||
return (t != NULL) ? t : glsl_error_type;
|
||||
}
|
||||
} else if (type_a->is_matrix()) {
|
||||
|
|
@ -641,9 +640,8 @@ ast_expression::hir(exec_list *instructions,
|
|||
* tree. This particular use must be at location specified in the grammar
|
||||
* as 'variable_identifier'.
|
||||
*/
|
||||
ir_variable *var = (ir_variable *)
|
||||
_mesa_symbol_table_find_symbol(state->symbols, 0,
|
||||
this->primary_expression.identifier);
|
||||
ir_variable *var =
|
||||
state->symbols->get_variable(this->primary_expression.identifier);
|
||||
|
||||
result = new ir_dereference(var);
|
||||
|
||||
|
|
@ -740,13 +738,13 @@ ast_compound_statement::hir(exec_list *instructions,
|
|||
|
||||
|
||||
if (new_scope)
|
||||
_mesa_symbol_table_push_scope(state->symbols);
|
||||
state->symbols->push_scope();
|
||||
|
||||
foreach (ptr, &statements)
|
||||
((ast_node *)ptr)->hir(instructions, state);
|
||||
|
||||
if (new_scope)
|
||||
_mesa_symbol_table_pop_scope(state->symbols);
|
||||
state->symbols->pop_scope();
|
||||
|
||||
/* Compound statements do not have r-values.
|
||||
*/
|
||||
|
|
@ -765,8 +763,7 @@ type_specifier_to_glsl_type(const struct ast_type_specifier *spec,
|
|||
/* FINISHME: Handle annonymous structures. */
|
||||
type = NULL;
|
||||
} else {
|
||||
type = (glsl_type *)
|
||||
_mesa_symbol_table_find_symbol(state->symbols, 0, spec->type_name);
|
||||
type = state->symbols->get_type(spec->type_name);
|
||||
*name = spec->type_name;
|
||||
|
||||
/* FINISHME: Handle array declarations. Note that this requires complete
|
||||
|
|
@ -880,8 +877,7 @@ ast_declarator_list::hir(exec_list *instructions,
|
|||
/* Attempt to add the variable to the symbol table. If this fails, it
|
||||
* means the variable has already been declared at this scope.
|
||||
*/
|
||||
if (_mesa_symbol_table_add_symbol(state->symbols, 0, decl->identifier,
|
||||
var) != 0) {
|
||||
if (!state->symbols->add_variable(decl->identifier, var)) {
|
||||
YYLTYPE loc = this->get_location();
|
||||
|
||||
_mesa_glsl_error(& loc, state, "`%s' redeclared",
|
||||
|
|
@ -1009,9 +1005,7 @@ ast_function_definition::hir(exec_list *instructions,
|
|||
* seen signature for a function with the same name, or, if a match is found,
|
||||
* that the previously seen signature does not have an associated definition.
|
||||
*/
|
||||
f = (ir_function *)
|
||||
_mesa_symbol_table_find_symbol(state->symbols, 0,
|
||||
this->prototype->identifier);
|
||||
f = state->symbols->get_function(this->prototype->identifier);
|
||||
if (f != NULL) {
|
||||
foreach_iter(exec_list_iterator, iter, f->signatures) {
|
||||
signature = (struct ir_function_signature *) iter.get();
|
||||
|
|
@ -1041,7 +1035,7 @@ ast_function_definition::hir(exec_list *instructions,
|
|||
f = new ir_function();
|
||||
f->name = this->prototype->identifier;
|
||||
|
||||
_mesa_symbol_table_add_symbol(state->symbols, 0, f->name, f);
|
||||
state->symbols->add_function(f->name, f);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1080,7 +1074,7 @@ ast_function_definition::hir(exec_list *instructions,
|
|||
* to the instruction list. There are other more efficient ways to do this,
|
||||
* but they involve ugly linked-list gymnastics.
|
||||
*/
|
||||
_mesa_symbol_table_push_scope(state->symbols);
|
||||
state->symbols->push_scope();
|
||||
foreach_iter(exec_list_iterator, iter, parameters) {
|
||||
ir_variable *const var = (ir_variable *) iter.get();
|
||||
|
||||
|
|
@ -1089,7 +1083,7 @@ ast_function_definition::hir(exec_list *instructions,
|
|||
iter.remove();
|
||||
instructions->push_tail(var);
|
||||
|
||||
_mesa_symbol_table_add_symbol(state->symbols, 0, var->name, var);
|
||||
state->symbols->add_variable(var->name, var);
|
||||
}
|
||||
|
||||
/* Convert the body of the function to HIR, and append the resulting
|
||||
|
|
@ -1098,7 +1092,7 @@ ast_function_definition::hir(exec_list *instructions,
|
|||
*/
|
||||
this->body->hir(instructions, state);
|
||||
|
||||
_mesa_symbol_table_pop_scope(state->symbols);
|
||||
state->symbols->pop_scope();
|
||||
|
||||
|
||||
/* Function definitions do not have r-values.
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#include "ast.h"
|
||||
#include "glsl_parser_extras.h"
|
||||
#include "glsl_parser.h"
|
||||
#include "symbol_table.h"
|
||||
#include "ir_print_visitor.h"
|
||||
|
||||
void
|
||||
|
|
@ -634,7 +633,7 @@ main(int argc, char **argv)
|
|||
|
||||
state.scanner = NULL;
|
||||
make_empty_list(& state.translation_unit);
|
||||
state.symbols = _mesa_symbol_table_ctor();
|
||||
state.symbols = new glsl_symbol_table;
|
||||
state.error = false;
|
||||
|
||||
_mesa_glsl_lexer_ctor(& state, shader, shader_len);
|
||||
|
|
@ -657,7 +656,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
_mesa_symbol_table_dtor(state.symbols);
|
||||
delete state.symbols;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <cstdlib>
|
||||
#include "main/simple_list.h"
|
||||
#include "glsl_symbol_table.h"
|
||||
|
||||
enum _mesa_glsl_parser_targets {
|
||||
vertex_shader,
|
||||
|
|
@ -37,7 +38,7 @@ enum _mesa_glsl_parser_targets {
|
|||
struct _mesa_glsl_parse_state {
|
||||
void *scanner;
|
||||
struct simple_node translation_unit;
|
||||
struct _mesa_symbol_table *symbols;
|
||||
glsl_symbol_table *symbols;
|
||||
|
||||
unsigned language_version;
|
||||
enum _mesa_glsl_parser_targets target;
|
||||
|
|
|
|||
|
|
@ -22,28 +22,27 @@
|
|||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "symbol_table.h"
|
||||
#include "glsl_symbol_table.h"
|
||||
#include "glsl_parser_extras.h"
|
||||
#include "glsl_types.h"
|
||||
#include "builtin_types.h"
|
||||
|
||||
|
||||
static void
|
||||
add_types_to_symbol_table(struct _mesa_symbol_table *symtab,
|
||||
add_types_to_symbol_table(glsl_symbol_table *symtab,
|
||||
const struct glsl_type *types,
|
||||
unsigned num_types)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < num_types; i++) {
|
||||
_mesa_symbol_table_add_symbol(symtab, 0, types[i].name,
|
||||
(void *) & types[i]);
|
||||
symtab->add_type(types[i].name, & types[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
generate_110_types(struct _mesa_symbol_table *symtab)
|
||||
generate_110_types(glsl_symbol_table *symtab)
|
||||
{
|
||||
add_types_to_symbol_table(symtab, builtin_core_types,
|
||||
Elements(builtin_core_types));
|
||||
|
|
@ -55,7 +54,7 @@ generate_110_types(struct _mesa_symbol_table *symtab)
|
|||
|
||||
|
||||
static void
|
||||
generate_120_types(struct _mesa_symbol_table *symtab)
|
||||
generate_120_types(glsl_symbol_table *symtab)
|
||||
{
|
||||
generate_110_types(symtab);
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ generate_120_types(struct _mesa_symbol_table *symtab)
|
|||
|
||||
|
||||
static void
|
||||
generate_130_types(struct _mesa_symbol_table *symtab)
|
||||
generate_130_types(glsl_symbol_table *symtab)
|
||||
{
|
||||
generate_120_types(symtab);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "glsl_parser_extras.h"
|
||||
#include "symbol_table.h"
|
||||
#include "glsl_symbol_table.h"
|
||||
#include "ir.h"
|
||||
#include "builtin_variables.h"
|
||||
|
||||
|
|
@ -32,13 +32,12 @@
|
|||
|
||||
static void
|
||||
add_builtin_variable(const builtin_variable *proto, exec_list *instructions,
|
||||
struct _mesa_symbol_table *symtab)
|
||||
glsl_symbol_table *symtab)
|
||||
{
|
||||
/* Create a new variable declaration from the description supplied by
|
||||
* the caller.
|
||||
*/
|
||||
const glsl_type *const type = (glsl_type *)
|
||||
_mesa_symbol_table_find_symbol(symtab, 0, proto->type);
|
||||
const glsl_type *const type = symtab->get_type(proto->type);
|
||||
|
||||
assert(type != NULL);
|
||||
|
||||
|
|
@ -54,13 +53,13 @@ add_builtin_variable(const builtin_variable *proto, exec_list *instructions,
|
|||
*/
|
||||
instructions->push_tail(var);
|
||||
|
||||
_mesa_symbol_table_add_symbol(symtab, 0, var->name, var);
|
||||
symtab->add_variable(var->name, var);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
generate_110_vs_variables(exec_list *instructions,
|
||||
struct _mesa_symbol_table *symtab)
|
||||
glsl_symbol_table *symtab)
|
||||
{
|
||||
for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) {
|
||||
add_builtin_variable(& builtin_core_vs_variables[i],
|
||||
|
|
@ -83,7 +82,7 @@ generate_110_vs_variables(exec_list *instructions,
|
|||
|
||||
static void
|
||||
generate_120_vs_variables(exec_list *instructions,
|
||||
struct _mesa_symbol_table *symtab)
|
||||
glsl_symbol_table *symtab)
|
||||
{
|
||||
/* GLSL version 1.20 did not add any built-in variables in the vertex
|
||||
* shader.
|
||||
|
|
@ -94,7 +93,7 @@ generate_120_vs_variables(exec_list *instructions,
|
|||
|
||||
static void
|
||||
generate_130_vs_variables(exec_list *instructions,
|
||||
struct _mesa_symbol_table *symtab)
|
||||
glsl_symbol_table *symtab)
|
||||
{
|
||||
generate_120_vs_variables(instructions, symtab);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue