diff options
| author | Rémi Verschelde <remi@verschelde.fr> | 2021-04-09 09:44:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-09 09:44:53 +0200 |
| commit | 3aadbec23a4d8eede16191e0b18f4a004887c6ff (patch) | |
| tree | 7a8ccc2a33147076a5cfcdafd4503144543b090b /modules/gdscript/gdscript_compiler.cpp | |
| parent | cba3b024b5d08b79e4389dc2c374e38ab4a64ff9 (diff) | |
| parent | cf4079cb5f51a40c8370a84f5131f944c398f4b8 (diff) | |
Merge pull request #47727 from vnen/gdscript-less-addressing
Reduce number of addressing modes in GDScript VM
Diffstat (limited to 'modules/gdscript/gdscript_compiler.cpp')
| -rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 6a91148575..abbca899bd 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -262,7 +262,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code GDScriptNativeClass *nc = nullptr; while (scr) { if (scr->constants.has(identifier)) { - return GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::CLASS_CONSTANT, gen->add_or_get_name(identifier)); // TODO: Get type here. + return codegen.add_constant(scr->constants[identifier]); // TODO: Get type here. } if (scr->native.is_valid()) { nc = scr->native.ptr(); @@ -319,7 +319,8 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) { int idx = GDScriptLanguage::get_singleton()->get_global_map()[identifier]; - return GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::GLOBAL, idx); // TODO: Get type. + Variant global = GDScriptLanguage::get_singleton()->get_global_array()[idx]; + return codegen.add_constant(global); // TODO: Get type. } // Try global classes. @@ -347,7 +348,9 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code #ifdef TOOLS_ENABLED if (GDScriptLanguage::get_singleton()->get_named_globals_map().has(identifier)) { - return GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::NAMED_GLOBAL, gen->add_or_get_name(identifier)); // TODO: Get type. + GDScriptCodeGenerator::Address global = codegen.add_temporary(); // TODO: Get type. + gen->write_store_named_global(global, identifier); + return global; } #endif |