summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gd_compiler.cpp7
-rw-r--r--modules/gdscript/gd_editor.cpp57
-rw-r--r--modules/gdscript/gd_functions.cpp1
-rw-r--r--modules/gdscript/gd_parser.cpp7
-rw-r--r--modules/gdscript/gd_script.cpp18
-rw-r--r--modules/gdscript/gd_script.h6
-rw-r--r--modules/gdscript/gd_tokenizer.cpp1
7 files changed, 37 insertions, 60 deletions
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
index 1f76f025d4..68c3dc98d3 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gd_compiler.cpp
@@ -460,7 +460,6 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
const GDParser::Node *instance = on->arguments[0];
- bool in_static=false;
if (instance->type==GDParser::Node::TYPE_SELF) {
//room for optimization
@@ -771,8 +770,6 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
Vector<int> setchain;
- int prev_key_idx=-1;
-
for(List<GDParser::OperatorNode*>::Element *E=chain.back();E;E=E->prev()) {
@@ -822,7 +819,6 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
setchain.push_back(named ? GDFunction::OPCODE_SET_NAMED : GDFunction::OPCODE_SET);
prev_pos=dst_pos;
- prev_key_idx=key_idx;
}
@@ -1211,7 +1207,6 @@ Error GDCompiler::_parse_function(GDScript *p_script,const GDParser::ClassNode *
if (p_func) {
for(int i=0;i<p_func->arguments.size();i++) {
- int idx = i;
codegen.add_stack_identifier(p_func->arguments[i],i);
#ifdef TOOLS_ENABLED
argnames.push_back(p_func->arguments[i]);
@@ -1441,6 +1436,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
p_script->member_functions.clear();
p_script->member_indices.clear();
p_script->member_info.clear();
+ p_script->_signals.clear();
p_script->initializer=NULL;
p_script->subclasses.clear();
@@ -1449,7 +1445,6 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
p_script->name=p_class->name;
- int index_from=0;
Ref<GDNativeClass> native;
if (p_class->extends_used) {
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 07a5a636d4..520a8b18d8 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -449,57 +449,21 @@ static Ref<Reference> _get_parent_class(GDCompletionContext& context) {
}
String base=context._class->extends_class[0];
- const GDParser::ClassNode *p = context._class->owner;
- Ref<GDScript> base_class;
-#if 0
- while(p) {
-
- if (p->subclasses.has(base)) {
-
- base_class=p->subclasses[base];
- break;
- }
- p=p->_owner;
- }
-#endif
- if (base_class.is_valid()) {
-#if 0
- for(int i=1;i<context._class->extends_class.size();i++) {
-
- String subclass=context._class->extends_class[i];
-
- if (base_class->subclasses.has(subclass)) {
-
- base_class=base_class->subclasses[subclass];
- } else {
-
- //print_line("Could not find subclass: "+subclass);
- return _get_type_from_class(context); //fail please
- }
- }
-
- script=base_class;
-#endif
-
- } else {
-
- if (context._class->extends_class.size()>1) {
- return REF();
+ if (context._class->extends_class.size()>1) {
+ return REF();
- }
- //if not found, try engine classes
- if (!GDScriptLanguage::get_singleton()->get_global_map().has(base)) {
-
- return REF();
- }
+ }
+ //if not found, try engine classes
+ if (!GDScriptLanguage::get_singleton()->get_global_map().has(base)) {
- int base_idx = GDScriptLanguage::get_singleton()->get_global_map()[base];
- native = GDScriptLanguage::get_singleton()->get_global_array()[base_idx];
- return native;
+ return REF();
}
+ int base_idx = GDScriptLanguage::get_singleton()->get_global_map()[base];
+ native = GDScriptLanguage::get_singleton()->get_global_array()[base_idx];
+ return native;
}
@@ -2100,10 +2064,8 @@ static void _find_call_arguments(GDCompletionContext& context,const GDParser::No
}
Error GDScriptLanguage::complete_code(const String& p_code, const String& p_base_path, Object*p_owner, List<String>* r_options, String &r_call_hint) {
- //print_line( p_code.replace(String::chr(0xFFFF),"<cursor>"));
GDParser p;
- //Error parse(const String& p_code, const String& p_base_path="", bool p_just_validate=false,const String& p_self_path="",bool p_for_completion=false);
Error err = p.parse(p_code,p_base_path,false,"",true);
bool isfunction=false;
@@ -2204,7 +2166,6 @@ Error GDScriptLanguage::complete_code(const String& p_code, const String& p_base
if (code!="") {
//if there is code, parse it. This way is slower but updates in real-time
GDParser p;
- //Error parse(const String& p_code, const String& p_base_path="", bool p_just_validate=false,const String& p_self_path="",bool p_for_completion=false);
Error err = p.parse(scr->get_source_code(),scr->get_path().get_base_dir(),true,"",false);
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index ec66841662..b9815a5efd 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -502,7 +502,6 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
Ref<FuncRef> fr = memnew( FuncRef);
- Object *obj = *p_args[0];
fr->set_instance(*p_args[0]);
fr->set_function(*p_args[1]);
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index c33bf00c7b..6a7cd5eb8c 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -514,8 +514,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
} 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) {
//single prefix operators like !expr -expr ++expr --expr
- OperatorNode *op = alloc_node<OperatorNode>();
-
+ alloc_node<OperatorNode>();
Expression e;
e.is_op=true;
@@ -1537,6 +1536,10 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
return;
}
tokenizer->advance();
+ if(tokenizer->get_token()==GDTokenizer::TK_SEMICOLON) {
+ // Ignore semicolon after 'pass'
+ tokenizer->advance();
+ }
} break;
case GDTokenizer::TK_PR_VAR: {
//variale declaration and (eventual) initialization
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index d9783c218a..d1946e2a63 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -1643,13 +1643,16 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script>& p_script,bool p_sof
}
#endif
+ for(Map<ObjectID,List<Pair<StringName,Variant> > >::Element *F=E->get()->pending_reload_state.front();F;F=F->next()) {
+ map[F->key()]=F->get(); //pending to reload, use this one instead
+ }
}
}
for(Map< Ref<GDScript>, Map<ObjectID,List<Pair<StringName,Variant> > > >::Element *E=to_reload.front();E;E=E->next()) {
Ref<GDScript> scr = E->key();
- scr->reload(true);
+ scr->reload(p_soft_reload);
//restore state if saved
for (Map<ObjectID,List<Pair<StringName,Variant> > >::Element *F=E->get().front();F;F=F->next()) {
@@ -1658,13 +1661,24 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script>& p_script,bool p_sof
if (!obj)
continue;
+ if (!p_soft_reload) {
+ //clear it just in case (may be a pending reload state)
+ obj->set_script(RefPtr());
+ }
obj->set_script(scr.get_ref_ptr());
- if (!obj->get_script_instance())
+ if (!obj->get_script_instance()) {
+ //failed, save reload state for next time if not saved
+ if (!scr->pending_reload_state.has(obj->get_instance_ID())) {
+ scr->pending_reload_state[obj->get_instance_ID()]=F->get();
+ }
continue;
+ }
for (List<Pair<StringName,Variant> >::Element *G=F->get().front();G;G=G->next()) {
obj->get_script_instance()->set(G->get().first,G->get().second);
}
+
+ scr->pending_reload_state.erase(obj->get_instance_ID()); //as it reloaded, remove pending state
}
//if instance states were saved, set them!
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h
index 723761c3a9..f0b6b7103c 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gd_script.h
@@ -120,7 +120,11 @@ friend class GDScriptLanguage;
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
#endif
+#ifdef DEBUG_ENABLED
+
+ Map<ObjectID,List<Pair<StringName,Variant> > > pending_reload_state;
+#endif
bool _update_exports();
@@ -265,6 +269,8 @@ class GDScriptLanguage : public ScriptLanguage {
Mutex *lock;
+
+
friend class GDScript;
SelfList<GDScript>::List script_list;
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp
index 0a77b96569..93863c4eb2 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gd_tokenizer.cpp
@@ -1156,7 +1156,6 @@ Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String& p_code) {
GDTokenizerText tt;
tt.set_code(p_code);
int line=-1;
- int col=0;
while(true) {