diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-10-27 22:42:21 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-10-27 22:42:21 -0300 |
commit | bde9528a847c4e0301fea509f815e6642245be8a (patch) | |
tree | f95003f0d6209e210164f79600872e7564e81c18 | |
parent | 4e31faab4a4d1a7d0d8786a07ee1210fd89c4245 (diff) | |
parent | 1317d20740470857308650095ac1fe50afd306e2 (diff) |
Merge pull request #832 from grabiller/#391
seems ok!
-rw-r--r-- | modules/gdscript/gd_parser.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 46eade0b7c..915fb1e60f 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -372,10 +372,26 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ } else if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER) { //identifier (reference) - IdentifierNode *id = alloc_node<IdentifierNode>(); - id->name=tokenizer->get_token_identifier(); - tokenizer->advance(); - expr=id; + const ClassNode* cln = static_cast<const ClassNode*>(get_parse_tree()); + bool bfn = false; + StringName idn( tokenizer->get_token_identifier() ); + + for( int i=0; i<cln->constant_expressions.size(); ++i ) { + + if( cln->constant_expressions[i].identifier == idn ) { + tokenizer->advance(); + expr = cln->constant_expressions[i].expression; + bfn = true; + break; + } + } + + if( !bfn ) { + IdentifierNode *id = alloc_node<IdentifierNode>(); + id->name = idn; + tokenizer->advance(); + expr = id; + } } else if (/*tokenizer->get_token()==GDTokenizer::TK_OP_ADD ||*/ tokenizer->get_token()==GDTokenizer::TK_OP_SUB || tokenizer->get_token()==GDTokenizer::TK_OP_NOT || tokenizer->get_token()==GDTokenizer::TK_OP_BIT_INVERT) { @@ -1179,7 +1195,7 @@ GDParser::Node* GDParser::_reduce_expression(Node *p_node,bool p_to_const) { case OperatorNode::OP_ASSIGN_BIT_XOR: { if (op->arguments[0]->type==Node::TYPE_CONSTANT) { - _set_error("Can't assign to constant"); + _set_error("Can't assign to constant",tokenizer->get_token_line()-1); return op; } |