From a00a8df2d9b4c121dd160df925447dfa6b66fd0d Mon Sep 17 00:00:00 2001 From: Alexander Markov Date: Mon, 26 Aug 2019 20:44:06 +0000 Subject: [PATCH] [vm/bytecode] Correct source positions for switch cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following tests in bytecode mode: service/step_through_switch_test broke service/step_through_switch_with_continue_test Change-Id: I3f6f835185b9dae86e5ebebfdd4484b4d1cb6af0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114549 Reviewed-by: Régis Crelier Commit-Queue: Alexander Markov --- pkg/vm/lib/bytecode/gen_bytecode.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/vm/lib/bytecode/gen_bytecode.dart b/pkg/vm/lib/bytecode/gen_bytecode.dart index 63a4e94fae9..701a3df57c7 100644 --- a/pkg/vm/lib/bytecode/gen_bytecode.dart +++ b/pkg/vm/lib/bytecode/gen_bytecode.dart @@ -3617,15 +3617,18 @@ class BytecodeGenerator extends RecursiveVisitor { if (switchCase.isDefault) { defaultLabel = caseLabel; } else { - for (var expr in switchCase.expressions) { + final savedSourcePosition = asm.currentSourcePosition; + for (int i = 0; i < switchCase.expressions.length; ++i) { + _recordSourcePosition(switchCase.expressionOffsets[i]); asm.emitPush(temp); - _genPushConstExpr(expr); + _genPushConstExpr(switchCase.expressions[i]); asm.emitInterfaceCall( cp.addInterfaceCall( InvocationKind.method, coreTypes.objectEquals, equalsArgDesc), 2); _genJumpIfTrue(/* negated = */ false, caseLabel); } + asm.currentSourcePosition = savedSourcePosition; } }