You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
4.7 KiB

4 years ago
  1. # @webassemblyjs/ast
  2. > AST utils for webassemblyjs
  3. ## Installation
  4. ```sh
  5. yarn add @webassemblyjs/ast
  6. ```
  7. ## Usage
  8. ### Traverse
  9. ```js
  10. import { traverse } from "@webassemblyjs/ast";
  11. traverse(ast, {
  12. Module(path) {
  13. console.log(path.node);
  14. }
  15. });
  16. ```
  17. ### Instruction signatures
  18. ```js
  19. import { signatures } from "@webassemblyjs/ast";
  20. console.log(signatures);
  21. ```
  22. ### Path methods
  23. - `findParent: NodeLocator`
  24. - `replaceWith: Node => void`
  25. - `remove: () => void`
  26. - `insertBefore: Node => void`
  27. - `insertAfter: Node => void`
  28. - `stop: () => void`
  29. ### AST utils
  30. - function `module(id, fields, metadata)`
  31. - function `moduleMetadata(sections, functionNames, localNames)`
  32. - function `moduleNameMetadata(value)`
  33. - function `functionNameMetadata(value, index)`
  34. - function `localNameMetadata(value, localIndex, functionIndex)`
  35. - function `binaryModule(id, blob)`
  36. - function `quoteModule(id, string)`
  37. - function `sectionMetadata(section, startOffset, size, vectorOfSize)`
  38. - function `loopInstruction(label, resulttype, instr)`
  39. - function `instruction(id, args, namedArgs)`
  40. - function `objectInstruction(id, object, args, namedArgs)`
  41. - function `ifInstruction(testLabel, test, result, consequent, alternate)`
  42. - function `stringLiteral(value)`
  43. - function `numberLiteralFromRaw(value, raw)`
  44. - function `longNumberLiteral(value, raw)`
  45. - function `floatLiteral(value, nan, inf, raw)`
  46. - function `elem(table, offset, funcs)`
  47. - function `indexInFuncSection(index)`
  48. - function `valtypeLiteral(name)`
  49. - function `typeInstruction(id, functype)`
  50. - function `start(index)`
  51. - function `globalType(valtype, mutability)`
  52. - function `leadingComment(value)`
  53. - function `blockComment(value)`
  54. - function `data(memoryIndex, offset, init)`
  55. - function `global(globalType, init, name)`
  56. - function `table(elementType, limits, name, elements)`
  57. - function `memory(limits, id)`
  58. - function `funcImportDescr(id, signature)`
  59. - function `moduleImport(module, name, descr)`
  60. - function `moduleExportDescr(exportType, id)`
  61. - function `moduleExport(name, descr)`
  62. - function `limit(min, max)`
  63. - function `signature(params, results)`
  64. - function `program(body)`
  65. - function `identifier(value, raw)`
  66. - function `blockInstruction(label, instr, result)`
  67. - function `callInstruction(index, instrArgs)`
  68. - function `callIndirectInstruction(signature, intrs)`
  69. - function `byteArray(values)`
  70. - function `func(name, signature, body, isExternal, metadata)`
  71. - Constant`isModule`
  72. - Constant`isModuleMetadata`
  73. - Constant`isModuleNameMetadata`
  74. - Constant`isFunctionNameMetadata`
  75. - Constant`isLocalNameMetadata`
  76. - Constant`isBinaryModule`
  77. - Constant`isQuoteModule`
  78. - Constant`isSectionMetadata`
  79. - Constant`isLoopInstruction`
  80. - Constant`isInstruction`
  81. - Constant`isObjectInstruction`
  82. - Constant`isIfInstruction`
  83. - Constant`isStringLiteral`
  84. - Constant`isNumberLiteral`
  85. - Constant`isLongNumberLiteral`
  86. - Constant`isFloatLiteral`
  87. - Constant`isElem`
  88. - Constant`isIndexInFuncSection`
  89. - Constant`isValtypeLiteral`
  90. - Constant`isTypeInstruction`
  91. - Constant`isStart`
  92. - Constant`isGlobalType`
  93. - Constant`isLeadingComment`
  94. - Constant`isBlockComment`
  95. - Constant`isData`
  96. - Constant`isGlobal`
  97. - Constant`isTable`
  98. - Constant`isMemory`
  99. - Constant`isFuncImportDescr`
  100. - Constant`isModuleImport`
  101. - Constant`isModuleExportDescr`
  102. - Constant`isModuleExport`
  103. - Constant`isLimit`
  104. - Constant`isSignature`
  105. - Constant`isProgram`
  106. - Constant`isIdentifier`
  107. - Constant`isBlockInstruction`
  108. - Constant`isCallInstruction`
  109. - Constant`isCallIndirectInstruction`
  110. - Constant`isByteArray`
  111. - Constant`isFunc`
  112. - Constant`assertModule`
  113. - Constant`assertModuleMetadata`
  114. - Constant`assertModuleNameMetadata`
  115. - Constant`assertFunctionNameMetadata`
  116. - Constant`assertLocalNameMetadata`
  117. - Constant`assertBinaryModule`
  118. - Constant`assertQuoteModule`
  119. - Constant`assertSectionMetadata`
  120. - Constant`assertLoopInstruction`
  121. - Constant`assertInstruction`
  122. - Constant`assertObjectInstruction`
  123. - Constant`assertIfInstruction`
  124. - Constant`assertStringLiteral`
  125. - Constant`assertNumberLiteral`
  126. - Constant`assertLongNumberLiteral`
  127. - Constant`assertFloatLiteral`
  128. - Constant`assertElem`
  129. - Constant`assertIndexInFuncSection`
  130. - Constant`assertValtypeLiteral`
  131. - Constant`assertTypeInstruction`
  132. - Constant`assertStart`
  133. - Constant`assertGlobalType`
  134. - Constant`assertLeadingComment`
  135. - Constant`assertBlockComment`
  136. - Constant`assertData`
  137. - Constant`assertGlobal`
  138. - Constant`assertTable`
  139. - Constant`assertMemory`
  140. - Constant`assertFuncImportDescr`
  141. - Constant`assertModuleImport`
  142. - Constant`assertModuleExportDescr`
  143. - Constant`assertModuleExport`
  144. - Constant`assertLimit`
  145. - Constant`assertSignature`
  146. - Constant`assertProgram`
  147. - Constant`assertIdentifier`
  148. - Constant`assertBlockInstruction`
  149. - Constant`assertCallInstruction`
  150. - Constant`assertCallIndirectInstruction`
  151. - Constant`assertByteArray`
  152. - Constant`assertFunc`