summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-06-29 22:17:55 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-06-29 22:17:55 -0300
commitcf0fbe493ff8e2dd80859d75a9794d364a03551c (patch)
treec1c35c486970345a0b99ee9894a9163444769690
parent36e754457fadef8f850db89cd0fa54d50ede5ab0 (diff)
Ability to put constants in constant expressions, closes #5264
-rw-r--r--modules/gdscript/gd_parser.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index e83bd3d21e..6c6560efa6 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -31,6 +31,7 @@
#include "io/resource_loader.h"
#include "os/file_access.h"
#include "script_language.h"
+#include "gd_script.h"
template<class T>
T* GDParser::alloc_node() {
@@ -494,6 +495,14 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
}
}
+ 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 ) {
IdentifierNode *id = alloc_node<IdentifierNode>();
id->name = identifier;