GDScript: Support % in shorthand for get_node

The `%` is used in scene unique nodes. Now `%` can also be used instead
of `$` for the shorthand, besides being allowed generally anywhere in
the path as the prefix for a node name.
This commit is contained in:
George Marques 2022-05-26 12:56:39 -03:00
parent d81c5eab8c
commit eba3e0a9fc
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
11 changed files with 182 additions and 80 deletions

View file

@ -667,20 +667,8 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
case GDScriptParser::Node::GET_NODE: {
const GDScriptParser::GetNodeNode *get_node = static_cast<const GDScriptParser::GetNodeNode *>(p_expression);
String node_name;
if (get_node->string != nullptr) {
node_name += String(get_node->string->value);
} else {
for (int i = 0; i < get_node->chain.size(); i++) {
if (i > 0) {
node_name += "/";
}
node_name += get_node->chain[i]->name;
}
}
Vector<GDScriptCodeGenerator::Address> args;
args.push_back(codegen.add_constant(NodePath(node_name)));
args.push_back(codegen.add_constant(NodePath(get_node->full_path)));
GDScriptCodeGenerator::Address result = codegen.add_temporary(_gdtype_from_datatype(get_node->get_datatype()));