diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2020-01-18 11:54:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-18 11:54:23 +0300 |
commit | 82482a7db80c7d5fc326830d1ab7cb5b0dc70432 (patch) | |
tree | 30c4cbcf99d54a3b4d9017dd860922f5fd23db06 | |
parent | ea1da40d799bf1bed338c46686e5fb35bfbed50b (diff) | |
parent | 1eb8d5e142b65ddf02f9a4950ea1b2d604874206 (diff) |
Merge pull request #35266 from Chaosus/shader_fix_arrays
Added missing form of array constructor in shaders
-rw-r--r-- | servers/visual/shader_language.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 2b61d72f6a..3e0a28ac1d 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -3964,33 +3964,42 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui tk = _get_token(); if (tk.type == TK_BRACKET_OPEN) { - Node *n = _parse_and_reduce_expression(p_block, p_builtin_types); - if (!n || n->type != Node::TYPE_CONSTANT || n->get_datatype() != TYPE_INT) { - _set_error("Expected single integer constant > 0"); - return ERR_PARSE_ERROR; - } + TkPos pos2 = _get_tkpos(); + tk = _get_token(); + if (tk.type == TK_BRACKET_CLOSE) { + array_size2 = var.array_size; + tk = _get_token(); + } else { + _set_tkpos(pos2); - ConstantNode *cnode = (ConstantNode *)n; - if (cnode->values.size() == 1) { - array_size2 = cnode->values[0].sint; - if (array_size2 <= 0) { + Node *n = _parse_and_reduce_expression(p_block, p_builtin_types); + if (!n || n->type != Node::TYPE_CONSTANT || n->get_datatype() != TYPE_INT) { + _set_error("Expected single integer constant > 0"); + return ERR_PARSE_ERROR; + } + + ConstantNode *cnode = (ConstantNode *)n; + if (cnode->values.size() == 1) { + array_size2 = cnode->values[0].sint; + if (array_size2 <= 0) { + _set_error("Expected single integer constant > 0"); + return ERR_PARSE_ERROR; + } + } else { _set_error("Expected single integer constant > 0"); return ERR_PARSE_ERROR; } - } else { - _set_error("Expected single integer constant > 0"); - return ERR_PARSE_ERROR; - } - tk = _get_token(); - if (tk.type != TK_BRACKET_CLOSE) { - _set_error("Expected ']"); - return ERR_PARSE_ERROR; - } else { tk = _get_token(); + if (tk.type != TK_BRACKET_CLOSE) { + _set_error("Expected ']'"); + return ERR_PARSE_ERROR; + } else { + tk = _get_token(); + } } } else { - _set_error("Expected '["); + _set_error("Expected '['"); return ERR_PARSE_ERROR; } |