Commit 9b3e6b19 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3dcompiler: Add the assignment node to the instruction list in make_assignment().

parent 95ef2fa5
......@@ -1057,6 +1057,9 @@ static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type t
node->loc = loc;
}
struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs,
enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN;
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN;
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN;
......@@ -1076,8 +1079,6 @@ struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
struct source_location *loc) DECLSPEC_HIDDEN;
struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type,
struct source_location *loc) DECLSPEC_HIDDEN;
struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assign_op assign_op,
struct hlsl_ir_node *right) DECLSPEC_HIDDEN;
void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
void init_functions_tree(struct wine_rb_tree *funcs) DECLSPEC_HIDDEN;
......
......@@ -777,7 +777,6 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
struct hlsl_type *type;
struct parse_variable_def *v, *v_next;
struct hlsl_ir_var *var;
struct hlsl_ir_node *assignment;
BOOL ret, local = TRUE;
struct list *statements_list = d3dcompiler_alloc(sizeof(*statements_list));
......@@ -892,9 +891,8 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
load = new_var_load(var, var->loc);
list_add_tail(v->initializer.instrs, &load->node.entry);
assignment = make_assignment(&load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]);
add_assignment(v->initializer.instrs, &load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]);
d3dcompiler_free(v->initializer.args);
list_add_tail(v->initializer.instrs, &assignment->entry);
if (modifiers & HLSL_STORAGE_STATIC)
list_move_tail(&hlsl_ctx.static_initializers, v->initializer.instrs);
......@@ -2722,24 +2720,24 @@ conditional_expr: logicor_expr
FIXME("ternary operator\n");
}
assignment_expr: conditional_expr
{
$$ = $1;
}
| unary_expr assign_op assignment_expr
{
struct hlsl_ir_node *instr;
assignment_expr:
if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "l-value is const");
YYABORT;
}
if (!(instr = make_assignment(node_from_list($1), $2, node_from_list($3))))
YYABORT;
instr->loc = get_location(&@2);
$$ = append_binop($3, $1, instr);
}
conditional_expr
| unary_expr assign_op assignment_expr
{
struct hlsl_ir_node *lhs = node_from_list($1), *rhs = node_from_list($3);
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "l-value is const");
YYABORT;
}
list_move_tail($3, $1);
d3dcompiler_free($1);
if (!add_assignment($3, lhs, $2, rhs))
YYABORT;
$$ = $3;
}
assign_op: '='
{
......
......@@ -1443,8 +1443,8 @@ static BOOL invert_swizzle(unsigned int *swizzle, unsigned int *writemask, unsig
return TRUE;
}
struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign_op assign_op,
struct hlsl_ir_node *rhs)
struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs,
enum parse_assign_op assign_op, struct hlsl_ir_node *rhs)
{
struct hlsl_ir_assignment *assign = d3dcompiler_alloc(sizeof(*assign));
struct hlsl_type *lhs_type;
......@@ -1524,6 +1524,7 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
rhs = expr;
}
assign->rhs = rhs;
list_add_tail(instrs, &assign->node.entry);
return &assign->node;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment