OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Used for encoding f32 and double constants to bits. | 5 // Used for encoding f32 and double constants to bits. |
6 let __buffer = new ArrayBuffer(8); | 6 let __buffer = new ArrayBuffer(8); |
7 let byte_view = new Int8Array(__buffer); | 7 let byte_view = new Int8Array(__buffer); |
8 let f32_view = new Float32Array(__buffer); | 8 let f32_view = new Float32Array(__buffer); |
9 let f64_view = new Float64Array(__buffer); | 9 let f64_view = new Float64Array(__buffer); |
10 | 10 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 let o = {module: module, name: name, kind: kExternalMemory, initial: initial
, maximum: maximum}; | 200 let o = {module: module, name: name, kind: kExternalMemory, initial: initial
, maximum: maximum}; |
201 this.imports.push(o); | 201 this.imports.push(o); |
202 return this; | 202 return this; |
203 } | 203 } |
204 | 204 |
205 addExport(name, index) { | 205 addExport(name, index) { |
206 this.exports.push({name: name, kind: kExternalFunction, index: index}); | 206 this.exports.push({name: name, kind: kExternalFunction, index: index}); |
207 return this; | 207 return this; |
208 } | 208 } |
209 | 209 |
| 210 addExportOfKind(name, kind, index) { |
| 211 this.exports.push({name: name, kind: kind, index: index}); |
| 212 return this; |
| 213 } |
| 214 |
210 addDataSegment(addr, data, is_global = false) { | 215 addDataSegment(addr, data, is_global = false) { |
211 this.segments.push({addr: addr, data: data, is_global: is_global}); | 216 this.segments.push({addr: addr, data: data, is_global: is_global}); |
212 return this.segments.length - 1; | 217 return this.segments.length - 1; |
213 } | 218 } |
214 | 219 |
215 exportMemoryAs(name) { | 220 exportMemoryAs(name) { |
216 this.exports.push({name: name, kind: kExternalMemory, index: 0}); | 221 this.exports.push({name: name, kind: kExternalMemory, index: 0}); |
217 } | 222 } |
218 | 223 |
219 addFunctionTableInit(base, is_global, array) { | 224 addFunctionTableInit(base, is_global, array) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 528 } |
524 return buffer; | 529 return buffer; |
525 } | 530 } |
526 | 531 |
527 instantiate(...args) { | 532 instantiate(...args) { |
528 let module = new WebAssembly.Module(this.toBuffer()); | 533 let module = new WebAssembly.Module(this.toBuffer()); |
529 let instance = new WebAssembly.Instance(module, ...args); | 534 let instance = new WebAssembly.Instance(module, ...args); |
530 return instance; | 535 return instance; |
531 } | 536 } |
532 } | 537 } |
OLD | NEW |