| 294 | } |
| 295 | |
| 296 | toText(options = {}) { |
| 297 | const foldExprs = options.foldExprs ?? false; |
| 298 | const inlineExport = options.inlineExport ?? false; |
| 299 | |
| 300 | const writeModuleResult_addr = Module._wabt_write_text_module( |
| 301 | this.module_addr, foldExprs, inlineExport); |
| 302 | |
| 303 | const result = |
| 304 | Module._wabt_write_module_result_get_result(writeModuleResult_addr); |
| 305 | |
| 306 | let outputBuffer; |
| 307 | try { |
| 308 | if (result !== WABT_OK) { |
| 309 | throw new Error('toText failed.'); |
| 310 | } |
| 311 | |
| 312 | outputBuffer = new OutputBuffer( |
| 313 | Module._wabt_write_module_result_release_output_buffer( |
| 314 | writeModuleResult_addr)); |
| 315 | |
| 316 | return outputBuffer.toString(); |
| 317 | |
| 318 | } finally { |
| 319 | if (outputBuffer) { |
| 320 | outputBuffer.destroy(); |
| 321 | } |
| 322 | Module._wabt_destroy_write_module_result(writeModuleResult_addr); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | toBinary(options = {}) { |
| 327 | const log = options.log ?? false; |