summaryrefslogtreecommitdiff
path: root/test/example/c-api-kitchen-sink.c
diff options
context:
space:
mode:
authorSiddharth <siddharth.bath@tweag.io>2019-05-22 02:42:19 +0200
committerAlon Zakai <azakai@google.com>2019-05-21 17:42:19 -0700
commit257a4c5ac940fe14bb85518a78fc9dba1c78b959 (patch)
tree3f9a20ceea7b12fa77daf3df0b7c97185e5c3728 /test/example/c-api-kitchen-sink.c
parent9b5e470bcef1c6934ae74457d8094143bad8d74a (diff)
downloadbinaryen-257a4c5ac940fe14bb85518a78fc9dba1c78b959.tar.gz
binaryen-257a4c5ac940fe14bb85518a78fc9dba1c78b959.tar.bz2
binaryen-257a4c5ac940fe14bb85518a78fc9dba1c78b959.zip
Add BinaryenModuleWriteSExpr to write a module to a string in s-expr format (#2106)
Fixes #2103.
Diffstat (limited to 'test/example/c-api-kitchen-sink.c')
-rw-r--r--test/example/c-api-kitchen-sink.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index 0efafde52..43069c865 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -785,6 +785,19 @@ void test_binaries() {
assert(BinaryenModuleValidate(module));
printf("module loaded from binary form:\n");
BinaryenModulePrint(module);
+
+ // write the s-expr representation of the module.
+ BinaryenModuleWriteText(module, buffer, 1024);
+ printf("module s-expr printed (in memory):\n%s\n", buffer);
+
+
+ // writ the s-expr representation to a pointer which is managed by the
+ // caller
+ char *text = BinaryenModuleAllocateAndWriteText(module);
+ printf("module s-expr printed (in memory, caller-owned):\n%s\n", text);
+ free(text);
+
+
BinaryenModuleDispose(module);
}