diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-12 12:40:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 12:40:54 +0200 |
commit | a7b1d85828dce68daea8cfdb4d2a17551bf33e11 (patch) | |
tree | 960bf5006c1106dbfd95d980aaff788b6a3a16e8 /servers/rendering | |
parent | 788f355ad2f8c1826f5e55477249934d45d62891 (diff) | |
parent | 0864c9abaa1dec1a8dcb4ddf65c80b86822383d3 (diff) |
Merge pull request #59825 from Chaosus/shader_fix
Fix incorrect parsing array's `length()` at return statement in shader
Diffstat (limited to 'servers/rendering')
-rw-r--r-- | servers/rendering/shader_language.cpp | 7 | ||||
-rw-r--r-- | servers/rendering/shader_language.h | 8 |
2 files changed, 6 insertions, 9 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index a0769ef106..816a02761d 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -5144,7 +5144,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (!call_expression) { return nullptr; } - data_type = call_expression->get_datatype(); } else if (tk.type == TK_BRACKET_OPEN) { // indexing index_expression = _parse_and_reduce_expression(p_block, p_function_info); if (!index_expression) { @@ -5598,15 +5597,13 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (p_block != nullptr) { p_block->block_tag = SubClassTag::TAG_ARRAY; } - Node *call_expression = _parse_and_reduce_expression(p_block, p_function_info); + mn->call_expression = _parse_and_reduce_expression(p_block, p_function_info); if (p_block != nullptr) { p_block->block_tag = SubClassTag::TAG_GLOBAL; } - if (!call_expression) { + if (!mn->call_expression) { return nullptr; } - mn->datatype = call_expression->get_datatype(); - mn->call_expression = call_expression; } else if (tk.type == TK_BRACKET_OPEN) { Node *index_expression = _parse_and_reduce_expression(p_block, p_function_info); if (!index_expression) { diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 25ec8760af..66ae220edf 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -451,8 +451,8 @@ public: int array_size = 0; bool is_local = false; - virtual DataType get_datatype() const override { return datatype_cache; } - virtual String get_datatype_name() const override { return String(struct_name); } + virtual DataType get_datatype() const override { return call_expression ? call_expression->get_datatype() : datatype_cache; } + virtual String get_datatype_name() const override { return call_expression ? call_expression->get_datatype_name() : String(struct_name); } virtual int get_array_size() const override { return (index_expression || call_expression) ? 0 : array_size; } virtual bool is_indexed() const override { return index_expression != nullptr; } @@ -558,8 +558,8 @@ public: Node *call_expression = nullptr; bool has_swizzling_duplicates = false; - virtual DataType get_datatype() const override { return datatype; } - virtual String get_datatype_name() const override { return String(struct_name); } + virtual DataType get_datatype() const override { return call_expression ? call_expression->get_datatype() : datatype; } + virtual String get_datatype_name() const override { return call_expression ? call_expression->get_datatype_name() : String(struct_name); } virtual int get_array_size() const override { return (index_expression || call_expression) ? 0 : array_size; } virtual bool is_indexed() const override { return index_expression != nullptr || call_expression != nullptr; } |