From 7b7e1b6a69b578f17ca9ab8a70fcdd023386dbb6 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 2 Jan 2012 13:11:50 -0800 Subject: [PATCH] do not set label when continue-ing to a loop with one entry --- src/analyzer.js | 10 ++++++++-- src/jsifier.js | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index eaa8a0dfd..26def9c45 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -1039,8 +1039,13 @@ function analyzer(data) { } // We will be in a loop, |continue| gets us back to the entry + var pattern = 'BCONT|' + blockId; + if (entries.length == 1) { + // We are returning to a loop that has one entry, so we don't need to set __label__ + pattern = 'BCNOL|' + blockId; + } entries.forEach(function(entry) { - replaceLabelLabels(internals, set(entries), 'BCONT|' + blockId); + replaceLabelLabels(internals, set(entries), pattern); }); // Find the entries of the external labels @@ -1118,7 +1123,7 @@ function analyzer(data) { assert(externalsEntries.length > 0); var pattern = 'BREAK|' + blockId; if (externalsEntries.length == 1) { - // We are breaking out of a loop and have one entry after it, so we don't need to set __label__ - keep the third field empty + // We are breaking out of a loop and have one entry after it, so we don't need to set __label__ pattern = 'BRNOL|' + blockId; } replaceLabelLabels(internals, externalsLabels, pattern); @@ -1280,6 +1285,7 @@ function analyzer(data) { replaceLabelLabels(block.labels, set('BCONT|*|' + block.willGetTo), 'BNOPP'); replaceLabelLabels(block.labels, set('BREAK|*|' + block.willGetTo), 'BNOPP'); replaceLabelLabels(block.labels, set('BRNOL|*|' + block.willGetTo), 'BNOPP'); + replaceLabelLabels(block.labels, set('BCNOL|*|' + block.willGetTo), 'BNOPP'); } } diff --git a/src/jsifier.js b/src/jsifier.js index 1f4ab7f8a..0cdafb5ad 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -765,6 +765,9 @@ function JSify(data, functionsOnly, givenFunctions) { } return pre + labelSetting + 'break ' + trueLabel + ';'; } else if (label[1] == 'C') { // CONT + if (label[2] == 'N') { // BCNOL: continue, no label setting + labelSetting = ''; + } return pre + labelSetting + 'continue ' + trueLabel + ';'; } else if (label[1] == 'N') { // NOPP return pre + ';'; // Returning no text might confuse this parser