Make all sections optional
This commit is contained in:
4
asm.js
4
asm.js
@@ -884,6 +884,7 @@ export class Assembler {
|
||||
|
||||
wasm_section_type() {
|
||||
const funcs = Object.values(this.funcs);
|
||||
if (funcs.length == 0) return null;
|
||||
const contents = funcs.map(({ params, results }) => {
|
||||
const param_types = Object.values(params);
|
||||
return [
|
||||
@@ -917,6 +918,7 @@ export class Assembler {
|
||||
|
||||
wasm_section_func() {
|
||||
const func_count = Object.entries(this.funcs).length;
|
||||
if (func_count == 0) return null;
|
||||
return [ func_count, ...Array(func_count).keys() ];
|
||||
}
|
||||
|
||||
@@ -940,6 +942,7 @@ export class Assembler {
|
||||
|
||||
wasm_section_export() {
|
||||
const exports = Object.entries(this.exports);
|
||||
if (exports.length == 0) return null;
|
||||
const contents = exports.map(([ name, { kind, index }]) => {
|
||||
const name_utf8 = this.encoder.encode(name);
|
||||
return [
|
||||
@@ -954,6 +957,7 @@ export class Assembler {
|
||||
|
||||
wasm_section_code() {
|
||||
const funcs = Object.values(this.funcs);
|
||||
if (funcs.length == 0) return null;
|
||||
const contents = funcs.map(({ body, locals }) => {
|
||||
const local_types = Object.values(locals);
|
||||
const local_count = local_types.length;
|
||||
|
||||
Reference in New Issue
Block a user