diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/intertyper.js | 7 | ||||
-rw-r--r-- | src/parseTools.js | 18 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 8c0136a3..b4c009f5 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -524,11 +524,12 @@ function intertyper(data, parseFunctions, baseLineNum) { } item.type = item.tokens[1].text; item.functionType = ''; - while (['@', '%'].indexOf(item.tokens[2].text[0]) == -1) { + while (['@', '%'].indexOf(item.tokens[2].text[0]) == -1 && !(item.tokens[2].text in PARSABLE_LLVM_FUNCTIONS)) { item.functionType += item.tokens[2].text; item.tokens.splice(2, 1); } - item.ident = item.tokens[2].text; + var tokensLeft = item.tokens.slice(2); + item.ident = eatLLVMIdent(tokensLeft); if (item.ident.substr(-2) == '()') { // See comment in isStructType() item.ident = item.ident.substr(0, item.ident.length-2); @@ -538,7 +539,7 @@ function intertyper(data, parseFunctions, baseLineNum) { } item.params = []; } else { - item.params = parseParamTokens(item.tokens[3].item.tokens); + item.params = parseParamTokens(tokensLeft[0].item.tokens); } if (item.indent == 2) { // standalone call - not in assign diff --git a/src/parseTools.js b/src/parseTools.js index d2e746ca..968550e1 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -341,6 +341,24 @@ function parseLLVMFunctionCall(segment) { return ret; } +// Gets an array of tokens, we parse out the first +// 'ident' - either a simple ident of one token, or +// an LLVM internal function that generates an ident. +// We shift out of the array list the tokens that +// we ate. +function eatLLVMIdent(tokens) { + var ret; + if (tokens[0].text in PARSABLE_LLVM_FUNCTIONS) { + ret = parseLLVMFunctionCall([{text: 'i0'}].concat(tokens.slice(0,2))).ident; // TODO: Handle more cases, return a full object, process it later + tokens.shift(); + tokens.shift(); + } else { + ret = tokens[0].text; + tokens.shift(); + } + return ret; +} + function cleanOutTokens(filterOut, tokens, index) { while (filterOut.indexOf(tokens[index].text) != -1) { tokens.splice(index, 1); |