*/
#include <cstdio>
-#include "symbol_table.h"
+#include "glsl_symbol_table.h"
#include "ast.h"
#include "glsl_types.h"
#include "ir.h"
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);
*/
#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"
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()) {
* 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);
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.
*/
/* 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
/* 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",
* 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();
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);
}
* 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();
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
*/
this->body->hir(instructions, state);
- _mesa_symbol_table_pop_scope(state->symbols);
+ state->symbols->pop_scope();
/* Function definitions do not have r-values.
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
-#include "symbol_table.h"
#include "ir_print_visitor.h"
void
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);
}
}
- _mesa_symbol_table_dtor(state.symbols);
+ delete state.symbols;
return 0;
}
#include <cstdlib>
#include "main/simple_list.h"
+#include "glsl_symbol_table.h"
enum _mesa_glsl_parser_targets {
vertex_shader,
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;
*/
#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));
static void
-generate_120_types(struct _mesa_symbol_table *symtab)
+generate_120_types(glsl_symbol_table *symtab)
{
generate_110_types(symtab);
static void
-generate_130_types(struct _mesa_symbol_table *symtab)
+generate_130_types(glsl_symbol_table *symtab)
{
generate_120_types(symtab);
*/
#include "glsl_parser_extras.h"
-#include "symbol_table.h"
+#include "glsl_symbol_table.h"
#include "ir.h"
#include "builtin_variables.h"
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);
*/
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],
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.
static void
generate_130_vs_variables(exec_list *instructions,
- struct _mesa_symbol_table *symtab)
+ glsl_symbol_table *symtab)
{
generate_120_vs_variables(instructions, symtab);