aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-26 17:16:49 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-26 17:16:49 -0700
commit1b9e31b552d0df4c1a3cb337b0c91473cae4b1af (patch)
treeeddfa3eba6674b4495fd51700eb4ca023814813e /src/parseTools.js
parenta10414394c866241d0daad84efea302ac8460909 (diff)
improve isFunctionType
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index f963a834..5fc4cd9e 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -241,7 +241,21 @@ function isFunctionType(type, out) {
returnType = 'i8*'; // some pointer type, no point in analyzing further
}
if (out) out.returnType = returnType;
- var argText = type.substr(lastOpen);
+ // find ( that starts the arguments
+ var depth = 0, i = type.length-1, argText = null;
+ while (i >= 0) {
+ var curr = type[i];
+ if (curr == ')') depth++;
+ else if (curr == '(') {
+ depth--;
+ if (depth == 0) {
+ argText = type.substr(i);
+ break;
+ }
+ }
+ i--;
+ }
+ assert(argText);
return isFunctionDef({ text: argText, item: tokenize(argText.substr(1, argText.length-2), true) }, out);
}
@@ -1649,6 +1663,7 @@ function checkBitcast(item) {
} else {
warnOnce('Casting a function pointer type to a potentially incompatible one (use VERBOSE=1 to see more)');
}
+ warnOnce('See checkBitcast in src/parseTools.js for more information on dangerous function pointer casts');
if (ASM_JS) warnOnce('Incompatible function pointer casts are very dangerous with ASM_JS=1, you should investigate and correct these');
}
if (oldCount != newCount && oldCount && newCount) {