How to use the mamacro.assert function in mamacro

To help you get started, we’ve selected a few mamacro 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 xtuc / webassemblyjs / packages / ast / src / nodes.js View on Github external
export function producerMetadata(
  language: Array,
  processedBy: Array,
  sdk: Array
): ProducerMetadata {
  assert(
    typeof language === "object" && typeof language.length !== "undefined"
  );

  assert(
    typeof processedBy === "object" && typeof processedBy.length !== "undefined"
  );

  assert(typeof sdk === "object" && typeof sdk.length !== "undefined");

  const node: ProducerMetadata = {
    type: "ProducerMetadata",
    language,
    processedBy,
    sdk
  };
github zc910704 / Vue.js-personal-note / www / day6.1.webpack的url-loader与babel / node_modules / @webassemblyjs / helper-module-context / src / index.js View on Github external
getGlobalOffsetByIdentifier(name) {
    assert(typeof name === "string");

    return this.globalsOffsetByIdentifier[name];
  }
github xtuc / webassemblyjs / packages / ast / src / nodes.js View on Github external
export function program(body: Array): Program {
  assert(typeof body === "object" && typeof body.length !== "undefined");

  const node: Program = {
    type: "Program",
    body
  };

  return node;
}
github xtuc / webassemblyjs / packages / ast / src / nodes.js View on Github external
export function callInstruction(
  index: Index,
  instrArgs?: Array,
  numeric?: Index
): CallInstruction {
  if (instrArgs !== null && instrArgs !== undefined) {
    assert(
      typeof instrArgs === "object" && typeof instrArgs.length !== "undefined"
    );
  }

  const node: CallInstruction = {
    type: "CallInstruction",
    id: "call",
    index
  };

  if (typeof instrArgs !== "undefined" && instrArgs.length > 0) {
    node.instrArgs = instrArgs;
  }

  if (typeof numeric !== "undefined") {
    node.numeric = numeric;
github xtuc / webassemblyjs / packages / helper-module-context / src / index.js View on Github external
export function moduleContextFromModuleAST(m) {
  const moduleContext = new ModuleContext();

  assert(m.type === "Module");

  m.fields.forEach(field => {
    switch (field.type) {
      case "Start": {
        moduleContext.setStart(field.index);
        break;
      }
      case "TypeInstruction": {
        moduleContext.addType(field);
        break;
      }
      case "Func": {
        moduleContext.addFunction(field);
        break;
      }
      case "Global": {
github xtuc / webassemblyjs / packages / ast / src / nodes.js View on Github external
export function instr(
  id: string,
  object?: Valtype,
  args: Array,
  namedArgs?: Object
): Instr {
  assert(
    typeof id === "string",
    "Argument id must be of type string, given: " + typeof id
  );

  assert(typeof args === "object" && typeof args.length !== "undefined");

  const node: Instr = {
    type: "Instr",
    id,
    args
  };

  if (typeof object !== "undefined") {
    node.object = object;
  }
github xtuc / webassemblyjs / packages / ast / src / nodes.js View on Github external
export function producerMetadataVersionedName(
  name: string,
  version: string
): ProducerMetadataVersionedName {
  assert(
    typeof name === "string",
    "Argument name must be of type string, given: " + typeof name
  );
  assert(
    typeof version === "string",
    "Argument version must be of type string, given: " + typeof version
  );

  const node: ProducerMetadataVersionedName = {
    type: "ProducerMetadataVersionedName",
    name,
    version
  };

  return node;
}
github xtuc / webassemblyjs / packages / webassemblyjs / src / interpreter / runtime / values / module.js View on Github external
validate(instantiatedItem);

      assertNotAlreadyExported(node.name);

      moduleInstance.exports.push({
        name: node.name,
        value: {
          type: node.descr.exportType,
          addr: instantiatedItem.addr
        }
      });
    } else if (isNumberLiteral(node.descr.id) === true) {
      const instantiatedItem = {
        addr: instantiatedItemInFromModule[parseInt(node.descr.id.value)]
      };
      assert(instantiatedItem !== undefined);

      validate(instantiatedItem);

      assertNotAlreadyExported(node.name);

      moduleInstance.exports.push({
        name: node.name,
        value: {
          type: node.descr.exportType,
          addr: instantiatedItem.addr
        }
      });
    } else {
      throw new CompileError(
        "Module exports must be referenced via an Identifier"
      );
github xtuc / webassemblyjs / packages / ast / src / nodes.js View on Github external
export function moduleExport(
  name: string,
  descr: ModuleExportDescr
): ModuleExport {
  assert(
    typeof name === "string",
    "Argument name must be of type string, given: " + typeof name
  );

  const node: ModuleExport = {
    type: "ModuleExport",
    name,
    descr
  };

  return node;
}
github xtuc / webassemblyjs / packages / ast / src / nodes.js View on Github external
export function numberLiteral(value: number, raw: string): NumberLiteral {
  assert(
    typeof value === "number",
    "Argument value must be of type number, given: " + typeof value
  );
  assert(
    typeof raw === "string",
    "Argument raw must be of type string, given: " + typeof raw
  );

  const node: NumberLiteral = {
    type: "NumberLiteral",
    value,
    raw
  };

  return node;
}

mamacro

MIT
Latest version published 6 years ago

Package Health Score

62 / 100
Full package analysis