aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-15 17:27:22 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-11-15 17:27:22 -0800
commit03d2cc7933a57da50db6d9b61336173111fcead8 (patch)
tree3192b3e9fd6c1d4c7d98bc4ac2dca89e3c4f31ea /src/parseTools.js
parent813f86354c41cbc49e9ab750d1d795d3a354f71d (diff)
optimize isPossiblyFunctionType and use it more
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 1205aff5..d5d8ada8 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -167,7 +167,15 @@ function isFunctionDef(token, out) {
return !fail;
}
+
+function isPossiblyFunctionType(type) {
+ // A quick but unreliable way to see if something is a function type. Yes is just 'maybe', no is definite.
+ var len = type.length;
+ return type[len-2] == ')' && type[len-1] == '*';
+}
+
function isFunctionType(type, out) {
+ if (!isPossiblyFunctionType(type)) return false;
type = type.replace(/"[^"]+"/g, '".."');
var parts;
// hackish, but quick splitting of function def parts. this must be fast as it happens a lot
@@ -188,12 +196,6 @@ function isType(type) { // TODO!
return isVoidType(type) || Runtime.isNumberType(type) || isStructType(type) || isPointerType(type) || isFunctionType(type);
}
-function isPossiblyFunctionType(type) {
- // A quick but unreliable way to see if something is a function type. Yes is just 'maybe', no is definite.
- var suffix = ')*';
- return type.substr(-suffix.length) == suffix;
-}
-
function isVarArgsFunctionType(type) {
// assumes this is known to be a function type already
var varArgsSuffix = '...)*';