diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-08-16 11:39:04 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-08-16 11:39:04 -0700 |
commit | ab6452296324f9827b07780c90847a69f2173ed8 (patch) | |
tree | 0e24becd8f51e8192e4b01f8ad8a7a0eddbc64e3 /src | |
parent | 52f2d45d070342b82dee9fcac325b8535f3adc65 (diff) |
generate separate function table wrappers for a single library function aliased with different signatures
Diffstat (limited to 'src')
-rw-r--r-- | src/modules.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/modules.js b/src/modules.js index 01f0d8ae..fa6c0983 100644 --- a/src/modules.js +++ b/src/modules.js @@ -321,7 +321,7 @@ var Functions = { tables[sig][index] = ident; } var generated = false; - var wrapped = {}; + var wrapped = {}; // whether we wrapped a lib func var maxTable = 0; for (var t in tables) { if (t == 'pre') continue; @@ -344,10 +344,11 @@ var Functions = { if (ASM_JS) { var curr = table[i]; if (curr && curr != '0' && !Functions.implementedFunctions[curr]) { - curr = toNiceIdent(curr); // fix Math.* to Math_* + var short = toNiceIdent(curr); // fix Math.* to Math_* + curr = t + '_' + short; // libfuncs can alias with different sigs, wrap each separately // This is a library function, we can't just put it in the function table, need a wrapper if (!wrapped[curr]) { - var args = '', arg_coercions = '', call = curr + '(', retPre = '', retPost = ''; + var args = '', arg_coercions = '', call = short + '(', retPre = '', retPost = ''; if (t[0] != 'v') { if (t[0] == 'i') { retPre = 'return '; @@ -362,7 +363,7 @@ var Functions = { call += (j > 1 ? ',' : '') + asmCoercion('a' + j, t[j] != 'i' ? 'float' : 'i32'); } call += ')'; - if (curr == '_setjmp') printErr('WARNING: setjmp used via a function pointer. If this is for libc setjmp (not something of your own with the same name), it will break things'); + if (short == '_setjmp') printErr('WARNING: setjmp used via a function pointer. If this is for libc setjmp (not something of your own with the same name), it will break things'); tables.pre += 'function ' + curr + '__wrapper(' + args + ') { ' + arg_coercions + ' ; ' + retPre + call + retPost + ' }\n'; wrapped[curr] = 1; } |