Skip to content

Commit

Permalink
Merge pull request #9588 from jamesgeorge007/feat/add-types
Browse files Browse the repository at this point in the history
chore(WebAssemblyGenerator): Added type metadata
  • Loading branch information
sokra committed Aug 19, 2019
2 parents d805632 + 8d3c3c5 commit 3675f64
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/wasm/WebAssemblyGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const getImportedGlobals = ast => {

t.traverse(ast, {
ModuleImport({ node }) {
if (t.isGlobalType(node.descr) === true) {
if (t.isGlobalType(node.descr)) {
importedGlobals.push(node);
}
}
Expand All @@ -79,12 +79,18 @@ const getImportedGlobals = ast => {
return importedGlobals;
};

/**
* Get the count for imported func
*
* @param {Object} ast Module's AST
* @returns {Number} - count
*/
const getCountImportedFunc = ast => {
let count = 0;

t.traverse(ast, {
ModuleImport({ node }) {
if (t.isFuncImportDescr(node.descr) === true) {
if (t.isFuncImportDescr(node.descr)) {
count++;
}
}
Expand Down Expand Up @@ -172,7 +178,7 @@ const rewriteImportedGlobals = state => bin => {

bin = editWithAST(state.ast, bin, {
ModuleImport(path) {
if (t.isGlobalType(path.node.descr) === true) {
if (t.isGlobalType(path.node.descr)) {
const globalType = path.node.descr;

globalType.mutability = "var";
Expand Down

0 comments on commit 3675f64

Please sign in to comment.