@@ -57,13 +57,16 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
5757 (type $fiF (func (param i32 f64) (result f32)))
5858 (type $v (func))
5959 (type $3 (func))
60+ (import "module" "base" (global $a-global-imp i32))
6061 (import "module" "base" (func $an-imported (param i32 f64) (result f32)))
6162 (memory $0 1 256)
6263 (data (i32.const 10) "hello, world")
6364 (data passive "I am passive")
6465 (table $0 1 funcref)
6566 (elem (i32.const 0) "$kitchen()sinker")
67+ (global $a-global i32 (i32.const 1))
6668 (export "kitchen_sinker" (func "$kitchen()sinker"))
69+ (export "a-global-exp" (global $a-global))
6770 (export "mem" (memory $0))
6871 (start $starter)
6972 (func "$kitchen()sinker" (; 1 ;) (type $iiIfF) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32)
@@ -1886,6 +1889,7 @@ optimized:
18861889module loaded from binary form:
18871890(module
18881891 (type $0 (func (param i32 i32) (result i32)))
1892+ (global $global$0 i32 (i32.const 3))
18891893 (func $adder (; 0 ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
18901894 (i32.add
18911895 (local.get $0)
@@ -3327,12 +3331,16 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
33273331 BinaryenType varTypes[] = { 1 };
33283332 functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[655]);
33293333 }
3334+ expressions[656] = BinaryenConst(the_module, BinaryenLiteralInt32(1));
3335+ globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[656]);
33303336 {
33313337 BinaryenType paramTypes[] = { 1, 4 };
33323338 functionTypes[1] = BinaryenAddFunctionType(the_module, "fiF", 3, paramTypes, 2);
33333339 }
33343340 BinaryenAddFunctionImport(the_module, "an-imported", "module", "base", functionTypes[1]);
3341+ BinaryenAddGlobalImport(the_module, "a-global-imp", "module", "base", 1);
33353342 exports[0] = BinaryenAddFunctionExport(the_module, "kitchen()sinker", "kitchen_sinker");
3343+ exports[1] = BinaryenAddGlobalExport(the_module, "a-global", "a-global-exp");
33363344 BinaryenFunctionGetName(functions[0]);
33373345 BinaryenFunctionImportGetModule(functions[0]);
33383346 BinaryenFunctionImportGetBase(functions[0]);
@@ -3350,24 +3358,24 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
33503358 const char* funcNames[] = { "kitchen()sinker" };
33513359 BinaryenSetFunctionTable(the_module, 1, 4294967295, funcNames, 1);
33523360 }
3353- expressions[656 ] = BinaryenConst(the_module, BinaryenLiteralInt32(10));
3361+ expressions[657 ] = BinaryenConst(the_module, BinaryenLiteralInt32(10));
33543362 {
33553363 const char segment0[] = { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100 };
33563364 const char segment1[] = { 73, 32, 97, 109, 32, 112, 97, 115, 115, 105, 118, 101 };
33573365 const char* segments[] = { segment0, segment1 };
33583366 int8_t segmentPassive[] = { 0, 1 };
3359- BinaryenExpressionRef segmentOffsets[] = { expressions[656 ], expressions[0] };
3367+ BinaryenExpressionRef segmentOffsets[] = { expressions[657 ], expressions[0] };
33603368 BinaryenIndex segmentSizes[] = { 12, 12 };
33613369 BinaryenSetMemory(the_module, 1, 256, "mem", segments, segmentPassive, segmentOffsets, segmentSizes, 2, 0);
33623370 }
33633371 {
33643372 BinaryenType paramTypes[] = { 0 };
33653373 functionTypes[2] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0);
33663374 }
3367- expressions[657 ] = BinaryenNop(the_module);
3375+ expressions[658 ] = BinaryenNop(the_module);
33683376 {
33693377 BinaryenType varTypes[] = { 0 };
3370- functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[2], varTypes, 0, expressions[657 ]);
3378+ functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[2], varTypes, 0, expressions[658 ]);
33713379 }
33723380 BinaryenSetStart(the_module, functions[1]);
33733381 {
@@ -3382,13 +3390,16 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
33823390 (type $fiF (func (param i32 f64) (result f32)))
33833391 (type $v (func))
33843392 (type $3 (func))
3393+ (import "module" "base" (global $a-global-imp i32))
33853394 (import "module" "base" (func $an-imported (param i32 f64) (result f32)))
33863395 (memory $0 1 256)
33873396 (data (i32.const 10) "hello, world")
33883397 (data passive "I am passive")
33893398 (table $0 1 funcref)
33903399 (elem (i32.const 0) "$kitchen()sinker")
3400+ (global $a-global i32 (i32.const 1))
33913401 (export "kitchen_sinker" (func "$kitchen()sinker"))
3402+ (export "a-global-exp" (global $a-global))
33923403 (export "mem" (memory $0))
33933404 (start $starter)
33943405 (func "$kitchen()sinker" (; 1 ;) (type $iiIfF) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32)
@@ -5691,6 +5702,7 @@ optimized:
56915702test_parsing text:
56925703(module
56935704 (type $iii (func (param i32 i32) (result i32)))
5705+ (global $a-global i32 (i32.const 3))
56945706 (func $adder (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
56955707 (i32.add
56965708 (local.get $0)
@@ -5702,6 +5714,7 @@ test_parsing text:
57025714module loaded from text form:
57035715(module
57045716 (type $iii (func (param i32 i32) (result i32)))
5717+ (global $a-global i32 (i32.const 3))
57055718 (func $ADD_ER (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
57065719 (i32.add
57075720 (local.get $0)
0 commit comments