Merge pull request #56287 from cdemirer/fix-member-property-only-getter-cant-be-set
This commit is contained in:
commit
c8b4fe3b8d
1 changed files with 14 additions and 18 deletions
|
@ -1078,29 +1078,25 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Regular assignment.
|
// Regular assignment.
|
||||||
GDScriptCodeGenerator::Address target;
|
ERR_FAIL_COND_V_MSG(assignment->assignee->type != GDScriptParser::Node::IDENTIFIER, GDScriptCodeGenerator::Address(), "Expected the assignee to be an identifier here.");
|
||||||
|
GDScriptCodeGenerator::Address member;
|
||||||
|
bool is_member = false;
|
||||||
bool has_setter = false;
|
bool has_setter = false;
|
||||||
bool is_in_setter = false;
|
bool is_in_setter = false;
|
||||||
StringName setter_function;
|
StringName setter_function;
|
||||||
if (assignment->assignee->type == GDScriptParser::Node::IDENTIFIER) {
|
StringName var_name = static_cast<const GDScriptParser::IdentifierNode *>(assignment->assignee)->name;
|
||||||
StringName var_name = static_cast<const GDScriptParser::IdentifierNode *>(assignment->assignee)->name;
|
if (!codegen.locals.has(var_name) && codegen.script->member_indices.has(var_name)) {
|
||||||
if (!codegen.locals.has(var_name) && codegen.script->member_indices.has(var_name)) {
|
is_member = true;
|
||||||
setter_function = codegen.script->member_indices[var_name].setter;
|
setter_function = codegen.script->member_indices[var_name].setter;
|
||||||
if (setter_function != StringName()) {
|
has_setter = setter_function != StringName();
|
||||||
has_setter = true;
|
is_in_setter = has_setter && setter_function == codegen.function_name;
|
||||||
is_in_setter = setter_function == codegen.function_name;
|
member.mode = GDScriptCodeGenerator::Address::MEMBER;
|
||||||
target.mode = GDScriptCodeGenerator::Address::MEMBER;
|
member.address = codegen.script->member_indices[var_name].index;
|
||||||
target.address = codegen.script->member_indices[var_name].index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_setter) {
|
GDScriptCodeGenerator::Address target;
|
||||||
if (!is_in_setter) {
|
if (is_member) {
|
||||||
// Store stack slot for the temp value.
|
target = member; // _parse_expression could call its getter, but we want to know the actual address
|
||||||
target = codegen.add_temporary(_gdtype_from_datatype(assignment->assignee->get_datatype()));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
target = _parse_expression(codegen, r_error, assignment->assignee);
|
target = _parse_expression(codegen, r_error, assignment->assignee);
|
||||||
if (r_error) {
|
if (r_error) {
|
||||||
|
|
Loading…
Reference in a new issue