From 0bac8f0daebc04c9e8b6170a022f6dea01125e2e Mon Sep 17 00:00:00 2001 From: "John J. Camilleri" Date: Mon, 1 Aug 2022 14:47:28 +0200 Subject: [PATCH] Load and read PGF in test-web: doesn't fail but abstract name is empty --- src/runtime/javascript/Dockerfile | 1 + src/runtime/javascript/test-web.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/runtime/javascript/Dockerfile b/src/runtime/javascript/Dockerfile index 13d37dc23..62378d73d 100644 --- a/src/runtime/javascript/Dockerfile +++ b/src/runtime/javascript/Dockerfile @@ -41,6 +41,7 @@ RUN emcc .libs/libgu.a .libs/libpgf.a -o pgf.js \ ccall,\ FS,\ getValue,\ + AsciiToString,\ stringToUTF8,\ UTF8ToString,\ allocateUTF8\ diff --git a/src/runtime/javascript/test-web.js b/src/runtime/javascript/test-web.js index 83b72ca41..2e4d3e87f 100644 --- a/src/runtime/javascript/test-web.js +++ b/src/runtime/javascript/test-web.js @@ -1,6 +1,19 @@ Module.onRuntimeInitialized = () => { const JSPGF = mkAPI(Module); + fetch('Foods.pgf') + .then((response) => response.arrayBuffer()) + .then((data) => { + const pgfPathFS = '/tmp/Foods.pgf'; + Module.FS.writeFile(pgfPathFS, new DataView(data)); + + // Read PGF + const pgf = JSPGF.readPGF(pgfPathFS); + + // Print its name + console.log(JSPGF.abstractName(pgf)); + }) + // Parse expression const expr = JSPGF.readExpr("Pred (Another (x f))");