aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
authorAlon Zakai <azakai@mozilla.com>2010-12-27 21:19:54 -0800
committerAlon Zakai <azakai@mozilla.com>2010-12-27 21:19:54 -0800
commit015823fb76b5c4572dd98f29ca13c5e75f911852 (patch)
tree522f41a228fe69897816c21310bc217d4b71847a /src/parseTools.js
parent9f0272883eaf9d73eb7124ac2d6b51ed8295a649 (diff)
use finalizeLLVMFunctionCall for more functions, and related minor fixes
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 05c8fc10..5f94b5cc 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -60,6 +60,18 @@ function toNiceIdent(ident) {
return ident.replace('%', '$').replace(/["\\ \.@:<>,\*\[\]-]/g, '_');
}
+// Kind of a hack. In some cases we have strings that we do not want
+// to |toNiceIdent|, as they are the output of previous processing. We
+// should refactor everything into an object, with an explicit flag
+// saying what has been |toNiceIdent|ed. Until then, this will detect
+// simple idents that are in need of |toNiceIdent|ation. Or, we should
+// ensure that processed strings never start with %,@, e.g. by always
+// enclosing them in ().
+function toNiceIdentCarefully(ident) {
+ if (ident[0] == '%' || ident[0] == '@') ident = toNiceIdent(ident);
+ return ident;
+}
+
function isStructPointerType(type) {
// This test is necessary for clang - in llvm-gcc, we
// could check for %struct. The downside is that %1 can
@@ -161,6 +173,7 @@ function findTokenText(item, text) {
// Splits a list of tokens separated by commas. For example, a list of arguments in a function call
function splitTokenList(tokens) {
if (tokens.length == 0) return [];
+ if (!tokens.slice) tokens = tokens.tokens;
if (tokens.slice(-1)[0].text != ',') tokens.push({text:','});
var ret = [];
var seg = [];
@@ -318,7 +331,7 @@ function cleanSegment(segment) {
return segment;
}
-PARSABLE_LLVM_FUNCTIONS = set('getelementptr', 'bitcast', 'inttoptr', 'ptrtoint', 'mul', 'icmp', 'zext');
+PARSABLE_LLVM_FUNCTIONS = set('getelementptr', 'bitcast', 'inttoptr', 'ptrtoint', 'mul', 'icmp', 'zext', 'sub', 'add', 'div');
// Parses a function call of form
// TYPE functionname MODIFIERS (...)