diff options
author | marha <marha@users.sourceforge.net> | 2012-04-10 10:49:59 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-04-10 10:49:59 +0200 |
commit | c6f80401dc533b04341afe8d596960d1bc25efce (patch) | |
tree | 2826007946218a8370d2eebc6aa32083618e2bfe /mesalib/src/glsl/ir_reader.cpp | |
parent | 31706e67674f308e3e7f2a8aaf02f1e0a00fbade (diff) | |
download | vcxsrv-c6f80401dc533b04341afe8d596960d1bc25efce.tar.gz vcxsrv-c6f80401dc533b04341afe8d596960d1bc25efce.tar.bz2 vcxsrv-c6f80401dc533b04341afe8d596960d1bc25efce.zip |
fontconfig mesa xkeyboard-config xserver pixman git update 10 Apr 2012
Diffstat (limited to 'mesalib/src/glsl/ir_reader.cpp')
-rw-r--r-- | mesalib/src/glsl/ir_reader.cpp | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp index 6f50cc439..7ce683ef7 100644 --- a/mesalib/src/glsl/ir_reader.cpp +++ b/mesalib/src/glsl/ir_reader.cpp @@ -51,16 +51,17 @@ private: ir_variable *read_declaration(s_expression *); ir_if *read_if(s_expression *, ir_loop *); ir_loop *read_loop(s_expression *); + ir_call *read_call(s_expression *); ir_return *read_return(s_expression *); ir_rvalue *read_rvalue(s_expression *); ir_assignment *read_assignment(s_expression *); ir_expression *read_expression(s_expression *); - ir_call *read_call(s_expression *); ir_swizzle *read_swizzle(s_expression *); ir_constant *read_constant(s_expression *); ir_texture *read_texture(s_expression *); ir_dereference *read_dereference(s_expression *); + ir_dereference_variable *read_var_ref(s_expression *); }; ir_reader::ir_reader(_mesa_glsl_parse_state *state) : state(state) @@ -348,6 +349,8 @@ ir_reader::read_instruction(s_expression *expr, ir_loop *loop_ctx) inst = read_if(list, loop_ctx); } else if (strcmp(tag->value(), "loop") == 0) { inst = read_loop(list); + } else if (strcmp(tag->value(), "call") == 0) { + inst = read_call(list); } else if (strcmp(tag->value(), "return") == 0) { inst = read_return(list); } else if (strcmp(tag->value(), "function") == 0) { @@ -521,8 +524,6 @@ ir_reader::read_rvalue(s_expression *expr) rvalue = read_swizzle(list); } else if (strcmp(tag->value(), "expression") == 0) { rvalue = read_expression(list); - } else if (strcmp(tag->value(), "call") == 0) { - rvalue = read_call(list); } else if (strcmp(tag->value(), "constant") == 0) { rvalue = read_constant(list); } else { @@ -610,10 +611,20 @@ ir_reader::read_call(s_expression *expr) { s_symbol *name; s_list *params; + s_list *s_return = NULL; - s_pattern pat[] = { "call", name, params }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "expected (call <name> (<param> ...))"); + ir_dereference_variable *return_deref = NULL; + + s_pattern void_pat[] = { "call", name, params }; + s_pattern non_void_pat[] = { "call", name, s_return, params }; + if (MATCH(expr, non_void_pat)) { + return_deref = read_var_ref(s_return); + if (return_deref == NULL) { + ir_read_error(s_return, "when reading a call's return storage"); + return NULL; + } + } else if (!MATCH(expr, void_pat)) { + ir_read_error(expr, "expected (call <name> [<deref>] (<param> ...))"); return NULL; } @@ -643,7 +654,15 @@ ir_reader::read_call(s_expression *expr) return NULL; } - return new(mem_ctx) ir_call(callee, ¶meters); + if (callee->return_type == glsl_type::void_type && return_deref) { + ir_read_error(expr, "call has return value storage but void type"); + return NULL; + } else if (callee->return_type != glsl_type::void_type && !return_deref) { + ir_read_error(expr, "call has non-void type but no return value storage"); + return NULL; + } + + return new(mem_ctx) ir_call(callee, return_deref, ¶meters); } ir_expression * @@ -828,17 +847,11 @@ ir_reader::read_constant(s_expression *expr) return new(mem_ctx) ir_constant(type, &data); } -ir_dereference * -ir_reader::read_dereference(s_expression *expr) +ir_dereference_variable * +ir_reader::read_var_ref(s_expression *expr) { s_symbol *s_var; - s_expression *s_subject; - s_expression *s_index; - s_symbol *s_field; - s_pattern var_pat[] = { "var_ref", s_var }; - s_pattern array_pat[] = { "array_ref", s_subject, s_index }; - s_pattern record_pat[] = { "record_ref", s_subject, s_field }; if (MATCH(expr, var_pat)) { ir_variable *var = state->symbols->get_variable(s_var->value()); @@ -847,6 +860,23 @@ ir_reader::read_dereference(s_expression *expr) return NULL; } return new(mem_ctx) ir_dereference_variable(var); + } + return NULL; +} + +ir_dereference * +ir_reader::read_dereference(s_expression *expr) +{ + s_expression *s_subject; + s_expression *s_index; + s_symbol *s_field; + + s_pattern array_pat[] = { "array_ref", s_subject, s_index }; + s_pattern record_pat[] = { "record_ref", s_subject, s_field }; + + ir_dereference_variable *var_ref = read_var_ref(expr); + if (var_ref != NULL) { + return var_ref; } else if (MATCH(expr, array_pat)) { ir_rvalue *subject = read_rvalue(s_subject); if (subject == NULL) { |