*/
#include "ir.h"
-#include "main/imports.h"
-#include "symbol_table.h"
#include "glsl_parser_extras.h"
#include "ast.h"
#include "glsl_types.h"
-struct ir_rvalue *
+ir_rvalue *
_mesa_ast_field_selection_to_hir(const ast_expression *expr,
exec_list *instructions,
struct _mesa_glsl_parse_state *state)
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ir_rvalue *result = NULL;
ir_rvalue *op;
YYLTYPE loc = expr->get_location();
if (op->type->is_error()) {
/* silently propagate the error */
- } else if (op->type->is_vector()) {
+ } else if (op->type->base_type == GLSL_TYPE_STRUCT
+ || op->type->base_type == GLSL_TYPE_INTERFACE) {
+ result = new(ctx) ir_dereference_record(op,
+ expr->primary_expression.identifier);
+
+ if (result->type->is_error()) {
+ _mesa_glsl_error(& loc, state, "cannot access field `%s' of "
+ "structure",
+ expr->primary_expression.identifier);
+ }
+ } else if (op->type->is_vector() ||
+ (state->has_420pack() && op->type->is_scalar())) {
ir_swizzle *swiz = ir_swizzle::create(op,
expr->primary_expression.identifier,
op->type->vector_elements);
* FINISHME: ir_swizzle::create. This allows the generation of more
* FINISHME: specific error messages.
*/
- _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'",
- expr->primary_expression.identifier);
- }
- } else if (op->type->base_type == GLSL_TYPE_STRUCT) {
- result = new(ctx) ir_dereference_record(op,
- expr->primary_expression.identifier);
-
- if (result->type->is_error()) {
- _mesa_glsl_error(& loc, state, "Cannot access field `%s' of "
- "structure",
+ _mesa_glsl_error(& loc, state, "invalid swizzle / mask `%s'",
expr->primary_expression.identifier);
}
} else {
- _mesa_glsl_error(& loc, state, "Cannot access field `%s' of "
- "non-structure / non-vector.",
+ _mesa_glsl_error(& loc, state, "cannot access field `%s' of "
+ "non-structure / non-vector",
expr->primary_expression.identifier);
}
- return result ? result : ir_call::get_error_instruction(ctx);
+ return result ? result : ir_rvalue::error_value(ctx);
}