*/
class ast_node {
public:
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
- node = talloc_zero_size(ctx, size);
+ node = rzalloc_size(ctx, size);
assert(node != NULL);
return node;
}
/* If the user *does* call delete, that's OK, we will just
- * talloc_free in that case. */
+ * ralloc_free in that case. */
static void operator delete(void *table)
{
- talloc_free(table);
+ ralloc_free(table);
}
/**
* formal or actual parameter list. Only the type is used.
*
* \return
- * A talloced string representing the prototype of the function.
+ * A ralloced string representing the prototype of the function.
*/
char *
prototype_string(const glsl_type *return_type, const char *name,
char *str = NULL;
if (return_type != NULL)
- str = talloc_asprintf(str, "%s ", return_type->name);
+ ralloc_asprintf(&str, "%s ", return_type->name);
- str = talloc_asprintf_append(str, "%s(", name);
+ ralloc_asprintf_append(&str, "%s(", name);
const char *comma = "";
foreach_list(node, parameters) {
const ir_instruction *const param = (ir_instruction *) node;
- str = talloc_asprintf_append(str, "%s%s", comma, param->type->name);
+ ralloc_asprintf_append(&str, "%s%s", comma, param->type->name);
comma = ", ";
}
- str = talloc_strdup_append(str, ")");
+ ralloc_strcat(&str, ")");
return str;
}
ir_dereference_variable *deref;
var = new(ctx) ir_variable(sig->return_type,
- talloc_asprintf(ctx, "%s_retval",
+ ralloc_asprintf(ctx, "%s_retval",
sig->function_name()),
ir_var_temporary);
instructions->push_tail(var);
_mesa_glsl_error(loc, state, "no matching function for call to `%s'",
str);
- talloc_free(str);
+ ralloc_free(str);
const char *prefix = "candidates are: ";
str = prototype_string(sig->return_type, f->name, &sig->parameters);
_mesa_glsl_error(loc, state, "%s%s\n", prefix, str);
- talloc_free(str);
+ ralloc_free(str);
prefix = " ";
}
static ir_rvalue *
convert_component(ir_rvalue *src, const glsl_type *desired_type)
{
- void *ctx = talloc_parent(src);
+ void *ctx = ralloc_parent(src);
const unsigned a = desired_type->base_type;
const unsigned b = src->type->base_type;
ir_expression *result = NULL;
static ir_rvalue *
dereference_component(ir_rvalue *src, unsigned component)
{
- void *ctx = talloc_parent(src);
+ void *ctx = ralloc_parent(src);
assert(component < src->type->components());
/* If the source is a constant, just create a new constant instead of a
static ir_rvalue *
get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue)
{
- void *ctx = talloc_parent(lvalue);
+ void *ctx = ralloc_parent(lvalue);
ir_variable *var;
var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp",
* the types to HIR. This ensures that structure definitions embedded in
* other structure definitions are processed.
*/
- glsl_struct_field *const fields = talloc_array(state, glsl_struct_field,
+ glsl_struct_field *const fields = ralloc_array(state, glsl_struct_field,
decl_count);
unsigned i = 0;
if (st->error) {
printf("error reading builtin: %.35s ...\\n", functions[i]);
printf("Info log:\\n%s\\n", st->info_log);
- talloc_free(sh);
+ ralloc_free(sh);
return NULL;
}
}
void
_mesa_glsl_release_functions(void)
{
- talloc_free(builtin_mem_ctx);
+ ralloc_free(builtin_mem_ctx);
builtin_mem_ctx = NULL;
memset(builtin_profiles, 0, sizeof(builtin_profiles));
}
if (sh == NULL) {
sh = read_builtins(GL_VERTEX_SHADER, prototypes, functions, count);
- talloc_steal(builtin_mem_ctx, sh);
+ ralloc_steal(builtin_mem_ctx, sh);
builtin_profiles[profile_index] = sh;
}
_mesa_glsl_initialize_functions(struct _mesa_glsl_parse_state *state)
{
if (builtin_mem_ctx == NULL) {
- builtin_mem_ctx = talloc_init("GLSL built-in functions");
+ builtin_mem_ctx = ralloc_context(NULL); // "GLSL built-in functions"
memset(&builtin_profiles, 0, sizeof(builtin_profiles));
}
void glcpp_set_lineno (int line_number ,yyscan_t yyscanner );
+int glcpp_get_column (yyscan_t yyscanner );
+
+void glcpp_set_column (int column_no ,yyscan_t yyscanner );
+
YYSTYPE * glcpp_get_lval (yyscan_t yyscanner );
void glcpp_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
/* Single-line comments */
-#line 958 "glcpp/glcpp-lex.c"
+#line 962 "glcpp/glcpp-lex.c"
yylval = yylval_param;
YY_RULE_SETUP
#line 94 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
yyextra->space_tokens = 0;
return HASH_VERSION;
}
YY_RULE_SETUP
#line 102 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
return OTHER;
YY_RULE_SETUP
#line 221 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
YY_BREAK
YY_RULE_SETUP
#line 226 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
YY_BREAK
YY_RULE_SETUP
#line 231 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
YY_BREAK
YY_RULE_SETUP
#line 276 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return IDENTIFIER;
}
YY_BREAK
YY_RULE_SETUP
#line 285 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return OTHER;
}
YY_BREAK
#line 319 "glcpp/glcpp-lex.l"
ECHO;
YY_BREAK
-#line 1475 "glcpp/glcpp-lex.c"
+#line 1479 "glcpp/glcpp-lex.c"
case YY_STATE_EOF(DONE):
case YY_STATE_EOF(COMMENT):
case YY_STATE_EOF(UNREACHABLE):
}
{HASH}version {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
yyextra->space_tokens = 0;
return HASH_VERSION;
}
/* glcpp doesn't handle #extension, #version, or #pragma directives.
* Simply pass them through to the main compiler's lexer/parser. */
{HASH}(extension|pragma)[^\n]+ {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
return OTHER;
}
{DECIMAL_INTEGER} {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
{OCTAL_INTEGER} {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
{HEXADECIMAL_INTEGER} {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
}
{IDENTIFIER} {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return IDENTIFIER;
}
}
{OTHER}+ {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return OTHER;
}
#include "main/core.h" /* for struct gl_extensions */
#include "main/mtypes.h" /* for gl_api enum */
-#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
-#define glcpp_printf(stream, fmt, args, ...) \
- stream = talloc_asprintf_append(stream, fmt, args)
-
static void
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
static token_list_t *
_argument_list_member_at (argument_list_t *list, int index);
-/* Note: This function talloc_steal()s the str pointer. */
+/* Note: This function ralloc_steal()s the str pointer. */
static token_t *
_token_create_str (void *ctx, int type, char *str);
static token_list_t *
_token_list_create (void *ctx);
-/* Note: This function calls talloc_steal on token. */
+/* Note: This function calls ralloc_steal on token. */
static void
_token_list_append (token_list_t *list, token_t *token);
/* Line 189 of yacc.c */
-#line 220 "glcpp/glcpp-parse.c"
+#line 216 "glcpp/glcpp-parse.c"
/* Enabling traces. */
#ifndef YYDEBUG
/* Line 264 of yacc.c */
-#line 308 "glcpp/glcpp-parse.c"
+#line 304 "glcpp/glcpp-parse.c"
#ifdef short
# undef short
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 185, 185, 187, 191, 194, 199, 200, 204, 207,
- 213, 216, 219, 222, 230, 249, 259, 264, 269, 288,
- 303, 306, 309, 330, 334, 343, 348, 349, 352, 355,
- 358, 361, 364, 367, 370, 373, 376, 379, 382, 385,
- 388, 391, 394, 397, 405, 408, 411, 414, 417, 420,
- 426, 431, 439, 440, 444, 450, 451, 454, 456, 463,
- 467, 471, 476, 480, 487, 492, 499, 503, 507, 511,
- 515, 522, 523, 524, 525, 526, 527, 528, 529, 530,
- 531, 532, 533, 534, 535, 536, 537, 538, 539, 540,
- 541, 542, 543, 544, 545, 546, 547, 548, 549, 550,
- 551, 552
+ 0, 181, 181, 183, 187, 190, 195, 196, 200, 203,
+ 209, 212, 215, 218, 226, 245, 255, 260, 265, 284,
+ 299, 302, 305, 326, 330, 339, 344, 345, 348, 351,
+ 354, 357, 360, 363, 366, 369, 372, 375, 378, 381,
+ 384, 387, 390, 393, 401, 404, 407, 410, 413, 416,
+ 422, 427, 435, 436, 440, 446, 447, 450, 452, 459,
+ 463, 467, 472, 476, 483, 488, 495, 499, 503, 507,
+ 511, 518, 519, 520, 521, 522, 523, 524, 525, 526,
+ 527, 528, 529, 530, 531, 532, 533, 534, 535, 536,
+ 537, 538, 539, 540, 541, 542, 543, 544, 545, 546,
+ 547, 548
};
#endif
/* User initialization code. */
/* Line 1251 of yacc.c */
-#line 152 "glcpp/glcpp-parse.y"
+#line 148 "glcpp/glcpp-parse.y"
{
yylloc.first_line = 1;
yylloc.first_column = 1;
}
/* Line 1251 of yacc.c */
-#line 1622 "glcpp/glcpp-parse.c"
+#line 1618 "glcpp/glcpp-parse.c"
yylsp[0] = yylloc;
goto yysetstate;
case 4:
/* Line 1464 of yacc.c */
-#line 191 "glcpp/glcpp-parse.y"
+#line 187 "glcpp/glcpp-parse.y"
{
- glcpp_print(parser->output, "\n");
+ ralloc_strcat (&parser->output, "\n");
;}
break;
case 5:
/* Line 1464 of yacc.c */
-#line 194 "glcpp/glcpp-parse.y"
+#line 190 "glcpp/glcpp-parse.y"
{
_glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
- glcpp_print(parser->output, "\n");
- talloc_free ((yyvsp[(1) - (1)].token_list));
+ ralloc_strcat (&parser->output, "\n");
+ ralloc_free ((yyvsp[(1) - (1)].token_list));
;}
break;
case 8:
/* Line 1464 of yacc.c */
-#line 204 "glcpp/glcpp-parse.y"
+#line 200 "glcpp/glcpp-parse.y"
{
_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
;}
case 9:
/* Line 1464 of yacc.c */
-#line 207 "glcpp/glcpp-parse.y"
+#line 203 "glcpp/glcpp-parse.y"
{
_glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
;}
case 10:
/* Line 1464 of yacc.c */
-#line 213 "glcpp/glcpp-parse.y"
+#line 209 "glcpp/glcpp-parse.y"
{
_define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
;}
case 11:
/* Line 1464 of yacc.c */
-#line 216 "glcpp/glcpp-parse.y"
+#line 212 "glcpp/glcpp-parse.y"
{
_define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
;}
case 12:
/* Line 1464 of yacc.c */
-#line 219 "glcpp/glcpp-parse.y"
+#line 215 "glcpp/glcpp-parse.y"
{
_define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
;}
case 13:
/* Line 1464 of yacc.c */
-#line 222 "glcpp/glcpp-parse.y"
+#line 218 "glcpp/glcpp-parse.y"
{
macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
if (macro) {
hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
- talloc_free (macro);
+ ralloc_free (macro);
}
- talloc_free ((yyvsp[(2) - (3)].str));
+ ralloc_free ((yyvsp[(2) - (3)].str));
;}
break;
case 14:
/* Line 1464 of yacc.c */
-#line 230 "glcpp/glcpp-parse.y"
+#line 226 "glcpp/glcpp-parse.y"
{
/* Be careful to only evaluate the 'if' expression if
* we are not skipping. When we are skipping, we
case 15:
/* Line 1464 of yacc.c */
-#line 249 "glcpp/glcpp-parse.y"
+#line 245 "glcpp/glcpp-parse.y"
{
/* #if without an expression is only an error if we
* are not skipping */
case 16:
/* Line 1464 of yacc.c */
-#line 259 "glcpp/glcpp-parse.y"
+#line 255 "glcpp/glcpp-parse.y"
{
macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
- talloc_free ((yyvsp[(2) - (4)].str));
+ ralloc_free ((yyvsp[(2) - (4)].str));
_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
;}
break;
case 17:
/* Line 1464 of yacc.c */
-#line 264 "glcpp/glcpp-parse.y"
+#line 260 "glcpp/glcpp-parse.y"
{
macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
- talloc_free ((yyvsp[(2) - (4)].str));
+ ralloc_free ((yyvsp[(2) - (4)].str));
_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
;}
break;
case 18:
/* Line 1464 of yacc.c */
-#line 269 "glcpp/glcpp-parse.y"
+#line 265 "glcpp/glcpp-parse.y"
{
/* Be careful to only evaluate the 'elif' expression
* if we are not skipping. When we are skipping, we
case 19:
/* Line 1464 of yacc.c */
-#line 288 "glcpp/glcpp-parse.y"
+#line 284 "glcpp/glcpp-parse.y"
{
/* #elif without an expression is an error unless we
* are skipping. */
case 20:
/* Line 1464 of yacc.c */
-#line 303 "glcpp/glcpp-parse.y"
+#line 299 "glcpp/glcpp-parse.y"
{
_glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1);
;}
case 21:
/* Line 1464 of yacc.c */
-#line 306 "glcpp/glcpp-parse.y"
+#line 302 "glcpp/glcpp-parse.y"
{
_glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)]));
;}
case 22:
/* Line 1464 of yacc.c */
-#line 309 "glcpp/glcpp-parse.y"
+#line 305 "glcpp/glcpp-parse.y"
{
macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
if (macro) {
hash_table_remove (parser->defines, "__VERSION__");
- talloc_free (macro);
+ ralloc_free (macro);
}
add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
if ((yyvsp[(2) - (3)].ival) >= 130 || (yyvsp[(2) - (3)].ival) == 100)
add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
- glcpp_printf(parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival));
+ ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival));
;}
break;
case 24:
/* Line 1464 of yacc.c */
-#line 334 "glcpp/glcpp-parse.y"
+#line 330 "glcpp/glcpp-parse.y"
{
if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) {
(yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16);
case 25:
/* Line 1464 of yacc.c */
-#line 343 "glcpp/glcpp-parse.y"
+#line 339 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (1)].ival);
;}
case 27:
/* Line 1464 of yacc.c */
-#line 349 "glcpp/glcpp-parse.y"
+#line 345 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival);
;}
case 28:
/* Line 1464 of yacc.c */
-#line 352 "glcpp/glcpp-parse.y"
+#line 348 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival);
;}
case 29:
/* Line 1464 of yacc.c */
-#line 355 "glcpp/glcpp-parse.y"
+#line 351 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival);
;}
case 30:
/* Line 1464 of yacc.c */
-#line 358 "glcpp/glcpp-parse.y"
+#line 354 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival);
;}
case 31:
/* Line 1464 of yacc.c */
-#line 361 "glcpp/glcpp-parse.y"
+#line 357 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival);
;}
case 32:
/* Line 1464 of yacc.c */
-#line 364 "glcpp/glcpp-parse.y"
+#line 360 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival);
;}
case 33:
/* Line 1464 of yacc.c */
-#line 367 "glcpp/glcpp-parse.y"
+#line 363 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival);
;}
case 34:
/* Line 1464 of yacc.c */
-#line 370 "glcpp/glcpp-parse.y"
+#line 366 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival);
;}
case 35:
/* Line 1464 of yacc.c */
-#line 373 "glcpp/glcpp-parse.y"
+#line 369 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival);
;}
case 36:
/* Line 1464 of yacc.c */
-#line 376 "glcpp/glcpp-parse.y"
+#line 372 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival);
;}
case 37:
/* Line 1464 of yacc.c */
-#line 379 "glcpp/glcpp-parse.y"
+#line 375 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival);
;}
case 38:
/* Line 1464 of yacc.c */
-#line 382 "glcpp/glcpp-parse.y"
+#line 378 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival);
;}
case 39:
/* Line 1464 of yacc.c */
-#line 385 "glcpp/glcpp-parse.y"
+#line 381 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival);
;}
case 40:
/* Line 1464 of yacc.c */
-#line 388 "glcpp/glcpp-parse.y"
+#line 384 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival);
;}
case 41:
/* Line 1464 of yacc.c */
-#line 391 "glcpp/glcpp-parse.y"
+#line 387 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival);
;}
case 42:
/* Line 1464 of yacc.c */
-#line 394 "glcpp/glcpp-parse.y"
+#line 390 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
;}
case 43:
/* Line 1464 of yacc.c */
-#line 397 "glcpp/glcpp-parse.y"
+#line 393 "glcpp/glcpp-parse.y"
{
if ((yyvsp[(3) - (3)].ival) == 0) {
yyerror (& (yylsp[(1) - (3)]), parser,
case 44:
/* Line 1464 of yacc.c */
-#line 405 "glcpp/glcpp-parse.y"
+#line 401 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival);
;}
case 45:
/* Line 1464 of yacc.c */
-#line 408 "glcpp/glcpp-parse.y"
+#line 404 "glcpp/glcpp-parse.y"
{
(yyval.ival) = ! (yyvsp[(2) - (2)].ival);
;}
case 46:
/* Line 1464 of yacc.c */
-#line 411 "glcpp/glcpp-parse.y"
+#line 407 "glcpp/glcpp-parse.y"
{
(yyval.ival) = ~ (yyvsp[(2) - (2)].ival);
;}
case 47:
/* Line 1464 of yacc.c */
-#line 414 "glcpp/glcpp-parse.y"
+#line 410 "glcpp/glcpp-parse.y"
{
(yyval.ival) = - (yyvsp[(2) - (2)].ival);
;}
case 48:
/* Line 1464 of yacc.c */
-#line 417 "glcpp/glcpp-parse.y"
+#line 413 "glcpp/glcpp-parse.y"
{
(yyval.ival) = + (yyvsp[(2) - (2)].ival);
;}
case 49:
/* Line 1464 of yacc.c */
-#line 420 "glcpp/glcpp-parse.y"
+#line 416 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(2) - (3)].ival);
;}
case 50:
/* Line 1464 of yacc.c */
-#line 426 "glcpp/glcpp-parse.y"
+#line 422 "glcpp/glcpp-parse.y"
{
(yyval.string_list) = _string_list_create (parser);
_string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str));
- talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
+ ralloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
;}
break;
case 51:
/* Line 1464 of yacc.c */
-#line 431 "glcpp/glcpp-parse.y"
+#line 427 "glcpp/glcpp-parse.y"
{
(yyval.string_list) = (yyvsp[(1) - (3)].string_list);
_string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str));
- talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
+ ralloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
;}
break;
case 52:
/* Line 1464 of yacc.c */
-#line 439 "glcpp/glcpp-parse.y"
+#line 435 "glcpp/glcpp-parse.y"
{ (yyval.token_list) = NULL; ;}
break;
case 54:
/* Line 1464 of yacc.c */
-#line 444 "glcpp/glcpp-parse.y"
+#line 440 "glcpp/glcpp-parse.y"
{
yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
;}
case 55:
/* Line 1464 of yacc.c */
-#line 450 "glcpp/glcpp-parse.y"
+#line 446 "glcpp/glcpp-parse.y"
{ (yyval.token_list) = NULL; ;}
break;
case 58:
/* Line 1464 of yacc.c */
-#line 456 "glcpp/glcpp-parse.y"
+#line 452 "glcpp/glcpp-parse.y"
{
glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
;}
case 59:
/* Line 1464 of yacc.c */
-#line 463 "glcpp/glcpp-parse.y"
+#line 459 "glcpp/glcpp-parse.y"
{
int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
(yyval.token) = _token_create_ival (parser, INTEGER, v);
case 60:
/* Line 1464 of yacc.c */
-#line 467 "glcpp/glcpp-parse.y"
+#line 463 "glcpp/glcpp-parse.y"
{
int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
(yyval.token) = _token_create_ival (parser, INTEGER, v);
case 62:
/* Line 1464 of yacc.c */
-#line 476 "glcpp/glcpp-parse.y"
+#line 472 "glcpp/glcpp-parse.y"
{
(yyval.token_list) = _token_list_create (parser);
_token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
case 63:
/* Line 1464 of yacc.c */
-#line 480 "glcpp/glcpp-parse.y"
+#line 476 "glcpp/glcpp-parse.y"
{
(yyval.token_list) = (yyvsp[(1) - (2)].token_list);
_token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
case 64:
/* Line 1464 of yacc.c */
-#line 487 "glcpp/glcpp-parse.y"
+#line 483 "glcpp/glcpp-parse.y"
{
parser->space_tokens = 1;
(yyval.token_list) = _token_list_create (parser);
case 65:
/* Line 1464 of yacc.c */
-#line 492 "glcpp/glcpp-parse.y"
+#line 488 "glcpp/glcpp-parse.y"
{
(yyval.token_list) = (yyvsp[(1) - (2)].token_list);
_token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
case 66:
/* Line 1464 of yacc.c */
-#line 499 "glcpp/glcpp-parse.y"
+#line 495 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
(yyval.token)->location = yylloc;
case 67:
/* Line 1464 of yacc.c */
-#line 503 "glcpp/glcpp-parse.y"
+#line 499 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
(yyval.token)->location = yylloc;
case 68:
/* Line 1464 of yacc.c */
-#line 507 "glcpp/glcpp-parse.y"
+#line 503 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
(yyval.token)->location = yylloc;
case 69:
/* Line 1464 of yacc.c */
-#line 511 "glcpp/glcpp-parse.y"
+#line 507 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
(yyval.token)->location = yylloc;
case 70:
/* Line 1464 of yacc.c */
-#line 515 "glcpp/glcpp-parse.y"
+#line 511 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_ival (parser, SPACE, SPACE);
(yyval.token)->location = yylloc;
case 71:
/* Line 1464 of yacc.c */
-#line 522 "glcpp/glcpp-parse.y"
+#line 518 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '['; ;}
break;
case 72:
/* Line 1464 of yacc.c */
-#line 523 "glcpp/glcpp-parse.y"
+#line 519 "glcpp/glcpp-parse.y"
{ (yyval.ival) = ']'; ;}
break;
case 73:
/* Line 1464 of yacc.c */
-#line 524 "glcpp/glcpp-parse.y"
+#line 520 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '('; ;}
break;
case 74:
/* Line 1464 of yacc.c */
-#line 525 "glcpp/glcpp-parse.y"
+#line 521 "glcpp/glcpp-parse.y"
{ (yyval.ival) = ')'; ;}
break;
case 75:
/* Line 1464 of yacc.c */
-#line 526 "glcpp/glcpp-parse.y"
+#line 522 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '{'; ;}
break;
case 76:
/* Line 1464 of yacc.c */
-#line 527 "glcpp/glcpp-parse.y"
+#line 523 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '}'; ;}
break;
case 77:
/* Line 1464 of yacc.c */
-#line 528 "glcpp/glcpp-parse.y"
+#line 524 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '.'; ;}
break;
case 78:
/* Line 1464 of yacc.c */
-#line 529 "glcpp/glcpp-parse.y"
+#line 525 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '&'; ;}
break;
case 79:
/* Line 1464 of yacc.c */
-#line 530 "glcpp/glcpp-parse.y"
+#line 526 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '*'; ;}
break;
case 80:
/* Line 1464 of yacc.c */
-#line 531 "glcpp/glcpp-parse.y"
+#line 527 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '+'; ;}
break;
case 81:
/* Line 1464 of yacc.c */
-#line 532 "glcpp/glcpp-parse.y"
+#line 528 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '-'; ;}
break;
case 82:
/* Line 1464 of yacc.c */
-#line 533 "glcpp/glcpp-parse.y"
+#line 529 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '~'; ;}
break;
case 83:
/* Line 1464 of yacc.c */
-#line 534 "glcpp/glcpp-parse.y"
+#line 530 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '!'; ;}
break;
case 84:
/* Line 1464 of yacc.c */
-#line 535 "glcpp/glcpp-parse.y"
+#line 531 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '/'; ;}
break;
case 85:
/* Line 1464 of yacc.c */
-#line 536 "glcpp/glcpp-parse.y"
+#line 532 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '%'; ;}
break;
case 86:
/* Line 1464 of yacc.c */
-#line 537 "glcpp/glcpp-parse.y"
+#line 533 "glcpp/glcpp-parse.y"
{ (yyval.ival) = LEFT_SHIFT; ;}
break;
case 87:
/* Line 1464 of yacc.c */
-#line 538 "glcpp/glcpp-parse.y"
+#line 534 "glcpp/glcpp-parse.y"
{ (yyval.ival) = RIGHT_SHIFT; ;}
break;
case 88:
/* Line 1464 of yacc.c */
-#line 539 "glcpp/glcpp-parse.y"
+#line 535 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '<'; ;}
break;
case 89:
/* Line 1464 of yacc.c */
-#line 540 "glcpp/glcpp-parse.y"
+#line 536 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '>'; ;}
break;
case 90:
/* Line 1464 of yacc.c */
-#line 541 "glcpp/glcpp-parse.y"
+#line 537 "glcpp/glcpp-parse.y"
{ (yyval.ival) = LESS_OR_EQUAL; ;}
break;
case 91:
/* Line 1464 of yacc.c */
-#line 542 "glcpp/glcpp-parse.y"
+#line 538 "glcpp/glcpp-parse.y"
{ (yyval.ival) = GREATER_OR_EQUAL; ;}
break;
case 92:
/* Line 1464 of yacc.c */
-#line 543 "glcpp/glcpp-parse.y"
+#line 539 "glcpp/glcpp-parse.y"
{ (yyval.ival) = EQUAL; ;}
break;
case 93:
/* Line 1464 of yacc.c */
-#line 544 "glcpp/glcpp-parse.y"
+#line 540 "glcpp/glcpp-parse.y"
{ (yyval.ival) = NOT_EQUAL; ;}
break;
case 94:
/* Line 1464 of yacc.c */
-#line 545 "glcpp/glcpp-parse.y"
+#line 541 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '^'; ;}
break;
case 95:
/* Line 1464 of yacc.c */
-#line 546 "glcpp/glcpp-parse.y"
+#line 542 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '|'; ;}
break;
case 96:
/* Line 1464 of yacc.c */
-#line 547 "glcpp/glcpp-parse.y"
+#line 543 "glcpp/glcpp-parse.y"
{ (yyval.ival) = AND; ;}
break;
case 97:
/* Line 1464 of yacc.c */
-#line 548 "glcpp/glcpp-parse.y"
+#line 544 "glcpp/glcpp-parse.y"
{ (yyval.ival) = OR; ;}
break;
case 98:
/* Line 1464 of yacc.c */
-#line 549 "glcpp/glcpp-parse.y"
+#line 545 "glcpp/glcpp-parse.y"
{ (yyval.ival) = ';'; ;}
break;
case 99:
/* Line 1464 of yacc.c */
-#line 550 "glcpp/glcpp-parse.y"
+#line 546 "glcpp/glcpp-parse.y"
{ (yyval.ival) = ','; ;}
break;
case 100:
/* Line 1464 of yacc.c */
-#line 551 "glcpp/glcpp-parse.y"
+#line 547 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '='; ;}
break;
case 101:
/* Line 1464 of yacc.c */
-#line 552 "glcpp/glcpp-parse.y"
+#line 548 "glcpp/glcpp-parse.y"
{ (yyval.ival) = PASTE; ;}
break;
/* Line 1464 of yacc.c */
-#line 2661 "glcpp/glcpp-parse.c"
+#line 2657 "glcpp/glcpp-parse.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
/* Line 1684 of yacc.c */
-#line 555 "glcpp/glcpp-parse.y"
+#line 551 "glcpp/glcpp-parse.y"
string_list_t *
{
string_list_t *list;
- list = talloc (ctx, string_list_t);
+ list = ralloc (ctx, string_list_t);
list->head = NULL;
list->tail = NULL;
{
string_node_t *node;
- node = talloc (list, string_node_t);
- node->str = talloc_strdup (node, str);
+ node = ralloc (list, string_node_t);
+ node->str = ralloc_strdup (node, str);
node->next = NULL;
{
argument_list_t *list;
- list = talloc (ctx, argument_list_t);
+ list = ralloc (ctx, argument_list_t);
list->head = NULL;
list->tail = NULL;
{
argument_node_t *node;
- node = talloc (list, argument_node_t);
+ node = ralloc (list, argument_node_t);
node->argument = argument;
node->next = NULL;
return NULL;
}
-/* Note: This function talloc_steal()s the str pointer. */
+/* Note: This function ralloc_steal()s the str pointer. */
token_t *
_token_create_str (void *ctx, int type, char *str)
{
token_t *token;
- token = talloc (ctx, token_t);
+ token = ralloc (ctx, token_t);
token->type = type;
- token->value.str = talloc_steal (token, str);
+ token->value.str = str;
+
+ ralloc_steal (token, str);
return token;
}
{
token_t *token;
- token = talloc (ctx, token_t);
+ token = ralloc (ctx, token_t);
token->type = type;
token->value.ival = ival;
{
token_list_t *list;
- list = talloc (ctx, token_list_t);
+ list = ralloc (ctx, token_list_t);
list->head = NULL;
list->tail = NULL;
list->non_space_tail = NULL;
{
token_node_t *node;
- node = talloc (list, token_node_t);
- node->token = talloc_steal (list, token);
-
+ node = ralloc (list, token_node_t);
+ node->token = token;
node->next = NULL;
+ ralloc_steal (list, token);
+
if (list->head == NULL) {
list->head = node;
} else {
copy = _token_list_create (ctx);
for (node = other->head; node; node = node->next) {
- token_t *new_token = talloc (copy, token_t);
+ token_t *new_token = ralloc (copy, token_t);
*new_token = *node->token;
_token_list_append (copy, new_token);
}
while (tail) {
next = tail->next;
- talloc_free (tail);
+ ralloc_free (tail);
tail = next;
}
}
_token_print (char **out, token_t *token)
{
if (token->type < 256) {
- glcpp_printf (*out, "%c", token->type);
+ ralloc_asprintf_append (out, "%c", token->type);
return;
}
switch (token->type) {
case INTEGER:
- glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
+ ralloc_asprintf_append (out, "%" PRIiMAX, token->value.ival);
break;
case IDENTIFIER:
case INTEGER_STRING:
case OTHER:
- glcpp_print (*out, token->value.str);
+ ralloc_strcat (out, token->value.str);
break;
case SPACE:
- glcpp_print (*out, " ");
+ ralloc_strcat (out, " ");
break;
case LEFT_SHIFT:
- glcpp_print (*out, "<<");
+ ralloc_strcat (out, "<<");
break;
case RIGHT_SHIFT:
- glcpp_print (*out, ">>");
+ ralloc_strcat (out, ">>");
break;
case LESS_OR_EQUAL:
- glcpp_print (*out, "<=");
+ ralloc_strcat (out, "<=");
break;
case GREATER_OR_EQUAL:
- glcpp_print (*out, ">=");
+ ralloc_strcat (out, ">=");
break;
case EQUAL:
- glcpp_print (*out, "==");
+ ralloc_strcat (out, "==");
break;
case NOT_EQUAL:
- glcpp_print (*out, "!=");
+ ralloc_strcat (out, "!=");
break;
case AND:
- glcpp_print (*out, "&&");
+ ralloc_strcat (out, "&&");
break;
case OR:
- glcpp_print (*out, "||");
+ ralloc_strcat (out, "||");
break;
case PASTE:
- glcpp_print (*out, "##");
+ ralloc_strcat (out, "##");
break;
case COMMA_FINAL:
- glcpp_print (*out, ",");
+ ralloc_strcat (out, ",");
break;
case PLACEHOLDER:
/* Nothing to print. */
}
}
-/* Return a new token (talloc()ed off of 'token') formed by pasting
+/* Return a new token (ralloc()ed off of 'token') formed by pasting
* 'token' and 'other'. Note that this function may return 'token' or
* 'other' directly rather than allocating anything new.
*
{
char *str;
- str = talloc_asprintf (token, "%s%s", token->value.str,
+ str = ralloc_asprintf (token, "%s%s", token->value.str,
other->value.str);
combined = _token_create_str (token, token->type, str);
combined->location = token->location;
}
glcpp_error (&token->location, parser, "");
- glcpp_print (parser->info_log, "Pasting \"");
+ ralloc_strcat (&parser->info_log, "Pasting \"");
_token_print (&parser->info_log, token);
- glcpp_print (parser->info_log, "\" and \"");
+ ralloc_strcat (&parser->info_log, "\" and \"");
_token_print (&parser->info_log, other);
- glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
+ ralloc_strcat (&parser->info_log, "\" does not give a valid preprocessing token.\n");
return token;
}
glcpp_parser_t *parser;
int language_version;
- parser = talloc (NULL, glcpp_parser_t);
+ parser = ralloc (NULL, glcpp_parser_t);
glcpp_lex_init_extra (parser, &parser->scanner);
parser->defines = hash_table_ctor (32, hash_table_string_hash,
parser->lex_from_list = NULL;
parser->lex_from_node = NULL;
- parser->output = talloc_strdup(parser, "");
- parser->info_log = talloc_strdup(parser, "");
+ parser->output = ralloc_strdup(parser, "");
+ parser->info_log = ralloc_strdup(parser, "");
parser->error = 0;
/* Add pre-defined macros. */
{
glcpp_lex_destroy (parser->scanner);
hash_table_dtor (parser->defines);
- talloc_free (parser);
+ ralloc_free (parser);
}
typedef enum function_status
/* Replace a macro defined as empty with a SPACE token. */
if (macro->replacements == NULL) {
- talloc_free (arguments);
+ ralloc_free (arguments);
return _token_list_create_with_one_space (parser);
}
token_list_t *expansion;
token_t *final;
- str = talloc_strdup (parser, token->value.str);
+ str = ralloc_strdup (parser, token->value.str);
final = _token_create_str (parser, OTHER, str);
expansion = _token_list_create (parser);
_token_list_append (expansion, final);
{
active_list_t *node;
- node = talloc (list, active_list_t);
- node->identifier = talloc_strdup (node, identifier);
+ node = ralloc (list, active_list_t);
+ node->identifier = ralloc_strdup (node, identifier);
node->marker = marker;
node->next = list;
return NULL;
node = list->next;
- talloc_free (list);
+ ralloc_free (list);
return node;
}
if (loc != NULL)
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = talloc (parser, macro_t);
+ macro = ralloc (parser, macro_t);
macro->is_function = 0;
macro->parameters = NULL;
- macro->identifier = talloc_strdup (macro, identifier);
- macro->replacements = talloc_steal (macro, replacements);
+ macro->identifier = ralloc_strdup (macro, identifier);
+ macro->replacements = replacements;
+ ralloc_steal (macro, replacements);
previous = hash_table_find (parser->defines, identifier);
if (previous) {
if (_macro_equal (macro, previous)) {
- talloc_free (macro);
+ ralloc_free (macro);
return;
}
glcpp_error (loc, parser, "Redefinition of macro %s\n",
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = talloc (parser, macro_t);
+ macro = ralloc (parser, macro_t);
+ ralloc_steal (macro, parameters);
+ ralloc_steal (macro, replacements);
macro->is_function = 1;
- macro->parameters = talloc_steal (macro, parameters);
- macro->identifier = talloc_strdup (macro, identifier);
- macro->replacements = talloc_steal (macro, replacements);
-
+ macro->parameters = parameters;
+ macro->identifier = ralloc_strdup (macro, identifier);
+ macro->replacements = replacements;
previous = hash_table_find (parser->defines, identifier);
if (previous) {
if (_macro_equal (macro, previous)) {
- talloc_free (macro);
+ ralloc_free (macro);
return;
}
glcpp_error (loc, parser, "Redefinition of macro %s\n",
node = parser->lex_from_node;
if (node == NULL) {
- talloc_free (parser->lex_from_list);
+ ralloc_free (parser->lex_from_list);
parser->lex_from_list = NULL;
return NEWLINE;
}
_token_list_append (parser->lex_from_list, node->token);
}
- talloc_free (list);
+ ralloc_free (list);
parser->lex_from_node = parser->lex_from_list->head;
/* It's possible the list consisted of nothing but whitespace. */
if (parser->lex_from_node == NULL) {
- talloc_free (parser->lex_from_list);
+ ralloc_free (parser->lex_from_list);
parser->lex_from_list = NULL;
}
}
if (parser->skip_stack)
current = parser->skip_stack->type;
- node = talloc (parser, skip_node_t);
+ node = ralloc (parser, skip_node_t);
node->loc = *loc;
if (current == SKIP_NO_SKIP) {
node = parser->skip_stack;
parser->skip_stack = node->next;
- talloc_free (node);
+ ralloc_free (node);
}
#include "main/core.h" /* for struct gl_extensions */
#include "main/mtypes.h" /* for gl_api enum */
-#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
-#define glcpp_printf(stream, fmt, args, ...) \
- stream = talloc_asprintf_append(stream, fmt, args)
-
static void
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
static token_list_t *
_argument_list_member_at (argument_list_t *list, int index);
-/* Note: This function talloc_steal()s the str pointer. */
+/* Note: This function ralloc_steal()s the str pointer. */
static token_t *
_token_create_str (void *ctx, int type, char *str);
static token_list_t *
_token_list_create (void *ctx);
-/* Note: This function calls talloc_steal on token. */
+/* Note: This function calls ralloc_steal on token. */
static void
_token_list_append (token_list_t *list, token_t *token);
line:
control_line {
- glcpp_print(parser->output, "\n");
+ ralloc_strcat (&parser->output, "\n");
}
| text_line {
_glcpp_parser_print_expanded_token_list (parser, $1);
- glcpp_print(parser->output, "\n");
- talloc_free ($1);
+ ralloc_strcat (&parser->output, "\n");
+ ralloc_free ($1);
}
| expanded_line
| HASH non_directive
macro_t *macro = hash_table_find (parser->defines, $2);
if (macro) {
hash_table_remove (parser->defines, $2);
- talloc_free (macro);
+ ralloc_free (macro);
}
- talloc_free ($2);
+ ralloc_free ($2);
}
| HASH_IF conditional_tokens NEWLINE {
/* Be careful to only evaluate the 'if' expression if
}
| HASH_IFDEF IDENTIFIER junk NEWLINE {
macro_t *macro = hash_table_find (parser->defines, $2);
- talloc_free ($2);
+ ralloc_free ($2);
_glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
}
| HASH_IFNDEF IDENTIFIER junk NEWLINE {
macro_t *macro = hash_table_find (parser->defines, $2);
- talloc_free ($2);
+ ralloc_free ($2);
_glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL);
}
| HASH_ELIF conditional_tokens NEWLINE {
macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
if (macro) {
hash_table_remove (parser->defines, "__VERSION__");
- talloc_free (macro);
+ ralloc_free (macro);
}
add_builtin_define (parser, "__VERSION__", $2);
if ($2 >= 130 || $2 == 100)
add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
- glcpp_printf(parser->output, "#version %" PRIiMAX, $2);
+ ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, $2);
}
| HASH NEWLINE
;
IDENTIFIER {
$$ = _string_list_create (parser);
_string_list_append_item ($$, $1);
- talloc_steal ($$, $1);
+ ralloc_steal ($$, $1);
}
| identifier_list ',' IDENTIFIER {
$$ = $1;
_string_list_append_item ($$, $3);
- talloc_steal ($$, $3);
+ ralloc_steal ($$, $3);
}
;
{
string_list_t *list;
- list = talloc (ctx, string_list_t);
+ list = ralloc (ctx, string_list_t);
list->head = NULL;
list->tail = NULL;
{
string_node_t *node;
- node = talloc (list, string_node_t);
- node->str = talloc_strdup (node, str);
+ node = ralloc (list, string_node_t);
+ node->str = ralloc_strdup (node, str);
node->next = NULL;
{
argument_list_t *list;
- list = talloc (ctx, argument_list_t);
+ list = ralloc (ctx, argument_list_t);
list->head = NULL;
list->tail = NULL;
{
argument_node_t *node;
- node = talloc (list, argument_node_t);
+ node = ralloc (list, argument_node_t);
node->argument = argument;
node->next = NULL;
return NULL;
}
-/* Note: This function talloc_steal()s the str pointer. */
+/* Note: This function ralloc_steal()s the str pointer. */
token_t *
_token_create_str (void *ctx, int type, char *str)
{
token_t *token;
- token = talloc (ctx, token_t);
+ token = ralloc (ctx, token_t);
token->type = type;
- token->value.str = talloc_steal (token, str);
+ token->value.str = str;
+
+ ralloc_steal (token, str);
return token;
}
{
token_t *token;
- token = talloc (ctx, token_t);
+ token = ralloc (ctx, token_t);
token->type = type;
token->value.ival = ival;
{
token_list_t *list;
- list = talloc (ctx, token_list_t);
+ list = ralloc (ctx, token_list_t);
list->head = NULL;
list->tail = NULL;
list->non_space_tail = NULL;
{
token_node_t *node;
- node = talloc (list, token_node_t);
- node->token = talloc_steal (list, token);
-
+ node = ralloc (list, token_node_t);
+ node->token = token;
node->next = NULL;
+ ralloc_steal (list, token);
+
if (list->head == NULL) {
list->head = node;
} else {
copy = _token_list_create (ctx);
for (node = other->head; node; node = node->next) {
- token_t *new_token = talloc (copy, token_t);
+ token_t *new_token = ralloc (copy, token_t);
*new_token = *node->token;
_token_list_append (copy, new_token);
}
while (tail) {
next = tail->next;
- talloc_free (tail);
+ ralloc_free (tail);
tail = next;
}
}
_token_print (char **out, token_t *token)
{
if (token->type < 256) {
- glcpp_printf (*out, "%c", token->type);
+ ralloc_asprintf_append (out, "%c", token->type);
return;
}
switch (token->type) {
case INTEGER:
- glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
+ ralloc_asprintf_append (out, "%" PRIiMAX, token->value.ival);
break;
case IDENTIFIER:
case INTEGER_STRING:
case OTHER:
- glcpp_print (*out, token->value.str);
+ ralloc_strcat (out, token->value.str);
break;
case SPACE:
- glcpp_print (*out, " ");
+ ralloc_strcat (out, " ");
break;
case LEFT_SHIFT:
- glcpp_print (*out, "<<");
+ ralloc_strcat (out, "<<");
break;
case RIGHT_SHIFT:
- glcpp_print (*out, ">>");
+ ralloc_strcat (out, ">>");
break;
case LESS_OR_EQUAL:
- glcpp_print (*out, "<=");
+ ralloc_strcat (out, "<=");
break;
case GREATER_OR_EQUAL:
- glcpp_print (*out, ">=");
+ ralloc_strcat (out, ">=");
break;
case EQUAL:
- glcpp_print (*out, "==");
+ ralloc_strcat (out, "==");
break;
case NOT_EQUAL:
- glcpp_print (*out, "!=");
+ ralloc_strcat (out, "!=");
break;
case AND:
- glcpp_print (*out, "&&");
+ ralloc_strcat (out, "&&");
break;
case OR:
- glcpp_print (*out, "||");
+ ralloc_strcat (out, "||");
break;
case PASTE:
- glcpp_print (*out, "##");
+ ralloc_strcat (out, "##");
break;
case COMMA_FINAL:
- glcpp_print (*out, ",");
+ ralloc_strcat (out, ",");
break;
case PLACEHOLDER:
/* Nothing to print. */
}
}
-/* Return a new token (talloc()ed off of 'token') formed by pasting
+/* Return a new token (ralloc()ed off of 'token') formed by pasting
* 'token' and 'other'. Note that this function may return 'token' or
* 'other' directly rather than allocating anything new.
*
{
char *str;
- str = talloc_asprintf (token, "%s%s", token->value.str,
+ str = ralloc_asprintf (token, "%s%s", token->value.str,
other->value.str);
combined = _token_create_str (token, token->type, str);
combined->location = token->location;
}
glcpp_error (&token->location, parser, "");
- glcpp_print (parser->info_log, "Pasting \"");
+ ralloc_strcat (&parser->info_log, "Pasting \"");
_token_print (&parser->info_log, token);
- glcpp_print (parser->info_log, "\" and \"");
+ ralloc_strcat (&parser->info_log, "\" and \"");
_token_print (&parser->info_log, other);
- glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
+ ralloc_strcat (&parser->info_log, "\" does not give a valid preprocessing token.\n");
return token;
}
glcpp_parser_t *parser;
int language_version;
- parser = talloc (NULL, glcpp_parser_t);
+ parser = ralloc (NULL, glcpp_parser_t);
glcpp_lex_init_extra (parser, &parser->scanner);
parser->defines = hash_table_ctor (32, hash_table_string_hash,
parser->lex_from_list = NULL;
parser->lex_from_node = NULL;
- parser->output = talloc_strdup(parser, "");
- parser->info_log = talloc_strdup(parser, "");
+ parser->output = ralloc_strdup(parser, "");
+ parser->info_log = ralloc_strdup(parser, "");
parser->error = 0;
/* Add pre-defined macros. */
{
glcpp_lex_destroy (parser->scanner);
hash_table_dtor (parser->defines);
- talloc_free (parser);
+ ralloc_free (parser);
}
typedef enum function_status
/* Replace a macro defined as empty with a SPACE token. */
if (macro->replacements == NULL) {
- talloc_free (arguments);
+ ralloc_free (arguments);
return _token_list_create_with_one_space (parser);
}
token_list_t *expansion;
token_t *final;
- str = talloc_strdup (parser, token->value.str);
+ str = ralloc_strdup (parser, token->value.str);
final = _token_create_str (parser, OTHER, str);
expansion = _token_list_create (parser);
_token_list_append (expansion, final);
{
active_list_t *node;
- node = talloc (list, active_list_t);
- node->identifier = talloc_strdup (node, identifier);
+ node = ralloc (list, active_list_t);
+ node->identifier = ralloc_strdup (node, identifier);
node->marker = marker;
node->next = list;
return NULL;
node = list->next;
- talloc_free (list);
+ ralloc_free (list);
return node;
}
if (loc != NULL)
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = talloc (parser, macro_t);
+ macro = ralloc (parser, macro_t);
macro->is_function = 0;
macro->parameters = NULL;
- macro->identifier = talloc_strdup (macro, identifier);
- macro->replacements = talloc_steal (macro, replacements);
+ macro->identifier = ralloc_strdup (macro, identifier);
+ macro->replacements = replacements;
+ ralloc_steal (macro, replacements);
previous = hash_table_find (parser->defines, identifier);
if (previous) {
if (_macro_equal (macro, previous)) {
- talloc_free (macro);
+ ralloc_free (macro);
return;
}
glcpp_error (loc, parser, "Redefinition of macro %s\n",
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = talloc (parser, macro_t);
+ macro = ralloc (parser, macro_t);
+ ralloc_steal (macro, parameters);
+ ralloc_steal (macro, replacements);
macro->is_function = 1;
- macro->parameters = talloc_steal (macro, parameters);
- macro->identifier = talloc_strdup (macro, identifier);
- macro->replacements = talloc_steal (macro, replacements);
-
+ macro->parameters = parameters;
+ macro->identifier = ralloc_strdup (macro, identifier);
+ macro->replacements = replacements;
previous = hash_table_find (parser->defines, identifier);
if (previous) {
if (_macro_equal (macro, previous)) {
- talloc_free (macro);
+ ralloc_free (macro);
return;
}
glcpp_error (loc, parser, "Redefinition of macro %s\n",
node = parser->lex_from_node;
if (node == NULL) {
- talloc_free (parser->lex_from_list);
+ ralloc_free (parser->lex_from_list);
parser->lex_from_list = NULL;
return NEWLINE;
}
_token_list_append (parser->lex_from_list, node->token);
}
- talloc_free (list);
+ ralloc_free (list);
parser->lex_from_node = parser->lex_from_list->head;
/* It's possible the list consisted of nothing but whitespace. */
if (parser->lex_from_node == NULL) {
- talloc_free (parser->lex_from_list);
+ ralloc_free (parser->lex_from_list);
parser->lex_from_list = NULL;
}
}
if (parser->skip_stack)
current = parser->skip_stack->type;
- node = talloc (parser, skip_node_t);
+ node = ralloc (parser, skip_node_t);
node->loc = *loc;
if (current == SKIP_NO_SKIP) {
node = parser->skip_stack;
parser->skip_stack = node->next;
- talloc_free (node);
+ ralloc_free (node);
}
while (1) {
if (total_read + CHUNK + 1 > text_size) {
text_size = text_size ? text_size * 2 : CHUNK + 1;
- text = talloc_realloc_size (ctx, text, text_size);
+ text = reralloc_size (ctx, text, text_size);
if (text == NULL) {
fprintf (stderr, "Out of memory\n");
return NULL;
if (bytes < 0) {
fprintf (stderr, "Error while reading: %s\n",
strerror (errno));
- talloc_free (text);
+ ralloc_free (text);
return NULL;
}
main (int argc, char *argv[])
{
char *filename = NULL;
- void *ctx = talloc(NULL, void*);
- char *info_log = talloc_strdup(ctx, "");
+ void *ctx = ralloc(NULL, void*);
+ char *info_log = ralloc_strdup(ctx, "");
const char *shader;
int ret;
printf("%s", shader);
fprintf(stderr, "%s", info_log);
- talloc_free(ctx);
+ ralloc_free(ctx);
return ret;
}
#include <stdint.h>
-#include <talloc.h>
+#include "../ralloc.h"
#include "program/hash_table.h"
glcpp_parser_destroy (glcpp_parser_t *parser);
int
-preprocess(void *talloc_ctx, const char **shader, char **info_log,
+preprocess(void *ralloc_ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, int api);
/* Functions for writing to the info log */
va_list ap;
parser->error = 1;
- parser->info_log = talloc_asprintf_append(parser->info_log,
- "%u:%u(%u): "
+ ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): "
"preprocessor error: ",
locp->source,
locp->first_line,
locp->first_column);
va_start(ap, fmt);
- parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
+ ralloc_vasprintf_append(&parser->info_log, fmt, ap);
va_end(ap);
- parser->info_log = talloc_strdup_append(parser->info_log, "\n");
+ ralloc_strcat(&parser->info_log, "\n");
}
void
{
va_list ap;
- parser->info_log = talloc_asprintf_append(parser->info_log,
- "%u:%u(%u): "
+ ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): "
"preprocessor warning: ",
locp->source,
locp->first_line,
locp->first_column);
va_start(ap, fmt);
- parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
+ ralloc_vasprintf_append(&parser->info_log, fmt, ap);
va_end(ap);
- parser->info_log = talloc_strdup_append(parser->info_log, "\n");
+ ralloc_strcat(&parser->info_log, "\n");
}
/* Searches backwards for '^ *#' from a given starting point. */
{
int in_continued_line = 0;
int extra_newlines = 0;
- char *clean = talloc_strdup(ctx, "");
+ char *clean = ralloc_strdup(ctx, "");
const char *search_start = shader;
const char *newline;
while ((newline = strchr(search_start, '\n')) != NULL) {
}
if (in_continued_line) {
/* Copy everything before the \ */
- clean = talloc_strndup_append(clean, shader, backslash - shader);
+ ralloc_strncat(&clean, shader, backslash - shader);
shader = newline + 1;
extra_newlines++;
}
} else if (in_continued_line) {
/* Copy everything up to and including the \n */
- clean = talloc_strndup_append(clean, shader, newline - shader + 1);
+ ralloc_strncat(&clean, shader, newline - shader + 1);
shader = newline + 1;
/* Output extra newlines to make line numbers match */
for (; extra_newlines > 0; extra_newlines--)
- clean = talloc_strdup_append(clean, "\n");
+ ralloc_strcat(&clean, "\n");
in_continued_line = 0;
}
search_start = newline + 1;
}
- clean = talloc_strdup_append(clean, shader);
+ ralloc_strcat(&clean, shader);
return clean;
}
int
-preprocess(void *talloc_ctx, const char **shader, char **info_log,
+preprocess(void *ralloc_ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, int api)
{
int errors;
if (parser->skip_stack)
glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");
- *info_log = talloc_strdup_append(*info_log, parser->info_log);
+ ralloc_strcat(info_log, parser->info_log);
- talloc_steal(talloc_ctx, parser->output);
+ ralloc_steal(ralloc_ctx, parser->output);
*shader = parser->output;
errors = parser->error;
{
struct _mesa_glsl_parse_state *state = yyextra;
void *ctx = state;
- yylval->identifier = talloc_strdup(ctx, yytext);
+ yylval->identifier = ralloc_strdup(ctx, yytext);
return IDENTIFIER;
}
YY_BREAK
[_a-zA-Z][_a-zA-Z0-9]* {
struct _mesa_glsl_parse_state *state = yyextra;
void *ctx = state;
- yylval->identifier = talloc_strdup(ctx, yytext);
+ yylval->identifier = ralloc_strdup(ctx, yytext);
return IDENTIFIER;
}
/* FINISHME: Check against implementation support versions. */
state->language_version = (yyvsp[(2) - (3)].n);
state->version_string =
- talloc_asprintf(state, "GLSL%s %d.%02d",
+ ralloc_asprintf(state, "GLSL%s %d.%02d",
state->es_shader ? " ES" : "",
state->language_version / 100,
state->language_version % 100);
/* FINISHME: Check against implementation support versions. */
state->language_version = $2;
state->version_string =
- talloc_asprintf(state, "GLSL%s %d.%02d",
+ ralloc_asprintf(state, "GLSL%s %d.%02d",
state->es_shader ? " ES" : "",
state->language_version / 100,
state->language_version % 100);
#include <assert.h>
extern "C" {
-#include <talloc.h>
#include "main/core.h" /* for struct gl_context */
}
+#include "ralloc.h"
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
this->scanner = NULL;
this->translation_unit.make_empty();
this->symbols = new(mem_ctx) glsl_symbol_table;
- this->info_log = talloc_strdup(mem_ctx, "");
+ this->info_log = ralloc_strdup(mem_ctx, "");
this->error = false;
this->loop_or_switch_nesting = NULL;
state->error = true;
assert(state->info_log != NULL);
- state->info_log = talloc_asprintf_append(state->info_log,
- "%u:%u(%u): error: ",
+ ralloc_asprintf_append(&state->info_log, "%u:%u(%u): error: ",
locp->source,
locp->first_line,
locp->first_column);
va_start(ap, fmt);
- state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
+ ralloc_vasprintf_append(&state->info_log, fmt, ap);
va_end(ap);
- state->info_log = talloc_strdup_append(state->info_log, "\n");
+ ralloc_strcat(&state->info_log, "\n");
}
va_list ap;
assert(state->info_log != NULL);
- state->info_log = talloc_asprintf_append(state->info_log,
- "%u:%u(%u): warning: ",
+ ralloc_asprintf_append(&state->info_log, "%u:%u(%u): warning: ",
locp->source,
locp->first_line,
locp->first_column);
va_start(ap, fmt);
- state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
+ ralloc_vasprintf_append(&state->info_log, fmt, ap);
va_end(ap);
- state->info_log = talloc_strdup_append(state->info_log, "\n");
+ ralloc_strcat(&state->info_log, "\n");
}
{
if (identifier == NULL) {
static unsigned anon_count = 1;
- identifier = talloc_asprintf(this, "#anon_struct_%04x", anon_count);
+ identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count);
anon_count++;
}
name = identifier;
_mesa_glsl_parse_state(struct gl_context *ctx, GLenum target,
void *mem_ctx);
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
- void *mem = talloc_zero_size(ctx, size);
+ void *mem = rzalloc_size(ctx, size);
assert(mem != NULL);
return mem;
}
/* If the user *does* call delete, that's OK, we will just
- * talloc_free in that case. */
+ * ralloc_free in that case. */
static void operator delete(void *mem)
{
- talloc_free(mem);
+ ralloc_free(mem);
}
void *scanner;
class symbol_table_entry {
public:
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
- void *entry = talloc_size(ctx, size);
+ void *entry = ralloc_size(ctx, size);
assert(entry != NULL);
return entry;
}
- /* If the user *does* call delete, that's OK, we will just talloc_free. */
+ /* If the user *does* call delete, that's OK, we will just ralloc_free. */
static void operator delete(void *entry)
{
- talloc_free(entry);
+ ralloc_free(entry);
}
symbol_table_entry(ir_variable *v) : v(v), f(0), t(0) {}
{
this->language_version = 120;
this->table = _mesa_symbol_table_ctor();
- this->mem_ctx = talloc_init("symbol table entries");
+ this->mem_ctx = ralloc_context(NULL);
}
glsl_symbol_table::~glsl_symbol_table()
{
_mesa_symbol_table_dtor(table);
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
void glsl_symbol_table::push_scope()
*/
struct glsl_symbol_table {
private:
- static int
+ static void
_glsl_symbol_table_destructor (glsl_symbol_table *table)
{
table->~glsl_symbol_table();
-
- return 0;
}
public:
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *table;
- table = talloc_size(ctx, size);
+ table = ralloc_size(ctx, size);
assert(table != NULL);
- talloc_set_destructor(table, (int (*)(void*)) _glsl_symbol_table_destructor);
+ ralloc_set_destructor(table, (void (*)(void*)) _glsl_symbol_table_destructor);
return table;
}
/* If the user *does* call delete, that's OK, we will just
- * talloc_free in that case. Here, C++ will have already called the
- * destructor so tell talloc not to do that again. */
+ * ralloc_free in that case. Here, C++ will have already called the
+ * destructor so tell ralloc not to do that again. */
static void operator delete(void *table)
{
- talloc_set_destructor(table, NULL);
- talloc_free(table);
+ ralloc_set_destructor(table, NULL);
+ ralloc_free(table);
}
glsl_symbol_table();
void *glsl_type::mem_ctx = NULL;
void
-glsl_type::init_talloc_type_ctx(void)
+glsl_type::init_ralloc_type_ctx(void)
{
if (glsl_type::mem_ctx == NULL) {
- glsl_type::mem_ctx = talloc_autofree_context();
+ glsl_type::mem_ctx = ralloc_autofree_context();
assert(glsl_type::mem_ctx != NULL);
}
}
vector_elements(vector_elements), matrix_columns(matrix_columns),
length(0)
{
- init_talloc_type_ctx();
- this->name = talloc_strdup(this->mem_ctx, name);
+ init_ralloc_type_ctx();
+ this->name = ralloc_strdup(this->mem_ctx, name);
/* Neither dimension is zero or both dimensions are zero.
*/
assert((vector_elements == 0) == (matrix_columns == 0));
vector_elements(0), matrix_columns(0),
length(0)
{
- init_talloc_type_ctx();
- this->name = talloc_strdup(this->mem_ctx, name);
+ init_ralloc_type_ctx();
+ this->name = ralloc_strdup(this->mem_ctx, name);
memset(& fields, 0, sizeof(fields));
}
{
unsigned int i;
- init_talloc_type_ctx();
- this->name = talloc_strdup(this->mem_ctx, name);
- this->fields.structure = talloc_array(this->mem_ctx,
+ init_ralloc_type_ctx();
+ this->name = ralloc_strdup(this->mem_ctx, name);
+ this->fields.structure = ralloc_array(this->mem_ctx,
glsl_struct_field, length);
for (i = 0; i < length; i++) {
this->fields.structure[i].type = fields[i].type;
- this->fields.structure[i].name = talloc_strdup(this->fields.structure,
+ this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
fields[i].name);
}
}
* NUL.
*/
const unsigned name_length = strlen(array->name) + 10 + 3;
- char *const n = (char *) talloc_size(this->mem_ctx, name_length);
+ char *const n = (char *) ralloc_size(this->mem_ctx, name_length);
if (length == 0)
snprintf(n, name_length, "%s[]", array->name);
if (t == NULL) {
t = new glsl_type(base, array_size);
- hash_table_insert(array_types, (void *) t, talloc_strdup(mem_ctx, key));
+ hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key));
}
assert(t->base_type == GLSL_TYPE_ARRAY);
extern "C" {
#include "GL/gl.h"
-#include <talloc.h>
}
+#include "ralloc.h"
+
struct _mesa_glsl_parse_state;
struct glsl_symbol_table;
* and \c GLSL_TYPE_UINT are valid.
*/
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'mem_ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
static void* operator new(size_t size)
{
if (glsl_type::mem_ctx == NULL) {
- glsl_type::mem_ctx = talloc_init("glsl_type");
+ glsl_type::mem_ctx = ralloc_context(NULL);
assert(glsl_type::mem_ctx != NULL);
}
void *type;
- type = talloc_size(glsl_type::mem_ctx, size);
+ type = ralloc_size(glsl_type::mem_ctx, size);
assert(type != NULL);
return type;
}
/* If the user *does* call delete, that's OK, we will just
- * talloc_free in that case. */
+ * ralloc_free in that case. */
static void operator delete(void *type)
{
- talloc_free(type);
+ ralloc_free(type);
}
/**
private:
/**
- * talloc context for all glsl_type allocations
+ * ralloc context for all glsl_type allocations
*
* Set on the first call to \c glsl_type::new.
*/
static void *mem_ctx;
- void init_talloc_type_ctx(void);
+ void init_ralloc_type_ctx(void);
/** Constructor for vector and matrix types */
glsl_type(GLenum gl_type,
|| type->is_record() || type->is_array());
if (type->is_array()) {
- this->array_elements = talloc_array(this, ir_constant *, type->length);
+ this->array_elements = ralloc_array(this, ir_constant *, type->length);
unsigned i = 0;
foreach_list(node, value_list) {
ir_constant *value = (ir_constant *) node;
ir_dereference_array::ir_dereference_array(ir_variable *var,
ir_rvalue *array_index)
{
- void *ctx = talloc_parent(var);
+ void *ctx = ralloc_parent(var);
this->ir_type = ir_type_dereference_array;
this->array_index = array_index;
{
this->ir_type = ir_type_dereference_record;
this->record = value;
- this->field = talloc_strdup(this, field);
+ this->field = ralloc_strdup(this, field);
this->type = (this->record != NULL)
? this->record->type->field_type(field) : glsl_type::error_type;
}
ir_dereference_record::ir_dereference_record(ir_variable *var,
const char *field)
{
- void *ctx = talloc_parent(var);
+ void *ctx = ralloc_parent(var);
this->ir_type = ir_type_dereference_record;
this->record = new(ctx) ir_dereference_variable(var);
- this->field = talloc_strdup(this, field);
+ this->field = ralloc_strdup(this, field);
this->type = (this->record != NULL)
? this->record->type->field_type(field) : glsl_type::error_type;
}
ir_swizzle *
ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length)
{
- void *ctx = talloc_parent(val);
+ void *ctx = ralloc_parent(val);
/* For each possible swizzle character, this table encodes the value in
* \c idx_map that represents the 0th element of the vector. For invalid
{
this->ir_type = ir_type_variable;
this->type = type;
- this->name = talloc_strdup(this, name);
+ this->name = ralloc_strdup(this, name);
this->explicit_location = false;
this->location = -1;
this->warn_extension = NULL;
ir_function::ir_function(const char *name)
{
this->ir_type = ir_type_function;
- this->name = talloc_strdup(this, name);
+ this->name = ralloc_strdup(this, name);
}
}
}
- talloc_steal(new_ctx, ir);
+ ralloc_steal(new_ctx, ir);
}
#include <cstdio>
#include <cstdlib>
-extern "C" {
-#include <talloc.h>
-}
-
+#include "ralloc.h"
#include "glsl_types.h"
#include "list.h"
#include "ir_visitor.h"
/**
* Get a generic ir_call object when an error occurs
*
- * Any allocation will be performed with 'ctx' as talloc owner.
+ * Any allocation will be performed with 'ctx' as ralloc owner.
*/
static ir_call *get_error_instruction(void *ctx);
ir_constant *c = new(mem_ctx) ir_constant;
c->type = this->type;
- c->array_elements = talloc_array(c, ir_constant *, this->type->length);
+ c->array_elements = ralloc_array(c, ir_constant *, this->type->length);
for (unsigned i = 0; i < this->type->length; i++) {
c->array_elements[i] = this->array_elements[i]->clone(mem_ctx, NULL);
}
components = op[1]->type->components();
}
- void *ctx = talloc_parent(this);
+ void *ctx = ralloc_parent(this);
/* Handle array operations here, rather than below. */
if (op[0]->type->is_array()) {
}
}
- void *ctx = talloc_parent(this);
+ void *ctx = ralloc_parent(this);
return new(ctx) ir_constant(this->type, &data);
}
return NULL;
if (!var->constant_value)
return NULL;
- return var->constant_value->clone(talloc_parent(var), NULL);
+ return var->constant_value->clone(ralloc_parent(var), NULL);
}
ir_constant *idx = this->array_index->constant_expression_value();
if ((array != NULL) && (idx != NULL)) {
- void *ctx = talloc_parent(this);
+ void *ctx = ralloc_parent(this);
if (array->type->is_matrix()) {
/* Array access of a matrix results in a vector.
*/
* - Fill "data" with appopriate constant data
* - Return an ir_constant directly.
*/
- void *mem_ctx = talloc_parent(this);
+ void *mem_ctx = ralloc_parent(this);
ir_expression *expr = NULL;
ir_constant_data data;
if (!ir || !this->predicate(ir))
return;
- void *ctx = talloc_parent(ir);
+ void *ctx = ralloc_parent(ir);
var = new(ctx) ir_variable(ir->type, "flattening_tmp", ir_var_temporary);
base_ir->insert_before(var);
* \param dest Destination instruction stream where new \c ir_function and
* \c ir_function_signature nodes will be stored
* \param symbols Symbol table where new functions will be stored
- * \param mem_ctx talloc memory context used for new allocations
+ * \param mem_ctx ralloc memory context used for new allocations
*/
void
import_prototypes(const exec_list *source, exec_list *dest,
}
read_instructions(instructions, expr, NULL);
- talloc_free(expr);
+ ralloc_free(expr);
if (debug)
validate_ir_tree(instructions);
state->error = true;
if (state->current_function != NULL)
- state->info_log = talloc_asprintf_append(state->info_log,
- "In function %s:\n",
- state->current_function->function_name());
- state->info_log = talloc_strdup_append(state->info_log, "error: ");
+ ralloc_asprintf_append(&state->info_log, "In function %s:\n",
+ state->current_function->function_name());
+ ralloc_strcat(&state->info_log, "error: ");
va_start(ap, fmt);
- state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
+ ralloc_vasprintf_append(&state->info_log, fmt, ap);
va_end(ap);
- state->info_log = talloc_strdup_append(state->info_log, "\n");
+ ralloc_strcat(&state->info_log, "\n");
if (expr != NULL) {
- state->info_log = talloc_strdup_append(state->info_log,
- "...in this context:\n ");
+ ralloc_strcat(&state->info_log, "...in this context:\n ");
expr->print();
- state->info_log = talloc_strdup_append(state->info_log, "\n\n");
+ ralloc_strcat(&state->info_log, "\n\n");
}
}
ir_visitor_status
ir_validate::visit_leave(ir_function *ir)
{
- assert(talloc_parent(ir->name) == ir);
+ assert(ralloc_parent(ir->name) == ir);
this->current_function = NULL;
return visit_continue;
* declared before it is dereferenced.
*/
if (ir->name)
- assert(talloc_parent(ir->name) == ir);
+ assert(ralloc_parent(ir->name) == ir);
hash_table_insert(ht, ir, ir);
return visit_continue;
public:
ir_variable_refcount_visitor(void)
{
- this->mem_ctx = talloc_new(NULL);
+ this->mem_ctx = ralloc_context(NULL);
this->variable_list.make_empty();
}
~ir_variable_refcount_visitor(void)
{
- talloc_free(this->mem_ctx);
+ ralloc_free(this->mem_ctx);
}
virtual ir_visitor_status visit(ir_variable *);
{
va_list ap;
- prog->InfoLog = talloc_strdup_append(prog->InfoLog, "error: ");
+ ralloc_strcat(&prog->InfoLog, "error: ");
va_start(ap, fmt);
- prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, ap);
+ ralloc_vasprintf_append(&prog->InfoLog, fmt, ap);
va_end(ap);
}
* FINISHME: will fail.
*/
existing->constant_value =
- var->constant_value->clone(talloc_parent(existing), NULL);
+ var->constant_value->clone(ralloc_parent(existing), NULL);
}
if (existing->invariant != var->invariant) {
if (type->is_record()) {
for (unsigned int i = 0; i < type->length; i++) {
const glsl_type *field_type = type->fields.structure[i].type;
- char *field_name = talloc_asprintf(mem_ctx, "%s.%s", name,
+ char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name,
type->fields.structure[i].name);
add_uniform(mem_ctx, uniforms, ht, field_name, field_type,
/* Array of structures. */
if (array_elem_type->is_record()) {
for (unsigned int i = 0; i < type->length; i++) {
- char *elem_name = talloc_asprintf(mem_ctx, "%s[%d]", name, i);
+ char *elem_name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i);
add_uniform(mem_ctx, uniforms, ht, elem_name, array_elem_type,
shader_type, next_shader_pos, total_uniforms);
}
unsigned total_uniforms = 0;
hash_table *ht = hash_table_ctor(32, hash_table_string_hash,
hash_table_string_compare);
- void *mem_ctx = talloc_new(NULL);
+ void *mem_ctx = ralloc_context(NULL);
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
if (prog->_LinkedShaders[i] == NULL)
}
}
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
gl_uniform_list *ul = (gl_uniform_list *)
calloc(1, sizeof(gl_uniform_list));
void
link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
{
- void *mem_ctx = talloc_init("temporary linker context");
+ void *mem_ctx = ralloc_context(NULL); // temporary linker context
prog->LinkStatus = false;
prog->Validated = false;
prog->_Used = false;
if (prog->InfoLog != NULL)
- talloc_free(prog->InfoLog);
+ ralloc_free(prog->InfoLog);
- prog->InfoLog = talloc_strdup(NULL, "");
+ prog->InfoLog = ralloc_strdup(NULL, "");
/* Separate the shaders into groups based on their type.
*/
reparent_ir(prog->_LinkedShaders[i]->ir, prog->_LinkedShaders[i]->ir);
}
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
#ifndef __cplusplus
#include <stddef.h>
-#include <talloc.h>
-#else
-extern "C" {
-#include <talloc.h>
-}
#endif
-
#include <assert.h>
+#include "ralloc.h"
+
struct exec_node {
struct exec_node *next;
struct exec_node *prev;
#ifdef __cplusplus
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
- node = talloc_size(ctx, size);
+ node = ralloc_size(ctx, size);
assert(node != NULL);
return node;
}
/* If the user *does* call delete, that's OK, we will just
- * talloc_free in that case. */
+ * ralloc_free in that case. */
static void operator delete(void *node)
{
- talloc_free(node);
+ ralloc_free(node);
}
exec_node() : next(NULL), prev(NULL)
struct exec_node *tail_pred;
#ifdef __cplusplus
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
- node = talloc_size(ctx, size);
+ node = ralloc_size(ctx, size);
assert(node != NULL);
return node;
}
/* If the user *does* call delete, that's OK, we will just
- * talloc_free in that case. */
+ * ralloc_free in that case. */
static void operator delete(void *node)
{
- talloc_free(node);
+ ralloc_free(node);
}
exec_list()
{
this->ht = hash_table_ctor(0, hash_table_pointer_hash,
hash_table_pointer_compare);
- this->mem_ctx = talloc_init("loop state");
+ this->mem_ctx = ralloc_context(NULL);
this->loop_found = false;
}
loop_state::~loop_state()
{
hash_table_dtor(this->ht);
- talloc_free(this->mem_ctx);
+ ralloc_free(this->mem_ctx);
}
loop_variable *
loop_variable_state::insert(ir_variable *var)
{
- void *mem_ctx = talloc_parent(this);
- loop_variable *lv = talloc_zero(mem_ctx, loop_variable);
+ void *mem_ctx = ralloc_parent(this);
+ loop_variable *lv = rzalloc(mem_ctx, loop_variable);
lv->var = var;
loop_terminator *
loop_variable_state::insert(ir_if *if_stmt)
{
- void *mem_ctx = talloc_parent(this);
- loop_terminator *t = talloc_zero(mem_ctx, loop_terminator);
+ void *mem_ctx = ralloc_parent(this);
+ loop_terminator *t = rzalloc(mem_ctx, loop_terminator);
t->ir = if_stmt;
this->terminators.push_tail(t);
}
if ((inc != NULL) && (rhs->operation == ir_binop_sub)) {
- void *mem_ctx = talloc_parent(ir);
+ void *mem_ctx = ralloc_parent(ir);
inc = new(mem_ctx) ir_expression(ir_unop_neg,
inc->type,
if (from == NULL || to == NULL || increment == NULL)
return -1;
- void *mem_ctx = talloc_init("%s", __func__);
+ void *mem_ctx = ralloc_context(NULL);
ir_expression *const sub =
new(mem_ctx) ir_expression(ir_binop_sub, from->type, to, from);
}
}
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
return (valid_loop) ? iter_value : -1;
}
*/
break_ir->remove();
- void *const mem_ctx = talloc_parent(ir);
+ void *const mem_ctx = ralloc_parent(ir);
ir_instruction *ir_to_replace = ir;
for (int i = 0; i < iterations; i++) {
}
}
- void *const mem_ctx = talloc_parent(ir);
+ void *const mem_ctx = ralloc_parent(ir);
for (int i = 0; i < iterations; i++) {
exec_list copy_list;
if (then_discard == NULL && else_discard == NULL)
return visit_continue;
- void *mem_ctx = talloc_parent(ir);
+ void *mem_ctx = ralloc_parent(ir);
ir_variable *temp = new(mem_ctx) ir_variable(glsl_type::bool_type,
"discard_cond_temp",
if (found_control_flow)
return visit_continue;
- void *mem_ctx = talloc_parent(ir);
+ void *mem_ctx = ralloc_parent(ir);
/* Store the condition to a variable so the assignment conditions are
* simpler.
assert(orig_expr->get_num_operands() <= 2);
- mem_ctx = talloc_parent(orig_assign);
+ mem_ctx = ralloc_parent(orig_assign);
ir_dereference_variable *lhs_deref =
orig_assign->lhs->as_dereference_variable();
* that implements noise. No hardware has a noise instruction.
*/
if (expr->operation == ir_unop_noise) {
- *rvalue = ir_constant::zero(talloc_parent(expr), expr->type);
+ *rvalue = ir_constant::zero(ralloc_parent(expr), expr->type);
this->progress = true;
}
}
if (!ir->projector)
return visit_continue;
- void *mem_ctx = talloc_parent(ir);
+ void *mem_ctx = ralloc_parent(ir);
ir_variable *var = new(mem_ctx) ir_variable(ir->projector->type,
"projector", ir_var_auto);
/* Just clone the rest of the deref chain when trying to get at the
* underlying variable.
*/
- void *mem_ctx = talloc_parent(base_ir);
+ void *mem_ctx = ralloc_parent(base_ir);
ir_dereference *element =
new(mem_ctx) ir_dereference_array(this->array->clone(mem_ctx, NULL),
new(mem_ctx) ir_constant(i));
linear_sequence_max_length(linear_sequence_max_length),
condition_components(condition_components)
{
- this->mem_ctx = talloc_parent(index);
+ this->mem_ctx = ralloc_parent(index);
}
void linear_sequence(unsigned begin, unsigned end, exec_list *list)
? orig_deref->array->type->length
: orig_deref->array->type->matrix_columns;
- void *const mem_ctx = talloc_parent(base_ir);
+ void *const mem_ctx = ralloc_parent(base_ir);
/* Temporary storage for either the result of the dereference of
* the array, or the RHS that's being assigned into the
if (needs_lowering(orig_deref)) {
ir_variable* var = convert_dereference_array(orig_deref, 0);
assert(var);
- *pir = new(talloc_parent(base_ir)) ir_dereference_variable(var);
+ *pir = new(ralloc_parent(base_ir)) ir_dereference_variable(var);
this->progress = true;
}
}
orig_deref->array->type->is_array())
return ir;
- void *mem_ctx = talloc_parent(ir);
+ void *mem_ctx = ralloc_parent(ir);
assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT);
orig_deref->array->type->is_array())
return visit_continue;
- void *mem_ctx = talloc_parent(ir);
+ void *mem_ctx = ralloc_parent(ir);
assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT);
if (!ir_constant)
return ir;
- void *ctx = talloc_parent(ir);
+ void *ctx = ralloc_parent(ir);
this->progress = true;
return new(ctx) ir_swizzle(deref->array,
ir_constant->value.i[0], 0, 0, 0, 1);
if (this->dont_lower_swz && is_extended_swizzle(expr))
return;
- /* FINISHME: Is this the right thing to use for the talloc context?
+ /* FINISHME: Is this the right thing to use for the ralloc context?
*/
void *const mem_ctx = expr;
(void) ctx;
assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
- shader = talloc_zero(NULL, struct gl_shader);
+ shader = rzalloc(NULL, struct gl_shader);
if (shader) {
shader->Type = type;
shader->Name = name;
ctx->Driver.NewShader = _mesa_new_shader;
}
-/* Returned string will have 'ctx' as its talloc owner. */
+/* Returned string will have 'ctx' as its ralloc owner. */
static char *
load_text_file(void *ctx, const char *file_name)
{
size = ftell(fp);
fseek(fp, 0L, SEEK_SET);
- text = (char *) talloc_size(ctx, size + 1);
+ text = (char *) ralloc_size(ctx, size + 1);
if (text != NULL) {
do {
size_t bytes = fread(text + total_read,
shader->num_builtins_to_link = state->num_builtins_to_link;
if (shader->InfoLog)
- talloc_free(shader->InfoLog);
+ ralloc_free(shader->InfoLog);
shader->InfoLog = state->info_log;
/* Retain any live IR, but trash the rest. */
reparent_ir(shader->ir, shader);
- talloc_free(state);
+ ralloc_free(state);
return;
}
struct gl_shader_program *whole_program;
- whole_program = talloc_zero (NULL, struct gl_shader_program);
+ whole_program = rzalloc (NULL, struct gl_shader_program);
assert(whole_program != NULL);
for (/* empty */; argc > optind; optind++) {
- whole_program->Shaders = (struct gl_shader **)
- talloc_realloc(whole_program, whole_program->Shaders,
- struct gl_shader *, whole_program->NumShaders + 1);
+ whole_program->Shaders =
+ reralloc(whole_program, whole_program->Shaders,
+ struct gl_shader *, whole_program->NumShaders + 1);
assert(whole_program->Shaders != NULL);
- struct gl_shader *shader = talloc_zero(whole_program, gl_shader);
+ struct gl_shader *shader = rzalloc(whole_program, gl_shader);
whole_program->Shaders[whole_program->NumShaders] = shader;
whole_program->NumShaders++;
}
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++)
- talloc_free(whole_program->_LinkedShaders[i]);
+ ralloc_free(whole_program->_LinkedShaders[i]);
- talloc_free(whole_program);
+ ralloc_free(whole_program);
_mesa_glsl_release_types();
_mesa_glsl_release_functions();
}
if (this->mem_ctx == NULL)
- this->mem_ctx = talloc_parent(ir);
+ this->mem_ctx = ralloc_parent(ir);
switch (ir->operation) {
case ir_unop_logic_not: {
ir_constant_propagation_visitor()
{
progress = false;
- mem_ctx = talloc_new(0);
+ mem_ctx = ralloc_context(0);
this->acp = new(mem_ctx) exec_list;
this->kills = new(mem_ctx) exec_list;
}
~ir_constant_propagation_visitor()
{
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
virtual ir_visitor_status visit_enter(class ir_loop *);
}
}
- *rvalue = new(talloc_parent(deref)) ir_constant(type, &data);
+ *rvalue = new(ralloc_parent(deref)) ir_constant(type, &data);
this->progress = true;
}
ir_copy_propagation_visitor()
{
progress = false;
- mem_ctx = talloc_new(0);
+ mem_ctx = ralloc_context(0);
this->acp = new(mem_ctx) exec_list;
this->kills = new(mem_ctx) exec_list;
}
~ir_copy_propagation_visitor()
{
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
virtual ir_visitor_status visit(class ir_dereference_variable *);
* calling us. Just flag it to not execute, and someone else
* will clean up the mess.
*/
- ir->condition = new(talloc_parent(ir)) ir_constant(false);
+ ir->condition = new(ralloc_parent(ir)) ir_constant(false);
this->progress = true;
} else {
entry = new(this->mem_ctx) acp_entry(lhs_var, rhs_var);
bool *out_progress = (bool *)data;
bool progress = false;
- void *ctx = talloc_new(NULL);
+ void *ctx = ralloc_context(NULL);
/* Safe looping, since process_assignment */
for (ir = first, ir_next = (ir_instruction *)first->next;;
ir = ir_next, ir_next = (ir_instruction *)ir->next) {
break;
}
*out_progress = progress;
- talloc_free(ctx);
+ ralloc_free(ctx);
}
/**
public:
ir_dead_functions_visitor()
{
- this->mem_ctx = talloc_new(NULL);
+ this->mem_ctx = ralloc_context(NULL);
}
~ir_dead_functions_visitor()
{
- talloc_free(this->mem_ctx);
+ ralloc_free(this->mem_ctx);
}
virtual ir_visitor_status visit_enter(ir_function_signature *);
static void
replace_return_with_assignment(ir_instruction *ir, void *data)
{
- void *ctx = talloc_parent(ir);
+ void *ctx = ralloc_parent(ir);
ir_variable *retval = (ir_variable *)data;
ir_return *ret = ir->as_return();
ir_rvalue *
ir_call::generate_inline(ir_instruction *next_ir)
{
- void *ctx = talloc_parent(this);
+ void *ctx = ralloc_parent(this);
ir_variable **parameters;
int num_parameters;
int i;
{
ir_dereference_variable *deref_var = (*deref)->as_dereference_variable();
if (deref_var && deref_var->var == this->sampler) {
- *deref = this->deref->clone(talloc_parent(*deref), NULL);
+ *deref = this->deref->clone(ralloc_parent(*deref), NULL);
}
}
ir_variable **components;
- /** talloc_parent(this->var) -- the shader's talloc context. */
+ /** ralloc_parent(this->var) -- the shader's ralloc context. */
void *mem_ctx;
};
public:
ir_structure_reference_visitor(void)
{
- this->mem_ctx = talloc_new(NULL);
+ this->mem_ctx = ralloc_context(NULL);
this->variable_list.make_empty();
}
~ir_structure_reference_visitor(void)
{
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
virtual ir_visitor_status visit(ir_variable *);
if (refs.variable_list.is_empty())
return false;
- void *mem_ctx = talloc_new(NULL);
+ void *mem_ctx = ralloc_context(NULL);
/* Replace the decls of the structures to be split with their split
* components.
variable_entry2 *entry = (variable_entry2 *)iter.get();
const struct glsl_type *type = entry->var->type;
- entry->mem_ctx = talloc_parent(entry->var);
+ entry->mem_ctx = ralloc_parent(entry->var);
- entry->components = talloc_array(mem_ctx,
+ entry->components = ralloc_array(mem_ctx,
ir_variable *,
type->length);
for (unsigned int i = 0; i < entry->var->type->length; i++) {
- const char *name = talloc_asprintf(mem_ctx, "%s_%s",
+ const char *name = ralloc_asprintf(mem_ctx, "%s_%s",
entry->var->name,
type->fields.structure[i].name);
ir_structure_splitting_visitor split(&refs.variable_list);
visit_list_elements(&split, instructions);
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
return true;
}
s_symbol::s_symbol(const char *tmp, size_t n)
{
- this->str = talloc_strndup (this, tmp, n);
+ this->str = ralloc_strndup (this, tmp, n);
assert(this->str != NULL);
}
* Read an S-Expression from the given string.
* Advances the supplied pointer to just after the expression read.
*
- * Any allocation will be performed with 'ctx' as the talloc owner.
+ * Any allocation will be performed with 'ctx' as the ralloc owner.
*/
static s_expression *read_expression(void *ctx, const char *&src);
if (ir->sampler->type->sampler_dimensionality != GLSL_SAMPLER_DIM_CUBE)
return visit_continue;
- void *mem_ctx = talloc_parent(ir);
+ void *mem_ctx = ralloc_parent(ir);
ir_variable *var = new(mem_ctx) ir_variable(ir->coordinate->type,
"coordinate", ir_var_auto);
{
struct brw_shader *shader;
- shader = talloc_zero(NULL, struct brw_shader);
+ shader = rzalloc(NULL, struct brw_shader);
if (shader) {
shader->base.Type = type;
shader->base.Name = name;
brw_new_shader_program(struct gl_context *ctx, GLuint name)
{
struct brw_shader_program *prog;
- prog = talloc_zero(NULL, struct brw_shader_program);
+ prog = rzalloc(NULL, struct brw_shader_program);
if (prog) {
prog->base.Name = name;
_mesa_init_shader_program(ctx, &prog->base);
struct brw_shader *shader =
(struct brw_shader *)prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
if (shader != NULL) {
- void *mem_ctx = talloc_new(NULL);
+ void *mem_ctx = ralloc_context(NULL);
bool progress;
if (shader->ir)
- talloc_free(shader->ir);
+ ralloc_free(shader->ir);
shader->ir = new(shader) exec_list;
clone_ir_list(mem_ctx, shader->ir, shader->base.ir);
validate_ir_tree(shader->ir);
reparent_ir(shader->ir, shader->ir);
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
if (!_mesa_ir_link_shader(ctx, prog))
virtual_grf_array_size = 16;
else
virtual_grf_array_size *= 2;
- virtual_grf_sizes = talloc_realloc(mem_ctx, virtual_grf_sizes,
- int, virtual_grf_array_size);
+ virtual_grf_sizes = reralloc(mem_ctx, virtual_grf_sizes, int,
+ virtual_grf_array_size);
/* This slot is always unused. */
virtual_grf_sizes[0] = 0;
}
for (int target = 0; target < c->key.nr_color_regions; target++) {
- this->current_annotation = talloc_asprintf(this->mem_ctx,
+ this->current_annotation = ralloc_asprintf(this->mem_ctx,
"FB write target %d",
target);
if (this->frag_color || this->frag_data) {
fs_visitor::calculate_live_intervals()
{
int num_vars = this->virtual_grf_next;
- int *def = talloc_array(mem_ctx, int, num_vars);
- int *use = talloc_array(mem_ctx, int, num_vars);
+ int *def = ralloc_array(mem_ctx, int, num_vars);
+ int *use = ralloc_array(mem_ctx, int, num_vars);
int loop_depth = 0;
int loop_start = 0;
int bb_header_ip = 0;
}
}
- talloc_free(this->virtual_grf_def);
- talloc_free(this->virtual_grf_use);
+ ralloc_free(this->virtual_grf_def);
+ ralloc_free(this->virtual_grf_use);
this->virtual_grf_def = def;
this->virtual_grf_use = use;
#include "brw_context.h"
#include "brw_eu.h"
#include "brw_wm.h"
-#include "talloc.h"
}
#include "../glsl/glsl_types.h"
#include "../glsl/ir.h"
class fs_reg {
public:
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
- node = talloc_size(ctx, size);
+ node = ralloc_size(ctx, size);
assert(node != NULL);
return node;
class fs_inst : public exec_node {
public:
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
- node = talloc_zero_size(ctx, size);
+ node = rzalloc_size(ctx, size);
assert(node != NULL);
return node;
this->fp = brw->fragment_program;
this->intel = &brw->intel;
this->ctx = &intel->ctx;
- this->mem_ctx = talloc_new(NULL);
+ this->mem_ctx = ralloc_context(NULL);
this->shader = shader;
this->fail = false;
this->variable_ht = hash_table_ctor(0,
~fs_visitor()
{
- talloc_free(this->mem_ctx);
+ ralloc_free(this->mem_ctx);
hash_table_dtor(this->variable_ht);
}
return visit_continue;
if (!this->mem_ctx)
- this->mem_ctx = talloc_parent(ir);
+ this->mem_ctx = ralloc_parent(ir);
for (i = 0; i < expr->get_num_operands(); i++) {
if (expr->operands[i]->type->is_vector()) {
}
- talloc_free(g);
- talloc_free(regs);
+ ralloc_free(g);
+ ralloc_free(regs);
return false;
}
this->grf_used = last_grf + 1;
- talloc_free(g);
- talloc_free(regs);
+ ralloc_free(g);
+ ralloc_free(regs);
return true;
}
instruction_scheduler(fs_visitor *v, void *mem_ctx, int virtual_grf_count)
{
this->v = v;
- this->mem_ctx = talloc_new(mem_ctx);
+ this->mem_ctx = ralloc_context(mem_ctx);
this->virtual_grf_count = virtual_grf_count;
this->instructions.make_empty();
this->instructions_to_schedule = 0;
~instruction_scheduler()
{
- talloc_free(this->mem_ctx);
+ ralloc_free(this->mem_ctx);
}
void add_barrier_deps(schedule_node *n);
void add_dep(schedule_node *before, schedule_node *after, int latency);
else
before->child_array_size *= 2;
- before->children = talloc_realloc(mem_ctx, before->children,
- schedule_node *,
- before->child_array_size);
- before->child_latency = talloc_realloc(mem_ctx, before->child_latency,
- int, before->child_array_size);
+ before->children = reralloc(mem_ctx, before->children,
+ schedule_node *,
+ before->child_array_size);
+ before->child_latency = reralloc(mem_ctx, before->child_latency,
+ int, before->child_array_size);
}
before->children[before->child_count] = after;
ir_variable *components[4];
- /** talloc_parent(this->var) -- the shader's talloc context. */
+ /** ralloc_parent(this->var) -- the shader's ralloc context. */
void *mem_ctx;
};
public:
ir_vector_reference_visitor(void)
{
- this->mem_ctx = talloc_new(NULL);
+ this->mem_ctx = ralloc_context(NULL);
this->variable_list.make_empty();
}
~ir_vector_reference_visitor(void)
{
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
virtual ir_visitor_status visit(ir_variable *);
if (refs.variable_list.is_empty())
return false;
- void *mem_ctx = talloc_new(NULL);
+ void *mem_ctx = ralloc_context(NULL);
/* Replace the decls of the vectors to be split with their split
* components.
const struct glsl_type *type;
type = glsl_type::get_instance(entry->var->type->base_type, 1, 1);
- entry->mem_ctx = talloc_parent(entry->var);
+ entry->mem_ctx = ralloc_parent(entry->var);
for (unsigned int i = 0; i < entry->var->type->vector_elements; i++) {
- const char *name = talloc_asprintf(mem_ctx, "%s_%c",
+ const char *name = ralloc_asprintf(mem_ctx, "%s_%c",
entry->var->name,
"xyzw"[i]);
ir_vector_splitting_visitor split(&refs.variable_list);
visit_list_elements(&split, instructions);
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
return true;
}
#include "program/program.h"
#include "program/programopt.h"
#include "tnl/tnl.h"
-#include "talloc.h"
+#include "../glsl/ralloc.h"
#include "brw_context.h"
#include "brw_wm.h"
shader = _mesa_lookup_shader_program(ctx, prog->Id);
if (shader) {
- shader->InfoLog = talloc_strdup_append(shader->InfoLog, msg);
+ ralloc_strcat(&shader->InfoLog, msg);
shader->LinkStatus = GL_FALSE;
}
}
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/prog_uniform.h"
-#include "talloc.h"
+#include "ralloc.h"
#include <stdbool.h>
#include "../glsl/glsl_parser_extras.h"
if (!shProg->Validated) {
/* update info log */
if (shProg->InfoLog) {
- talloc_free(shProg->InfoLog);
+ ralloc_free(shProg->InfoLog);
}
- shProg->InfoLog = talloc_strdup(shProg, errMsg);
+ shProg->InfoLog = ralloc_strdup(shProg, errMsg);
}
}
#endif
}
- shProg->InfoLog = talloc_strdup_append(shProg->InfoLog, sh->InfoLog);
+ ralloc_strcat(&shProg->InfoLog, sh->InfoLog);
}
delete_shader(ctx, shader);
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/prog_uniform.h"
-#include "talloc.h"
+#include "ralloc.h"
/**********************************************************************/
/*** Shader object functions ***/
struct gl_shader *shader;
assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER ||
type == GL_GEOMETRY_SHADER_ARB);
- shader = talloc_zero(NULL, struct gl_shader);
+ shader = rzalloc(NULL, struct gl_shader);
if (shader) {
shader->Type = type;
shader->Name = name;
if (sh->Source)
free((void *) sh->Source);
_mesa_reference_program(ctx, &sh->Program, NULL);
- talloc_free(sh);
+ ralloc_free(sh);
}
_mesa_new_shader_program(struct gl_context *ctx, GLuint name)
{
struct gl_shader_program *shProg;
- shProg = talloc_zero(NULL, struct gl_shader_program);
+ shProg = rzalloc(NULL, struct gl_shader_program);
if (shProg) {
shProg->Name = name;
_mesa_init_shader_program(ctx, shProg);
}
if (shProg->InfoLog) {
- talloc_free(shProg->InfoLog);
+ ralloc_free(shProg->InfoLog);
shProg->InfoLog = NULL;
}
{
_mesa_free_shader_program_data(ctx, shProg);
- talloc_free(shProg);
+ ralloc_free(shProg);
}
class ir_to_mesa_instruction : public exec_node {
public:
- /* Callers of this talloc-based new need not call delete. It's
- * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
- node = talloc_zero_size(ctx, size);
+ node = rzalloc_size(ctx, size);
assert(node != NULL);
return node;
{
va_list args;
va_start(args, fmt);
- prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, args);
+ ralloc_vasprintf_append(&prog->InfoLog, fmt, args);
va_end(args);
prog->LinkStatus = GL_FALSE;
this->result, src_reg_for_float(element_size));
}
- src_reg.reladdr = talloc(mem_ctx, ir_to_mesa_src_reg);
+ src_reg.reladdr = ralloc(mem_ctx, ir_to_mesa_src_reg);
memcpy(src_reg.reladdr, &index_reg, sizeof(index_reg));
}
return entry;
}
- entry = talloc(mem_ctx, function_entry);
+ entry = ralloc(mem_ctx, function_entry);
entry->sig = sig;
entry->sig_id = this->next_signature_id++;
entry->bgn_inst = NULL;
next_temp = 1;
next_signature_id = 1;
current_function = NULL;
- mem_ctx = talloc_new(NULL);
+ mem_ctx = ralloc_context(NULL);
}
ir_to_mesa_visitor::~ir_to_mesa_visitor()
{
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
static struct prog_src_register
}
}
- if_stack = talloc_zero_array(v->mem_ctx, int, if_count);
- loop_stack = talloc_zero_array(v->mem_ctx, int, loop_count);
+ if_stack = rzalloc_array(v->mem_ctx, int, if_count);
+ loop_stack = rzalloc_array(v->mem_ctx, int, loop_count);
for (i = 0; i < num_instructions; i++) {
switch (mesa_instructions[i].Opcode) {
unsigned int next_sampler = 0, num_uniforms = 0;
struct uniform_sort *sorted_uniforms;
- sorted_uniforms = talloc_array(NULL, struct uniform_sort,
+ sorted_uniforms = ralloc_array(NULL, struct uniform_sort,
shader_program->Uniforms->NumUniforms);
for (i = 0; i < shader_program->Uniforms->NumUniforms; i++) {
}
}
- talloc_free(sorted_uniforms);
+ ralloc_free(sorted_uniforms);
}
static void
for (unsigned int i = 0; i < type->length; i++) {
const glsl_type *field_type = type->fields.structure[i].type;
- const char *field_name = talloc_asprintf(mem_ctx, "%s.%s", name,
+ const char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name,
type->fields.structure[i].name);
set_uniform_initializer(ctx, mem_ctx, shader_program, field_name,
field_type, field_constant);
void *values;
if (element_type->base_type == GLSL_TYPE_BOOL) {
- int *conv = talloc_array(mem_ctx, int, element_type->components());
+ int *conv = ralloc_array(mem_ctx, int, element_type->components());
for (unsigned int j = 0; j < element_type->components(); j++) {
conv[j] = element->value.b[j];
}
continue;
if (!mem_ctx)
- mem_ctx = talloc_new(NULL);
+ mem_ctx = ralloc_context(NULL);
set_uniform_initializer(ctx, mem_ctx, shader_program, var->name,
var->type, var->constant_value);
}
}
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
/*
void
ir_to_mesa_visitor::copy_propagate(void)
{
- ir_to_mesa_instruction **acp = talloc_zero_array(mem_ctx,
+ ir_to_mesa_instruction **acp = rzalloc_array(mem_ctx,
ir_to_mesa_instruction *,
this->next_temp * 4);
}
}
- talloc_free(acp);
+ ralloc_free(acp);
}
mesa_instructions =
(struct prog_instruction *)calloc(num_instructions,
sizeof(*mesa_instructions));
- mesa_instruction_annotation = talloc_array(v.mem_ctx, ir_instruction *,
+ mesa_instruction_annotation = ralloc_array(v.mem_ctx, ir_instruction *,
num_instructions);
v.copy_propagate();
_mesa_glsl_lexer_dtor(state);
}
- talloc_free(shader->ir);
+ ralloc_free(shader->ir);
shader->ir = new(shader) exec_list;
if (!state->error && !state->translation_unit.is_empty())
_mesa_ast_to_hir(shader->ir, state);
/* Retain any live IR, but trash the rest. */
reparent_ir(shader->ir, shader->ir);
- talloc_free(state);
+ ralloc_free(state);
if (shader->CompileStatus) {
if (!ctx->Driver.CompileShader(ctx, shader))
* Graph-coloring register allocator.
*/
-#include <talloc.h>
+#include <ralloc.h>
#include "main/imports.h"
#include "main/macros.h"
unsigned int i;
struct ra_regs *regs;
- regs = talloc_zero(NULL, struct ra_regs);
+ regs = rzalloc(NULL, struct ra_regs);
regs->count = count;
- regs->regs = talloc_zero_array(regs, struct ra_reg, count);
+ regs->regs = rzalloc_array(regs, struct ra_reg, count);
for (i = 0; i < count; i++) {
- regs->regs[i].conflicts = talloc_zero_array(regs->regs, GLboolean, count);
+ regs->regs[i].conflicts = rzalloc_array(regs->regs, GLboolean, count);
regs->regs[i].conflicts[i] = GL_TRUE;
- regs->regs[i].conflict_list = talloc_array(regs->regs, unsigned int, 4);
+ regs->regs[i].conflict_list = ralloc_array(regs->regs, unsigned int, 4);
regs->regs[i].conflict_list_size = 4;
regs->regs[i].conflict_list[0] = i;
regs->regs[i].num_conflicts = 1;
if (reg1->conflict_list_size == reg1->num_conflicts) {
reg1->conflict_list_size *= 2;
- reg1->conflict_list = talloc_realloc(regs->regs,
- reg1->conflict_list,
- unsigned int,
- reg1->conflict_list_size);
+ reg1->conflict_list = reralloc(regs->regs, reg1->conflict_list,
+ unsigned int, reg1->conflict_list_size);
}
reg1->conflict_list[reg1->num_conflicts++] = r2;
reg1->conflicts[r2] = GL_TRUE;
{
struct ra_class *class;
- regs->classes = talloc_realloc(regs->regs, regs->classes,
- struct ra_class *,
- regs->class_count + 1);
+ regs->classes = reralloc(regs->regs, regs->classes, struct ra_class *,
+ regs->class_count + 1);
- class = talloc_zero(regs, struct ra_class);
+ class = rzalloc(regs, struct ra_class);
regs->classes[regs->class_count] = class;
- class->regs = talloc_zero_array(class, GLboolean, regs->count);
+ class->regs = rzalloc_array(class, GLboolean, regs->count);
return regs->class_count++;
}
unsigned int b, c;
for (b = 0; b < regs->class_count; b++) {
- regs->classes[b]->q = talloc_array(regs, unsigned int, regs->class_count);
+ regs->classes[b]->q = ralloc_array(regs, unsigned int, regs->class_count);
}
/* Compute, for each class B and C, how many regs of B an
struct ra_graph *g;
unsigned int i;
- g = talloc_zero(regs, struct ra_graph);
+ g = rzalloc(regs, struct ra_graph);
g->regs = regs;
- g->nodes = talloc_zero_array(g, struct ra_node, count);
+ g->nodes = rzalloc_array(g, struct ra_node, count);
g->count = count;
- g->stack = talloc_zero_array(g, unsigned int, count);
+ g->stack = rzalloc_array(g, unsigned int, count);
for (i = 0; i < count; i++) {
- g->nodes[i].adjacency = talloc_zero_array(g, GLboolean, count);
- g->nodes[i].adjacency_list = talloc_array(g, unsigned int, count);
+ g->nodes[i].adjacency = rzalloc_array(g, GLboolean, count);
+ g->nodes[i].adjacency_list = ralloc_array(g, unsigned int, count);
g->nodes[i].adjacency_count = 0;
ra_add_node_adjacency(g, i, i);
g->nodes[i].reg = ~0;
{
va_list args;
va_start(args, fmt);
- prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, args);
+ ralloc_vasprintf_append(&prog->InfoLog, fmt, args);
va_end(args);
prog->LinkStatus = GL_FALSE;
get_sampler_name(ir_dereference *last,
struct gl_shader_program *shader_program)
{
- this->mem_ctx = talloc_new(NULL);
+ this->mem_ctx = ralloc_context(NULL);
this->shader_program = shader_program;
this->name = NULL;
this->offset = 0;
~get_sampler_name()
{
- talloc_free(this->mem_ctx);
+ ralloc_free(this->mem_ctx);
}
virtual ir_visitor_status visit(ir_dereference_variable *ir)
virtual ir_visitor_status visit_leave(ir_dereference_record *ir)
{
- this->name = talloc_asprintf(mem_ctx, "%s.%s", name, ir->field);
+ this->name = ralloc_asprintf(mem_ctx, "%s.%s", name, ir->field);
return visit_continue;
}
* all that would work would be an unrolled loop counter that ends
* up being constant above.
*/
- shader_program->InfoLog =
- talloc_asprintf_append(shader_program->InfoLog,
- "warning: Variable sampler array index "
- "unsupported.\nThis feature of the language "
- "was removed in GLSL 1.20 and is unlikely "
- "to be supported for 1.10 in Mesa.\n");
+ ralloc_strcat(&shader_program->InfoLog,
+ "warning: Variable sampler array index unsupported.\n"
+ "This feature of the language was removed in GLSL 1.20 "
+ "and is unlikely to be supported for 1.10 in Mesa.\n");
i = 0;
}
if (ir != last) {
- this->name = talloc_asprintf(mem_ctx, "%s[%d]", name, i);
+ this->name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i);
} else {
offset = i;
}