Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import * as encoder from "./encoder";
  2. export function encodeNode(n) {
  3. switch (n.type) {
  4. case "ModuleImport":
  5. // $FlowIgnore: ModuleImport ensure that the node is well formated
  6. return encoder.encodeModuleImport(n);
  7. case "SectionMetadata":
  8. // $FlowIgnore: SectionMetadata ensure that the node is well formated
  9. return encoder.encodeSectionMetadata(n);
  10. case "CallInstruction":
  11. // $FlowIgnore: SectionMetadata ensure that the node is well formated
  12. return encoder.encodeCallInstruction(n);
  13. case "CallIndirectInstruction":
  14. // $FlowIgnore: SectionMetadata ensure that the node is well formated
  15. return encoder.encodeCallIndirectInstruction(n);
  16. case "TypeInstruction":
  17. return encoder.encodeTypeInstruction(n);
  18. case "Instr":
  19. // $FlowIgnore
  20. return encoder.encodeInstr(n);
  21. case "ModuleExport":
  22. // $FlowIgnore: SectionMetadata ensure that the node is well formated
  23. return encoder.encodeModuleExport(n);
  24. case "Global":
  25. // $FlowIgnore
  26. return encoder.encodeGlobal(n);
  27. case "Func":
  28. return encoder.encodeFuncBody(n);
  29. case "IndexInFuncSection":
  30. return encoder.encodeIndexInFuncSection(n);
  31. case "StringLiteral":
  32. return encoder.encodeStringLiteral(n);
  33. case "Elem":
  34. return encoder.encodeElem(n);
  35. default:
  36. throw new Error("Unsupported encoding for node of type: " + JSON.stringify(n.type));
  37. }
  38. }
  39. export var encodeU32 = encoder.encodeU32;