diff options
author | Bernhard Liebl <Bernhard.Liebl@gmx.org> | 2018-01-18 22:03:34 +0100 |
---|---|---|
committer | Bernhard Liebl <Bernhard.Liebl@gmx.org> | 2018-01-18 22:13:00 +0100 |
commit | be5517123101fe669ebfc3d3f16a0431ca2804dd (patch) | |
tree | 6539df7c4a91d1629a90ac2442a50f0eb07f3d66 /modules/gdscript/gdscript_parser.cpp | |
parent | d0d511b0f8d9cb4d48c861b2c097fa15876f432c (diff) | |
download | redot-engine-be5517123101fe669ebfc3d3f16a0431ca2804dd.tar.gz |
Add Color.from_hsv()
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 2a6d37812e..c2097a49d4 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -578,18 +578,47 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (identifier == StringName()) { - _set_error("Built-in type constant expected after '.'"); + _set_error("Built-in type constant or static function expected after '.'"); return NULL; } if (!Variant::has_numeric_constant(bi_type, identifier)) { - _set_error("Static constant '" + identifier.operator String() + "' not present in built-in type " + Variant::get_type_name(bi_type) + "."); - return NULL; - } + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN && + Variant::is_method_const(bi_type, identifier) && + Variant::get_method_return_type(bi_type, identifier) == bi_type) { + + tokenizer->advance(); + + OperatorNode *construct = alloc_node<OperatorNode>(); + construct->op = OperatorNode::OP_CALL; + + TypeNode *tn = alloc_node<TypeNode>(); + tn->vtype = bi_type; + construct->arguments.push_back(tn); + + OperatorNode *op = alloc_node<OperatorNode>(); + op->op = OperatorNode::OP_CALL; + op->arguments.push_back(construct); + + IdentifierNode *id = alloc_node<IdentifierNode>(); + id->name = identifier; + op->arguments.push_back(id); + + if (!_parse_arguments(op, op->arguments, p_static, true)) + return NULL; + + expr = op; + } else { - ConstantNode *cn = alloc_node<ConstantNode>(); - cn->value = Variant::get_numeric_constant_value(bi_type, identifier); - expr = cn; + _set_error("Static constant '" + identifier.operator String() + "' not present in built-in type " + Variant::get_type_name(bi_type) + "."); + return NULL; + } + } else { + + ConstantNode *cn = alloc_node<ConstantNode>(); + cn->value = Variant::get_numeric_constant_value(bi_type, identifier); + expr = cn; + } } else if (tokenizer->get_token(1) == GDScriptTokenizer::TK_PARENTHESIS_OPEN && tokenizer->is_token_literal()) { // We check with is_token_literal, as this allows us to use match/sync/etc. as a name |