Only check for constants when parsing constants, should close #5497
This commit is contained in:
parent
cf0fbe493f
commit
e49b73e93a
|
@ -217,7 +217,7 @@ bool GDParser::_get_completable_identifier(CompletionType p_type,StringName& ide
|
|||
}
|
||||
|
||||
|
||||
GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_allow_assign) {
|
||||
GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_allow_assign,bool p_parsing_constant) {
|
||||
|
||||
// Vector<Node*> expressions;
|
||||
// Vector<OperatorNode::Operator> operators;
|
||||
|
@ -244,7 +244,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||
//subexpression ()
|
||||
tokenizer->advance();
|
||||
parenthesis++;
|
||||
Node* subexpr = _parse_expression(p_parent,p_static);
|
||||
Node* subexpr = _parse_expression(p_parent,p_static,p_allow_assign,p_parsing_constant);
|
||||
parenthesis--;
|
||||
if (!subexpr)
|
||||
return NULL;
|
||||
|
@ -485,22 +485,24 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||
|
||||
}
|
||||
|
||||
for( int i=0; i<cln->constant_expressions.size(); ++i ) {
|
||||
if (p_parsing_constant) {
|
||||
for( int i=0; i<cln->constant_expressions.size(); ++i ) {
|
||||
|
||||
if( cln->constant_expressions[i].identifier == identifier ) {
|
||||
if( cln->constant_expressions[i].identifier == identifier ) {
|
||||
|
||||
expr = cln->constant_expressions[i].expression;
|
||||
bfn = true;
|
||||
break;
|
||||
expr = cln->constant_expressions[i].expression;
|
||||
bfn = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) {
|
||||
//check from constants
|
||||
ConstantNode *constant = alloc_node<ConstantNode>();
|
||||
constant->value = GDScriptLanguage::get_singleton()->get_global_array()[ GDScriptLanguage::get_singleton()->get_global_map()[identifier] ];
|
||||
expr=constant;
|
||||
bfn = true;
|
||||
if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) {
|
||||
//check from constants
|
||||
ConstantNode *constant = alloc_node<ConstantNode>();
|
||||
constant->value = GDScriptLanguage::get_singleton()->get_global_array()[ GDScriptLanguage::get_singleton()->get_global_map()[identifier] ];
|
||||
expr=constant;
|
||||
bfn = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !bfn ) {
|
||||
|
@ -576,7 +578,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||
_set_error("',' or ']' expected");
|
||||
return NULL;
|
||||
}
|
||||
Node *n = _parse_expression(arr,p_static);
|
||||
Node *n = _parse_expression(arr,p_static,p_allow_assign,p_parsing_constant);
|
||||
if (!n)
|
||||
return NULL;
|
||||
arr->elements.push_back(n);
|
||||
|
@ -683,7 +685,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||
expecting=DICT_EXPECT_VALUE;
|
||||
} else {
|
||||
//python/js style more flexible
|
||||
key = _parse_expression(dict,p_static);
|
||||
key = _parse_expression(dict,p_static,p_allow_assign,p_parsing_constant);
|
||||
if (!key)
|
||||
return NULL;
|
||||
expecting=DICT_EXPECT_COLON;
|
||||
|
@ -691,7 +693,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||
}
|
||||
|
||||
if (expecting==DICT_EXPECT_VALUE) {
|
||||
Node *value = _parse_expression(dict,p_static);
|
||||
Node *value = _parse_expression(dict,p_static,p_allow_assign,p_parsing_constant);
|
||||
if (!value)
|
||||
return NULL;
|
||||
expecting=DICT_EXPECT_COMMA;
|
||||
|
@ -842,7 +844,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||
|
||||
tokenizer->advance(1);
|
||||
|
||||
Node *subexpr = _parse_expression(op,p_static);
|
||||
Node *subexpr = _parse_expression(op,p_static,p_allow_assign,p_parsing_constant);
|
||||
if (!subexpr) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1441,7 +1443,7 @@ GDParser::Node* GDParser::_reduce_expression(Node *p_node,bool p_to_const) {
|
|||
|
||||
GDParser::Node* GDParser::_parse_and_reduce_expression(Node *p_parent,bool p_static,bool p_reduce_const,bool p_allow_assign) {
|
||||
|
||||
Node* expr=_parse_expression(p_parent,p_static,p_allow_assign);
|
||||
Node* expr=_parse_expression(p_parent,p_static,p_allow_assign,p_reduce_const);
|
||||
if (!expr || error_set)
|
||||
return NULL;
|
||||
expr = _reduce_expression(expr,p_reduce_const);
|
||||
|
|
|
@ -435,7 +435,7 @@ private:
|
|||
bool _parse_arguments(Node* p_parent, Vector<Node*>& p_args, bool p_static, bool p_can_codecomplete=false);
|
||||
bool _enter_indent_block(BlockNode *p_block=NULL);
|
||||
bool _parse_newline();
|
||||
Node* _parse_expression(Node *p_parent,bool p_static,bool p_allow_assign=false);
|
||||
Node* _parse_expression(Node *p_parent, bool p_static, bool p_allow_assign=false, bool p_parsing_constant=false);
|
||||
Node* _reduce_expression(Node *p_node,bool p_to_const=false);
|
||||
Node* _parse_and_reduce_expression(Node *p_parent,bool p_static,bool p_reduce_const=false,bool p_allow_assign=false);
|
||||
|
||||
|
|
Loading…
Reference in New Issue