summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/doc_classes/GDScript.xml4
-rw-r--r--modules/gdscript/doc_classes/GDScriptFunctionState.xml2
-rw-r--r--modules/gdscript/doc_classes/GDScriptNativeClass.xml2
-rw-r--r--modules/gdscript/gdscript_compiler.cpp38
-rw-r--r--modules/gdscript/gdscript_parser.cpp4
5 files changed, 29 insertions, 21 deletions
diff --git a/modules/gdscript/doc_classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml
index ba7d56a3b2..59cb00e3f6 100644
--- a/modules/gdscript/doc_classes/GDScript.xml
+++ b/modules/gdscript/doc_classes/GDScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScript" inherits="Script" category="Core" version="3.0-rc1">
+<class name="GDScript" inherits="Script" category="Core" version="3.0-stable">
<brief_description>
A script implemented in the GDScript programming language.
</brief_description>
@@ -8,7 +8,7 @@
[method new] creates a new instance of the script. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
</description>
<tutorials>
- http://docs.godotengine.org/en/3.0/learning/scripting/gdscript/index.html
+ http://docs.godotengine.org/en/3.0/getting_started/scripting/gdscript/index.html
</tutorials>
<demos>
</demos>
diff --git a/modules/gdscript/doc_classes/GDScriptFunctionState.xml b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
index e670635aa4..8510136f68 100644
--- a/modules/gdscript/doc_classes/GDScriptFunctionState.xml
+++ b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScriptFunctionState" inherits="Reference" category="Core" version="3.0-rc1">
+<class name="GDScriptFunctionState" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
State of a function call after yielding.
</brief_description>
diff --git a/modules/gdscript/doc_classes/GDScriptNativeClass.xml b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
index dfd4703f36..48826ec1e0 100644
--- a/modules/gdscript/doc_classes/GDScriptNativeClass.xml
+++ b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScriptNativeClass" inherits="Reference" category="Core" version="3.0-rc1">
+<class name="GDScriptNativeClass" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index f380bedf7f..1649fb52f2 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -37,6 +37,9 @@ bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringN
if (!codegen.function_node || codegen.function_node->_static)
return false;
+ if (codegen.stack_identifiers.has(p_name))
+ return false; //shadowed
+
return _is_class_member_property(codegen.script, p_name);
}
@@ -184,6 +187,14 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
StringName identifier = in->name;
+ // TRY STACK!
+ if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
+
+ int pos = codegen.stack_identifiers[identifier];
+ return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS);
+ }
+
+ // TRY CLASS MEMBER
if (_is_class_member_property(codegen, identifier)) {
//get property
codegen.opcodes.push_back(GDScriptFunction::OPCODE_GET_MEMBER); // perform operator
@@ -194,12 +205,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
return dst_addr;
}
- // TRY STACK!
- if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
-
- int pos = codegen.stack_identifiers[identifier];
- return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS);
- }
//TRY MEMBERS!
if (!codegen.function_node || !codegen.function_node->_static) {
@@ -1336,10 +1341,12 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(s);
- if (_is_class_member_property(codegen, lv->name)) {
- _set_error("Name for local variable '" + String(lv->name) + "' can't shadow class property of the same name.", lv);
- return ERR_ALREADY_EXISTS;
- }
+ // since we are using properties now for most class access, allow shadowing of class members to make user's life easier.
+ //
+ //if (_is_class_member_property(codegen, lv->name)) {
+ // _set_error("Name for local variable '" + String(lv->name) + "' can't shadow class property of the same name.", lv);
+ // return ERR_ALREADY_EXISTS;
+ //}
codegen.add_stack_identifier(lv->name, p_stack_level++);
codegen.alloc_stack(p_stack_level);
@@ -1376,10 +1383,13 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
if (p_func) {
for (int i = 0; i < p_func->arguments.size(); i++) {
- if (_is_class_member_property(p_script, p_func->arguments[i])) {
- _set_error("Name for argument '" + String(p_func->arguments[i]) + "' can't shadow class property of the same name.", p_func);
- return ERR_ALREADY_EXISTS;
- }
+ // since we are using properties now for most class access, allow shadowing of class members to make user's life easier.
+ //
+ //if (_is_class_member_property(p_script, p_func->arguments[i])) {
+ // _set_error("Name for argument '" + String(p_func->arguments[i]) + "' can't shadow class property of the same name.", p_func);
+ // return ERR_ALREADY_EXISTS;
+ //}
+
codegen.add_stack_identifier(p_func->arguments[i], i);
#ifdef TOOLS_ENABLED
argnames.push_back(p_func->arguments[i]);
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 75fb7e15c4..1392323d56 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -95,8 +95,6 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
int indent = tokenizer->get_token_line_indent();
int current = tab_level.back()->get();
if (indent <= current) {
- print_line("current: " + itos(current) + " indent: " + itos(indent));
- print_line("less than current");
return false;
}
@@ -460,7 +458,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
//this can be too slow for just validating code
if (for_completion && ScriptCodeCompletionCache::get_singleton()) {
res = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(path);
- } else if (FileAccess::exists(path)) {
+ } else { // essential; see issue 15902
res = ResourceLoader::load(path);
}
if (!res.is_valid()) {