aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-05-20 16:45:27 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-05-20 16:57:45 -0700
commit5efd506b7a9bc9ebae72f883e8fa5f1b18a85de2 (patch)
tree8fea83a4659337e9ca5ce7dcb9ac0e8bf29c22a6 /src
parent6346adec3b5f59415d9eb9650eeefd4120f32763 (diff)
correctly count the number of normal vars even when there are i64s before a varargs
Diffstat (limited to 'src')
-rw-r--r--src/parseTools.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 1a58b4e7..f30883b5 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -286,11 +286,22 @@ function isVarArgsFunctionType(type) {
return type.substr(-varArgsSuffix.length) == varArgsSuffix;
}
+function getNumVars(type) { // how many variables are needed to represent this type
+ if (type in Runtime.FLOAT_TYPES) return 1;
+ return Math.max(getNumIntChunks(type), 1);
+}
+
function countNormalArgs(type, out) {
out = out || {};
if (!isFunctionType(type, out)) return -1;
- if (isVarArgsFunctionType(type)) out.numArgs--;
- return out.numArgs;
+ var ret = 0;
+ if (out.segments) {
+ for (var i = 0; i < out.segments.length; i++) {
+ ret += getNumVars(out.segments[i][0].text);
+ }
+ }
+ if (isVarArgsFunctionType(type)) ret--;
+ return ret;
}
function addIdent(token) {