How to use the @webassemblyjs/ast.global function in @webassemblyjs/ast

To help you get started, we’ve selected a few @webassemblyjs/ast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zc910704 / Vue.js-personal-note / www / day6.1.webpack的url-loader与babel / node_modules / @webassemblyjs / wasm-parser / esm / decoder.js View on Github external
function parseGlobalSection(numberOfGlobals) {
    var globals = [];
    dump([numberOfGlobals], "num globals");

    for (var i = 0; i < numberOfGlobals; i++) {
      var startLoc = getPosition();
      var globalType = parseGlobalType();
      /**
       * Global expressions
       */

      var init = [];
      parseInstructionBlock(init);
      var endLoc = getPosition();
      var node = t.withLoc(t.global(globalType, init), endLoc, startLoc);
      globals.push(node);
      state.globalsInModule.push(node);
    }

    return globals;
  }
github xtuc / webassemblyjs / packages / wast-parser / src / grammar.js View on Github external
init.push(
          t.moduleImport(importing.module, importing.name, importing.descr)
        );
      }

      /**
       * instr*
       */
      while (token.type === tokens.openParen) {
        eatToken();

        init.push(parseFuncInstr());
        eatTokenOfType(tokens.closeParen);
      }

      return t.global(type, init, name);
    }
github johandb / svg-drawing-tool / node_modules / webpack / lib / wasm / WebAssemblyGenerator.js View on Github external
ModuleImport(path) {
			if (t.isGlobalType(path.node.descr) === true) {
				const globalType = path.node.descr;

				globalType.mutability = "var";

				const init = createDefaultInitForGlobal(globalType);

				newGlobals.push(t.global(globalType, [init]));

				path.remove();
			}
		},
github flaviuse / mern-authentication / client / node_modules / @webassemblyjs / wasm-parser / esm / decoder.js View on Github external
var signature = state.typesInModule[typeindex];

        if (typeof signature === "undefined") {
          throw new CompileError("function signature not found (".concat(typeindex, ")"));
        }

        var id = getUniqueName("func");
        importDescr = t.funcImportDescr(id, t.signature(signature.params, signature.result));
        state.functionsInModule.push({
          id: t.identifier(name.value),
          signature: signature,
          isExternal: true
        });
      } else if (descrType === "global") {
        importDescr = parseGlobalType();
        var globalNode = t.global(importDescr, []);
        state.globalsInModule.push(globalNode);
      } else if (descrType === "table") {
        importDescr = parseTableType(i);
      } else if (descrType === "mem") {
        var memoryNode = parseMemoryType(0);
        state.memoriesInModule.push(memoryNode);
        importDescr = memoryNode;
      } else {
        throw new CompileError("Unsupported import of type: " + descrType);
      }

      imports.push(function () {
        var endLoc = getPosition();
        return t.withLoc(t.moduleImport(moduleName.value, name.value, importDescr), endLoc, _startLoc2);
      }());
    }
github M0nica / React-Ladies / node_modules / webpack / lib / wasm / WebAssemblyGenerator.js View on Github external
ModuleImport(path) {
			if (t.isGlobalType(path.node.descr) === true) {
				const globalType = path.node.descr;

				globalType.mutability = "var";

				const init = createDefaultInitForGlobal(globalType);

				newGlobals.push(t.global(globalType, [init]));

				path.remove();
			}
		},
github maxdenaro / maxgraph-youtube-source / JS-плагины №7. Новое подключение swiper.js через npm / node_modules / @webassemblyjs / wast-parser / esm / grammar.js View on Github external
if (importing != null) {
        importing.descr = type;
        init.push(t.moduleImport(importing.module, importing.name, importing.descr));
      }
      /**
       * instr*
       */


      while (token.type === tokens.openParen) {
        eatToken();
        init.push(parseFuncInstr());
        eatTokenOfType(tokens.closeParen);
      }

      return t.global(type, init, name);
    }
    /**
github M0nica / React-Ladies / node_modules / @webassemblyjs / wast-parser / lib / grammar.js View on Github external
if (importing != null) {
        importing.descr = type;
        init.push(t.moduleImport(importing.module, importing.name, importing.descr));
      }
      /**
       * instr*
       */


      while (token.type === tokens.openParen) {
        eatToken();
        init.push(parseFuncInstr());
        eatTokenOfType(tokens.closeParen);
      }

      return t.global(type, init, name);
    }
    /**
github M0nica / React-Ladies / node_modules / @webassemblyjs / wasm-parser / lib / decoder.js View on Github external
function parseGlobalSection(numberOfGlobals) {
    var globals = [];
    dump([numberOfGlobals], "num globals");

    for (var i = 0; i < numberOfGlobals; i++) {
      var startLoc = getPosition();
      var globalType = parseGlobalType();
      /**
       * Global expressions
       */

      var init = [];
      parseInstructionBlock(init);
      var endLoc = getPosition();
      var node = t.withLoc(t.global(globalType, init), endLoc, startLoc);
      globals.push(node);
      state.globalsInModule.push(node);
    }

    return globals;
  }
github maxdenaro / maxgraph-youtube-source / JS-плагины №7. Новое подключение swiper.js через npm / node_modules / @webassemblyjs / wasm-parser / esm / decoder.js View on Github external
var signature = state.typesInModule[typeindex];

        if (typeof signature === "undefined") {
          throw new CompileError("function signature not found (".concat(typeindex, ")"));
        }

        var id = getUniqueName("func");
        importDescr = t.funcImportDescr(id, t.signature(signature.params, signature.result));
        state.functionsInModule.push({
          id: t.identifier(name.value),
          signature: signature,
          isExternal: true
        });
      } else if (descrType === "global") {
        importDescr = parseGlobalType();
        var globalNode = t.global(importDescr, []);
        state.globalsInModule.push(globalNode);
      } else if (descrType === "table") {
        importDescr = parseTableType(i);
      } else if (descrType === "mem") {
        var memoryNode = parseMemoryType(0);
        state.memoriesInModule.push(memoryNode);
        importDescr = memoryNode;
      } else {
        throw new CompileError("Unsupported import of type: " + descrType);
      }

      imports.push(function () {
        var endLoc = getPosition();
        return t.withLoc(t.moduleImport(moduleName.value, name.value, importDescr), endLoc, _startLoc2);
      }());
    }