diff options
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index db834206..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) { @@ -1118,6 +1129,8 @@ var asmPrintCounter = 0; // See makeSetValue function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSafe, forceAsm) { if (UNALIGNED_MEMORY) align = 1; + else if (FORCE_ALIGNED_MEMORY && !isIllegalType(type)) align = 8; + if (isStructType(type)) { var typeData = Types.types[type]; var ret = []; @@ -1220,6 +1233,8 @@ function indexizeFunctions(value, type) { //! @param noNeedFirst Whether to ignore the offset in the pointer itself. function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, sep, forcedAlign, forceAsm) { if (UNALIGNED_MEMORY && !forcedAlign) align = 1; + else if (FORCE_ALIGNED_MEMORY && !isIllegalType(type)) align = 8; + sep = sep || ';'; if (isStructType(type)) { var typeData = Types.types[type]; @@ -1678,10 +1693,10 @@ function checkBitcast(item) { function showWarning() { if (warned) return; warned = true; - if (VERBOSE || ASM_JS) { + if (VERBOSE) { warnOnce('Casting potentially incompatible function pointer ' + oldType + ' to ' + newType + ', for ' + item.params[0].ident.slice(1)); } else { - warnOnce('Casting a function pointer type to a potentially incompatible one (use VERBOSE=1 to see more)'); + warnOnce('Casting a function pointer type to a potentially incompatible one (use -s VERBOSE=1 to see more)'); } warnOnce('See https://github.com/kripken/emscripten/wiki/CodeGuidlinesAndLimitations#function-pointer-issues 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'); @@ -1806,7 +1821,7 @@ function makeStructuralReturn(values, inAsm) { var i = -1; return 'return ' + asmCoercion(values.slice(1).map(function(value) { i++; - return ASM_JS ? (inAsm ? 'tempRet' + i + ' = ' + value : 'asm.setTempRet' + i + '(' + value + ')') + return ASM_JS ? (inAsm ? 'tempRet' + i + ' = ' + value : 'asm["setTempRet' + i + '"](' + value + ')') : 'tempRet' + i + ' = ' + value; }).concat([values[0]]).join(','), 'i32'); } else { |