Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/js/binaryen.js-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,15 @@ function wrapModule(module, self = {}) {
};

// TODO: string.*
self['string'] = {
/**
* Creates a new string from the literal string contents.
* This instruction is constant and can be used in global variable initializers.
*/
'const'(value) {
return preserveStack(() => Module['_BinaryenStringConst'](module, strToStack(value)));
}
};

// 'Module' operations
self['addFunction'] = function(name, params, results, varTypes, body) {
Expand Down
7 changes: 5 additions & 2 deletions test/binaryen.js/gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var arrayType = binaryen.getTypeFromHeapType(arrayHeapType, true);
var funcArrayType = binaryen.getTypeFromHeapType(funcArrayHeapType, true);

var module = new binaryen.Module();
module.setFeatures(binaryen.Features.ReferenceTypes | binaryen.Features.BulkMemory | binaryen.Features.GC);
module.setFeatures(binaryen.Features.ReferenceTypes | binaryen.Features.BulkMemory | binaryen.Features.GC | binaryen.Features.Strings);

module.addFunction("add", binaryen.createType([binaryen.i32, binaryen.i32]), binaryen.i32, [],
module.i32.add(
Expand Down Expand Up @@ -157,7 +157,10 @@ var valueList = [
module.i32.const(0),
module.i32.const(1),
module.i32.const(2)
)
),

// string
module.string.const("hello 🌎"),
];
module.addFunction("main", binaryen.none, binaryen.none, [],
module.block(
Expand Down
3 changes: 3 additions & 0 deletions test/binaryen.js/gc.js.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
(i32.const 1)
(i32.const 2)
)
(drop
(string.const "hello \f0\9f\8c\8e")
)
)
)

Loading