diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-12-03 14:06:11 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-12-03 14:06:11 -0800 |
commit | 4edb36d31bb553b07c46b44d2c8f28ed27421bb5 (patch) | |
tree | d43458ad08939638cb42d2a5182ce987c0817034 | |
parent | 4bf23981037b66af07ddf9ee9b089a9f2b62b2a1 (diff) |
optimize metadata parsing
-rw-r--r-- | src/intertyper.js | 30 | ||||
-rw-r--r-- | src/modules.js | 31 |
2 files changed, 35 insertions, 26 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 417a4f21..86da2a1f 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -11,28 +11,28 @@ function tokenize(text) { function intertyper(data, sidePass, baseLineNum) { var mainPass = !sidePass; - dprint('framework', 'Big picture: Starting intertyper, main pass=' + mainPass); - baseLineNum = baseLineNum || 0; - // Substrate + dprint('framework', 'Big picture: Starting intertyper, main pass=' + mainPass); - if (LLVM_STYLE === null) { - // new = clang on 2.8, old = llvm-gcc anywhere or clang on 2.7 - LLVM_STYLE = (data.indexOf('<label>') == -1 && data.indexOf('entry:') != -1) ? 'old' : 'new'; - //dprint('LLVM_STYLE: ' + LLVM_STYLE); - } + if (mainPass) { + if (LLVM_STYLE === null) { + // new = clang on 2.8, old = llvm-gcc anywhere or clang on 2.7 + LLVM_STYLE = (data.indexOf('<label>') == -1 && data.indexOf('entry:') != -1) ? 'old' : 'new'; + //dprint('LLVM_STYLE: ' + LLVM_STYLE); + } - // If the source contains debug info as LLVM metadata, process that out (and save the debugging info for later) - for (var i = data.length-1; i >= 0; i--) { - if (/^!\d+ = metadata .*/.exec(data[i])) { - data = Debugging.processMetadata(data); - //print(data.join('\n')); - //dprint(JSON.stringify(Debugging)); - break; + // If the source contains debug info as LLVM metadata, process that out (and save the debugging info for later) + for (var i = data.length-1; i >= 0; i--) { + if (/^!\d+ = metadata .*/.exec(data[i])) { + Debugging.processMetadata(data); + break; + } } } + // Substrate + var substrate = new Substrate('Intertyper'); // Line splitter. We break off some bunches of lines into unparsedBundles, which are diff --git a/src/modules.js b/src/modules.js index 02a1f102..eef02c5b 100644 --- a/src/modules.js +++ b/src/modules.js @@ -51,16 +51,21 @@ var Debugging = { var debugComment = new RegExp(/; +\[debug line = \d+:\d+\]/); - var ret = lines.map(function(line, i) { + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; line = line.replace(debugComment, ''); var skipLine = false; - if (form6.exec(line)) return ';'; + if (form6.exec(line)) { + lines[i] = ';'; + continue; + } var calc = form1.exec(line) || form2.exec(line); if (calc) { llvmLineToMetadata[i+1] = calc[1]; - return line.replace(', !dbg !' + calc[1], ''); + lines[i] = line.replace(', !dbg !' + calc[1], ''); + continue; } calc = formStruct.exec(line); if (calc) { @@ -89,22 +94,28 @@ var Debugging = { if (calc) { metadataToSourceLine[calc[1]] = calc[2]; metadataToParentMetadata[calc[1]] = calc[3]; - return ';'; // return an empty line, to keep line numbers of subsequent lines the same + lines[i] = ';'; // return an empty line, to keep line numbers of subsequent lines the same + continue; } calc = form3a.exec(line) || form3ab.exec(line) || form3ac.exec(line) || form3ad.exec(line); if (calc) { metadataToParentMetadata[calc[1]] = calc[2]; - return ';'; + lines[i] = ';'; + continue; } calc = form3b.exec(line); if (calc) { metadataToFilename[calc[1]] = /* LLVM 2.8<= : calc[3] + '/' + */ calc[2]; - return ';'; + lines[i] = ';'; + continue; } calc = form3c.exec(line) || form4.exec(line) || form5.exec(line); - if (calc) return ';'; - return skipLine ? ';' : line; - }, this); + if (calc) { + lines[i] = ';'; + continue; + } + lines[i] = skipLine ? ';' : line; + } /* dprint("ll ==> meta: " + JSON.stringify(llvmLineToMetadata)); @@ -157,8 +168,6 @@ var Debugging = { } this.on = true; - - return ret; }, clear: function() { |