Fix duplicated lines in GDScript bytecode

Fixes #26789

(cherry picked from commit b64f9f03f8)
This commit is contained in:
Bojidar Marinov 2019-03-14 18:38:07 +02:00 committed by Rémi Verschelde
parent a51b2b8a82
commit 0d8492cf9e
3 changed files with 4 additions and 7 deletions

View File

@ -563,7 +563,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
case GDScriptFunction::OPCODE_OPERATOR: { case GDScriptFunction::OPCODE_OPERATOR: {
int op = code[ip + 1]; int op = code[ip + 1];
txt += "op "; txt += " op ";
String opname = Variant::get_operator_name(Variant::Operator(op)); String opname = Variant::get_operator_name(Variant::Operator(op));

View File

@ -1396,11 +1396,6 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
case GDScriptParser::ControlFlowNode::CF_IF: { case GDScriptParser::ControlFlowNode::CF_IF: {
#ifdef DEBUG_ENABLED
codegen.opcodes.push_back(GDScriptFunction::OPCODE_LINE);
codegen.opcodes.push_back(cf->line);
codegen.current_line = cf->line;
#endif
int ret2 = _parse_expression(codegen, cf->arguments[0], p_stack_level, false); int ret2 = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
if (ret2 < 0) if (ret2 < 0)
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;

View File

@ -2741,6 +2741,8 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
} break; } break;
case GDScriptTokenizer::TK_NEWLINE: { case GDScriptTokenizer::TK_NEWLINE: {
int line = tokenizer->get_token_line();
if (!_parse_newline()) { if (!_parse_newline()) {
if (!error_set) { if (!error_set) {
p_block->end_line = tokenizer->get_token_line(); p_block->end_line = tokenizer->get_token_line();
@ -2750,7 +2752,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
} }
NewLineNode *nl2 = alloc_node<NewLineNode>(); NewLineNode *nl2 = alloc_node<NewLineNode>();
nl2->line = tokenizer->get_token_line(); nl2->line = line;
p_block->statements.push_back(nl2); p_block->statements.push_back(nl2);
} break; } break;