diff options
| author | Alon Zakai <alonzakai@gmail.com> | 2012-01-02 13:11:50 -0800 | 
|---|---|---|
| committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-02 13:11:50 -0800 | 
| commit | 7b7e1b6a69b578f17ca9ab8a70fcdd023386dbb6 (patch) | |
| tree | f09b4b1ad374e822163463575ec592096c840c09 | |
| parent | aa449f08f0dfd1fb3581ab0c40b7633f718be7e3 (diff) | |
do not set label when continue-ing to a loop with one entry
| -rw-r--r-- | src/analyzer.js | 10 | ||||
| -rw-r--r-- | src/jsifier.js | 3 | 
2 files changed, 11 insertions, 2 deletions
| diff --git a/src/analyzer.js b/src/analyzer.js index eaa8a0df..26def9c4 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 1f4ab7f8..0cdafb5a 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 | 
