summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-05-01 11:34:10 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-05-01 11:34:10 -0300
commit6572d5128856b2ec55a2c417c92e584899f4906f (patch)
tree9e01d6efab14567bfff5dd7b8b3b858d83b1868e /modules
parent4dc4e96c8a4fb7e34ecae3a39ef0f3f3fb275e97 (diff)
-Fixes to OpenSSL compilation (more)
-Fix bug in GDScript, now static functions can call static functions.
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gd_compiler.cpp7
-rw-r--r--modules/gdscript/gd_script.cpp5
-rw-r--r--modules/gdscript/gd_script.h20
3 files changed, 22 insertions, 10 deletions
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
index dd2834bf34..90c83c201b 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gd_compiler.cpp
@@ -452,6 +452,7 @@ 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
@@ -465,7 +466,10 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
int ret;
- if (i==1) {
+ if (i==0 && on->arguments[i]->type==GDParser::Node::TYPE_SELF && codegen.function_node && codegen.function_node->_static) {
+ //static call to self
+ ret=(GDFunction::ADDR_TYPE_CLASS<<GDFunction::ADDR_BITS);
+ } else if (i==1) {
if (on->arguments[i]->type!=GDParser::Node::TYPE_IDENTIFIER) {
_set_error("Attempt to call a non-identifier.",on);
@@ -475,6 +479,7 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
ret=codegen.get_name_map_pos(id->name);
} else {
+
ret = _parse_expression(codegen,on->arguments[i],slevel);
if (ret<0)
return ret;
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 75bb47ceab..299a7d3e54 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -61,6 +61,10 @@ Variant *GDFunction::_get_variant(int p_address,GDInstance *p_instance,GDScript
}
return &self;
} break;
+ case ADDR_TYPE_CLASS: {
+
+ return &p_script->_static_ref;
+ } break;
case ADDR_TYPE_MEMBER: {
//member indexing is O(1)
if (!p_instance) {
@@ -1678,6 +1682,7 @@ Ref<GDScript> GDScript::get_base() const {
GDScript::GDScript() {
+ _static_ref=this;
valid=false;
subclass_count=0;
initializer=NULL;
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h
index 55bc547e8d..983899240a 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gd_script.h
@@ -75,13 +75,14 @@ public:
ADDR_MASK=((1<<ADDR_BITS)-1),
ADDR_TYPE_MASK=~ADDR_MASK,
ADDR_TYPE_SELF=0,
- ADDR_TYPE_MEMBER=1,
- ADDR_TYPE_CLASS_CONSTANT=2,
- ADDR_TYPE_LOCAL_CONSTANT=3,
- ADDR_TYPE_STACK=4,
- ADDR_TYPE_STACK_VARIABLE=5,
- ADDR_TYPE_GLOBAL=6,
- ADDR_TYPE_NIL=7
+ ADDR_TYPE_CLASS=1,
+ ADDR_TYPE_MEMBER=2,
+ ADDR_TYPE_CLASS_CONSTANT=3,
+ ADDR_TYPE_LOCAL_CONSTANT=4,
+ ADDR_TYPE_STACK=5,
+ ADDR_TYPE_STACK_VARIABLE=6,
+ ADDR_TYPE_GLOBAL=7,
+ ADDR_TYPE_NIL=8
};
struct StackDebug {
@@ -139,9 +140,9 @@ public:
int get_max_stack_size() const;
int get_default_argument_count() const;
int get_default_argument_addr(int p_idx) const;
- GDScript *get_script() const { return _script; }
+ GDScript *get_script() const { return _script; }
- void debug_get_stack_member_state(int p_line,List<Pair<StringName,int> > *r_stackvars) const;
+ void debug_get_stack_member_state(int p_line,List<Pair<StringName,int> > *r_stackvars) const;
_FORCE_INLINE_ bool is_empty() const { return _code_size==0; }
@@ -183,6 +184,7 @@ friend class GDInstance;
friend class GDFunction;
friend class GDCompiler;
friend class GDFunctions;
+ Variant _static_ref; //used for static call
Ref<GDNativeClass> native;
Ref<GDScript> base;
GDScript *_base; //fast pointer access