(sig)
| 126 | |
| 127 | |
| 128 | def make_invoke(sig): |
| 129 | legal_sig = legalize_sig(sig) # TODO: do this in extcall, jscall? |
| 130 | args = ['index'] + ['a' + str(i) for i in range(1, len(legal_sig))] |
| 131 | ret = 'return ' if sig[0] != 'v' else '' |
| 132 | # For function that needs to return a genuine i64 (i.e. if legal_sig[0] is 'j') |
| 133 | # we need to return an actual BigInt, even in the exceptional case because |
| 134 | # wasm won't implicitly convert undefined to 0 in this case. |
| 135 | exceptional_ret = '\n return 0n;' if legal_sig[0] == 'j' else '' |
| 136 | body = '%s%s;' % (ret, make_dynCall(sig, args)) |
| 137 | # Create a try-catch guard that rethrows the Emscripten EH exception. |
| 138 | maybe_rethrow = 'if (!(e instanceof EmscriptenEH)) throw e;' |
| 139 | |
| 140 | ret = '''\ |
| 141 | function invoke_%s(%s) { |
| 142 | var sp = stackSave(); |
| 143 | try { |
| 144 | %s |
| 145 | } catch(e) { |
| 146 | stackRestore(sp); |
| 147 | %s |
| 148 | _setThrew(1, 0);%s |
| 149 | } |
| 150 | }''' % (sig, ','.join(args), body, maybe_rethrow, exceptional_ret) |
| 151 | |
| 152 | return ret |
| 153 | |
| 154 | |
| 155 | def make_wasm64_wrapper(sig): |
nothing calls this directly
no test coverage detected