HASH_TOKEN DEFINE_TOKEN define
| HASH_TOKEN UNDEF IDENTIFIER NEWLINE {
macro_t *macro;
+ struct hash_entry *entry;
/* Section 3.4 (Preprocessor) of the GLSL ES 3.00 spec says:
*
glcpp_error(& @1, parser, "Built-in (pre-defined)"
" macro names cannot be undefined.");
- macro = hash_table_find (parser->defines, $3);
- if (macro) {
- hash_table_remove (parser->defines, $3);
+ entry = _mesa_hash_table_search (parser->defines, $3);
+ if (entry) {
+ macro = entry->data;
+ _mesa_hash_table_remove (parser->defines, entry);
ralloc_free (macro);
}
ralloc_free ($3);
_glcpp_parser_skip_stack_push_if (parser, & @1, 0);
}
| HASH_TOKEN IFDEF IDENTIFIER junk NEWLINE {
- macro_t *macro = hash_table_find (parser->defines, $3);
+ struct hash_entry *entry =
+ _mesa_hash_table_search(parser->defines, $3);
+ macro_t *macro = entry ? entry->data : NULL;
ralloc_free ($3);
_glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
}
| HASH_TOKEN IFNDEF IDENTIFIER junk NEWLINE {
- macro_t *macro = hash_table_find (parser->defines, $3);
- ralloc_free ($3);
+ struct hash_entry *entry =
+ _mesa_hash_table_search(parser->defines, $3);
+ macro_t *macro = entry ? entry->data : NULL;
_glcpp_parser_skip_stack_push_if (parser, & @3, macro == NULL);
}
| HASH_TOKEN ELIF pp_tokens NEWLINE {
parser = ralloc (NULL, glcpp_parser_t);
glcpp_lex_init_extra (parser, &parser->scanner);
- parser->defines = hash_table_ctor(32, hash_table_string_hash,
- hash_table_string_compare);
+ parser->defines = _mesa_hash_table_create(NULL, _mesa_key_hash_string,
+ _mesa_key_string_equal);
parser->active = NULL;
parser->lexing_directive = 0;
parser->space_tokens = 1;
glcpp_parser_destroy(glcpp_parser_t *parser)
{
glcpp_lex_destroy (parser->scanner);
- hash_table_dtor (parser->defines);
+ _mesa_hash_table_destroy(parser->defines, NULL);
ralloc_free (parser);
}
*last = node;
- return hash_table_find(parser->defines,
- argument->token->value.str) ? 1 : 0;
+ return _mesa_hash_table_search(parser->defines,
+ argument->token->value.str) ? 1 : 0;
FAIL:
glcpp_error (&defined->token->location, parser,
_glcpp_parser_expand_function(glcpp_parser_t *parser, token_node_t *node,
token_node_t **last, expansion_mode_t mode)
{
+ struct hash_entry *entry;
macro_t *macro;
const char *identifier;
argument_list_t *arguments;
identifier = node->token->value.str;
- macro = hash_table_find(parser->defines, identifier);
+ entry = _mesa_hash_table_search(parser->defines, identifier);
+ macro = entry ? entry->data : NULL;
assert(macro->is_function);
{
token_t *token = node->token;
const char *identifier;
+ struct hash_entry *entry;
macro_t *macro;
/* We only expand identifiers */
return _token_list_create_with_one_integer(parser, node->token->location.source);
/* Look up this identifier in the hash table. */
- macro = hash_table_find(parser->defines, identifier);
+ entry = _mesa_hash_table_search(parser->defines, identifier);
+ macro = entry ? entry->data : NULL;
/* Not a macro, so no expansion needed. */
if (macro == NULL)
const char *identifier, token_list_t *replacements)
{
macro_t *macro, *previous;
+ struct hash_entry *entry;
/* We define pre-defined macros before we've started parsing the actual
* file. So if there's no location defined yet, that's what were doing and
macro->replacements = replacements;
ralloc_steal (macro, replacements);
- previous = hash_table_find (parser->defines, identifier);
+ entry = _mesa_hash_table_search(parser->defines, identifier);
+ previous = entry ? entry->data : NULL;
if (previous) {
if (_macro_equal (macro, previous)) {
ralloc_free (macro);
glcpp_error (loc, parser, "Redefinition of macro %s\n", identifier);
}
- hash_table_insert (parser->defines, macro, identifier);
+ _mesa_hash_table_insert (parser->defines, identifier, macro);
}
void
token_list_t *replacements)
{
macro_t *macro, *previous;
+ struct hash_entry *entry;
const char *dup;
_check_for_reserved_macro_name(parser, loc, identifier);
macro->parameters = parameters;
macro->identifier = ralloc_strdup (macro, identifier);
macro->replacements = replacements;
- previous = hash_table_find (parser->defines, identifier);
+
+ entry = _mesa_hash_table_search(parser->defines, identifier);
+ previous = entry ? entry->data : NULL;
if (previous) {
if (_macro_equal (macro, previous)) {
ralloc_free (macro);
glcpp_error (loc, parser, "Redefinition of macro %s\n", identifier);
}
- hash_table_insert(parser->defines, macro, identifier);
+ _mesa_hash_table_insert(parser->defines, identifier, macro);
}
static int
ret == ENDIF || ret == HASH_TOKEN) {
parser->in_control_line = 1;
} else if (ret == IDENTIFIER) {
- macro_t *macro;
- macro = hash_table_find (parser->defines,
- yylval->str);
+ struct hash_entry *entry = _mesa_hash_table_search(parser->defines,
+ yylval->str);
+ macro_t *macro = entry ? entry->data : NULL;
if (macro && macro->is_function) {
parser->newline_as_space = 1;
parser->paren_count = 0;