diff options
author | Alon Zakai <azakai@mozilla.com> | 2011-02-22 20:49:21 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2011-02-22 20:49:21 -0800 |
commit | 8d224bc085bbfcf626db8fe1da2a9679d13d96f4 (patch) | |
tree | e707275bbff04c84e2560815988a7964976c7538 /src/parseTools.js | |
parent | 9efae48667c05a5cd7e699a3a95b7db80539b801 (diff) |
optimize type discovery
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 4c70867a..a6a1038b 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -271,6 +271,7 @@ function parseParamTokens(params) { value: null, ident: toNiceIdent('%') + anonymousIndex }); + Types.needAnalysis[ret.type] = 0; anonymousIndex ++; } } else if (segment[1].text in PARSABLE_LLVM_FUNCTIONS) { @@ -289,6 +290,7 @@ function parseParamTokens(params) { value: segment[1], ident: toNiceIdent(parseNumerical(segment[1].text)) }); + Types.needAnalysis[ret.type] = 0; // } else { // throw "what is this params token? " + JSON.stringify(segment); } @@ -298,23 +300,30 @@ function parseParamTokens(params) { // Segment ==> Parameter function parseLLVMSegment(segment) { + var type; if (segment.length == 1) { + type = isType(segment[0].text) ? segment[0].text : '?'; + Types.needAnalysis[type] = 0; return { intertype: 'value', ident: toNiceIdent(segment[0].text), - type: isType(segment[0].text) ? segment[0].text : '?' + type: type }; } else if (segment[1].type == '{') { + type = segment[0].text; + Types.needAnalysis[type] = 0; return { intertype: 'structvalue', values: splitTokenList(segment[1].tokens).map(parseLLVMSegment), - type: segment[0].text + type: type }; } else if (segment[0].text in PARSABLE_LLVM_FUNCTIONS) { return parseLLVMFunctionCall([{text: '?'}].concat(segment)); } else if (segment[1].text in PARSABLE_LLVM_FUNCTIONS) { return parseLLVMFunctionCall(segment); } else { + type = segment[0].text; + Types.needAnalysis[type] = 0; return { intertype: 'value', ident: toNiceIdent(segment[1].text), @@ -365,6 +374,7 @@ function parseLLVMFunctionCall(segment) { type: type, params: parseParamTokens(segment[2].item.tokens) }; + Types.needAnalysis[ret.type] = 0; ret.ident = toNiceIdent(ret.params[0].ident); return ret; } @@ -393,6 +403,12 @@ function cleanOutTokens(filterOut, tokens, index) { } } +function cleanOutTokensSet(filterOut, tokens, index) { + while (tokens[index].text in filterOut) { + tokens.splice(index, 1); + } +} + function _IntToHex(x) { assert(x >= 0 && x <= 15); if (x <= 9) { |