Fixes to constants in scope
This commit is contained in:
parent
6572d51288
commit
f1d3b30a45
2 changed files with 47 additions and 32 deletions
|
@ -185,7 +185,10 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
|
|||
|
||||
//TRY CLASS CONSTANTS
|
||||
|
||||
GDScript *scr = codegen.script;
|
||||
GDScript *owner = codegen.script;
|
||||
while (owner) {
|
||||
|
||||
GDScript *scr = owner;
|
||||
GDNativeClass *nc=NULL;
|
||||
while(scr) {
|
||||
|
||||
|
@ -224,12 +227,17 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
|
|||
|
||||
}
|
||||
|
||||
owner=owner->_owner;
|
||||
}
|
||||
|
||||
/*
|
||||
handled in constants now
|
||||
if (codegen.script->subclasses.has(identifier)) {
|
||||
//same with a subclass, make it a local constant.
|
||||
int idx = codegen.get_constant_pos(codegen.script->subclasses[identifier]);
|
||||
return idx|(GDFunction::ADDR_TYPE_LOCAL_CONSTANT<<GDFunction::ADDR_BITS); //make it a local constant (faster access)
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) {
|
||||
|
||||
|
@ -1457,6 +1465,8 @@ Error GDCompiler::_parse_class(GDScript *p_script,GDScript *p_owner,const GDPars
|
|||
Error err = _parse_class(subclass.ptr(),p_script,p_class->subclasses[i]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
p_script->constants.insert(name,subclass); //once parsed, goes to the list of constants
|
||||
p_script->subclasses.insert(name,subclass);
|
||||
|
||||
}
|
||||
|
|
|
@ -76,17 +76,22 @@ Variant *GDFunction::_get_variant(int p_address,GDInstance *p_instance,GDScript
|
|||
case ADDR_TYPE_CLASS_CONSTANT: {
|
||||
|
||||
//todo change to index!
|
||||
GDScript *s=p_script;
|
||||
GDScript *o=p_script;
|
||||
ERR_FAIL_INDEX_V(address,_global_names_count,NULL);
|
||||
const StringName *sn = &_global_names_ptr[address];
|
||||
|
||||
while(o) {
|
||||
GDScript *s=o;
|
||||
while(s) {
|
||||
|
||||
Map<StringName,Variant>::Element *E=s->constants.find(*sn);
|
||||
if (E) {
|
||||
return &E->get();
|
||||
}
|
||||
s=s->_base;
|
||||
}
|
||||
o=o->_owner;
|
||||
}
|
||||
|
||||
|
||||
ERR_EXPLAIN("GDCompiler bug..");
|
||||
|
|
Loading…
Add table
Reference in a new issue