Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/LICENSE +21 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/README.md +167 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/clone.js +4 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/definitions.js +668 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/index.js +7 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/node-helpers.js +84 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/node-path.js +141 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/nodes.js +925 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/signatures.js +199 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/transform/ast-module-to-module-context/index.js +377 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/transform/denormalize-type-references/index.js +76 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/transform/wast-identifier-to-index/index.js +229 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/traverse.js +96 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/types/basic.js +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/types/nodes.js +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/types/traverse.js +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/utils.js +272 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/clone.js +11 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/definitions.js +670 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/index.js +129 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/node-helpers.js +107 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/node-path.js +148 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/nodes.js +1144 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/signatures.js +207 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/transform/ast-module-to-module-context/index.js +389 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/transform/denormalize-type-references/index.js +83 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/transform/wast-identifier-to-index/index.js +238 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/traverse.js +105 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/types/basic.js +1 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/types/nodes.js +1 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/types/traverse.js +1 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/utils.js +315 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/package.json +32 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/scripts/generateNodeUtils.js +219 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/scripts/generateTypeDefinitions.js +48 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/scripts/util.js +38 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/LICENSE +21 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/README.md +34 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/esm/index.js +42 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/lib/index.js +49 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/package.json +24 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-api-error/LICENSE +21 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-api-error/esm/index.js +63 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-api-error/lib/index.js +78 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-api-error/package.json +18 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/LICENSE +21 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/esm/compare.js +65 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/esm/index.js +78 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/lib/compare.js +73 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/lib/index.js +89 -0
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018 Sven Sauleau <sven@sauleau.com>
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @webassemblyjs/ast
|
| 2 |
+
|
| 3 |
+
> AST utils for webassemblyjs
|
| 4 |
+
|
| 5 |
+
## Installation
|
| 6 |
+
|
| 7 |
+
```sh
|
| 8 |
+
yarn add @webassemblyjs/ast
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
## Usage
|
| 12 |
+
|
| 13 |
+
### Traverse
|
| 14 |
+
|
| 15 |
+
```js
|
| 16 |
+
import { traverse } from "@webassemblyjs/ast";
|
| 17 |
+
|
| 18 |
+
traverse(ast, {
|
| 19 |
+
Module(path) {
|
| 20 |
+
console.log(path.node);
|
| 21 |
+
}
|
| 22 |
+
});
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
### Instruction signatures
|
| 26 |
+
|
| 27 |
+
```js
|
| 28 |
+
import { signatures } from "@webassemblyjs/ast";
|
| 29 |
+
|
| 30 |
+
console.log(signatures);
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
### Path methods
|
| 34 |
+
|
| 35 |
+
- `findParent: NodeLocator`
|
| 36 |
+
- `replaceWith: Node => void`
|
| 37 |
+
- `remove: () => void`
|
| 38 |
+
- `insertBefore: Node => void`
|
| 39 |
+
- `insertAfter: Node => void`
|
| 40 |
+
- `stop: () => void`
|
| 41 |
+
|
| 42 |
+
### AST utils
|
| 43 |
+
|
| 44 |
+
- function `module(id, fields, metadata)`
|
| 45 |
+
- function `moduleMetadata(sections, functionNames, localNames)`
|
| 46 |
+
- function `moduleNameMetadata(value)`
|
| 47 |
+
- function `functionNameMetadata(value, index)`
|
| 48 |
+
- function `localNameMetadata(value, localIndex, functionIndex)`
|
| 49 |
+
- function `binaryModule(id, blob)`
|
| 50 |
+
- function `quoteModule(id, string)`
|
| 51 |
+
- function `sectionMetadata(section, startOffset, size, vectorOfSize)`
|
| 52 |
+
- function `loopInstruction(label, resulttype, instr)`
|
| 53 |
+
- function `instruction(id, args, namedArgs)`
|
| 54 |
+
- function `objectInstruction(id, object, args, namedArgs)`
|
| 55 |
+
- function `ifInstruction(testLabel, test, result, consequent, alternate)`
|
| 56 |
+
- function `stringLiteral(value)`
|
| 57 |
+
- function `numberLiteralFromRaw(value, raw)`
|
| 58 |
+
- function `longNumberLiteral(value, raw)`
|
| 59 |
+
- function `floatLiteral(value, nan, inf, raw)`
|
| 60 |
+
- function `elem(table, offset, funcs)`
|
| 61 |
+
- function `indexInFuncSection(index)`
|
| 62 |
+
- function `valtypeLiteral(name)`
|
| 63 |
+
- function `typeInstruction(id, functype)`
|
| 64 |
+
- function `start(index)`
|
| 65 |
+
- function `globalType(valtype, mutability)`
|
| 66 |
+
- function `leadingComment(value)`
|
| 67 |
+
- function `blockComment(value)`
|
| 68 |
+
- function `data(memoryIndex, offset, init)`
|
| 69 |
+
- function `global(globalType, init, name)`
|
| 70 |
+
- function `table(elementType, limits, name, elements)`
|
| 71 |
+
- function `memory(limits, id)`
|
| 72 |
+
- function `funcImportDescr(id, signature)`
|
| 73 |
+
- function `moduleImport(module, name, descr)`
|
| 74 |
+
- function `moduleExportDescr(exportType, id)`
|
| 75 |
+
- function `moduleExport(name, descr)`
|
| 76 |
+
- function `limit(min, max)`
|
| 77 |
+
- function `signature(params, results)`
|
| 78 |
+
- function `program(body)`
|
| 79 |
+
- function `identifier(value, raw)`
|
| 80 |
+
- function `blockInstruction(label, instr, result)`
|
| 81 |
+
- function `callInstruction(index, instrArgs)`
|
| 82 |
+
- function `callIndirectInstruction(signature, intrs)`
|
| 83 |
+
- function `byteArray(values)`
|
| 84 |
+
- function `func(name, signature, body, isExternal, metadata)`
|
| 85 |
+
- Constant`isModule`
|
| 86 |
+
- Constant`isModuleMetadata`
|
| 87 |
+
- Constant`isModuleNameMetadata`
|
| 88 |
+
- Constant`isFunctionNameMetadata`
|
| 89 |
+
- Constant`isLocalNameMetadata`
|
| 90 |
+
- Constant`isBinaryModule`
|
| 91 |
+
- Constant`isQuoteModule`
|
| 92 |
+
- Constant`isSectionMetadata`
|
| 93 |
+
- Constant`isLoopInstruction`
|
| 94 |
+
- Constant`isInstruction`
|
| 95 |
+
- Constant`isObjectInstruction`
|
| 96 |
+
- Constant`isIfInstruction`
|
| 97 |
+
- Constant`isStringLiteral`
|
| 98 |
+
- Constant`isNumberLiteral`
|
| 99 |
+
- Constant`isLongNumberLiteral`
|
| 100 |
+
- Constant`isFloatLiteral`
|
| 101 |
+
- Constant`isElem`
|
| 102 |
+
- Constant`isIndexInFuncSection`
|
| 103 |
+
- Constant`isValtypeLiteral`
|
| 104 |
+
- Constant`isTypeInstruction`
|
| 105 |
+
- Constant`isStart`
|
| 106 |
+
- Constant`isGlobalType`
|
| 107 |
+
- Constant`isLeadingComment`
|
| 108 |
+
- Constant`isBlockComment`
|
| 109 |
+
- Constant`isData`
|
| 110 |
+
- Constant`isGlobal`
|
| 111 |
+
- Constant`isTable`
|
| 112 |
+
- Constant`isMemory`
|
| 113 |
+
- Constant`isFuncImportDescr`
|
| 114 |
+
- Constant`isModuleImport`
|
| 115 |
+
- Constant`isModuleExportDescr`
|
| 116 |
+
- Constant`isModuleExport`
|
| 117 |
+
- Constant`isLimit`
|
| 118 |
+
- Constant`isSignature`
|
| 119 |
+
- Constant`isProgram`
|
| 120 |
+
- Constant`isIdentifier`
|
| 121 |
+
- Constant`isBlockInstruction`
|
| 122 |
+
- Constant`isCallInstruction`
|
| 123 |
+
- Constant`isCallIndirectInstruction`
|
| 124 |
+
- Constant`isByteArray`
|
| 125 |
+
- Constant`isFunc`
|
| 126 |
+
- Constant`assertModule`
|
| 127 |
+
- Constant`assertModuleMetadata`
|
| 128 |
+
- Constant`assertModuleNameMetadata`
|
| 129 |
+
- Constant`assertFunctionNameMetadata`
|
| 130 |
+
- Constant`assertLocalNameMetadata`
|
| 131 |
+
- Constant`assertBinaryModule`
|
| 132 |
+
- Constant`assertQuoteModule`
|
| 133 |
+
- Constant`assertSectionMetadata`
|
| 134 |
+
- Constant`assertLoopInstruction`
|
| 135 |
+
- Constant`assertInstruction`
|
| 136 |
+
- Constant`assertObjectInstruction`
|
| 137 |
+
- Constant`assertIfInstruction`
|
| 138 |
+
- Constant`assertStringLiteral`
|
| 139 |
+
- Constant`assertNumberLiteral`
|
| 140 |
+
- Constant`assertLongNumberLiteral`
|
| 141 |
+
- Constant`assertFloatLiteral`
|
| 142 |
+
- Constant`assertElem`
|
| 143 |
+
- Constant`assertIndexInFuncSection`
|
| 144 |
+
- Constant`assertValtypeLiteral`
|
| 145 |
+
- Constant`assertTypeInstruction`
|
| 146 |
+
- Constant`assertStart`
|
| 147 |
+
- Constant`assertGlobalType`
|
| 148 |
+
- Constant`assertLeadingComment`
|
| 149 |
+
- Constant`assertBlockComment`
|
| 150 |
+
- Constant`assertData`
|
| 151 |
+
- Constant`assertGlobal`
|
| 152 |
+
- Constant`assertTable`
|
| 153 |
+
- Constant`assertMemory`
|
| 154 |
+
- Constant`assertFuncImportDescr`
|
| 155 |
+
- Constant`assertModuleImport`
|
| 156 |
+
- Constant`assertModuleExportDescr`
|
| 157 |
+
- Constant`assertModuleExport`
|
| 158 |
+
- Constant`assertLimit`
|
| 159 |
+
- Constant`assertSignature`
|
| 160 |
+
- Constant`assertProgram`
|
| 161 |
+
- Constant`assertIdentifier`
|
| 162 |
+
- Constant`assertBlockInstruction`
|
| 163 |
+
- Constant`assertCallInstruction`
|
| 164 |
+
- Constant`assertCallIndirectInstruction`
|
| 165 |
+
- Constant`assertByteArray`
|
| 166 |
+
- Constant`assertFunc`
|
| 167 |
+
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/clone.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export function cloneNode(n) {
|
| 2 |
+
// $FlowIgnore
|
| 3 |
+
return Object.assign({}, n);
|
| 4 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/definitions.js
ADDED
|
@@ -0,0 +1,668 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var definitions = {};
|
| 2 |
+
|
| 3 |
+
function defineType(typeName, metadata) {
|
| 4 |
+
definitions[typeName] = metadata;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
defineType("Module", {
|
| 8 |
+
spec: {
|
| 9 |
+
wasm: "https://webassembly.github.io/spec/core/binary/modules.html#binary-module",
|
| 10 |
+
wat: "https://webassembly.github.io/spec/core/text/modules.html#text-module"
|
| 11 |
+
},
|
| 12 |
+
doc: "A module consists of a sequence of sections (termed fields in the text format).",
|
| 13 |
+
unionType: ["Node"],
|
| 14 |
+
fields: {
|
| 15 |
+
id: {
|
| 16 |
+
maybe: true,
|
| 17 |
+
type: "string"
|
| 18 |
+
},
|
| 19 |
+
fields: {
|
| 20 |
+
array: true,
|
| 21 |
+
type: "Node"
|
| 22 |
+
},
|
| 23 |
+
metadata: {
|
| 24 |
+
optional: true,
|
| 25 |
+
type: "ModuleMetadata"
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
});
|
| 29 |
+
defineType("ModuleMetadata", {
|
| 30 |
+
unionType: ["Node"],
|
| 31 |
+
fields: {
|
| 32 |
+
sections: {
|
| 33 |
+
array: true,
|
| 34 |
+
type: "SectionMetadata"
|
| 35 |
+
},
|
| 36 |
+
functionNames: {
|
| 37 |
+
optional: true,
|
| 38 |
+
array: true,
|
| 39 |
+
type: "FunctionNameMetadata"
|
| 40 |
+
},
|
| 41 |
+
localNames: {
|
| 42 |
+
optional: true,
|
| 43 |
+
array: true,
|
| 44 |
+
type: "ModuleMetadata"
|
| 45 |
+
},
|
| 46 |
+
producers: {
|
| 47 |
+
optional: true,
|
| 48 |
+
array: true,
|
| 49 |
+
type: "ProducersSectionMetadata"
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
});
|
| 53 |
+
defineType("ModuleNameMetadata", {
|
| 54 |
+
unionType: ["Node"],
|
| 55 |
+
fields: {
|
| 56 |
+
value: {
|
| 57 |
+
type: "string"
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
});
|
| 61 |
+
defineType("FunctionNameMetadata", {
|
| 62 |
+
unionType: ["Node"],
|
| 63 |
+
fields: {
|
| 64 |
+
value: {
|
| 65 |
+
type: "string"
|
| 66 |
+
},
|
| 67 |
+
index: {
|
| 68 |
+
type: "number"
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
});
|
| 72 |
+
defineType("LocalNameMetadata", {
|
| 73 |
+
unionType: ["Node"],
|
| 74 |
+
fields: {
|
| 75 |
+
value: {
|
| 76 |
+
type: "string"
|
| 77 |
+
},
|
| 78 |
+
localIndex: {
|
| 79 |
+
type: "number"
|
| 80 |
+
},
|
| 81 |
+
functionIndex: {
|
| 82 |
+
type: "number"
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
});
|
| 86 |
+
defineType("BinaryModule", {
|
| 87 |
+
unionType: ["Node"],
|
| 88 |
+
fields: {
|
| 89 |
+
id: {
|
| 90 |
+
maybe: true,
|
| 91 |
+
type: "string"
|
| 92 |
+
},
|
| 93 |
+
blob: {
|
| 94 |
+
array: true,
|
| 95 |
+
type: "string"
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
});
|
| 99 |
+
defineType("QuoteModule", {
|
| 100 |
+
unionType: ["Node"],
|
| 101 |
+
fields: {
|
| 102 |
+
id: {
|
| 103 |
+
maybe: true,
|
| 104 |
+
type: "string"
|
| 105 |
+
},
|
| 106 |
+
string: {
|
| 107 |
+
array: true,
|
| 108 |
+
type: "string"
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
});
|
| 112 |
+
defineType("SectionMetadata", {
|
| 113 |
+
unionType: ["Node"],
|
| 114 |
+
fields: {
|
| 115 |
+
section: {
|
| 116 |
+
type: "SectionName"
|
| 117 |
+
},
|
| 118 |
+
startOffset: {
|
| 119 |
+
type: "number"
|
| 120 |
+
},
|
| 121 |
+
size: {
|
| 122 |
+
type: "NumberLiteral"
|
| 123 |
+
},
|
| 124 |
+
vectorOfSize: {
|
| 125 |
+
comment: "Size of the vector in the section (if any)",
|
| 126 |
+
type: "NumberLiteral"
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
});
|
| 130 |
+
defineType("ProducersSectionMetadata", {
|
| 131 |
+
unionType: ["Node"],
|
| 132 |
+
fields: {
|
| 133 |
+
producers: {
|
| 134 |
+
array: true,
|
| 135 |
+
type: "ProducerMetadata"
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
});
|
| 139 |
+
defineType("ProducerMetadata", {
|
| 140 |
+
unionType: ["Node"],
|
| 141 |
+
fields: {
|
| 142 |
+
language: {
|
| 143 |
+
type: "ProducerMetadataVersionedName",
|
| 144 |
+
array: true
|
| 145 |
+
},
|
| 146 |
+
processedBy: {
|
| 147 |
+
type: "ProducerMetadataVersionedName",
|
| 148 |
+
array: true
|
| 149 |
+
},
|
| 150 |
+
sdk: {
|
| 151 |
+
type: "ProducerMetadataVersionedName",
|
| 152 |
+
array: true
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
});
|
| 156 |
+
defineType("ProducerMetadataVersionedName", {
|
| 157 |
+
unionType: ["Node"],
|
| 158 |
+
fields: {
|
| 159 |
+
name: {
|
| 160 |
+
type: "string"
|
| 161 |
+
},
|
| 162 |
+
version: {
|
| 163 |
+
type: "string"
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
});
|
| 167 |
+
/*
|
| 168 |
+
Instructions
|
| 169 |
+
*/
|
| 170 |
+
|
| 171 |
+
defineType("LoopInstruction", {
|
| 172 |
+
unionType: ["Node", "Block", "Instruction"],
|
| 173 |
+
fields: {
|
| 174 |
+
id: {
|
| 175 |
+
constant: true,
|
| 176 |
+
type: "string",
|
| 177 |
+
value: "loop"
|
| 178 |
+
},
|
| 179 |
+
label: {
|
| 180 |
+
maybe: true,
|
| 181 |
+
type: "Identifier"
|
| 182 |
+
},
|
| 183 |
+
resulttype: {
|
| 184 |
+
maybe: true,
|
| 185 |
+
type: "Valtype"
|
| 186 |
+
},
|
| 187 |
+
instr: {
|
| 188 |
+
array: true,
|
| 189 |
+
type: "Instruction"
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
});
|
| 193 |
+
defineType("Instr", {
|
| 194 |
+
unionType: ["Node", "Expression", "Instruction"],
|
| 195 |
+
fields: {
|
| 196 |
+
id: {
|
| 197 |
+
type: "string"
|
| 198 |
+
},
|
| 199 |
+
object: {
|
| 200 |
+
optional: true,
|
| 201 |
+
type: "Valtype"
|
| 202 |
+
},
|
| 203 |
+
args: {
|
| 204 |
+
array: true,
|
| 205 |
+
type: "Expression"
|
| 206 |
+
},
|
| 207 |
+
namedArgs: {
|
| 208 |
+
optional: true,
|
| 209 |
+
type: "Object"
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
});
|
| 213 |
+
defineType("IfInstruction", {
|
| 214 |
+
unionType: ["Node", "Instruction"],
|
| 215 |
+
fields: {
|
| 216 |
+
id: {
|
| 217 |
+
constant: true,
|
| 218 |
+
type: "string",
|
| 219 |
+
value: "if"
|
| 220 |
+
},
|
| 221 |
+
testLabel: {
|
| 222 |
+
comment: "only for WAST",
|
| 223 |
+
type: "Identifier"
|
| 224 |
+
},
|
| 225 |
+
test: {
|
| 226 |
+
array: true,
|
| 227 |
+
type: "Instruction"
|
| 228 |
+
},
|
| 229 |
+
result: {
|
| 230 |
+
maybe: true,
|
| 231 |
+
type: "Valtype"
|
| 232 |
+
},
|
| 233 |
+
consequent: {
|
| 234 |
+
array: true,
|
| 235 |
+
type: "Instruction"
|
| 236 |
+
},
|
| 237 |
+
alternate: {
|
| 238 |
+
array: true,
|
| 239 |
+
type: "Instruction"
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
});
|
| 243 |
+
/*
|
| 244 |
+
Concrete value types
|
| 245 |
+
*/
|
| 246 |
+
|
| 247 |
+
defineType("StringLiteral", {
|
| 248 |
+
unionType: ["Node", "Expression"],
|
| 249 |
+
fields: {
|
| 250 |
+
value: {
|
| 251 |
+
type: "string"
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
});
|
| 255 |
+
defineType("NumberLiteral", {
|
| 256 |
+
unionType: ["Node", "NumericLiteral", "Expression"],
|
| 257 |
+
fields: {
|
| 258 |
+
value: {
|
| 259 |
+
type: "number"
|
| 260 |
+
},
|
| 261 |
+
raw: {
|
| 262 |
+
type: "string"
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
});
|
| 266 |
+
defineType("LongNumberLiteral", {
|
| 267 |
+
unionType: ["Node", "NumericLiteral", "Expression"],
|
| 268 |
+
fields: {
|
| 269 |
+
value: {
|
| 270 |
+
type: "LongNumber"
|
| 271 |
+
},
|
| 272 |
+
raw: {
|
| 273 |
+
type: "string"
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
});
|
| 277 |
+
defineType("FloatLiteral", {
|
| 278 |
+
unionType: ["Node", "NumericLiteral", "Expression"],
|
| 279 |
+
fields: {
|
| 280 |
+
value: {
|
| 281 |
+
type: "number"
|
| 282 |
+
},
|
| 283 |
+
nan: {
|
| 284 |
+
optional: true,
|
| 285 |
+
type: "boolean"
|
| 286 |
+
},
|
| 287 |
+
inf: {
|
| 288 |
+
optional: true,
|
| 289 |
+
type: "boolean"
|
| 290 |
+
},
|
| 291 |
+
raw: {
|
| 292 |
+
type: "string"
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
});
|
| 296 |
+
defineType("Elem", {
|
| 297 |
+
unionType: ["Node"],
|
| 298 |
+
fields: {
|
| 299 |
+
table: {
|
| 300 |
+
type: "Index"
|
| 301 |
+
},
|
| 302 |
+
offset: {
|
| 303 |
+
array: true,
|
| 304 |
+
type: "Instruction"
|
| 305 |
+
},
|
| 306 |
+
funcs: {
|
| 307 |
+
array: true,
|
| 308 |
+
type: "Index"
|
| 309 |
+
}
|
| 310 |
+
}
|
| 311 |
+
});
|
| 312 |
+
defineType("IndexInFuncSection", {
|
| 313 |
+
unionType: ["Node"],
|
| 314 |
+
fields: {
|
| 315 |
+
index: {
|
| 316 |
+
type: "Index"
|
| 317 |
+
}
|
| 318 |
+
}
|
| 319 |
+
});
|
| 320 |
+
defineType("ValtypeLiteral", {
|
| 321 |
+
unionType: ["Node", "Expression"],
|
| 322 |
+
fields: {
|
| 323 |
+
name: {
|
| 324 |
+
type: "Valtype"
|
| 325 |
+
}
|
| 326 |
+
}
|
| 327 |
+
});
|
| 328 |
+
defineType("TypeInstruction", {
|
| 329 |
+
unionType: ["Node", "Instruction"],
|
| 330 |
+
fields: {
|
| 331 |
+
id: {
|
| 332 |
+
maybe: true,
|
| 333 |
+
type: "Index"
|
| 334 |
+
},
|
| 335 |
+
functype: {
|
| 336 |
+
type: "Signature"
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
});
|
| 340 |
+
defineType("Start", {
|
| 341 |
+
unionType: ["Node"],
|
| 342 |
+
fields: {
|
| 343 |
+
index: {
|
| 344 |
+
type: "Index"
|
| 345 |
+
}
|
| 346 |
+
}
|
| 347 |
+
});
|
| 348 |
+
defineType("GlobalType", {
|
| 349 |
+
unionType: ["Node", "ImportDescr"],
|
| 350 |
+
fields: {
|
| 351 |
+
valtype: {
|
| 352 |
+
type: "Valtype"
|
| 353 |
+
},
|
| 354 |
+
mutability: {
|
| 355 |
+
type: "Mutability"
|
| 356 |
+
}
|
| 357 |
+
}
|
| 358 |
+
});
|
| 359 |
+
defineType("LeadingComment", {
|
| 360 |
+
unionType: ["Node"],
|
| 361 |
+
fields: {
|
| 362 |
+
value: {
|
| 363 |
+
type: "string"
|
| 364 |
+
}
|
| 365 |
+
}
|
| 366 |
+
});
|
| 367 |
+
defineType("BlockComment", {
|
| 368 |
+
unionType: ["Node"],
|
| 369 |
+
fields: {
|
| 370 |
+
value: {
|
| 371 |
+
type: "string"
|
| 372 |
+
}
|
| 373 |
+
}
|
| 374 |
+
});
|
| 375 |
+
defineType("Data", {
|
| 376 |
+
unionType: ["Node"],
|
| 377 |
+
fields: {
|
| 378 |
+
memoryIndex: {
|
| 379 |
+
type: "Memidx"
|
| 380 |
+
},
|
| 381 |
+
offset: {
|
| 382 |
+
type: "Instruction"
|
| 383 |
+
},
|
| 384 |
+
init: {
|
| 385 |
+
type: "ByteArray"
|
| 386 |
+
}
|
| 387 |
+
}
|
| 388 |
+
});
|
| 389 |
+
defineType("Global", {
|
| 390 |
+
unionType: ["Node"],
|
| 391 |
+
fields: {
|
| 392 |
+
globalType: {
|
| 393 |
+
type: "GlobalType"
|
| 394 |
+
},
|
| 395 |
+
init: {
|
| 396 |
+
array: true,
|
| 397 |
+
type: "Instruction"
|
| 398 |
+
},
|
| 399 |
+
name: {
|
| 400 |
+
maybe: true,
|
| 401 |
+
type: "Identifier"
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
});
|
| 405 |
+
defineType("Table", {
|
| 406 |
+
unionType: ["Node", "ImportDescr"],
|
| 407 |
+
fields: {
|
| 408 |
+
elementType: {
|
| 409 |
+
type: "TableElementType"
|
| 410 |
+
},
|
| 411 |
+
limits: {
|
| 412 |
+
assertNodeType: true,
|
| 413 |
+
type: "Limit"
|
| 414 |
+
},
|
| 415 |
+
name: {
|
| 416 |
+
maybe: true,
|
| 417 |
+
type: "Identifier"
|
| 418 |
+
},
|
| 419 |
+
elements: {
|
| 420 |
+
array: true,
|
| 421 |
+
optional: true,
|
| 422 |
+
type: "Index"
|
| 423 |
+
}
|
| 424 |
+
}
|
| 425 |
+
});
|
| 426 |
+
defineType("Memory", {
|
| 427 |
+
unionType: ["Node", "ImportDescr"],
|
| 428 |
+
fields: {
|
| 429 |
+
limits: {
|
| 430 |
+
type: "Limit"
|
| 431 |
+
},
|
| 432 |
+
id: {
|
| 433 |
+
maybe: true,
|
| 434 |
+
type: "Index"
|
| 435 |
+
}
|
| 436 |
+
}
|
| 437 |
+
});
|
| 438 |
+
defineType("FuncImportDescr", {
|
| 439 |
+
unionType: ["Node", "ImportDescr"],
|
| 440 |
+
fields: {
|
| 441 |
+
id: {
|
| 442 |
+
type: "Identifier"
|
| 443 |
+
},
|
| 444 |
+
signature: {
|
| 445 |
+
type: "Signature"
|
| 446 |
+
}
|
| 447 |
+
}
|
| 448 |
+
});
|
| 449 |
+
defineType("ModuleImport", {
|
| 450 |
+
unionType: ["Node"],
|
| 451 |
+
fields: {
|
| 452 |
+
module: {
|
| 453 |
+
type: "string"
|
| 454 |
+
},
|
| 455 |
+
name: {
|
| 456 |
+
type: "string"
|
| 457 |
+
},
|
| 458 |
+
descr: {
|
| 459 |
+
type: "ImportDescr"
|
| 460 |
+
}
|
| 461 |
+
}
|
| 462 |
+
});
|
| 463 |
+
defineType("ModuleExportDescr", {
|
| 464 |
+
unionType: ["Node"],
|
| 465 |
+
fields: {
|
| 466 |
+
exportType: {
|
| 467 |
+
type: "ExportDescrType"
|
| 468 |
+
},
|
| 469 |
+
id: {
|
| 470 |
+
type: "Index"
|
| 471 |
+
}
|
| 472 |
+
}
|
| 473 |
+
});
|
| 474 |
+
defineType("ModuleExport", {
|
| 475 |
+
unionType: ["Node"],
|
| 476 |
+
fields: {
|
| 477 |
+
name: {
|
| 478 |
+
type: "string"
|
| 479 |
+
},
|
| 480 |
+
descr: {
|
| 481 |
+
type: "ModuleExportDescr"
|
| 482 |
+
}
|
| 483 |
+
}
|
| 484 |
+
});
|
| 485 |
+
defineType("Limit", {
|
| 486 |
+
unionType: ["Node"],
|
| 487 |
+
fields: {
|
| 488 |
+
min: {
|
| 489 |
+
type: "number"
|
| 490 |
+
},
|
| 491 |
+
max: {
|
| 492 |
+
optional: true,
|
| 493 |
+
type: "number"
|
| 494 |
+
},
|
| 495 |
+
// Threads proposal, shared memory
|
| 496 |
+
shared: {
|
| 497 |
+
optional: true,
|
| 498 |
+
type: "boolean"
|
| 499 |
+
}
|
| 500 |
+
}
|
| 501 |
+
});
|
| 502 |
+
defineType("Signature", {
|
| 503 |
+
unionType: ["Node"],
|
| 504 |
+
fields: {
|
| 505 |
+
params: {
|
| 506 |
+
array: true,
|
| 507 |
+
type: "FuncParam"
|
| 508 |
+
},
|
| 509 |
+
results: {
|
| 510 |
+
array: true,
|
| 511 |
+
type: "Valtype"
|
| 512 |
+
}
|
| 513 |
+
}
|
| 514 |
+
});
|
| 515 |
+
defineType("Program", {
|
| 516 |
+
unionType: ["Node"],
|
| 517 |
+
fields: {
|
| 518 |
+
body: {
|
| 519 |
+
array: true,
|
| 520 |
+
type: "Node"
|
| 521 |
+
}
|
| 522 |
+
}
|
| 523 |
+
});
|
| 524 |
+
defineType("Identifier", {
|
| 525 |
+
unionType: ["Node", "Expression"],
|
| 526 |
+
fields: {
|
| 527 |
+
value: {
|
| 528 |
+
type: "string"
|
| 529 |
+
},
|
| 530 |
+
raw: {
|
| 531 |
+
optional: true,
|
| 532 |
+
type: "string"
|
| 533 |
+
}
|
| 534 |
+
}
|
| 535 |
+
});
|
| 536 |
+
defineType("BlockInstruction", {
|
| 537 |
+
unionType: ["Node", "Block", "Instruction"],
|
| 538 |
+
fields: {
|
| 539 |
+
id: {
|
| 540 |
+
constant: true,
|
| 541 |
+
type: "string",
|
| 542 |
+
value: "block"
|
| 543 |
+
},
|
| 544 |
+
label: {
|
| 545 |
+
maybe: true,
|
| 546 |
+
type: "Identifier"
|
| 547 |
+
},
|
| 548 |
+
instr: {
|
| 549 |
+
array: true,
|
| 550 |
+
type: "Instruction"
|
| 551 |
+
},
|
| 552 |
+
result: {
|
| 553 |
+
maybe: true,
|
| 554 |
+
type: "Valtype"
|
| 555 |
+
}
|
| 556 |
+
}
|
| 557 |
+
});
|
| 558 |
+
defineType("CallInstruction", {
|
| 559 |
+
unionType: ["Node", "Instruction"],
|
| 560 |
+
fields: {
|
| 561 |
+
id: {
|
| 562 |
+
constant: true,
|
| 563 |
+
type: "string",
|
| 564 |
+
value: "call"
|
| 565 |
+
},
|
| 566 |
+
index: {
|
| 567 |
+
type: "Index"
|
| 568 |
+
},
|
| 569 |
+
instrArgs: {
|
| 570 |
+
array: true,
|
| 571 |
+
optional: true,
|
| 572 |
+
type: "Expression"
|
| 573 |
+
},
|
| 574 |
+
numeric: {
|
| 575 |
+
type: "Index",
|
| 576 |
+
optional: true
|
| 577 |
+
}
|
| 578 |
+
}
|
| 579 |
+
});
|
| 580 |
+
defineType("CallIndirectInstruction", {
|
| 581 |
+
unionType: ["Node", "Instruction"],
|
| 582 |
+
fields: {
|
| 583 |
+
id: {
|
| 584 |
+
constant: true,
|
| 585 |
+
type: "string",
|
| 586 |
+
value: "call_indirect"
|
| 587 |
+
},
|
| 588 |
+
signature: {
|
| 589 |
+
type: "SignatureOrTypeRef"
|
| 590 |
+
},
|
| 591 |
+
intrs: {
|
| 592 |
+
array: true,
|
| 593 |
+
optional: true,
|
| 594 |
+
type: "Expression"
|
| 595 |
+
}
|
| 596 |
+
}
|
| 597 |
+
});
|
| 598 |
+
defineType("ByteArray", {
|
| 599 |
+
unionType: ["Node"],
|
| 600 |
+
fields: {
|
| 601 |
+
values: {
|
| 602 |
+
array: true,
|
| 603 |
+
type: "Byte"
|
| 604 |
+
}
|
| 605 |
+
}
|
| 606 |
+
});
|
| 607 |
+
defineType("Func", {
|
| 608 |
+
unionType: ["Node", "Block"],
|
| 609 |
+
fields: {
|
| 610 |
+
name: {
|
| 611 |
+
maybe: true,
|
| 612 |
+
type: "Index"
|
| 613 |
+
},
|
| 614 |
+
signature: {
|
| 615 |
+
type: "SignatureOrTypeRef"
|
| 616 |
+
},
|
| 617 |
+
body: {
|
| 618 |
+
array: true,
|
| 619 |
+
type: "Instruction"
|
| 620 |
+
},
|
| 621 |
+
isExternal: {
|
| 622 |
+
comment: "means that it has been imported from the outside js",
|
| 623 |
+
optional: true,
|
| 624 |
+
type: "boolean"
|
| 625 |
+
},
|
| 626 |
+
metadata: {
|
| 627 |
+
optional: true,
|
| 628 |
+
type: "FuncMetadata"
|
| 629 |
+
}
|
| 630 |
+
}
|
| 631 |
+
});
|
| 632 |
+
/**
|
| 633 |
+
* Intrinsics
|
| 634 |
+
*/
|
| 635 |
+
|
| 636 |
+
defineType("InternalBrUnless", {
|
| 637 |
+
unionType: ["Node", "Intrinsic"],
|
| 638 |
+
fields: {
|
| 639 |
+
target: {
|
| 640 |
+
type: "number"
|
| 641 |
+
}
|
| 642 |
+
}
|
| 643 |
+
});
|
| 644 |
+
defineType("InternalGoto", {
|
| 645 |
+
unionType: ["Node", "Intrinsic"],
|
| 646 |
+
fields: {
|
| 647 |
+
target: {
|
| 648 |
+
type: "number"
|
| 649 |
+
}
|
| 650 |
+
}
|
| 651 |
+
});
|
| 652 |
+
defineType("InternalCallExtern", {
|
| 653 |
+
unionType: ["Node", "Intrinsic"],
|
| 654 |
+
fields: {
|
| 655 |
+
target: {
|
| 656 |
+
type: "number"
|
| 657 |
+
}
|
| 658 |
+
}
|
| 659 |
+
}); // function bodies are terminated by an `end` instruction but are missing a
|
| 660 |
+
// return instruction
|
| 661 |
+
//
|
| 662 |
+
// Since we can't inject a new instruction we are injecting a new instruction.
|
| 663 |
+
|
| 664 |
+
defineType("InternalEndAndReturn", {
|
| 665 |
+
unionType: ["Node", "Intrinsic"],
|
| 666 |
+
fields: {}
|
| 667 |
+
});
|
| 668 |
+
module.exports = definitions;
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from "./nodes";
|
| 2 |
+
export { numberLiteralFromRaw, withLoc, withRaw, funcParam, indexLiteral, memIndexLiteral, instruction, objectInstruction } from "./node-helpers.js";
|
| 3 |
+
export { traverse } from "./traverse";
|
| 4 |
+
export { signatures } from "./signatures";
|
| 5 |
+
export * from "./utils";
|
| 6 |
+
export { cloneNode } from "./clone";
|
| 7 |
+
export { moduleContextFromModuleAST } from "./transform/ast-module-to-module-context";
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/node-helpers.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { parse32F, parse64F, parse32I, parse64I, parseU32, isNanLiteral, isInfLiteral } from "@webassemblyjs/helper-numbers";
|
| 2 |
+
import { longNumberLiteral, floatLiteral, numberLiteral, instr } from "./nodes";
|
| 3 |
+
export function numberLiteralFromRaw(rawValue) {
|
| 4 |
+
var instructionType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "i32";
|
| 5 |
+
var original = rawValue; // Remove numeric separators _
|
| 6 |
+
|
| 7 |
+
if (typeof rawValue === "string") {
|
| 8 |
+
rawValue = rawValue.replace(/_/g, "");
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
if (typeof rawValue === "number") {
|
| 12 |
+
return numberLiteral(rawValue, String(original));
|
| 13 |
+
} else {
|
| 14 |
+
switch (instructionType) {
|
| 15 |
+
case "i32":
|
| 16 |
+
{
|
| 17 |
+
return numberLiteral(parse32I(rawValue), String(original));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
case "u32":
|
| 21 |
+
{
|
| 22 |
+
return numberLiteral(parseU32(rawValue), String(original));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
case "i64":
|
| 26 |
+
{
|
| 27 |
+
return longNumberLiteral(parse64I(rawValue), String(original));
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
case "f32":
|
| 31 |
+
{
|
| 32 |
+
return floatLiteral(parse32F(rawValue), isNanLiteral(rawValue), isInfLiteral(rawValue), String(original));
|
| 33 |
+
}
|
| 34 |
+
// f64
|
| 35 |
+
|
| 36 |
+
default:
|
| 37 |
+
{
|
| 38 |
+
return floatLiteral(parse64F(rawValue), isNanLiteral(rawValue), isInfLiteral(rawValue), String(original));
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
export function instruction(id) {
|
| 44 |
+
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
| 45 |
+
var namedArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
| 46 |
+
return instr(id, undefined, args, namedArgs);
|
| 47 |
+
}
|
| 48 |
+
export function objectInstruction(id, object) {
|
| 49 |
+
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
| 50 |
+
var namedArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
| 51 |
+
return instr(id, object, args, namedArgs);
|
| 52 |
+
}
|
| 53 |
+
/**
|
| 54 |
+
* Decorators
|
| 55 |
+
*/
|
| 56 |
+
|
| 57 |
+
export function withLoc(n, end, start) {
|
| 58 |
+
var loc = {
|
| 59 |
+
start: start,
|
| 60 |
+
end: end
|
| 61 |
+
};
|
| 62 |
+
n.loc = loc;
|
| 63 |
+
return n;
|
| 64 |
+
}
|
| 65 |
+
export function withRaw(n, raw) {
|
| 66 |
+
n.raw = raw;
|
| 67 |
+
return n;
|
| 68 |
+
}
|
| 69 |
+
export function funcParam(valtype, id) {
|
| 70 |
+
return {
|
| 71 |
+
id: id,
|
| 72 |
+
valtype: valtype
|
| 73 |
+
};
|
| 74 |
+
}
|
| 75 |
+
export function indexLiteral(value) {
|
| 76 |
+
// $FlowIgnore
|
| 77 |
+
var x = numberLiteralFromRaw(value, "u32");
|
| 78 |
+
return x;
|
| 79 |
+
}
|
| 80 |
+
export function memIndexLiteral(value) {
|
| 81 |
+
// $FlowIgnore
|
| 82 |
+
var x = numberLiteralFromRaw(value, "u32");
|
| 83 |
+
return x;
|
| 84 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/node-path.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
| 2 |
+
|
| 3 |
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
| 4 |
+
|
| 5 |
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
| 6 |
+
|
| 7 |
+
function findParent(_ref, cb) {
|
| 8 |
+
var parentPath = _ref.parentPath;
|
| 9 |
+
|
| 10 |
+
if (parentPath == null) {
|
| 11 |
+
throw new Error("node is root");
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
var currentPath = parentPath;
|
| 15 |
+
|
| 16 |
+
while (cb(currentPath) !== false) {
|
| 17 |
+
// Hit the root node, stop
|
| 18 |
+
// $FlowIgnore
|
| 19 |
+
if (currentPath.parentPath == null) {
|
| 20 |
+
return null;
|
| 21 |
+
} // $FlowIgnore
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
currentPath = currentPath.parentPath;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
return currentPath.node;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
function insertBefore(context, newNode) {
|
| 31 |
+
return insert(context, newNode);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function insertAfter(context, newNode) {
|
| 35 |
+
return insert(context, newNode, 1);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
function insert(_ref2, newNode) {
|
| 39 |
+
var node = _ref2.node,
|
| 40 |
+
inList = _ref2.inList,
|
| 41 |
+
parentPath = _ref2.parentPath,
|
| 42 |
+
parentKey = _ref2.parentKey;
|
| 43 |
+
var indexOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
| 44 |
+
|
| 45 |
+
if (!inList) {
|
| 46 |
+
throw new Error('inList' + " error: " + ("insert can only be used for nodes that are within lists" || "unknown"));
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
if (!(parentPath != null)) {
|
| 50 |
+
throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown"));
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
// $FlowIgnore
|
| 54 |
+
var parentList = parentPath.node[parentKey];
|
| 55 |
+
var indexInList = parentList.findIndex(function (n) {
|
| 56 |
+
return n === node;
|
| 57 |
+
});
|
| 58 |
+
parentList.splice(indexInList + indexOffset, 0, newNode);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
function remove(_ref3) {
|
| 62 |
+
var node = _ref3.node,
|
| 63 |
+
parentKey = _ref3.parentKey,
|
| 64 |
+
parentPath = _ref3.parentPath;
|
| 65 |
+
|
| 66 |
+
if (!(parentPath != null)) {
|
| 67 |
+
throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown"));
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
// $FlowIgnore
|
| 71 |
+
var parentNode = parentPath.node; // $FlowIgnore
|
| 72 |
+
|
| 73 |
+
var parentProperty = parentNode[parentKey];
|
| 74 |
+
|
| 75 |
+
if (Array.isArray(parentProperty)) {
|
| 76 |
+
// $FlowIgnore
|
| 77 |
+
parentNode[parentKey] = parentProperty.filter(function (n) {
|
| 78 |
+
return n !== node;
|
| 79 |
+
});
|
| 80 |
+
} else {
|
| 81 |
+
// $FlowIgnore
|
| 82 |
+
delete parentNode[parentKey];
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
node._deleted = true;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function stop(context) {
|
| 89 |
+
context.shouldStop = true;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
function replaceWith(context, newNode) {
|
| 93 |
+
// $FlowIgnore
|
| 94 |
+
var parentNode = context.parentPath.node; // $FlowIgnore
|
| 95 |
+
|
| 96 |
+
var parentProperty = parentNode[context.parentKey];
|
| 97 |
+
|
| 98 |
+
if (Array.isArray(parentProperty)) {
|
| 99 |
+
var indexInList = parentProperty.findIndex(function (n) {
|
| 100 |
+
return n === context.node;
|
| 101 |
+
});
|
| 102 |
+
parentProperty.splice(indexInList, 1, newNode);
|
| 103 |
+
} else {
|
| 104 |
+
// $FlowIgnore
|
| 105 |
+
parentNode[context.parentKey] = newNode;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
context.node._deleted = true;
|
| 109 |
+
context.node = newNode;
|
| 110 |
+
} // bind the context to the first argument of node operations
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
function bindNodeOperations(operations, context) {
|
| 114 |
+
var keys = Object.keys(operations);
|
| 115 |
+
var boundOperations = {};
|
| 116 |
+
keys.forEach(function (key) {
|
| 117 |
+
boundOperations[key] = operations[key].bind(null, context);
|
| 118 |
+
});
|
| 119 |
+
return boundOperations;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
function createPathOperations(context) {
|
| 123 |
+
// $FlowIgnore
|
| 124 |
+
return bindNodeOperations({
|
| 125 |
+
findParent: findParent,
|
| 126 |
+
replaceWith: replaceWith,
|
| 127 |
+
remove: remove,
|
| 128 |
+
insertBefore: insertBefore,
|
| 129 |
+
insertAfter: insertAfter,
|
| 130 |
+
stop: stop
|
| 131 |
+
}, context);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
export function createPath(context) {
|
| 135 |
+
var path = _objectSpread({}, context); // $FlowIgnore
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
Object.assign(path, createPathOperations(path)); // $FlowIgnore
|
| 139 |
+
|
| 140 |
+
return path;
|
| 141 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/nodes.js
ADDED
|
@@ -0,0 +1,925 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
| 2 |
+
|
| 3 |
+
// THIS FILE IS AUTOGENERATED
|
| 4 |
+
// see scripts/generateNodeUtils.js
|
| 5 |
+
function isTypeOf(t) {
|
| 6 |
+
return function (n) {
|
| 7 |
+
return n.type === t;
|
| 8 |
+
};
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function assertTypeOf(t) {
|
| 12 |
+
return function (n) {
|
| 13 |
+
return function () {
|
| 14 |
+
if (!(n.type === t)) {
|
| 15 |
+
throw new Error('n.type === t' + " error: " + (undefined || "unknown"));
|
| 16 |
+
}
|
| 17 |
+
}();
|
| 18 |
+
};
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
export function module(id, fields, metadata) {
|
| 22 |
+
if (id !== null && id !== undefined) {
|
| 23 |
+
if (!(typeof id === "string")) {
|
| 24 |
+
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
if (!(_typeof(fields) === "object" && typeof fields.length !== "undefined")) {
|
| 29 |
+
throw new Error('typeof fields === "object" && typeof fields.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
var node = {
|
| 33 |
+
type: "Module",
|
| 34 |
+
id: id,
|
| 35 |
+
fields: fields
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
if (typeof metadata !== "undefined") {
|
| 39 |
+
node.metadata = metadata;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return node;
|
| 43 |
+
}
|
| 44 |
+
export function moduleMetadata(sections, functionNames, localNames, producers) {
|
| 45 |
+
if (!(_typeof(sections) === "object" && typeof sections.length !== "undefined")) {
|
| 46 |
+
throw new Error('typeof sections === "object" && typeof sections.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
if (functionNames !== null && functionNames !== undefined) {
|
| 50 |
+
if (!(_typeof(functionNames) === "object" && typeof functionNames.length !== "undefined")) {
|
| 51 |
+
throw new Error('typeof functionNames === "object" && typeof functionNames.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
if (localNames !== null && localNames !== undefined) {
|
| 56 |
+
if (!(_typeof(localNames) === "object" && typeof localNames.length !== "undefined")) {
|
| 57 |
+
throw new Error('typeof localNames === "object" && typeof localNames.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
if (producers !== null && producers !== undefined) {
|
| 62 |
+
if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) {
|
| 63 |
+
throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
var node = {
|
| 68 |
+
type: "ModuleMetadata",
|
| 69 |
+
sections: sections
|
| 70 |
+
};
|
| 71 |
+
|
| 72 |
+
if (typeof functionNames !== "undefined" && functionNames.length > 0) {
|
| 73 |
+
node.functionNames = functionNames;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
if (typeof localNames !== "undefined" && localNames.length > 0) {
|
| 77 |
+
node.localNames = localNames;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
if (typeof producers !== "undefined" && producers.length > 0) {
|
| 81 |
+
node.producers = producers;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
return node;
|
| 85 |
+
}
|
| 86 |
+
export function moduleNameMetadata(value) {
|
| 87 |
+
if (!(typeof value === "string")) {
|
| 88 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
var node = {
|
| 92 |
+
type: "ModuleNameMetadata",
|
| 93 |
+
value: value
|
| 94 |
+
};
|
| 95 |
+
return node;
|
| 96 |
+
}
|
| 97 |
+
export function functionNameMetadata(value, index) {
|
| 98 |
+
if (!(typeof value === "string")) {
|
| 99 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
if (!(typeof index === "number")) {
|
| 103 |
+
throw new Error('typeof index === "number"' + " error: " + ("Argument index must be of type number, given: " + _typeof(index) || "unknown"));
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
var node = {
|
| 107 |
+
type: "FunctionNameMetadata",
|
| 108 |
+
value: value,
|
| 109 |
+
index: index
|
| 110 |
+
};
|
| 111 |
+
return node;
|
| 112 |
+
}
|
| 113 |
+
export function localNameMetadata(value, localIndex, functionIndex) {
|
| 114 |
+
if (!(typeof value === "string")) {
|
| 115 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
if (!(typeof localIndex === "number")) {
|
| 119 |
+
throw new Error('typeof localIndex === "number"' + " error: " + ("Argument localIndex must be of type number, given: " + _typeof(localIndex) || "unknown"));
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
if (!(typeof functionIndex === "number")) {
|
| 123 |
+
throw new Error('typeof functionIndex === "number"' + " error: " + ("Argument functionIndex must be of type number, given: " + _typeof(functionIndex) || "unknown"));
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
var node = {
|
| 127 |
+
type: "LocalNameMetadata",
|
| 128 |
+
value: value,
|
| 129 |
+
localIndex: localIndex,
|
| 130 |
+
functionIndex: functionIndex
|
| 131 |
+
};
|
| 132 |
+
return node;
|
| 133 |
+
}
|
| 134 |
+
export function binaryModule(id, blob) {
|
| 135 |
+
if (id !== null && id !== undefined) {
|
| 136 |
+
if (!(typeof id === "string")) {
|
| 137 |
+
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
if (!(_typeof(blob) === "object" && typeof blob.length !== "undefined")) {
|
| 142 |
+
throw new Error('typeof blob === "object" && typeof blob.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
var node = {
|
| 146 |
+
type: "BinaryModule",
|
| 147 |
+
id: id,
|
| 148 |
+
blob: blob
|
| 149 |
+
};
|
| 150 |
+
return node;
|
| 151 |
+
}
|
| 152 |
+
export function quoteModule(id, string) {
|
| 153 |
+
if (id !== null && id !== undefined) {
|
| 154 |
+
if (!(typeof id === "string")) {
|
| 155 |
+
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
if (!(_typeof(string) === "object" && typeof string.length !== "undefined")) {
|
| 160 |
+
throw new Error('typeof string === "object" && typeof string.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
var node = {
|
| 164 |
+
type: "QuoteModule",
|
| 165 |
+
id: id,
|
| 166 |
+
string: string
|
| 167 |
+
};
|
| 168 |
+
return node;
|
| 169 |
+
}
|
| 170 |
+
export function sectionMetadata(section, startOffset, size, vectorOfSize) {
|
| 171 |
+
if (!(typeof startOffset === "number")) {
|
| 172 |
+
throw new Error('typeof startOffset === "number"' + " error: " + ("Argument startOffset must be of type number, given: " + _typeof(startOffset) || "unknown"));
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
var node = {
|
| 176 |
+
type: "SectionMetadata",
|
| 177 |
+
section: section,
|
| 178 |
+
startOffset: startOffset,
|
| 179 |
+
size: size,
|
| 180 |
+
vectorOfSize: vectorOfSize
|
| 181 |
+
};
|
| 182 |
+
return node;
|
| 183 |
+
}
|
| 184 |
+
export function producersSectionMetadata(producers) {
|
| 185 |
+
if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) {
|
| 186 |
+
throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
var node = {
|
| 190 |
+
type: "ProducersSectionMetadata",
|
| 191 |
+
producers: producers
|
| 192 |
+
};
|
| 193 |
+
return node;
|
| 194 |
+
}
|
| 195 |
+
export function producerMetadata(language, processedBy, sdk) {
|
| 196 |
+
if (!(_typeof(language) === "object" && typeof language.length !== "undefined")) {
|
| 197 |
+
throw new Error('typeof language === "object" && typeof language.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
if (!(_typeof(processedBy) === "object" && typeof processedBy.length !== "undefined")) {
|
| 201 |
+
throw new Error('typeof processedBy === "object" && typeof processedBy.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
if (!(_typeof(sdk) === "object" && typeof sdk.length !== "undefined")) {
|
| 205 |
+
throw new Error('typeof sdk === "object" && typeof sdk.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
var node = {
|
| 209 |
+
type: "ProducerMetadata",
|
| 210 |
+
language: language,
|
| 211 |
+
processedBy: processedBy,
|
| 212 |
+
sdk: sdk
|
| 213 |
+
};
|
| 214 |
+
return node;
|
| 215 |
+
}
|
| 216 |
+
export function producerMetadataVersionedName(name, version) {
|
| 217 |
+
if (!(typeof name === "string")) {
|
| 218 |
+
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
if (!(typeof version === "string")) {
|
| 222 |
+
throw new Error('typeof version === "string"' + " error: " + ("Argument version must be of type string, given: " + _typeof(version) || "unknown"));
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
var node = {
|
| 226 |
+
type: "ProducerMetadataVersionedName",
|
| 227 |
+
name: name,
|
| 228 |
+
version: version
|
| 229 |
+
};
|
| 230 |
+
return node;
|
| 231 |
+
}
|
| 232 |
+
export function loopInstruction(label, resulttype, instr) {
|
| 233 |
+
if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) {
|
| 234 |
+
throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
var node = {
|
| 238 |
+
type: "LoopInstruction",
|
| 239 |
+
id: "loop",
|
| 240 |
+
label: label,
|
| 241 |
+
resulttype: resulttype,
|
| 242 |
+
instr: instr
|
| 243 |
+
};
|
| 244 |
+
return node;
|
| 245 |
+
}
|
| 246 |
+
export function instr(id, object, args, namedArgs) {
|
| 247 |
+
if (!(typeof id === "string")) {
|
| 248 |
+
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
if (!(_typeof(args) === "object" && typeof args.length !== "undefined")) {
|
| 252 |
+
throw new Error('typeof args === "object" && typeof args.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
var node = {
|
| 256 |
+
type: "Instr",
|
| 257 |
+
id: id,
|
| 258 |
+
args: args
|
| 259 |
+
};
|
| 260 |
+
|
| 261 |
+
if (typeof object !== "undefined") {
|
| 262 |
+
node.object = object;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
if (typeof namedArgs !== "undefined" && Object.keys(namedArgs).length !== 0) {
|
| 266 |
+
node.namedArgs = namedArgs;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
return node;
|
| 270 |
+
}
|
| 271 |
+
export function ifInstruction(testLabel, test, result, consequent, alternate) {
|
| 272 |
+
if (!(_typeof(test) === "object" && typeof test.length !== "undefined")) {
|
| 273 |
+
throw new Error('typeof test === "object" && typeof test.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
if (!(_typeof(consequent) === "object" && typeof consequent.length !== "undefined")) {
|
| 277 |
+
throw new Error('typeof consequent === "object" && typeof consequent.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
if (!(_typeof(alternate) === "object" && typeof alternate.length !== "undefined")) {
|
| 281 |
+
throw new Error('typeof alternate === "object" && typeof alternate.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
var node = {
|
| 285 |
+
type: "IfInstruction",
|
| 286 |
+
id: "if",
|
| 287 |
+
testLabel: testLabel,
|
| 288 |
+
test: test,
|
| 289 |
+
result: result,
|
| 290 |
+
consequent: consequent,
|
| 291 |
+
alternate: alternate
|
| 292 |
+
};
|
| 293 |
+
return node;
|
| 294 |
+
}
|
| 295 |
+
export function stringLiteral(value) {
|
| 296 |
+
if (!(typeof value === "string")) {
|
| 297 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
var node = {
|
| 301 |
+
type: "StringLiteral",
|
| 302 |
+
value: value
|
| 303 |
+
};
|
| 304 |
+
return node;
|
| 305 |
+
}
|
| 306 |
+
export function numberLiteral(value, raw) {
|
| 307 |
+
if (!(typeof value === "number")) {
|
| 308 |
+
throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown"));
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
if (!(typeof raw === "string")) {
|
| 312 |
+
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
var node = {
|
| 316 |
+
type: "NumberLiteral",
|
| 317 |
+
value: value,
|
| 318 |
+
raw: raw
|
| 319 |
+
};
|
| 320 |
+
return node;
|
| 321 |
+
}
|
| 322 |
+
export function longNumberLiteral(value, raw) {
|
| 323 |
+
if (!(typeof raw === "string")) {
|
| 324 |
+
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
var node = {
|
| 328 |
+
type: "LongNumberLiteral",
|
| 329 |
+
value: value,
|
| 330 |
+
raw: raw
|
| 331 |
+
};
|
| 332 |
+
return node;
|
| 333 |
+
}
|
| 334 |
+
export function floatLiteral(value, nan, inf, raw) {
|
| 335 |
+
if (!(typeof value === "number")) {
|
| 336 |
+
throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown"));
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
if (nan !== null && nan !== undefined) {
|
| 340 |
+
if (!(typeof nan === "boolean")) {
|
| 341 |
+
throw new Error('typeof nan === "boolean"' + " error: " + ("Argument nan must be of type boolean, given: " + _typeof(nan) || "unknown"));
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
if (inf !== null && inf !== undefined) {
|
| 346 |
+
if (!(typeof inf === "boolean")) {
|
| 347 |
+
throw new Error('typeof inf === "boolean"' + " error: " + ("Argument inf must be of type boolean, given: " + _typeof(inf) || "unknown"));
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
if (!(typeof raw === "string")) {
|
| 352 |
+
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
var node = {
|
| 356 |
+
type: "FloatLiteral",
|
| 357 |
+
value: value,
|
| 358 |
+
raw: raw
|
| 359 |
+
};
|
| 360 |
+
|
| 361 |
+
if (nan === true) {
|
| 362 |
+
node.nan = true;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
if (inf === true) {
|
| 366 |
+
node.inf = true;
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
return node;
|
| 370 |
+
}
|
| 371 |
+
export function elem(table, offset, funcs) {
|
| 372 |
+
if (!(_typeof(offset) === "object" && typeof offset.length !== "undefined")) {
|
| 373 |
+
throw new Error('typeof offset === "object" && typeof offset.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
if (!(_typeof(funcs) === "object" && typeof funcs.length !== "undefined")) {
|
| 377 |
+
throw new Error('typeof funcs === "object" && typeof funcs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
var node = {
|
| 381 |
+
type: "Elem",
|
| 382 |
+
table: table,
|
| 383 |
+
offset: offset,
|
| 384 |
+
funcs: funcs
|
| 385 |
+
};
|
| 386 |
+
return node;
|
| 387 |
+
}
|
| 388 |
+
export function indexInFuncSection(index) {
|
| 389 |
+
var node = {
|
| 390 |
+
type: "IndexInFuncSection",
|
| 391 |
+
index: index
|
| 392 |
+
};
|
| 393 |
+
return node;
|
| 394 |
+
}
|
| 395 |
+
export function valtypeLiteral(name) {
|
| 396 |
+
var node = {
|
| 397 |
+
type: "ValtypeLiteral",
|
| 398 |
+
name: name
|
| 399 |
+
};
|
| 400 |
+
return node;
|
| 401 |
+
}
|
| 402 |
+
export function typeInstruction(id, functype) {
|
| 403 |
+
var node = {
|
| 404 |
+
type: "TypeInstruction",
|
| 405 |
+
id: id,
|
| 406 |
+
functype: functype
|
| 407 |
+
};
|
| 408 |
+
return node;
|
| 409 |
+
}
|
| 410 |
+
export function start(index) {
|
| 411 |
+
var node = {
|
| 412 |
+
type: "Start",
|
| 413 |
+
index: index
|
| 414 |
+
};
|
| 415 |
+
return node;
|
| 416 |
+
}
|
| 417 |
+
export function globalType(valtype, mutability) {
|
| 418 |
+
var node = {
|
| 419 |
+
type: "GlobalType",
|
| 420 |
+
valtype: valtype,
|
| 421 |
+
mutability: mutability
|
| 422 |
+
};
|
| 423 |
+
return node;
|
| 424 |
+
}
|
| 425 |
+
export function leadingComment(value) {
|
| 426 |
+
if (!(typeof value === "string")) {
|
| 427 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
var node = {
|
| 431 |
+
type: "LeadingComment",
|
| 432 |
+
value: value
|
| 433 |
+
};
|
| 434 |
+
return node;
|
| 435 |
+
}
|
| 436 |
+
export function blockComment(value) {
|
| 437 |
+
if (!(typeof value === "string")) {
|
| 438 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
var node = {
|
| 442 |
+
type: "BlockComment",
|
| 443 |
+
value: value
|
| 444 |
+
};
|
| 445 |
+
return node;
|
| 446 |
+
}
|
| 447 |
+
export function data(memoryIndex, offset, init) {
|
| 448 |
+
var node = {
|
| 449 |
+
type: "Data",
|
| 450 |
+
memoryIndex: memoryIndex,
|
| 451 |
+
offset: offset,
|
| 452 |
+
init: init
|
| 453 |
+
};
|
| 454 |
+
return node;
|
| 455 |
+
}
|
| 456 |
+
export function global(globalType, init, name) {
|
| 457 |
+
if (!(_typeof(init) === "object" && typeof init.length !== "undefined")) {
|
| 458 |
+
throw new Error('typeof init === "object" && typeof init.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
var node = {
|
| 462 |
+
type: "Global",
|
| 463 |
+
globalType: globalType,
|
| 464 |
+
init: init,
|
| 465 |
+
name: name
|
| 466 |
+
};
|
| 467 |
+
return node;
|
| 468 |
+
}
|
| 469 |
+
export function table(elementType, limits, name, elements) {
|
| 470 |
+
if (!(limits.type === "Limit")) {
|
| 471 |
+
throw new Error('limits.type === "Limit"' + " error: " + ("Argument limits must be of type Limit, given: " + limits.type || "unknown"));
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
if (elements !== null && elements !== undefined) {
|
| 475 |
+
if (!(_typeof(elements) === "object" && typeof elements.length !== "undefined")) {
|
| 476 |
+
throw new Error('typeof elements === "object" && typeof elements.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 477 |
+
}
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
var node = {
|
| 481 |
+
type: "Table",
|
| 482 |
+
elementType: elementType,
|
| 483 |
+
limits: limits,
|
| 484 |
+
name: name
|
| 485 |
+
};
|
| 486 |
+
|
| 487 |
+
if (typeof elements !== "undefined" && elements.length > 0) {
|
| 488 |
+
node.elements = elements;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
return node;
|
| 492 |
+
}
|
| 493 |
+
export function memory(limits, id) {
|
| 494 |
+
var node = {
|
| 495 |
+
type: "Memory",
|
| 496 |
+
limits: limits,
|
| 497 |
+
id: id
|
| 498 |
+
};
|
| 499 |
+
return node;
|
| 500 |
+
}
|
| 501 |
+
export function funcImportDescr(id, signature) {
|
| 502 |
+
var node = {
|
| 503 |
+
type: "FuncImportDescr",
|
| 504 |
+
id: id,
|
| 505 |
+
signature: signature
|
| 506 |
+
};
|
| 507 |
+
return node;
|
| 508 |
+
}
|
| 509 |
+
export function moduleImport(module, name, descr) {
|
| 510 |
+
if (!(typeof module === "string")) {
|
| 511 |
+
throw new Error('typeof module === "string"' + " error: " + ("Argument module must be of type string, given: " + _typeof(module) || "unknown"));
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
if (!(typeof name === "string")) {
|
| 515 |
+
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
var node = {
|
| 519 |
+
type: "ModuleImport",
|
| 520 |
+
module: module,
|
| 521 |
+
name: name,
|
| 522 |
+
descr: descr
|
| 523 |
+
};
|
| 524 |
+
return node;
|
| 525 |
+
}
|
| 526 |
+
export function moduleExportDescr(exportType, id) {
|
| 527 |
+
var node = {
|
| 528 |
+
type: "ModuleExportDescr",
|
| 529 |
+
exportType: exportType,
|
| 530 |
+
id: id
|
| 531 |
+
};
|
| 532 |
+
return node;
|
| 533 |
+
}
|
| 534 |
+
export function moduleExport(name, descr) {
|
| 535 |
+
if (!(typeof name === "string")) {
|
| 536 |
+
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
var node = {
|
| 540 |
+
type: "ModuleExport",
|
| 541 |
+
name: name,
|
| 542 |
+
descr: descr
|
| 543 |
+
};
|
| 544 |
+
return node;
|
| 545 |
+
}
|
| 546 |
+
export function limit(min, max, shared) {
|
| 547 |
+
if (!(typeof min === "number")) {
|
| 548 |
+
throw new Error('typeof min === "number"' + " error: " + ("Argument min must be of type number, given: " + _typeof(min) || "unknown"));
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
if (max !== null && max !== undefined) {
|
| 552 |
+
if (!(typeof max === "number")) {
|
| 553 |
+
throw new Error('typeof max === "number"' + " error: " + ("Argument max must be of type number, given: " + _typeof(max) || "unknown"));
|
| 554 |
+
}
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
if (shared !== null && shared !== undefined) {
|
| 558 |
+
if (!(typeof shared === "boolean")) {
|
| 559 |
+
throw new Error('typeof shared === "boolean"' + " error: " + ("Argument shared must be of type boolean, given: " + _typeof(shared) || "unknown"));
|
| 560 |
+
}
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
var node = {
|
| 564 |
+
type: "Limit",
|
| 565 |
+
min: min
|
| 566 |
+
};
|
| 567 |
+
|
| 568 |
+
if (typeof max !== "undefined") {
|
| 569 |
+
node.max = max;
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
if (shared === true) {
|
| 573 |
+
node.shared = true;
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
return node;
|
| 577 |
+
}
|
| 578 |
+
export function signature(params, results) {
|
| 579 |
+
if (!(_typeof(params) === "object" && typeof params.length !== "undefined")) {
|
| 580 |
+
throw new Error('typeof params === "object" && typeof params.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
if (!(_typeof(results) === "object" && typeof results.length !== "undefined")) {
|
| 584 |
+
throw new Error('typeof results === "object" && typeof results.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
var node = {
|
| 588 |
+
type: "Signature",
|
| 589 |
+
params: params,
|
| 590 |
+
results: results
|
| 591 |
+
};
|
| 592 |
+
return node;
|
| 593 |
+
}
|
| 594 |
+
export function program(body) {
|
| 595 |
+
if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
|
| 596 |
+
throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
var node = {
|
| 600 |
+
type: "Program",
|
| 601 |
+
body: body
|
| 602 |
+
};
|
| 603 |
+
return node;
|
| 604 |
+
}
|
| 605 |
+
export function identifier(value, raw) {
|
| 606 |
+
if (!(typeof value === "string")) {
|
| 607 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
if (raw !== null && raw !== undefined) {
|
| 611 |
+
if (!(typeof raw === "string")) {
|
| 612 |
+
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
| 613 |
+
}
|
| 614 |
+
}
|
| 615 |
+
|
| 616 |
+
var node = {
|
| 617 |
+
type: "Identifier",
|
| 618 |
+
value: value
|
| 619 |
+
};
|
| 620 |
+
|
| 621 |
+
if (typeof raw !== "undefined") {
|
| 622 |
+
node.raw = raw;
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
return node;
|
| 626 |
+
}
|
| 627 |
+
export function blockInstruction(label, instr, result) {
|
| 628 |
+
if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) {
|
| 629 |
+
throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
var node = {
|
| 633 |
+
type: "BlockInstruction",
|
| 634 |
+
id: "block",
|
| 635 |
+
label: label,
|
| 636 |
+
instr: instr,
|
| 637 |
+
result: result
|
| 638 |
+
};
|
| 639 |
+
return node;
|
| 640 |
+
}
|
| 641 |
+
export function callInstruction(index, instrArgs, numeric) {
|
| 642 |
+
if (instrArgs !== null && instrArgs !== undefined) {
|
| 643 |
+
if (!(_typeof(instrArgs) === "object" && typeof instrArgs.length !== "undefined")) {
|
| 644 |
+
throw new Error('typeof instrArgs === "object" && typeof instrArgs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 645 |
+
}
|
| 646 |
+
}
|
| 647 |
+
|
| 648 |
+
var node = {
|
| 649 |
+
type: "CallInstruction",
|
| 650 |
+
id: "call",
|
| 651 |
+
index: index
|
| 652 |
+
};
|
| 653 |
+
|
| 654 |
+
if (typeof instrArgs !== "undefined" && instrArgs.length > 0) {
|
| 655 |
+
node.instrArgs = instrArgs;
|
| 656 |
+
}
|
| 657 |
+
|
| 658 |
+
if (typeof numeric !== "undefined") {
|
| 659 |
+
node.numeric = numeric;
|
| 660 |
+
}
|
| 661 |
+
|
| 662 |
+
return node;
|
| 663 |
+
}
|
| 664 |
+
export function callIndirectInstruction(signature, intrs) {
|
| 665 |
+
if (intrs !== null && intrs !== undefined) {
|
| 666 |
+
if (!(_typeof(intrs) === "object" && typeof intrs.length !== "undefined")) {
|
| 667 |
+
throw new Error('typeof intrs === "object" && typeof intrs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 668 |
+
}
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
var node = {
|
| 672 |
+
type: "CallIndirectInstruction",
|
| 673 |
+
id: "call_indirect",
|
| 674 |
+
signature: signature
|
| 675 |
+
};
|
| 676 |
+
|
| 677 |
+
if (typeof intrs !== "undefined" && intrs.length > 0) {
|
| 678 |
+
node.intrs = intrs;
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
return node;
|
| 682 |
+
}
|
| 683 |
+
export function byteArray(values) {
|
| 684 |
+
if (!(_typeof(values) === "object" && typeof values.length !== "undefined")) {
|
| 685 |
+
throw new Error('typeof values === "object" && typeof values.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
var node = {
|
| 689 |
+
type: "ByteArray",
|
| 690 |
+
values: values
|
| 691 |
+
};
|
| 692 |
+
return node;
|
| 693 |
+
}
|
| 694 |
+
export function func(name, signature, body, isExternal, metadata) {
|
| 695 |
+
if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
|
| 696 |
+
throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 697 |
+
}
|
| 698 |
+
|
| 699 |
+
if (isExternal !== null && isExternal !== undefined) {
|
| 700 |
+
if (!(typeof isExternal === "boolean")) {
|
| 701 |
+
throw new Error('typeof isExternal === "boolean"' + " error: " + ("Argument isExternal must be of type boolean, given: " + _typeof(isExternal) || "unknown"));
|
| 702 |
+
}
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
var node = {
|
| 706 |
+
type: "Func",
|
| 707 |
+
name: name,
|
| 708 |
+
signature: signature,
|
| 709 |
+
body: body
|
| 710 |
+
};
|
| 711 |
+
|
| 712 |
+
if (isExternal === true) {
|
| 713 |
+
node.isExternal = true;
|
| 714 |
+
}
|
| 715 |
+
|
| 716 |
+
if (typeof metadata !== "undefined") {
|
| 717 |
+
node.metadata = metadata;
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
return node;
|
| 721 |
+
}
|
| 722 |
+
export function internalBrUnless(target) {
|
| 723 |
+
if (!(typeof target === "number")) {
|
| 724 |
+
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
| 725 |
+
}
|
| 726 |
+
|
| 727 |
+
var node = {
|
| 728 |
+
type: "InternalBrUnless",
|
| 729 |
+
target: target
|
| 730 |
+
};
|
| 731 |
+
return node;
|
| 732 |
+
}
|
| 733 |
+
export function internalGoto(target) {
|
| 734 |
+
if (!(typeof target === "number")) {
|
| 735 |
+
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
var node = {
|
| 739 |
+
type: "InternalGoto",
|
| 740 |
+
target: target
|
| 741 |
+
};
|
| 742 |
+
return node;
|
| 743 |
+
}
|
| 744 |
+
export function internalCallExtern(target) {
|
| 745 |
+
if (!(typeof target === "number")) {
|
| 746 |
+
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
| 747 |
+
}
|
| 748 |
+
|
| 749 |
+
var node = {
|
| 750 |
+
type: "InternalCallExtern",
|
| 751 |
+
target: target
|
| 752 |
+
};
|
| 753 |
+
return node;
|
| 754 |
+
}
|
| 755 |
+
export function internalEndAndReturn() {
|
| 756 |
+
var node = {
|
| 757 |
+
type: "InternalEndAndReturn"
|
| 758 |
+
};
|
| 759 |
+
return node;
|
| 760 |
+
}
|
| 761 |
+
export var isModule = isTypeOf("Module");
|
| 762 |
+
export var isModuleMetadata = isTypeOf("ModuleMetadata");
|
| 763 |
+
export var isModuleNameMetadata = isTypeOf("ModuleNameMetadata");
|
| 764 |
+
export var isFunctionNameMetadata = isTypeOf("FunctionNameMetadata");
|
| 765 |
+
export var isLocalNameMetadata = isTypeOf("LocalNameMetadata");
|
| 766 |
+
export var isBinaryModule = isTypeOf("BinaryModule");
|
| 767 |
+
export var isQuoteModule = isTypeOf("QuoteModule");
|
| 768 |
+
export var isSectionMetadata = isTypeOf("SectionMetadata");
|
| 769 |
+
export var isProducersSectionMetadata = isTypeOf("ProducersSectionMetadata");
|
| 770 |
+
export var isProducerMetadata = isTypeOf("ProducerMetadata");
|
| 771 |
+
export var isProducerMetadataVersionedName = isTypeOf("ProducerMetadataVersionedName");
|
| 772 |
+
export var isLoopInstruction = isTypeOf("LoopInstruction");
|
| 773 |
+
export var isInstr = isTypeOf("Instr");
|
| 774 |
+
export var isIfInstruction = isTypeOf("IfInstruction");
|
| 775 |
+
export var isStringLiteral = isTypeOf("StringLiteral");
|
| 776 |
+
export var isNumberLiteral = isTypeOf("NumberLiteral");
|
| 777 |
+
export var isLongNumberLiteral = isTypeOf("LongNumberLiteral");
|
| 778 |
+
export var isFloatLiteral = isTypeOf("FloatLiteral");
|
| 779 |
+
export var isElem = isTypeOf("Elem");
|
| 780 |
+
export var isIndexInFuncSection = isTypeOf("IndexInFuncSection");
|
| 781 |
+
export var isValtypeLiteral = isTypeOf("ValtypeLiteral");
|
| 782 |
+
export var isTypeInstruction = isTypeOf("TypeInstruction");
|
| 783 |
+
export var isStart = isTypeOf("Start");
|
| 784 |
+
export var isGlobalType = isTypeOf("GlobalType");
|
| 785 |
+
export var isLeadingComment = isTypeOf("LeadingComment");
|
| 786 |
+
export var isBlockComment = isTypeOf("BlockComment");
|
| 787 |
+
export var isData = isTypeOf("Data");
|
| 788 |
+
export var isGlobal = isTypeOf("Global");
|
| 789 |
+
export var isTable = isTypeOf("Table");
|
| 790 |
+
export var isMemory = isTypeOf("Memory");
|
| 791 |
+
export var isFuncImportDescr = isTypeOf("FuncImportDescr");
|
| 792 |
+
export var isModuleImport = isTypeOf("ModuleImport");
|
| 793 |
+
export var isModuleExportDescr = isTypeOf("ModuleExportDescr");
|
| 794 |
+
export var isModuleExport = isTypeOf("ModuleExport");
|
| 795 |
+
export var isLimit = isTypeOf("Limit");
|
| 796 |
+
export var isSignature = isTypeOf("Signature");
|
| 797 |
+
export var isProgram = isTypeOf("Program");
|
| 798 |
+
export var isIdentifier = isTypeOf("Identifier");
|
| 799 |
+
export var isBlockInstruction = isTypeOf("BlockInstruction");
|
| 800 |
+
export var isCallInstruction = isTypeOf("CallInstruction");
|
| 801 |
+
export var isCallIndirectInstruction = isTypeOf("CallIndirectInstruction");
|
| 802 |
+
export var isByteArray = isTypeOf("ByteArray");
|
| 803 |
+
export var isFunc = isTypeOf("Func");
|
| 804 |
+
export var isInternalBrUnless = isTypeOf("InternalBrUnless");
|
| 805 |
+
export var isInternalGoto = isTypeOf("InternalGoto");
|
| 806 |
+
export var isInternalCallExtern = isTypeOf("InternalCallExtern");
|
| 807 |
+
export var isInternalEndAndReturn = isTypeOf("InternalEndAndReturn");
|
| 808 |
+
export var isNode = function isNode(node) {
|
| 809 |
+
return isModule(node) || isModuleMetadata(node) || isModuleNameMetadata(node) || isFunctionNameMetadata(node) || isLocalNameMetadata(node) || isBinaryModule(node) || isQuoteModule(node) || isSectionMetadata(node) || isProducersSectionMetadata(node) || isProducerMetadata(node) || isProducerMetadataVersionedName(node) || isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isElem(node) || isIndexInFuncSection(node) || isValtypeLiteral(node) || isTypeInstruction(node) || isStart(node) || isGlobalType(node) || isLeadingComment(node) || isBlockComment(node) || isData(node) || isGlobal(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node) || isModuleImport(node) || isModuleExportDescr(node) || isModuleExport(node) || isLimit(node) || isSignature(node) || isProgram(node) || isIdentifier(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node) || isByteArray(node) || isFunc(node) || isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node);
|
| 810 |
+
};
|
| 811 |
+
export var isBlock = function isBlock(node) {
|
| 812 |
+
return isLoopInstruction(node) || isBlockInstruction(node) || isFunc(node);
|
| 813 |
+
};
|
| 814 |
+
export var isInstruction = function isInstruction(node) {
|
| 815 |
+
return isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isTypeInstruction(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node);
|
| 816 |
+
};
|
| 817 |
+
export var isExpression = function isExpression(node) {
|
| 818 |
+
return isInstr(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isValtypeLiteral(node) || isIdentifier(node);
|
| 819 |
+
};
|
| 820 |
+
export var isNumericLiteral = function isNumericLiteral(node) {
|
| 821 |
+
return isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node);
|
| 822 |
+
};
|
| 823 |
+
export var isImportDescr = function isImportDescr(node) {
|
| 824 |
+
return isGlobalType(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node);
|
| 825 |
+
};
|
| 826 |
+
export var isIntrinsic = function isIntrinsic(node) {
|
| 827 |
+
return isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node);
|
| 828 |
+
};
|
| 829 |
+
export var assertModule = assertTypeOf("Module");
|
| 830 |
+
export var assertModuleMetadata = assertTypeOf("ModuleMetadata");
|
| 831 |
+
export var assertModuleNameMetadata = assertTypeOf("ModuleNameMetadata");
|
| 832 |
+
export var assertFunctionNameMetadata = assertTypeOf("FunctionNameMetadata");
|
| 833 |
+
export var assertLocalNameMetadata = assertTypeOf("LocalNameMetadata");
|
| 834 |
+
export var assertBinaryModule = assertTypeOf("BinaryModule");
|
| 835 |
+
export var assertQuoteModule = assertTypeOf("QuoteModule");
|
| 836 |
+
export var assertSectionMetadata = assertTypeOf("SectionMetadata");
|
| 837 |
+
export var assertProducersSectionMetadata = assertTypeOf("ProducersSectionMetadata");
|
| 838 |
+
export var assertProducerMetadata = assertTypeOf("ProducerMetadata");
|
| 839 |
+
export var assertProducerMetadataVersionedName = assertTypeOf("ProducerMetadataVersionedName");
|
| 840 |
+
export var assertLoopInstruction = assertTypeOf("LoopInstruction");
|
| 841 |
+
export var assertInstr = assertTypeOf("Instr");
|
| 842 |
+
export var assertIfInstruction = assertTypeOf("IfInstruction");
|
| 843 |
+
export var assertStringLiteral = assertTypeOf("StringLiteral");
|
| 844 |
+
export var assertNumberLiteral = assertTypeOf("NumberLiteral");
|
| 845 |
+
export var assertLongNumberLiteral = assertTypeOf("LongNumberLiteral");
|
| 846 |
+
export var assertFloatLiteral = assertTypeOf("FloatLiteral");
|
| 847 |
+
export var assertElem = assertTypeOf("Elem");
|
| 848 |
+
export var assertIndexInFuncSection = assertTypeOf("IndexInFuncSection");
|
| 849 |
+
export var assertValtypeLiteral = assertTypeOf("ValtypeLiteral");
|
| 850 |
+
export var assertTypeInstruction = assertTypeOf("TypeInstruction");
|
| 851 |
+
export var assertStart = assertTypeOf("Start");
|
| 852 |
+
export var assertGlobalType = assertTypeOf("GlobalType");
|
| 853 |
+
export var assertLeadingComment = assertTypeOf("LeadingComment");
|
| 854 |
+
export var assertBlockComment = assertTypeOf("BlockComment");
|
| 855 |
+
export var assertData = assertTypeOf("Data");
|
| 856 |
+
export var assertGlobal = assertTypeOf("Global");
|
| 857 |
+
export var assertTable = assertTypeOf("Table");
|
| 858 |
+
export var assertMemory = assertTypeOf("Memory");
|
| 859 |
+
export var assertFuncImportDescr = assertTypeOf("FuncImportDescr");
|
| 860 |
+
export var assertModuleImport = assertTypeOf("ModuleImport");
|
| 861 |
+
export var assertModuleExportDescr = assertTypeOf("ModuleExportDescr");
|
| 862 |
+
export var assertModuleExport = assertTypeOf("ModuleExport");
|
| 863 |
+
export var assertLimit = assertTypeOf("Limit");
|
| 864 |
+
export var assertSignature = assertTypeOf("Signature");
|
| 865 |
+
export var assertProgram = assertTypeOf("Program");
|
| 866 |
+
export var assertIdentifier = assertTypeOf("Identifier");
|
| 867 |
+
export var assertBlockInstruction = assertTypeOf("BlockInstruction");
|
| 868 |
+
export var assertCallInstruction = assertTypeOf("CallInstruction");
|
| 869 |
+
export var assertCallIndirectInstruction = assertTypeOf("CallIndirectInstruction");
|
| 870 |
+
export var assertByteArray = assertTypeOf("ByteArray");
|
| 871 |
+
export var assertFunc = assertTypeOf("Func");
|
| 872 |
+
export var assertInternalBrUnless = assertTypeOf("InternalBrUnless");
|
| 873 |
+
export var assertInternalGoto = assertTypeOf("InternalGoto");
|
| 874 |
+
export var assertInternalCallExtern = assertTypeOf("InternalCallExtern");
|
| 875 |
+
export var assertInternalEndAndReturn = assertTypeOf("InternalEndAndReturn");
|
| 876 |
+
export var unionTypesMap = {
|
| 877 |
+
Module: ["Node"],
|
| 878 |
+
ModuleMetadata: ["Node"],
|
| 879 |
+
ModuleNameMetadata: ["Node"],
|
| 880 |
+
FunctionNameMetadata: ["Node"],
|
| 881 |
+
LocalNameMetadata: ["Node"],
|
| 882 |
+
BinaryModule: ["Node"],
|
| 883 |
+
QuoteModule: ["Node"],
|
| 884 |
+
SectionMetadata: ["Node"],
|
| 885 |
+
ProducersSectionMetadata: ["Node"],
|
| 886 |
+
ProducerMetadata: ["Node"],
|
| 887 |
+
ProducerMetadataVersionedName: ["Node"],
|
| 888 |
+
LoopInstruction: ["Node", "Block", "Instruction"],
|
| 889 |
+
Instr: ["Node", "Expression", "Instruction"],
|
| 890 |
+
IfInstruction: ["Node", "Instruction"],
|
| 891 |
+
StringLiteral: ["Node", "Expression"],
|
| 892 |
+
NumberLiteral: ["Node", "NumericLiteral", "Expression"],
|
| 893 |
+
LongNumberLiteral: ["Node", "NumericLiteral", "Expression"],
|
| 894 |
+
FloatLiteral: ["Node", "NumericLiteral", "Expression"],
|
| 895 |
+
Elem: ["Node"],
|
| 896 |
+
IndexInFuncSection: ["Node"],
|
| 897 |
+
ValtypeLiteral: ["Node", "Expression"],
|
| 898 |
+
TypeInstruction: ["Node", "Instruction"],
|
| 899 |
+
Start: ["Node"],
|
| 900 |
+
GlobalType: ["Node", "ImportDescr"],
|
| 901 |
+
LeadingComment: ["Node"],
|
| 902 |
+
BlockComment: ["Node"],
|
| 903 |
+
Data: ["Node"],
|
| 904 |
+
Global: ["Node"],
|
| 905 |
+
Table: ["Node", "ImportDescr"],
|
| 906 |
+
Memory: ["Node", "ImportDescr"],
|
| 907 |
+
FuncImportDescr: ["Node", "ImportDescr"],
|
| 908 |
+
ModuleImport: ["Node"],
|
| 909 |
+
ModuleExportDescr: ["Node"],
|
| 910 |
+
ModuleExport: ["Node"],
|
| 911 |
+
Limit: ["Node"],
|
| 912 |
+
Signature: ["Node"],
|
| 913 |
+
Program: ["Node"],
|
| 914 |
+
Identifier: ["Node", "Expression"],
|
| 915 |
+
BlockInstruction: ["Node", "Block", "Instruction"],
|
| 916 |
+
CallInstruction: ["Node", "Instruction"],
|
| 917 |
+
CallIndirectInstruction: ["Node", "Instruction"],
|
| 918 |
+
ByteArray: ["Node"],
|
| 919 |
+
Func: ["Node", "Block"],
|
| 920 |
+
InternalBrUnless: ["Node", "Intrinsic"],
|
| 921 |
+
InternalGoto: ["Node", "Intrinsic"],
|
| 922 |
+
InternalCallExtern: ["Node", "Intrinsic"],
|
| 923 |
+
InternalEndAndReturn: ["Node", "Intrinsic"]
|
| 924 |
+
};
|
| 925 |
+
export var nodeAndUnionTypes = ["Module", "ModuleMetadata", "ModuleNameMetadata", "FunctionNameMetadata", "LocalNameMetadata", "BinaryModule", "QuoteModule", "SectionMetadata", "ProducersSectionMetadata", "ProducerMetadata", "ProducerMetadataVersionedName", "LoopInstruction", "Instr", "IfInstruction", "StringLiteral", "NumberLiteral", "LongNumberLiteral", "FloatLiteral", "Elem", "IndexInFuncSection", "ValtypeLiteral", "TypeInstruction", "Start", "GlobalType", "LeadingComment", "BlockComment", "Data", "Global", "Table", "Memory", "FuncImportDescr", "ModuleImport", "ModuleExportDescr", "ModuleExport", "Limit", "Signature", "Program", "Identifier", "BlockInstruction", "CallInstruction", "CallIndirectInstruction", "ByteArray", "Func", "InternalBrUnless", "InternalGoto", "InternalCallExtern", "InternalEndAndReturn", "Node", "Block", "Instruction", "Expression", "NumericLiteral", "ImportDescr", "Intrinsic"];
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/signatures.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function sign(input, output) {
|
| 2 |
+
return [input, output];
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
var u32 = "u32";
|
| 6 |
+
var i32 = "i32";
|
| 7 |
+
var i64 = "i64";
|
| 8 |
+
var f32 = "f32";
|
| 9 |
+
var f64 = "f64";
|
| 10 |
+
|
| 11 |
+
var vector = function vector(t) {
|
| 12 |
+
var vecType = [t]; // $FlowIgnore
|
| 13 |
+
|
| 14 |
+
vecType.vector = true;
|
| 15 |
+
return vecType;
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
var controlInstructions = {
|
| 19 |
+
unreachable: sign([], []),
|
| 20 |
+
nop: sign([], []),
|
| 21 |
+
// block ?
|
| 22 |
+
// loop ?
|
| 23 |
+
// if ?
|
| 24 |
+
// if else ?
|
| 25 |
+
br: sign([u32], []),
|
| 26 |
+
br_if: sign([u32], []),
|
| 27 |
+
br_table: sign(vector(u32), []),
|
| 28 |
+
"return": sign([], []),
|
| 29 |
+
call: sign([u32], []),
|
| 30 |
+
call_indirect: sign([u32], [])
|
| 31 |
+
};
|
| 32 |
+
var parametricInstructions = {
|
| 33 |
+
drop: sign([], []),
|
| 34 |
+
select: sign([], [])
|
| 35 |
+
};
|
| 36 |
+
var variableInstructions = {
|
| 37 |
+
get_local: sign([u32], []),
|
| 38 |
+
set_local: sign([u32], []),
|
| 39 |
+
tee_local: sign([u32], []),
|
| 40 |
+
get_global: sign([u32], []),
|
| 41 |
+
set_global: sign([u32], [])
|
| 42 |
+
};
|
| 43 |
+
var memoryInstructions = {
|
| 44 |
+
"i32.load": sign([u32, u32], [i32]),
|
| 45 |
+
"i64.load": sign([u32, u32], []),
|
| 46 |
+
"f32.load": sign([u32, u32], []),
|
| 47 |
+
"f64.load": sign([u32, u32], []),
|
| 48 |
+
"i32.load8_s": sign([u32, u32], [i32]),
|
| 49 |
+
"i32.load8_u": sign([u32, u32], [i32]),
|
| 50 |
+
"i32.load16_s": sign([u32, u32], [i32]),
|
| 51 |
+
"i32.load16_u": sign([u32, u32], [i32]),
|
| 52 |
+
"i64.load8_s": sign([u32, u32], [i64]),
|
| 53 |
+
"i64.load8_u": sign([u32, u32], [i64]),
|
| 54 |
+
"i64.load16_s": sign([u32, u32], [i64]),
|
| 55 |
+
"i64.load16_u": sign([u32, u32], [i64]),
|
| 56 |
+
"i64.load32_s": sign([u32, u32], [i64]),
|
| 57 |
+
"i64.load32_u": sign([u32, u32], [i64]),
|
| 58 |
+
"i32.store": sign([u32, u32], []),
|
| 59 |
+
"i64.store": sign([u32, u32], []),
|
| 60 |
+
"f32.store": sign([u32, u32], []),
|
| 61 |
+
"f64.store": sign([u32, u32], []),
|
| 62 |
+
"i32.store8": sign([u32, u32], []),
|
| 63 |
+
"i32.store16": sign([u32, u32], []),
|
| 64 |
+
"i64.store8": sign([u32, u32], []),
|
| 65 |
+
"i64.store16": sign([u32, u32], []),
|
| 66 |
+
"i64.store32": sign([u32, u32], []),
|
| 67 |
+
current_memory: sign([], []),
|
| 68 |
+
grow_memory: sign([], [])
|
| 69 |
+
};
|
| 70 |
+
var numericInstructions = {
|
| 71 |
+
"i32.const": sign([i32], [i32]),
|
| 72 |
+
"i64.const": sign([i64], [i64]),
|
| 73 |
+
"f32.const": sign([f32], [f32]),
|
| 74 |
+
"f64.const": sign([f64], [f64]),
|
| 75 |
+
"i32.eqz": sign([i32], [i32]),
|
| 76 |
+
"i32.eq": sign([i32, i32], [i32]),
|
| 77 |
+
"i32.ne": sign([i32, i32], [i32]),
|
| 78 |
+
"i32.lt_s": sign([i32, i32], [i32]),
|
| 79 |
+
"i32.lt_u": sign([i32, i32], [i32]),
|
| 80 |
+
"i32.gt_s": sign([i32, i32], [i32]),
|
| 81 |
+
"i32.gt_u": sign([i32, i32], [i32]),
|
| 82 |
+
"i32.le_s": sign([i32, i32], [i32]),
|
| 83 |
+
"i32.le_u": sign([i32, i32], [i32]),
|
| 84 |
+
"i32.ge_s": sign([i32, i32], [i32]),
|
| 85 |
+
"i32.ge_u": sign([i32, i32], [i32]),
|
| 86 |
+
"i64.eqz": sign([i64], [i64]),
|
| 87 |
+
"i64.eq": sign([i64, i64], [i32]),
|
| 88 |
+
"i64.ne": sign([i64, i64], [i32]),
|
| 89 |
+
"i64.lt_s": sign([i64, i64], [i32]),
|
| 90 |
+
"i64.lt_u": sign([i64, i64], [i32]),
|
| 91 |
+
"i64.gt_s": sign([i64, i64], [i32]),
|
| 92 |
+
"i64.gt_u": sign([i64, i64], [i32]),
|
| 93 |
+
"i64.le_s": sign([i64, i64], [i32]),
|
| 94 |
+
"i64.le_u": sign([i64, i64], [i32]),
|
| 95 |
+
"i64.ge_s": sign([i64, i64], [i32]),
|
| 96 |
+
"i64.ge_u": sign([i64, i64], [i32]),
|
| 97 |
+
"f32.eq": sign([f32, f32], [i32]),
|
| 98 |
+
"f32.ne": sign([f32, f32], [i32]),
|
| 99 |
+
"f32.lt": sign([f32, f32], [i32]),
|
| 100 |
+
"f32.gt": sign([f32, f32], [i32]),
|
| 101 |
+
"f32.le": sign([f32, f32], [i32]),
|
| 102 |
+
"f32.ge": sign([f32, f32], [i32]),
|
| 103 |
+
"f64.eq": sign([f64, f64], [i32]),
|
| 104 |
+
"f64.ne": sign([f64, f64], [i32]),
|
| 105 |
+
"f64.lt": sign([f64, f64], [i32]),
|
| 106 |
+
"f64.gt": sign([f64, f64], [i32]),
|
| 107 |
+
"f64.le": sign([f64, f64], [i32]),
|
| 108 |
+
"f64.ge": sign([f64, f64], [i32]),
|
| 109 |
+
"i32.clz": sign([i32], [i32]),
|
| 110 |
+
"i32.ctz": sign([i32], [i32]),
|
| 111 |
+
"i32.popcnt": sign([i32], [i32]),
|
| 112 |
+
"i32.add": sign([i32, i32], [i32]),
|
| 113 |
+
"i32.sub": sign([i32, i32], [i32]),
|
| 114 |
+
"i32.mul": sign([i32, i32], [i32]),
|
| 115 |
+
"i32.div_s": sign([i32, i32], [i32]),
|
| 116 |
+
"i32.div_u": sign([i32, i32], [i32]),
|
| 117 |
+
"i32.rem_s": sign([i32, i32], [i32]),
|
| 118 |
+
"i32.rem_u": sign([i32, i32], [i32]),
|
| 119 |
+
"i32.and": sign([i32, i32], [i32]),
|
| 120 |
+
"i32.or": sign([i32, i32], [i32]),
|
| 121 |
+
"i32.xor": sign([i32, i32], [i32]),
|
| 122 |
+
"i32.shl": sign([i32, i32], [i32]),
|
| 123 |
+
"i32.shr_s": sign([i32, i32], [i32]),
|
| 124 |
+
"i32.shr_u": sign([i32, i32], [i32]),
|
| 125 |
+
"i32.rotl": sign([i32, i32], [i32]),
|
| 126 |
+
"i32.rotr": sign([i32, i32], [i32]),
|
| 127 |
+
"i64.clz": sign([i64], [i64]),
|
| 128 |
+
"i64.ctz": sign([i64], [i64]),
|
| 129 |
+
"i64.popcnt": sign([i64], [i64]),
|
| 130 |
+
"i64.add": sign([i64, i64], [i64]),
|
| 131 |
+
"i64.sub": sign([i64, i64], [i64]),
|
| 132 |
+
"i64.mul": sign([i64, i64], [i64]),
|
| 133 |
+
"i64.div_s": sign([i64, i64], [i64]),
|
| 134 |
+
"i64.div_u": sign([i64, i64], [i64]),
|
| 135 |
+
"i64.rem_s": sign([i64, i64], [i64]),
|
| 136 |
+
"i64.rem_u": sign([i64, i64], [i64]),
|
| 137 |
+
"i64.and": sign([i64, i64], [i64]),
|
| 138 |
+
"i64.or": sign([i64, i64], [i64]),
|
| 139 |
+
"i64.xor": sign([i64, i64], [i64]),
|
| 140 |
+
"i64.shl": sign([i64, i64], [i64]),
|
| 141 |
+
"i64.shr_s": sign([i64, i64], [i64]),
|
| 142 |
+
"i64.shr_u": sign([i64, i64], [i64]),
|
| 143 |
+
"i64.rotl": sign([i64, i64], [i64]),
|
| 144 |
+
"i64.rotr": sign([i64, i64], [i64]),
|
| 145 |
+
"f32.abs": sign([f32], [f32]),
|
| 146 |
+
"f32.neg": sign([f32], [f32]),
|
| 147 |
+
"f32.ceil": sign([f32], [f32]),
|
| 148 |
+
"f32.floor": sign([f32], [f32]),
|
| 149 |
+
"f32.trunc": sign([f32], [f32]),
|
| 150 |
+
"f32.nearest": sign([f32], [f32]),
|
| 151 |
+
"f32.sqrt": sign([f32], [f32]),
|
| 152 |
+
"f32.add": sign([f32, f32], [f32]),
|
| 153 |
+
"f32.sub": sign([f32, f32], [f32]),
|
| 154 |
+
"f32.mul": sign([f32, f32], [f32]),
|
| 155 |
+
"f32.div": sign([f32, f32], [f32]),
|
| 156 |
+
"f32.min": sign([f32, f32], [f32]),
|
| 157 |
+
"f32.max": sign([f32, f32], [f32]),
|
| 158 |
+
"f32.copysign": sign([f32, f32], [f32]),
|
| 159 |
+
"f64.abs": sign([f64], [f64]),
|
| 160 |
+
"f64.neg": sign([f64], [f64]),
|
| 161 |
+
"f64.ceil": sign([f64], [f64]),
|
| 162 |
+
"f64.floor": sign([f64], [f64]),
|
| 163 |
+
"f64.trunc": sign([f64], [f64]),
|
| 164 |
+
"f64.nearest": sign([f64], [f64]),
|
| 165 |
+
"f64.sqrt": sign([f64], [f64]),
|
| 166 |
+
"f64.add": sign([f64, f64], [f64]),
|
| 167 |
+
"f64.sub": sign([f64, f64], [f64]),
|
| 168 |
+
"f64.mul": sign([f64, f64], [f64]),
|
| 169 |
+
"f64.div": sign([f64, f64], [f64]),
|
| 170 |
+
"f64.min": sign([f64, f64], [f64]),
|
| 171 |
+
"f64.max": sign([f64, f64], [f64]),
|
| 172 |
+
"f64.copysign": sign([f64, f64], [f64]),
|
| 173 |
+
"i32.wrap/i64": sign([i64], [i32]),
|
| 174 |
+
"i32.trunc_s/f32": sign([f32], [i32]),
|
| 175 |
+
"i32.trunc_u/f32": sign([f32], [i32]),
|
| 176 |
+
"i32.trunc_s/f64": sign([f32], [i32]),
|
| 177 |
+
"i32.trunc_u/f64": sign([f64], [i32]),
|
| 178 |
+
"i64.extend_s/i32": sign([i32], [i64]),
|
| 179 |
+
"i64.extend_u/i32": sign([i32], [i64]),
|
| 180 |
+
"i64.trunc_s/f32": sign([f32], [i64]),
|
| 181 |
+
"i64.trunc_u/f32": sign([f32], [i64]),
|
| 182 |
+
"i64.trunc_s/f64": sign([f64], [i64]),
|
| 183 |
+
"i64.trunc_u/f64": sign([f64], [i64]),
|
| 184 |
+
"f32.convert_s/i32": sign([i32], [f32]),
|
| 185 |
+
"f32.convert_u/i32": sign([i32], [f32]),
|
| 186 |
+
"f32.convert_s/i64": sign([i64], [f32]),
|
| 187 |
+
"f32.convert_u/i64": sign([i64], [f32]),
|
| 188 |
+
"f32.demote/f64": sign([f64], [f32]),
|
| 189 |
+
"f64.convert_s/i32": sign([i32], [f64]),
|
| 190 |
+
"f64.convert_u/i32": sign([i32], [f64]),
|
| 191 |
+
"f64.convert_s/i64": sign([i64], [f64]),
|
| 192 |
+
"f64.convert_u/i64": sign([i64], [f64]),
|
| 193 |
+
"f64.promote/f32": sign([f32], [f64]),
|
| 194 |
+
"i32.reinterpret/f32": sign([f32], [i32]),
|
| 195 |
+
"i64.reinterpret/f64": sign([f64], [i64]),
|
| 196 |
+
"f32.reinterpret/i32": sign([i32], [f32]),
|
| 197 |
+
"f64.reinterpret/i64": sign([i64], [f64])
|
| 198 |
+
};
|
| 199 |
+
export var signatures = Object.assign({}, controlInstructions, parametricInstructions, variableInstructions, memoryInstructions, numericInstructions);
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/transform/ast-module-to-module-context/index.js
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
| 2 |
+
|
| 3 |
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
| 4 |
+
|
| 5 |
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
| 6 |
+
|
| 7 |
+
import { isSignature, isNumberLiteral } from "../../nodes.js";
|
| 8 |
+
export function moduleContextFromModuleAST(m) {
|
| 9 |
+
var moduleContext = new ModuleContext();
|
| 10 |
+
|
| 11 |
+
if (!(m.type === "Module")) {
|
| 12 |
+
throw new Error('m.type === "Module"' + " error: " + (undefined || "unknown"));
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
m.fields.forEach(function (field) {
|
| 16 |
+
switch (field.type) {
|
| 17 |
+
case "Start":
|
| 18 |
+
{
|
| 19 |
+
moduleContext.setStart(field.index);
|
| 20 |
+
break;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
case "TypeInstruction":
|
| 24 |
+
{
|
| 25 |
+
moduleContext.addType(field);
|
| 26 |
+
break;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
case "Func":
|
| 30 |
+
{
|
| 31 |
+
moduleContext.addFunction(field);
|
| 32 |
+
break;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
case "Global":
|
| 36 |
+
{
|
| 37 |
+
moduleContext.defineGlobal(field);
|
| 38 |
+
break;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
case "ModuleImport":
|
| 42 |
+
{
|
| 43 |
+
switch (field.descr.type) {
|
| 44 |
+
case "GlobalType":
|
| 45 |
+
{
|
| 46 |
+
moduleContext.importGlobal(field.descr.valtype, field.descr.mutability);
|
| 47 |
+
break;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
case "Memory":
|
| 51 |
+
{
|
| 52 |
+
moduleContext.addMemory(field.descr.limits.min, field.descr.limits.max);
|
| 53 |
+
break;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
case "FuncImportDescr":
|
| 57 |
+
{
|
| 58 |
+
moduleContext.importFunction(field.descr);
|
| 59 |
+
break;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
case "Table":
|
| 63 |
+
{
|
| 64 |
+
// FIXME(sven): not implemented yet
|
| 65 |
+
break;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
default:
|
| 69 |
+
throw new Error("Unsupported ModuleImport of type " + JSON.stringify(field.descr.type));
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
break;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
case "Memory":
|
| 76 |
+
{
|
| 77 |
+
moduleContext.addMemory(field.limits.min, field.limits.max);
|
| 78 |
+
break;
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
});
|
| 82 |
+
return moduleContext;
|
| 83 |
+
}
|
| 84 |
+
/**
|
| 85 |
+
* Module context for type checking
|
| 86 |
+
*/
|
| 87 |
+
|
| 88 |
+
export var ModuleContext = /*#__PURE__*/function () {
|
| 89 |
+
function ModuleContext() {
|
| 90 |
+
_classCallCheck(this, ModuleContext);
|
| 91 |
+
|
| 92 |
+
this.funcs = [];
|
| 93 |
+
this.funcsOffsetByIdentifier = [];
|
| 94 |
+
this.types = [];
|
| 95 |
+
this.globals = [];
|
| 96 |
+
this.globalsOffsetByIdentifier = [];
|
| 97 |
+
this.mems = []; // Current stack frame
|
| 98 |
+
|
| 99 |
+
this.locals = [];
|
| 100 |
+
this.labels = [];
|
| 101 |
+
this["return"] = [];
|
| 102 |
+
this.debugName = "unknown";
|
| 103 |
+
this.start = null;
|
| 104 |
+
}
|
| 105 |
+
/**
|
| 106 |
+
* Set start segment
|
| 107 |
+
*/
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
_createClass(ModuleContext, [{
|
| 111 |
+
key: "setStart",
|
| 112 |
+
value: function setStart(index) {
|
| 113 |
+
this.start = index.value;
|
| 114 |
+
}
|
| 115 |
+
/**
|
| 116 |
+
* Get start function
|
| 117 |
+
*/
|
| 118 |
+
|
| 119 |
+
}, {
|
| 120 |
+
key: "getStart",
|
| 121 |
+
value: function getStart() {
|
| 122 |
+
return this.start;
|
| 123 |
+
}
|
| 124 |
+
/**
|
| 125 |
+
* Reset the active stack frame
|
| 126 |
+
*/
|
| 127 |
+
|
| 128 |
+
}, {
|
| 129 |
+
key: "newContext",
|
| 130 |
+
value: function newContext(debugName, expectedResult) {
|
| 131 |
+
this.locals = [];
|
| 132 |
+
this.labels = [expectedResult];
|
| 133 |
+
this["return"] = expectedResult;
|
| 134 |
+
this.debugName = debugName;
|
| 135 |
+
}
|
| 136 |
+
/**
|
| 137 |
+
* Functions
|
| 138 |
+
*/
|
| 139 |
+
|
| 140 |
+
}, {
|
| 141 |
+
key: "addFunction",
|
| 142 |
+
value: function addFunction(func) {
|
| 143 |
+
/* eslint-disable */
|
| 144 |
+
// $FlowIgnore
|
| 145 |
+
var _ref = func.signature || {},
|
| 146 |
+
_ref$params = _ref.params,
|
| 147 |
+
args = _ref$params === void 0 ? [] : _ref$params,
|
| 148 |
+
_ref$results = _ref.results,
|
| 149 |
+
result = _ref$results === void 0 ? [] : _ref$results;
|
| 150 |
+
/* eslint-enable */
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
args = args.map(function (arg) {
|
| 154 |
+
return arg.valtype;
|
| 155 |
+
});
|
| 156 |
+
this.funcs.push({
|
| 157 |
+
args: args,
|
| 158 |
+
result: result
|
| 159 |
+
});
|
| 160 |
+
|
| 161 |
+
if (typeof func.name !== "undefined") {
|
| 162 |
+
// $FlowIgnore
|
| 163 |
+
this.funcsOffsetByIdentifier[func.name.value] = this.funcs.length - 1;
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
}, {
|
| 167 |
+
key: "importFunction",
|
| 168 |
+
value: function importFunction(funcimport) {
|
| 169 |
+
if (isSignature(funcimport.signature)) {
|
| 170 |
+
// eslint-disable-next-line prefer-const
|
| 171 |
+
var _funcimport$signature = funcimport.signature,
|
| 172 |
+
args = _funcimport$signature.params,
|
| 173 |
+
result = _funcimport$signature.results;
|
| 174 |
+
args = args.map(function (arg) {
|
| 175 |
+
return arg.valtype;
|
| 176 |
+
});
|
| 177 |
+
this.funcs.push({
|
| 178 |
+
args: args,
|
| 179 |
+
result: result
|
| 180 |
+
});
|
| 181 |
+
} else {
|
| 182 |
+
if (!isNumberLiteral(funcimport.signature)) {
|
| 183 |
+
throw new Error('isNumberLiteral(funcimport.signature)' + " error: " + (undefined || "unknown"));
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
var typeId = funcimport.signature.value;
|
| 187 |
+
|
| 188 |
+
if (!this.hasType(typeId)) {
|
| 189 |
+
throw new Error('this.hasType(typeId)' + " error: " + (undefined || "unknown"));
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
var signature = this.getType(typeId);
|
| 193 |
+
this.funcs.push({
|
| 194 |
+
args: signature.params.map(function (arg) {
|
| 195 |
+
return arg.valtype;
|
| 196 |
+
}),
|
| 197 |
+
result: signature.results
|
| 198 |
+
});
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
if (typeof funcimport.id !== "undefined") {
|
| 202 |
+
// imports are first, we can assume their index in the array
|
| 203 |
+
this.funcsOffsetByIdentifier[funcimport.id.value] = this.funcs.length - 1;
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
}, {
|
| 207 |
+
key: "hasFunction",
|
| 208 |
+
value: function hasFunction(index) {
|
| 209 |
+
return typeof this.getFunction(index) !== "undefined";
|
| 210 |
+
}
|
| 211 |
+
}, {
|
| 212 |
+
key: "getFunction",
|
| 213 |
+
value: function getFunction(index) {
|
| 214 |
+
if (typeof index !== "number") {
|
| 215 |
+
throw new Error("getFunction only supported for number index");
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
return this.funcs[index];
|
| 219 |
+
}
|
| 220 |
+
}, {
|
| 221 |
+
key: "getFunctionOffsetByIdentifier",
|
| 222 |
+
value: function getFunctionOffsetByIdentifier(name) {
|
| 223 |
+
if (!(typeof name === "string")) {
|
| 224 |
+
throw new Error('typeof name === "string"' + " error: " + (undefined || "unknown"));
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
return this.funcsOffsetByIdentifier[name];
|
| 228 |
+
}
|
| 229 |
+
/**
|
| 230 |
+
* Labels
|
| 231 |
+
*/
|
| 232 |
+
|
| 233 |
+
}, {
|
| 234 |
+
key: "addLabel",
|
| 235 |
+
value: function addLabel(result) {
|
| 236 |
+
this.labels.unshift(result);
|
| 237 |
+
}
|
| 238 |
+
}, {
|
| 239 |
+
key: "hasLabel",
|
| 240 |
+
value: function hasLabel(index) {
|
| 241 |
+
return this.labels.length > index && index >= 0;
|
| 242 |
+
}
|
| 243 |
+
}, {
|
| 244 |
+
key: "getLabel",
|
| 245 |
+
value: function getLabel(index) {
|
| 246 |
+
return this.labels[index];
|
| 247 |
+
}
|
| 248 |
+
}, {
|
| 249 |
+
key: "popLabel",
|
| 250 |
+
value: function popLabel() {
|
| 251 |
+
this.labels.shift();
|
| 252 |
+
}
|
| 253 |
+
/**
|
| 254 |
+
* Locals
|
| 255 |
+
*/
|
| 256 |
+
|
| 257 |
+
}, {
|
| 258 |
+
key: "hasLocal",
|
| 259 |
+
value: function hasLocal(index) {
|
| 260 |
+
return typeof this.getLocal(index) !== "undefined";
|
| 261 |
+
}
|
| 262 |
+
}, {
|
| 263 |
+
key: "getLocal",
|
| 264 |
+
value: function getLocal(index) {
|
| 265 |
+
return this.locals[index];
|
| 266 |
+
}
|
| 267 |
+
}, {
|
| 268 |
+
key: "addLocal",
|
| 269 |
+
value: function addLocal(type) {
|
| 270 |
+
this.locals.push(type);
|
| 271 |
+
}
|
| 272 |
+
/**
|
| 273 |
+
* Types
|
| 274 |
+
*/
|
| 275 |
+
|
| 276 |
+
}, {
|
| 277 |
+
key: "addType",
|
| 278 |
+
value: function addType(type) {
|
| 279 |
+
if (!(type.functype.type === "Signature")) {
|
| 280 |
+
throw new Error('type.functype.type === "Signature"' + " error: " + (undefined || "unknown"));
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
this.types.push(type.functype);
|
| 284 |
+
}
|
| 285 |
+
}, {
|
| 286 |
+
key: "hasType",
|
| 287 |
+
value: function hasType(index) {
|
| 288 |
+
return this.types[index] !== undefined;
|
| 289 |
+
}
|
| 290 |
+
}, {
|
| 291 |
+
key: "getType",
|
| 292 |
+
value: function getType(index) {
|
| 293 |
+
return this.types[index];
|
| 294 |
+
}
|
| 295 |
+
/**
|
| 296 |
+
* Globals
|
| 297 |
+
*/
|
| 298 |
+
|
| 299 |
+
}, {
|
| 300 |
+
key: "hasGlobal",
|
| 301 |
+
value: function hasGlobal(index) {
|
| 302 |
+
return this.globals.length > index && index >= 0;
|
| 303 |
+
}
|
| 304 |
+
}, {
|
| 305 |
+
key: "getGlobal",
|
| 306 |
+
value: function getGlobal(index) {
|
| 307 |
+
return this.globals[index].type;
|
| 308 |
+
}
|
| 309 |
+
}, {
|
| 310 |
+
key: "getGlobalOffsetByIdentifier",
|
| 311 |
+
value: function getGlobalOffsetByIdentifier(name) {
|
| 312 |
+
if (!(typeof name === "string")) {
|
| 313 |
+
throw new Error('typeof name === "string"' + " error: " + (undefined || "unknown"));
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
// $FlowIgnore
|
| 317 |
+
return this.globalsOffsetByIdentifier[name];
|
| 318 |
+
}
|
| 319 |
+
}, {
|
| 320 |
+
key: "defineGlobal",
|
| 321 |
+
value: function defineGlobal(global) {
|
| 322 |
+
var type = global.globalType.valtype;
|
| 323 |
+
var mutability = global.globalType.mutability;
|
| 324 |
+
this.globals.push({
|
| 325 |
+
type: type,
|
| 326 |
+
mutability: mutability
|
| 327 |
+
});
|
| 328 |
+
|
| 329 |
+
if (typeof global.name !== "undefined") {
|
| 330 |
+
// $FlowIgnore
|
| 331 |
+
this.globalsOffsetByIdentifier[global.name.value] = this.globals.length - 1;
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
}, {
|
| 335 |
+
key: "importGlobal",
|
| 336 |
+
value: function importGlobal(type, mutability) {
|
| 337 |
+
this.globals.push({
|
| 338 |
+
type: type,
|
| 339 |
+
mutability: mutability
|
| 340 |
+
});
|
| 341 |
+
}
|
| 342 |
+
}, {
|
| 343 |
+
key: "isMutableGlobal",
|
| 344 |
+
value: function isMutableGlobal(index) {
|
| 345 |
+
return this.globals[index].mutability === "var";
|
| 346 |
+
}
|
| 347 |
+
}, {
|
| 348 |
+
key: "isImmutableGlobal",
|
| 349 |
+
value: function isImmutableGlobal(index) {
|
| 350 |
+
return this.globals[index].mutability === "const";
|
| 351 |
+
}
|
| 352 |
+
/**
|
| 353 |
+
* Memories
|
| 354 |
+
*/
|
| 355 |
+
|
| 356 |
+
}, {
|
| 357 |
+
key: "hasMemory",
|
| 358 |
+
value: function hasMemory(index) {
|
| 359 |
+
return this.mems.length > index && index >= 0;
|
| 360 |
+
}
|
| 361 |
+
}, {
|
| 362 |
+
key: "addMemory",
|
| 363 |
+
value: function addMemory(min, max) {
|
| 364 |
+
this.mems.push({
|
| 365 |
+
min: min,
|
| 366 |
+
max: max
|
| 367 |
+
});
|
| 368 |
+
}
|
| 369 |
+
}, {
|
| 370 |
+
key: "getMemory",
|
| 371 |
+
value: function getMemory(index) {
|
| 372 |
+
return this.mems[index];
|
| 373 |
+
}
|
| 374 |
+
}]);
|
| 375 |
+
|
| 376 |
+
return ModuleContext;
|
| 377 |
+
}();
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/transform/denormalize-type-references/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var t = require("../../index"); // func and call_indirect instructions can either define a signature inline, or
|
| 2 |
+
// reference a signature, e.g.
|
| 3 |
+
//
|
| 4 |
+
// ;; inline signature
|
| 5 |
+
// (func (result i64)
|
| 6 |
+
// (i64.const 2)
|
| 7 |
+
// )
|
| 8 |
+
// ;; signature reference
|
| 9 |
+
// (type (func (result i64)))
|
| 10 |
+
// (func (type 0)
|
| 11 |
+
// (i64.const 2))
|
| 12 |
+
// )
|
| 13 |
+
//
|
| 14 |
+
// this AST transform denormalises the type references, making all signatures within the module
|
| 15 |
+
// inline.
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
export function transform(ast) {
|
| 19 |
+
var typeInstructions = [];
|
| 20 |
+
t.traverse(ast, {
|
| 21 |
+
TypeInstruction: function TypeInstruction(_ref) {
|
| 22 |
+
var node = _ref.node;
|
| 23 |
+
typeInstructions.push(node);
|
| 24 |
+
}
|
| 25 |
+
});
|
| 26 |
+
|
| 27 |
+
if (!typeInstructions.length) {
|
| 28 |
+
return;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function denormalizeSignature(signature) {
|
| 32 |
+
// signature referenced by identifier
|
| 33 |
+
if (signature.type === "Identifier") {
|
| 34 |
+
var identifier = signature;
|
| 35 |
+
var typeInstruction = typeInstructions.find(function (t) {
|
| 36 |
+
return t.id.type === identifier.type && t.id.value === identifier.value;
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
if (!typeInstruction) {
|
| 40 |
+
throw new Error("A type instruction reference was not found ".concat(JSON.stringify(signature)));
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
return typeInstruction.functype;
|
| 44 |
+
} // signature referenced by index
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
if (signature.type === "NumberLiteral") {
|
| 48 |
+
var signatureRef = signature;
|
| 49 |
+
var _typeInstruction = typeInstructions[signatureRef.value];
|
| 50 |
+
return _typeInstruction.functype;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
return signature;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
t.traverse(ast, {
|
| 57 |
+
Func: function (_Func) {
|
| 58 |
+
function Func(_x) {
|
| 59 |
+
return _Func.apply(this, arguments);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
Func.toString = function () {
|
| 63 |
+
return _Func.toString();
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
return Func;
|
| 67 |
+
}(function (_ref2) {
|
| 68 |
+
var node = _ref2.node;
|
| 69 |
+
node.signature = denormalizeSignature(node.signature);
|
| 70 |
+
}),
|
| 71 |
+
CallIndirectInstruction: function CallIndirectInstruction(_ref3) {
|
| 72 |
+
var node = _ref3.node;
|
| 73 |
+
node.signature = denormalizeSignature(node.signature);
|
| 74 |
+
}
|
| 75 |
+
});
|
| 76 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/transform/wast-identifier-to-index/index.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
| 2 |
+
|
| 3 |
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
| 4 |
+
|
| 5 |
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
| 6 |
+
|
| 7 |
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
| 8 |
+
|
| 9 |
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
| 10 |
+
|
| 11 |
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
| 12 |
+
|
| 13 |
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
| 14 |
+
|
| 15 |
+
import { isBlock, isFunc, isIdentifier, numberLiteralFromRaw, traverse } from "../../index";
|
| 16 |
+
import { moduleContextFromModuleAST } from "../ast-module-to-module-context"; // FIXME(sven): do the same with all block instructions, must be more generic here
|
| 17 |
+
|
| 18 |
+
function newUnexpectedFunction(i) {
|
| 19 |
+
return new Error("unknown function at offset: " + i);
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export function transform(ast) {
|
| 23 |
+
var module = null;
|
| 24 |
+
traverse(ast, {
|
| 25 |
+
Module: function (_Module) {
|
| 26 |
+
function Module(_x) {
|
| 27 |
+
return _Module.apply(this, arguments);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
Module.toString = function () {
|
| 31 |
+
return _Module.toString();
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
return Module;
|
| 35 |
+
}(function (path) {
|
| 36 |
+
module = path.node;
|
| 37 |
+
})
|
| 38 |
+
});
|
| 39 |
+
|
| 40 |
+
if (module == null) {
|
| 41 |
+
throw new Error("Module not foudn in program");
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
var moduleContext = moduleContextFromModuleAST(module); // Transform the actual instruction in function bodies
|
| 45 |
+
|
| 46 |
+
traverse(ast, {
|
| 47 |
+
Func: function (_Func) {
|
| 48 |
+
function Func(_x2) {
|
| 49 |
+
return _Func.apply(this, arguments);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
Func.toString = function () {
|
| 53 |
+
return _Func.toString();
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
return Func;
|
| 57 |
+
}(function (path) {
|
| 58 |
+
transformFuncPath(path, moduleContext);
|
| 59 |
+
}),
|
| 60 |
+
Start: function (_Start) {
|
| 61 |
+
function Start(_x3) {
|
| 62 |
+
return _Start.apply(this, arguments);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
Start.toString = function () {
|
| 66 |
+
return _Start.toString();
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
return Start;
|
| 70 |
+
}(function (path) {
|
| 71 |
+
var index = path.node.index;
|
| 72 |
+
|
| 73 |
+
if (isIdentifier(index) === true) {
|
| 74 |
+
var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value);
|
| 75 |
+
|
| 76 |
+
if (typeof offsetInModule === "undefined") {
|
| 77 |
+
throw newUnexpectedFunction(index.value);
|
| 78 |
+
} // Replace the index Identifier
|
| 79 |
+
// $FlowIgnore: reference?
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
path.node.index = numberLiteralFromRaw(offsetInModule);
|
| 83 |
+
}
|
| 84 |
+
})
|
| 85 |
+
});
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function transformFuncPath(funcPath, moduleContext) {
|
| 89 |
+
var funcNode = funcPath.node;
|
| 90 |
+
var signature = funcNode.signature;
|
| 91 |
+
|
| 92 |
+
if (signature.type !== "Signature") {
|
| 93 |
+
throw new Error("Function signatures must be denormalised before execution");
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
var params = signature.params; // Add func locals in the context
|
| 97 |
+
|
| 98 |
+
params.forEach(function (p) {
|
| 99 |
+
return moduleContext.addLocal(p.valtype);
|
| 100 |
+
});
|
| 101 |
+
traverse(funcNode, {
|
| 102 |
+
Instr: function (_Instr) {
|
| 103 |
+
function Instr(_x4) {
|
| 104 |
+
return _Instr.apply(this, arguments);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
Instr.toString = function () {
|
| 108 |
+
return _Instr.toString();
|
| 109 |
+
};
|
| 110 |
+
|
| 111 |
+
return Instr;
|
| 112 |
+
}(function (instrPath) {
|
| 113 |
+
var instrNode = instrPath.node;
|
| 114 |
+
/**
|
| 115 |
+
* Local access
|
| 116 |
+
*/
|
| 117 |
+
|
| 118 |
+
if (instrNode.id === "get_local" || instrNode.id === "set_local" || instrNode.id === "tee_local") {
|
| 119 |
+
var _instrNode$args = _slicedToArray(instrNode.args, 1),
|
| 120 |
+
firstArg = _instrNode$args[0];
|
| 121 |
+
|
| 122 |
+
if (firstArg.type === "Identifier") {
|
| 123 |
+
var offsetInParams = params.findIndex(function (_ref) {
|
| 124 |
+
var id = _ref.id;
|
| 125 |
+
return id === firstArg.value;
|
| 126 |
+
});
|
| 127 |
+
|
| 128 |
+
if (offsetInParams === -1) {
|
| 129 |
+
throw new Error("".concat(firstArg.value, " not found in ").concat(instrNode.id, ": not declared in func params"));
|
| 130 |
+
} // Replace the Identifer node by our new NumberLiteral node
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
instrNode.args[0] = numberLiteralFromRaw(offsetInParams);
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
/**
|
| 137 |
+
* Global access
|
| 138 |
+
*/
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
if (instrNode.id === "get_global" || instrNode.id === "set_global") {
|
| 142 |
+
var _instrNode$args2 = _slicedToArray(instrNode.args, 1),
|
| 143 |
+
_firstArg = _instrNode$args2[0];
|
| 144 |
+
|
| 145 |
+
if (isIdentifier(_firstArg) === true) {
|
| 146 |
+
var globalOffset = moduleContext.getGlobalOffsetByIdentifier( // $FlowIgnore: reference?
|
| 147 |
+
_firstArg.value);
|
| 148 |
+
|
| 149 |
+
if (typeof globalOffset === "undefined") {
|
| 150 |
+
// $FlowIgnore: reference?
|
| 151 |
+
throw new Error("global ".concat(_firstArg.value, " not found in module"));
|
| 152 |
+
} // Replace the Identifer node by our new NumberLiteral node
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
instrNode.args[0] = numberLiteralFromRaw(globalOffset);
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
/**
|
| 159 |
+
* Labels lookup
|
| 160 |
+
*/
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
if (instrNode.id === "br") {
|
| 164 |
+
var _instrNode$args3 = _slicedToArray(instrNode.args, 1),
|
| 165 |
+
_firstArg2 = _instrNode$args3[0];
|
| 166 |
+
|
| 167 |
+
if (isIdentifier(_firstArg2) === true) {
|
| 168 |
+
// if the labels is not found it is going to be replaced with -1
|
| 169 |
+
// which is invalid.
|
| 170 |
+
var relativeBlockCount = -1; // $FlowIgnore: reference?
|
| 171 |
+
|
| 172 |
+
instrPath.findParent(function (_ref2) {
|
| 173 |
+
var node = _ref2.node;
|
| 174 |
+
|
| 175 |
+
if (isBlock(node)) {
|
| 176 |
+
relativeBlockCount++; // $FlowIgnore: reference?
|
| 177 |
+
|
| 178 |
+
var name = node.label || node.name;
|
| 179 |
+
|
| 180 |
+
if (_typeof(name) === "object") {
|
| 181 |
+
// $FlowIgnore: isIdentifier ensures that
|
| 182 |
+
if (name.value === _firstArg2.value) {
|
| 183 |
+
// Found it
|
| 184 |
+
return false;
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
if (isFunc(node)) {
|
| 190 |
+
return false;
|
| 191 |
+
}
|
| 192 |
+
}); // Replace the Identifer node by our new NumberLiteral node
|
| 193 |
+
|
| 194 |
+
instrNode.args[0] = numberLiteralFromRaw(relativeBlockCount);
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
}),
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* Func lookup
|
| 201 |
+
*/
|
| 202 |
+
CallInstruction: function (_CallInstruction) {
|
| 203 |
+
function CallInstruction(_x5) {
|
| 204 |
+
return _CallInstruction.apply(this, arguments);
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
CallInstruction.toString = function () {
|
| 208 |
+
return _CallInstruction.toString();
|
| 209 |
+
};
|
| 210 |
+
|
| 211 |
+
return CallInstruction;
|
| 212 |
+
}(function (_ref3) {
|
| 213 |
+
var node = _ref3.node;
|
| 214 |
+
var index = node.index;
|
| 215 |
+
|
| 216 |
+
if (isIdentifier(index) === true) {
|
| 217 |
+
var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value);
|
| 218 |
+
|
| 219 |
+
if (typeof offsetInModule === "undefined") {
|
| 220 |
+
throw newUnexpectedFunction(index.value);
|
| 221 |
+
} // Replace the index Identifier
|
| 222 |
+
// $FlowIgnore: reference?
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
node.index = numberLiteralFromRaw(offsetInModule);
|
| 226 |
+
}
|
| 227 |
+
})
|
| 228 |
+
});
|
| 229 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/traverse.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { createPath } from "./node-path";
|
| 2 |
+
import { unionTypesMap, nodeAndUnionTypes } from "./nodes"; // recursively walks the AST starting at the given node. The callback is invoked for
|
| 3 |
+
// and object that has a 'type' property.
|
| 4 |
+
|
| 5 |
+
function walk(context, callback) {
|
| 6 |
+
var stop = false;
|
| 7 |
+
|
| 8 |
+
function innerWalk(context, callback) {
|
| 9 |
+
if (stop) {
|
| 10 |
+
return;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
var node = context.node;
|
| 14 |
+
|
| 15 |
+
if (node === undefined) {
|
| 16 |
+
console.warn("traversing with an empty context");
|
| 17 |
+
return;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
if (node._deleted === true) {
|
| 21 |
+
return;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
var path = createPath(context);
|
| 25 |
+
callback(node.type, path);
|
| 26 |
+
|
| 27 |
+
if (path.shouldStop) {
|
| 28 |
+
stop = true;
|
| 29 |
+
return;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
Object.keys(node).forEach(function (prop) {
|
| 33 |
+
var value = node[prop];
|
| 34 |
+
|
| 35 |
+
if (value === null || value === undefined) {
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
var valueAsArray = Array.isArray(value) ? value : [value];
|
| 40 |
+
valueAsArray.forEach(function (childNode) {
|
| 41 |
+
if (typeof childNode.type === "string") {
|
| 42 |
+
var childContext = {
|
| 43 |
+
node: childNode,
|
| 44 |
+
parentKey: prop,
|
| 45 |
+
parentPath: path,
|
| 46 |
+
shouldStop: false,
|
| 47 |
+
inList: Array.isArray(value)
|
| 48 |
+
};
|
| 49 |
+
innerWalk(childContext, callback);
|
| 50 |
+
}
|
| 51 |
+
});
|
| 52 |
+
});
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
innerWalk(context, callback);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
var noop = function noop() {};
|
| 59 |
+
|
| 60 |
+
export function traverse(node, visitors) {
|
| 61 |
+
var before = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
|
| 62 |
+
var after = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop;
|
| 63 |
+
Object.keys(visitors).forEach(function (visitor) {
|
| 64 |
+
if (!nodeAndUnionTypes.includes(visitor)) {
|
| 65 |
+
throw new Error("Unexpected visitor ".concat(visitor));
|
| 66 |
+
}
|
| 67 |
+
});
|
| 68 |
+
var context = {
|
| 69 |
+
node: node,
|
| 70 |
+
inList: false,
|
| 71 |
+
shouldStop: false,
|
| 72 |
+
parentPath: null,
|
| 73 |
+
parentKey: null
|
| 74 |
+
};
|
| 75 |
+
walk(context, function (type, path) {
|
| 76 |
+
if (typeof visitors[type] === "function") {
|
| 77 |
+
before(type, path);
|
| 78 |
+
visitors[type](path);
|
| 79 |
+
after(type, path);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
var unionTypes = unionTypesMap[type];
|
| 83 |
+
|
| 84 |
+
if (!unionTypes) {
|
| 85 |
+
throw new Error("Unexpected node type ".concat(type));
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
unionTypes.forEach(function (unionType) {
|
| 89 |
+
if (typeof visitors[unionType] === "function") {
|
| 90 |
+
before(unionType, path);
|
| 91 |
+
visitors[unionType](path);
|
| 92 |
+
after(unionType, path);
|
| 93 |
+
}
|
| 94 |
+
});
|
| 95 |
+
});
|
| 96 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/types/basic.js
ADDED
|
File without changes
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/types/nodes.js
ADDED
|
File without changes
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/types/traverse.js
ADDED
|
File without changes
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/esm/utils.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
| 2 |
+
|
| 3 |
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
| 4 |
+
|
| 5 |
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
| 6 |
+
|
| 7 |
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
| 8 |
+
|
| 9 |
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
| 10 |
+
|
| 11 |
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
| 12 |
+
|
| 13 |
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
| 14 |
+
|
| 15 |
+
import { signatures } from "./signatures";
|
| 16 |
+
import { traverse } from "./traverse";
|
| 17 |
+
import constants from "@webassemblyjs/helper-wasm-bytecode";
|
| 18 |
+
import { getSectionForNode } from "@webassemblyjs/helper-wasm-bytecode";
|
| 19 |
+
export function isAnonymous(ident) {
|
| 20 |
+
return ident.raw === "";
|
| 21 |
+
}
|
| 22 |
+
export function getSectionMetadata(ast, name) {
|
| 23 |
+
var section;
|
| 24 |
+
traverse(ast, {
|
| 25 |
+
SectionMetadata: function (_SectionMetadata) {
|
| 26 |
+
function SectionMetadata(_x) {
|
| 27 |
+
return _SectionMetadata.apply(this, arguments);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
SectionMetadata.toString = function () {
|
| 31 |
+
return _SectionMetadata.toString();
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
return SectionMetadata;
|
| 35 |
+
}(function (_ref) {
|
| 36 |
+
var node = _ref.node;
|
| 37 |
+
|
| 38 |
+
if (node.section === name) {
|
| 39 |
+
section = node;
|
| 40 |
+
}
|
| 41 |
+
})
|
| 42 |
+
});
|
| 43 |
+
return section;
|
| 44 |
+
}
|
| 45 |
+
export function getSectionMetadatas(ast, name) {
|
| 46 |
+
var sections = [];
|
| 47 |
+
traverse(ast, {
|
| 48 |
+
SectionMetadata: function (_SectionMetadata2) {
|
| 49 |
+
function SectionMetadata(_x2) {
|
| 50 |
+
return _SectionMetadata2.apply(this, arguments);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
SectionMetadata.toString = function () {
|
| 54 |
+
return _SectionMetadata2.toString();
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
return SectionMetadata;
|
| 58 |
+
}(function (_ref2) {
|
| 59 |
+
var node = _ref2.node;
|
| 60 |
+
|
| 61 |
+
if (node.section === name) {
|
| 62 |
+
sections.push(node);
|
| 63 |
+
}
|
| 64 |
+
})
|
| 65 |
+
});
|
| 66 |
+
return sections;
|
| 67 |
+
}
|
| 68 |
+
export function sortSectionMetadata(m) {
|
| 69 |
+
if (m.metadata == null) {
|
| 70 |
+
console.warn("sortSectionMetadata: no metadata to sort");
|
| 71 |
+
return;
|
| 72 |
+
} // $FlowIgnore
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
m.metadata.sections.sort(function (a, b) {
|
| 76 |
+
var aId = constants.sections[a.section];
|
| 77 |
+
var bId = constants.sections[b.section];
|
| 78 |
+
|
| 79 |
+
if (typeof aId !== "number" || typeof bId !== "number") {
|
| 80 |
+
throw new Error("Section id not found");
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
return aId - bId;
|
| 84 |
+
});
|
| 85 |
+
}
|
| 86 |
+
export function orderedInsertNode(m, n) {
|
| 87 |
+
assertHasLoc(n);
|
| 88 |
+
var didInsert = false;
|
| 89 |
+
|
| 90 |
+
if (n.type === "ModuleExport") {
|
| 91 |
+
m.fields.push(n);
|
| 92 |
+
return;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
m.fields = m.fields.reduce(function (acc, field) {
|
| 96 |
+
var fieldEndCol = Infinity;
|
| 97 |
+
|
| 98 |
+
if (field.loc != null) {
|
| 99 |
+
// $FlowIgnore
|
| 100 |
+
fieldEndCol = field.loc.end.column;
|
| 101 |
+
} // $FlowIgnore: assertHasLoc ensures that
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
if (didInsert === false && n.loc.start.column < fieldEndCol) {
|
| 105 |
+
didInsert = true;
|
| 106 |
+
acc.push(n);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
acc.push(field);
|
| 110 |
+
return acc;
|
| 111 |
+
}, []); // Handles empty modules or n is the last element
|
| 112 |
+
|
| 113 |
+
if (didInsert === false) {
|
| 114 |
+
m.fields.push(n);
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
export function assertHasLoc(n) {
|
| 118 |
+
if (n.loc == null || n.loc.start == null || n.loc.end == null) {
|
| 119 |
+
throw new Error("Internal failure: node (".concat(JSON.stringify(n.type), ") has no location information"));
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
export function getEndOfSection(s) {
|
| 123 |
+
assertHasLoc(s.size);
|
| 124 |
+
return s.startOffset + s.size.value + (s.size.loc.end.column - s.size.loc.start.column);
|
| 125 |
+
}
|
| 126 |
+
export function shiftLoc(node, delta) {
|
| 127 |
+
// $FlowIgnore
|
| 128 |
+
node.loc.start.column += delta; // $FlowIgnore
|
| 129 |
+
|
| 130 |
+
node.loc.end.column += delta;
|
| 131 |
+
}
|
| 132 |
+
export function shiftSection(ast, node, delta) {
|
| 133 |
+
if (node.type !== "SectionMetadata") {
|
| 134 |
+
throw new Error("Can not shift node " + JSON.stringify(node.type));
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
node.startOffset += delta;
|
| 138 |
+
|
| 139 |
+
if (_typeof(node.size.loc) === "object") {
|
| 140 |
+
shiftLoc(node.size, delta);
|
| 141 |
+
} // Custom sections doesn't have vectorOfSize
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
if (_typeof(node.vectorOfSize) === "object" && _typeof(node.vectorOfSize.loc) === "object") {
|
| 145 |
+
shiftLoc(node.vectorOfSize, delta);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
var sectionName = node.section; // shift node locations within that section
|
| 149 |
+
|
| 150 |
+
traverse(ast, {
|
| 151 |
+
Node: function Node(_ref3) {
|
| 152 |
+
var node = _ref3.node;
|
| 153 |
+
var section = getSectionForNode(node);
|
| 154 |
+
|
| 155 |
+
if (section === sectionName && _typeof(node.loc) === "object") {
|
| 156 |
+
shiftLoc(node, delta);
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
});
|
| 160 |
+
}
|
| 161 |
+
export function signatureForOpcode(object, name) {
|
| 162 |
+
var opcodeName = name;
|
| 163 |
+
|
| 164 |
+
if (object !== undefined && object !== "") {
|
| 165 |
+
opcodeName = object + "." + name;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
var sign = signatures[opcodeName];
|
| 169 |
+
|
| 170 |
+
if (sign == undefined) {
|
| 171 |
+
// TODO: Uncomment this when br_table and others has been done
|
| 172 |
+
//throw new Error("Invalid opcode: "+opcodeName);
|
| 173 |
+
return [object, object];
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
return sign[0];
|
| 177 |
+
}
|
| 178 |
+
export function getUniqueNameGenerator() {
|
| 179 |
+
var inc = {};
|
| 180 |
+
return function () {
|
| 181 |
+
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "temp";
|
| 182 |
+
|
| 183 |
+
if (!(prefix in inc)) {
|
| 184 |
+
inc[prefix] = 0;
|
| 185 |
+
} else {
|
| 186 |
+
inc[prefix] = inc[prefix] + 1;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
return prefix + "_" + inc[prefix];
|
| 190 |
+
};
|
| 191 |
+
}
|
| 192 |
+
export function getStartByteOffset(n) {
|
| 193 |
+
// $FlowIgnore
|
| 194 |
+
if (typeof n.loc === "undefined" || typeof n.loc.start === "undefined") {
|
| 195 |
+
throw new Error( // $FlowIgnore
|
| 196 |
+
"Can not get byte offset without loc informations, node: " + String(n.id));
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
return n.loc.start.column;
|
| 200 |
+
}
|
| 201 |
+
export function getEndByteOffset(n) {
|
| 202 |
+
// $FlowIgnore
|
| 203 |
+
if (typeof n.loc === "undefined" || typeof n.loc.end === "undefined") {
|
| 204 |
+
throw new Error("Can not get byte offset without loc informations, node: " + n.type);
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
return n.loc.end.column;
|
| 208 |
+
}
|
| 209 |
+
export function getFunctionBeginingByteOffset(n) {
|
| 210 |
+
if (!(n.body.length > 0)) {
|
| 211 |
+
throw new Error('n.body.length > 0' + " error: " + (undefined || "unknown"));
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
var _n$body = _slicedToArray(n.body, 1),
|
| 215 |
+
firstInstruction = _n$body[0];
|
| 216 |
+
|
| 217 |
+
return getStartByteOffset(firstInstruction);
|
| 218 |
+
}
|
| 219 |
+
export function getEndBlockByteOffset(n) {
|
| 220 |
+
// $FlowIgnore
|
| 221 |
+
if (!(n.instr.length > 0 || n.body.length > 0)) {
|
| 222 |
+
throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown"));
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
var lastInstruction;
|
| 226 |
+
|
| 227 |
+
if (n.instr) {
|
| 228 |
+
// $FlowIgnore
|
| 229 |
+
lastInstruction = n.instr[n.instr.length - 1];
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
if (n.body) {
|
| 233 |
+
// $FlowIgnore
|
| 234 |
+
lastInstruction = n.body[n.body.length - 1];
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
if (!(_typeof(lastInstruction) === "object")) {
|
| 238 |
+
throw new Error('typeof lastInstruction === "object"' + " error: " + (undefined || "unknown"));
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
// $FlowIgnore
|
| 242 |
+
return getStartByteOffset(lastInstruction);
|
| 243 |
+
}
|
| 244 |
+
export function getStartBlockByteOffset(n) {
|
| 245 |
+
// $FlowIgnore
|
| 246 |
+
if (!(n.instr.length > 0 || n.body.length > 0)) {
|
| 247 |
+
throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown"));
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
var fistInstruction;
|
| 251 |
+
|
| 252 |
+
if (n.instr) {
|
| 253 |
+
// $FlowIgnore
|
| 254 |
+
var _n$instr = _slicedToArray(n.instr, 1);
|
| 255 |
+
|
| 256 |
+
fistInstruction = _n$instr[0];
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
if (n.body) {
|
| 260 |
+
// $FlowIgnore
|
| 261 |
+
var _n$body2 = _slicedToArray(n.body, 1);
|
| 262 |
+
|
| 263 |
+
fistInstruction = _n$body2[0];
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
if (!(_typeof(fistInstruction) === "object")) {
|
| 267 |
+
throw new Error('typeof fistInstruction === "object"' + " error: " + (undefined || "unknown"));
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
// $FlowIgnore
|
| 271 |
+
return getStartByteOffset(fistInstruction);
|
| 272 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/clone.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.cloneNode = cloneNode;
|
| 7 |
+
|
| 8 |
+
function cloneNode(n) {
|
| 9 |
+
// $FlowIgnore
|
| 10 |
+
return Object.assign({}, n);
|
| 11 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/definitions.js
ADDED
|
@@ -0,0 +1,670 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
var definitions = {};
|
| 4 |
+
|
| 5 |
+
function defineType(typeName, metadata) {
|
| 6 |
+
definitions[typeName] = metadata;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
defineType("Module", {
|
| 10 |
+
spec: {
|
| 11 |
+
wasm: "https://webassembly.github.io/spec/core/binary/modules.html#binary-module",
|
| 12 |
+
wat: "https://webassembly.github.io/spec/core/text/modules.html#text-module"
|
| 13 |
+
},
|
| 14 |
+
doc: "A module consists of a sequence of sections (termed fields in the text format).",
|
| 15 |
+
unionType: ["Node"],
|
| 16 |
+
fields: {
|
| 17 |
+
id: {
|
| 18 |
+
maybe: true,
|
| 19 |
+
type: "string"
|
| 20 |
+
},
|
| 21 |
+
fields: {
|
| 22 |
+
array: true,
|
| 23 |
+
type: "Node"
|
| 24 |
+
},
|
| 25 |
+
metadata: {
|
| 26 |
+
optional: true,
|
| 27 |
+
type: "ModuleMetadata"
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
});
|
| 31 |
+
defineType("ModuleMetadata", {
|
| 32 |
+
unionType: ["Node"],
|
| 33 |
+
fields: {
|
| 34 |
+
sections: {
|
| 35 |
+
array: true,
|
| 36 |
+
type: "SectionMetadata"
|
| 37 |
+
},
|
| 38 |
+
functionNames: {
|
| 39 |
+
optional: true,
|
| 40 |
+
array: true,
|
| 41 |
+
type: "FunctionNameMetadata"
|
| 42 |
+
},
|
| 43 |
+
localNames: {
|
| 44 |
+
optional: true,
|
| 45 |
+
array: true,
|
| 46 |
+
type: "ModuleMetadata"
|
| 47 |
+
},
|
| 48 |
+
producers: {
|
| 49 |
+
optional: true,
|
| 50 |
+
array: true,
|
| 51 |
+
type: "ProducersSectionMetadata"
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
});
|
| 55 |
+
defineType("ModuleNameMetadata", {
|
| 56 |
+
unionType: ["Node"],
|
| 57 |
+
fields: {
|
| 58 |
+
value: {
|
| 59 |
+
type: "string"
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
});
|
| 63 |
+
defineType("FunctionNameMetadata", {
|
| 64 |
+
unionType: ["Node"],
|
| 65 |
+
fields: {
|
| 66 |
+
value: {
|
| 67 |
+
type: "string"
|
| 68 |
+
},
|
| 69 |
+
index: {
|
| 70 |
+
type: "number"
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
});
|
| 74 |
+
defineType("LocalNameMetadata", {
|
| 75 |
+
unionType: ["Node"],
|
| 76 |
+
fields: {
|
| 77 |
+
value: {
|
| 78 |
+
type: "string"
|
| 79 |
+
},
|
| 80 |
+
localIndex: {
|
| 81 |
+
type: "number"
|
| 82 |
+
},
|
| 83 |
+
functionIndex: {
|
| 84 |
+
type: "number"
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
});
|
| 88 |
+
defineType("BinaryModule", {
|
| 89 |
+
unionType: ["Node"],
|
| 90 |
+
fields: {
|
| 91 |
+
id: {
|
| 92 |
+
maybe: true,
|
| 93 |
+
type: "string"
|
| 94 |
+
},
|
| 95 |
+
blob: {
|
| 96 |
+
array: true,
|
| 97 |
+
type: "string"
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
});
|
| 101 |
+
defineType("QuoteModule", {
|
| 102 |
+
unionType: ["Node"],
|
| 103 |
+
fields: {
|
| 104 |
+
id: {
|
| 105 |
+
maybe: true,
|
| 106 |
+
type: "string"
|
| 107 |
+
},
|
| 108 |
+
string: {
|
| 109 |
+
array: true,
|
| 110 |
+
type: "string"
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
});
|
| 114 |
+
defineType("SectionMetadata", {
|
| 115 |
+
unionType: ["Node"],
|
| 116 |
+
fields: {
|
| 117 |
+
section: {
|
| 118 |
+
type: "SectionName"
|
| 119 |
+
},
|
| 120 |
+
startOffset: {
|
| 121 |
+
type: "number"
|
| 122 |
+
},
|
| 123 |
+
size: {
|
| 124 |
+
type: "NumberLiteral"
|
| 125 |
+
},
|
| 126 |
+
vectorOfSize: {
|
| 127 |
+
comment: "Size of the vector in the section (if any)",
|
| 128 |
+
type: "NumberLiteral"
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
});
|
| 132 |
+
defineType("ProducersSectionMetadata", {
|
| 133 |
+
unionType: ["Node"],
|
| 134 |
+
fields: {
|
| 135 |
+
producers: {
|
| 136 |
+
array: true,
|
| 137 |
+
type: "ProducerMetadata"
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
});
|
| 141 |
+
defineType("ProducerMetadata", {
|
| 142 |
+
unionType: ["Node"],
|
| 143 |
+
fields: {
|
| 144 |
+
language: {
|
| 145 |
+
type: "ProducerMetadataVersionedName",
|
| 146 |
+
array: true
|
| 147 |
+
},
|
| 148 |
+
processedBy: {
|
| 149 |
+
type: "ProducerMetadataVersionedName",
|
| 150 |
+
array: true
|
| 151 |
+
},
|
| 152 |
+
sdk: {
|
| 153 |
+
type: "ProducerMetadataVersionedName",
|
| 154 |
+
array: true
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
});
|
| 158 |
+
defineType("ProducerMetadataVersionedName", {
|
| 159 |
+
unionType: ["Node"],
|
| 160 |
+
fields: {
|
| 161 |
+
name: {
|
| 162 |
+
type: "string"
|
| 163 |
+
},
|
| 164 |
+
version: {
|
| 165 |
+
type: "string"
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
});
|
| 169 |
+
/*
|
| 170 |
+
Instructions
|
| 171 |
+
*/
|
| 172 |
+
|
| 173 |
+
defineType("LoopInstruction", {
|
| 174 |
+
unionType: ["Node", "Block", "Instruction"],
|
| 175 |
+
fields: {
|
| 176 |
+
id: {
|
| 177 |
+
constant: true,
|
| 178 |
+
type: "string",
|
| 179 |
+
value: "loop"
|
| 180 |
+
},
|
| 181 |
+
label: {
|
| 182 |
+
maybe: true,
|
| 183 |
+
type: "Identifier"
|
| 184 |
+
},
|
| 185 |
+
resulttype: {
|
| 186 |
+
maybe: true,
|
| 187 |
+
type: "Valtype"
|
| 188 |
+
},
|
| 189 |
+
instr: {
|
| 190 |
+
array: true,
|
| 191 |
+
type: "Instruction"
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
});
|
| 195 |
+
defineType("Instr", {
|
| 196 |
+
unionType: ["Node", "Expression", "Instruction"],
|
| 197 |
+
fields: {
|
| 198 |
+
id: {
|
| 199 |
+
type: "string"
|
| 200 |
+
},
|
| 201 |
+
object: {
|
| 202 |
+
optional: true,
|
| 203 |
+
type: "Valtype"
|
| 204 |
+
},
|
| 205 |
+
args: {
|
| 206 |
+
array: true,
|
| 207 |
+
type: "Expression"
|
| 208 |
+
},
|
| 209 |
+
namedArgs: {
|
| 210 |
+
optional: true,
|
| 211 |
+
type: "Object"
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
});
|
| 215 |
+
defineType("IfInstruction", {
|
| 216 |
+
unionType: ["Node", "Instruction"],
|
| 217 |
+
fields: {
|
| 218 |
+
id: {
|
| 219 |
+
constant: true,
|
| 220 |
+
type: "string",
|
| 221 |
+
value: "if"
|
| 222 |
+
},
|
| 223 |
+
testLabel: {
|
| 224 |
+
comment: "only for WAST",
|
| 225 |
+
type: "Identifier"
|
| 226 |
+
},
|
| 227 |
+
test: {
|
| 228 |
+
array: true,
|
| 229 |
+
type: "Instruction"
|
| 230 |
+
},
|
| 231 |
+
result: {
|
| 232 |
+
maybe: true,
|
| 233 |
+
type: "Valtype"
|
| 234 |
+
},
|
| 235 |
+
consequent: {
|
| 236 |
+
array: true,
|
| 237 |
+
type: "Instruction"
|
| 238 |
+
},
|
| 239 |
+
alternate: {
|
| 240 |
+
array: true,
|
| 241 |
+
type: "Instruction"
|
| 242 |
+
}
|
| 243 |
+
}
|
| 244 |
+
});
|
| 245 |
+
/*
|
| 246 |
+
Concrete value types
|
| 247 |
+
*/
|
| 248 |
+
|
| 249 |
+
defineType("StringLiteral", {
|
| 250 |
+
unionType: ["Node", "Expression"],
|
| 251 |
+
fields: {
|
| 252 |
+
value: {
|
| 253 |
+
type: "string"
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
});
|
| 257 |
+
defineType("NumberLiteral", {
|
| 258 |
+
unionType: ["Node", "NumericLiteral", "Expression"],
|
| 259 |
+
fields: {
|
| 260 |
+
value: {
|
| 261 |
+
type: "number"
|
| 262 |
+
},
|
| 263 |
+
raw: {
|
| 264 |
+
type: "string"
|
| 265 |
+
}
|
| 266 |
+
}
|
| 267 |
+
});
|
| 268 |
+
defineType("LongNumberLiteral", {
|
| 269 |
+
unionType: ["Node", "NumericLiteral", "Expression"],
|
| 270 |
+
fields: {
|
| 271 |
+
value: {
|
| 272 |
+
type: "LongNumber"
|
| 273 |
+
},
|
| 274 |
+
raw: {
|
| 275 |
+
type: "string"
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
});
|
| 279 |
+
defineType("FloatLiteral", {
|
| 280 |
+
unionType: ["Node", "NumericLiteral", "Expression"],
|
| 281 |
+
fields: {
|
| 282 |
+
value: {
|
| 283 |
+
type: "number"
|
| 284 |
+
},
|
| 285 |
+
nan: {
|
| 286 |
+
optional: true,
|
| 287 |
+
type: "boolean"
|
| 288 |
+
},
|
| 289 |
+
inf: {
|
| 290 |
+
optional: true,
|
| 291 |
+
type: "boolean"
|
| 292 |
+
},
|
| 293 |
+
raw: {
|
| 294 |
+
type: "string"
|
| 295 |
+
}
|
| 296 |
+
}
|
| 297 |
+
});
|
| 298 |
+
defineType("Elem", {
|
| 299 |
+
unionType: ["Node"],
|
| 300 |
+
fields: {
|
| 301 |
+
table: {
|
| 302 |
+
type: "Index"
|
| 303 |
+
},
|
| 304 |
+
offset: {
|
| 305 |
+
array: true,
|
| 306 |
+
type: "Instruction"
|
| 307 |
+
},
|
| 308 |
+
funcs: {
|
| 309 |
+
array: true,
|
| 310 |
+
type: "Index"
|
| 311 |
+
}
|
| 312 |
+
}
|
| 313 |
+
});
|
| 314 |
+
defineType("IndexInFuncSection", {
|
| 315 |
+
unionType: ["Node"],
|
| 316 |
+
fields: {
|
| 317 |
+
index: {
|
| 318 |
+
type: "Index"
|
| 319 |
+
}
|
| 320 |
+
}
|
| 321 |
+
});
|
| 322 |
+
defineType("ValtypeLiteral", {
|
| 323 |
+
unionType: ["Node", "Expression"],
|
| 324 |
+
fields: {
|
| 325 |
+
name: {
|
| 326 |
+
type: "Valtype"
|
| 327 |
+
}
|
| 328 |
+
}
|
| 329 |
+
});
|
| 330 |
+
defineType("TypeInstruction", {
|
| 331 |
+
unionType: ["Node", "Instruction"],
|
| 332 |
+
fields: {
|
| 333 |
+
id: {
|
| 334 |
+
maybe: true,
|
| 335 |
+
type: "Index"
|
| 336 |
+
},
|
| 337 |
+
functype: {
|
| 338 |
+
type: "Signature"
|
| 339 |
+
}
|
| 340 |
+
}
|
| 341 |
+
});
|
| 342 |
+
defineType("Start", {
|
| 343 |
+
unionType: ["Node"],
|
| 344 |
+
fields: {
|
| 345 |
+
index: {
|
| 346 |
+
type: "Index"
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
});
|
| 350 |
+
defineType("GlobalType", {
|
| 351 |
+
unionType: ["Node", "ImportDescr"],
|
| 352 |
+
fields: {
|
| 353 |
+
valtype: {
|
| 354 |
+
type: "Valtype"
|
| 355 |
+
},
|
| 356 |
+
mutability: {
|
| 357 |
+
type: "Mutability"
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
});
|
| 361 |
+
defineType("LeadingComment", {
|
| 362 |
+
unionType: ["Node"],
|
| 363 |
+
fields: {
|
| 364 |
+
value: {
|
| 365 |
+
type: "string"
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
+
});
|
| 369 |
+
defineType("BlockComment", {
|
| 370 |
+
unionType: ["Node"],
|
| 371 |
+
fields: {
|
| 372 |
+
value: {
|
| 373 |
+
type: "string"
|
| 374 |
+
}
|
| 375 |
+
}
|
| 376 |
+
});
|
| 377 |
+
defineType("Data", {
|
| 378 |
+
unionType: ["Node"],
|
| 379 |
+
fields: {
|
| 380 |
+
memoryIndex: {
|
| 381 |
+
type: "Memidx"
|
| 382 |
+
},
|
| 383 |
+
offset: {
|
| 384 |
+
type: "Instruction"
|
| 385 |
+
},
|
| 386 |
+
init: {
|
| 387 |
+
type: "ByteArray"
|
| 388 |
+
}
|
| 389 |
+
}
|
| 390 |
+
});
|
| 391 |
+
defineType("Global", {
|
| 392 |
+
unionType: ["Node"],
|
| 393 |
+
fields: {
|
| 394 |
+
globalType: {
|
| 395 |
+
type: "GlobalType"
|
| 396 |
+
},
|
| 397 |
+
init: {
|
| 398 |
+
array: true,
|
| 399 |
+
type: "Instruction"
|
| 400 |
+
},
|
| 401 |
+
name: {
|
| 402 |
+
maybe: true,
|
| 403 |
+
type: "Identifier"
|
| 404 |
+
}
|
| 405 |
+
}
|
| 406 |
+
});
|
| 407 |
+
defineType("Table", {
|
| 408 |
+
unionType: ["Node", "ImportDescr"],
|
| 409 |
+
fields: {
|
| 410 |
+
elementType: {
|
| 411 |
+
type: "TableElementType"
|
| 412 |
+
},
|
| 413 |
+
limits: {
|
| 414 |
+
assertNodeType: true,
|
| 415 |
+
type: "Limit"
|
| 416 |
+
},
|
| 417 |
+
name: {
|
| 418 |
+
maybe: true,
|
| 419 |
+
type: "Identifier"
|
| 420 |
+
},
|
| 421 |
+
elements: {
|
| 422 |
+
array: true,
|
| 423 |
+
optional: true,
|
| 424 |
+
type: "Index"
|
| 425 |
+
}
|
| 426 |
+
}
|
| 427 |
+
});
|
| 428 |
+
defineType("Memory", {
|
| 429 |
+
unionType: ["Node", "ImportDescr"],
|
| 430 |
+
fields: {
|
| 431 |
+
limits: {
|
| 432 |
+
type: "Limit"
|
| 433 |
+
},
|
| 434 |
+
id: {
|
| 435 |
+
maybe: true,
|
| 436 |
+
type: "Index"
|
| 437 |
+
}
|
| 438 |
+
}
|
| 439 |
+
});
|
| 440 |
+
defineType("FuncImportDescr", {
|
| 441 |
+
unionType: ["Node", "ImportDescr"],
|
| 442 |
+
fields: {
|
| 443 |
+
id: {
|
| 444 |
+
type: "Identifier"
|
| 445 |
+
},
|
| 446 |
+
signature: {
|
| 447 |
+
type: "Signature"
|
| 448 |
+
}
|
| 449 |
+
}
|
| 450 |
+
});
|
| 451 |
+
defineType("ModuleImport", {
|
| 452 |
+
unionType: ["Node"],
|
| 453 |
+
fields: {
|
| 454 |
+
module: {
|
| 455 |
+
type: "string"
|
| 456 |
+
},
|
| 457 |
+
name: {
|
| 458 |
+
type: "string"
|
| 459 |
+
},
|
| 460 |
+
descr: {
|
| 461 |
+
type: "ImportDescr"
|
| 462 |
+
}
|
| 463 |
+
}
|
| 464 |
+
});
|
| 465 |
+
defineType("ModuleExportDescr", {
|
| 466 |
+
unionType: ["Node"],
|
| 467 |
+
fields: {
|
| 468 |
+
exportType: {
|
| 469 |
+
type: "ExportDescrType"
|
| 470 |
+
},
|
| 471 |
+
id: {
|
| 472 |
+
type: "Index"
|
| 473 |
+
}
|
| 474 |
+
}
|
| 475 |
+
});
|
| 476 |
+
defineType("ModuleExport", {
|
| 477 |
+
unionType: ["Node"],
|
| 478 |
+
fields: {
|
| 479 |
+
name: {
|
| 480 |
+
type: "string"
|
| 481 |
+
},
|
| 482 |
+
descr: {
|
| 483 |
+
type: "ModuleExportDescr"
|
| 484 |
+
}
|
| 485 |
+
}
|
| 486 |
+
});
|
| 487 |
+
defineType("Limit", {
|
| 488 |
+
unionType: ["Node"],
|
| 489 |
+
fields: {
|
| 490 |
+
min: {
|
| 491 |
+
type: "number"
|
| 492 |
+
},
|
| 493 |
+
max: {
|
| 494 |
+
optional: true,
|
| 495 |
+
type: "number"
|
| 496 |
+
},
|
| 497 |
+
// Threads proposal, shared memory
|
| 498 |
+
shared: {
|
| 499 |
+
optional: true,
|
| 500 |
+
type: "boolean"
|
| 501 |
+
}
|
| 502 |
+
}
|
| 503 |
+
});
|
| 504 |
+
defineType("Signature", {
|
| 505 |
+
unionType: ["Node"],
|
| 506 |
+
fields: {
|
| 507 |
+
params: {
|
| 508 |
+
array: true,
|
| 509 |
+
type: "FuncParam"
|
| 510 |
+
},
|
| 511 |
+
results: {
|
| 512 |
+
array: true,
|
| 513 |
+
type: "Valtype"
|
| 514 |
+
}
|
| 515 |
+
}
|
| 516 |
+
});
|
| 517 |
+
defineType("Program", {
|
| 518 |
+
unionType: ["Node"],
|
| 519 |
+
fields: {
|
| 520 |
+
body: {
|
| 521 |
+
array: true,
|
| 522 |
+
type: "Node"
|
| 523 |
+
}
|
| 524 |
+
}
|
| 525 |
+
});
|
| 526 |
+
defineType("Identifier", {
|
| 527 |
+
unionType: ["Node", "Expression"],
|
| 528 |
+
fields: {
|
| 529 |
+
value: {
|
| 530 |
+
type: "string"
|
| 531 |
+
},
|
| 532 |
+
raw: {
|
| 533 |
+
optional: true,
|
| 534 |
+
type: "string"
|
| 535 |
+
}
|
| 536 |
+
}
|
| 537 |
+
});
|
| 538 |
+
defineType("BlockInstruction", {
|
| 539 |
+
unionType: ["Node", "Block", "Instruction"],
|
| 540 |
+
fields: {
|
| 541 |
+
id: {
|
| 542 |
+
constant: true,
|
| 543 |
+
type: "string",
|
| 544 |
+
value: "block"
|
| 545 |
+
},
|
| 546 |
+
label: {
|
| 547 |
+
maybe: true,
|
| 548 |
+
type: "Identifier"
|
| 549 |
+
},
|
| 550 |
+
instr: {
|
| 551 |
+
array: true,
|
| 552 |
+
type: "Instruction"
|
| 553 |
+
},
|
| 554 |
+
result: {
|
| 555 |
+
maybe: true,
|
| 556 |
+
type: "Valtype"
|
| 557 |
+
}
|
| 558 |
+
}
|
| 559 |
+
});
|
| 560 |
+
defineType("CallInstruction", {
|
| 561 |
+
unionType: ["Node", "Instruction"],
|
| 562 |
+
fields: {
|
| 563 |
+
id: {
|
| 564 |
+
constant: true,
|
| 565 |
+
type: "string",
|
| 566 |
+
value: "call"
|
| 567 |
+
},
|
| 568 |
+
index: {
|
| 569 |
+
type: "Index"
|
| 570 |
+
},
|
| 571 |
+
instrArgs: {
|
| 572 |
+
array: true,
|
| 573 |
+
optional: true,
|
| 574 |
+
type: "Expression"
|
| 575 |
+
},
|
| 576 |
+
numeric: {
|
| 577 |
+
type: "Index",
|
| 578 |
+
optional: true
|
| 579 |
+
}
|
| 580 |
+
}
|
| 581 |
+
});
|
| 582 |
+
defineType("CallIndirectInstruction", {
|
| 583 |
+
unionType: ["Node", "Instruction"],
|
| 584 |
+
fields: {
|
| 585 |
+
id: {
|
| 586 |
+
constant: true,
|
| 587 |
+
type: "string",
|
| 588 |
+
value: "call_indirect"
|
| 589 |
+
},
|
| 590 |
+
signature: {
|
| 591 |
+
type: "SignatureOrTypeRef"
|
| 592 |
+
},
|
| 593 |
+
intrs: {
|
| 594 |
+
array: true,
|
| 595 |
+
optional: true,
|
| 596 |
+
type: "Expression"
|
| 597 |
+
}
|
| 598 |
+
}
|
| 599 |
+
});
|
| 600 |
+
defineType("ByteArray", {
|
| 601 |
+
unionType: ["Node"],
|
| 602 |
+
fields: {
|
| 603 |
+
values: {
|
| 604 |
+
array: true,
|
| 605 |
+
type: "Byte"
|
| 606 |
+
}
|
| 607 |
+
}
|
| 608 |
+
});
|
| 609 |
+
defineType("Func", {
|
| 610 |
+
unionType: ["Node", "Block"],
|
| 611 |
+
fields: {
|
| 612 |
+
name: {
|
| 613 |
+
maybe: true,
|
| 614 |
+
type: "Index"
|
| 615 |
+
},
|
| 616 |
+
signature: {
|
| 617 |
+
type: "SignatureOrTypeRef"
|
| 618 |
+
},
|
| 619 |
+
body: {
|
| 620 |
+
array: true,
|
| 621 |
+
type: "Instruction"
|
| 622 |
+
},
|
| 623 |
+
isExternal: {
|
| 624 |
+
comment: "means that it has been imported from the outside js",
|
| 625 |
+
optional: true,
|
| 626 |
+
type: "boolean"
|
| 627 |
+
},
|
| 628 |
+
metadata: {
|
| 629 |
+
optional: true,
|
| 630 |
+
type: "FuncMetadata"
|
| 631 |
+
}
|
| 632 |
+
}
|
| 633 |
+
});
|
| 634 |
+
/**
|
| 635 |
+
* Intrinsics
|
| 636 |
+
*/
|
| 637 |
+
|
| 638 |
+
defineType("InternalBrUnless", {
|
| 639 |
+
unionType: ["Node", "Intrinsic"],
|
| 640 |
+
fields: {
|
| 641 |
+
target: {
|
| 642 |
+
type: "number"
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
});
|
| 646 |
+
defineType("InternalGoto", {
|
| 647 |
+
unionType: ["Node", "Intrinsic"],
|
| 648 |
+
fields: {
|
| 649 |
+
target: {
|
| 650 |
+
type: "number"
|
| 651 |
+
}
|
| 652 |
+
}
|
| 653 |
+
});
|
| 654 |
+
defineType("InternalCallExtern", {
|
| 655 |
+
unionType: ["Node", "Intrinsic"],
|
| 656 |
+
fields: {
|
| 657 |
+
target: {
|
| 658 |
+
type: "number"
|
| 659 |
+
}
|
| 660 |
+
}
|
| 661 |
+
}); // function bodies are terminated by an `end` instruction but are missing a
|
| 662 |
+
// return instruction
|
| 663 |
+
//
|
| 664 |
+
// Since we can't inject a new instruction we are injecting a new instruction.
|
| 665 |
+
|
| 666 |
+
defineType("InternalEndAndReturn", {
|
| 667 |
+
unionType: ["Node", "Intrinsic"],
|
| 668 |
+
fields: {}
|
| 669 |
+
});
|
| 670 |
+
module.exports = definitions;
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/index.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
var _exportNames = {
|
| 7 |
+
numberLiteralFromRaw: true,
|
| 8 |
+
withLoc: true,
|
| 9 |
+
withRaw: true,
|
| 10 |
+
funcParam: true,
|
| 11 |
+
indexLiteral: true,
|
| 12 |
+
memIndexLiteral: true,
|
| 13 |
+
instruction: true,
|
| 14 |
+
objectInstruction: true,
|
| 15 |
+
traverse: true,
|
| 16 |
+
signatures: true,
|
| 17 |
+
cloneNode: true,
|
| 18 |
+
moduleContextFromModuleAST: true
|
| 19 |
+
};
|
| 20 |
+
Object.defineProperty(exports, "numberLiteralFromRaw", {
|
| 21 |
+
enumerable: true,
|
| 22 |
+
get: function get() {
|
| 23 |
+
return _nodeHelpers.numberLiteralFromRaw;
|
| 24 |
+
}
|
| 25 |
+
});
|
| 26 |
+
Object.defineProperty(exports, "withLoc", {
|
| 27 |
+
enumerable: true,
|
| 28 |
+
get: function get() {
|
| 29 |
+
return _nodeHelpers.withLoc;
|
| 30 |
+
}
|
| 31 |
+
});
|
| 32 |
+
Object.defineProperty(exports, "withRaw", {
|
| 33 |
+
enumerable: true,
|
| 34 |
+
get: function get() {
|
| 35 |
+
return _nodeHelpers.withRaw;
|
| 36 |
+
}
|
| 37 |
+
});
|
| 38 |
+
Object.defineProperty(exports, "funcParam", {
|
| 39 |
+
enumerable: true,
|
| 40 |
+
get: function get() {
|
| 41 |
+
return _nodeHelpers.funcParam;
|
| 42 |
+
}
|
| 43 |
+
});
|
| 44 |
+
Object.defineProperty(exports, "indexLiteral", {
|
| 45 |
+
enumerable: true,
|
| 46 |
+
get: function get() {
|
| 47 |
+
return _nodeHelpers.indexLiteral;
|
| 48 |
+
}
|
| 49 |
+
});
|
| 50 |
+
Object.defineProperty(exports, "memIndexLiteral", {
|
| 51 |
+
enumerable: true,
|
| 52 |
+
get: function get() {
|
| 53 |
+
return _nodeHelpers.memIndexLiteral;
|
| 54 |
+
}
|
| 55 |
+
});
|
| 56 |
+
Object.defineProperty(exports, "instruction", {
|
| 57 |
+
enumerable: true,
|
| 58 |
+
get: function get() {
|
| 59 |
+
return _nodeHelpers.instruction;
|
| 60 |
+
}
|
| 61 |
+
});
|
| 62 |
+
Object.defineProperty(exports, "objectInstruction", {
|
| 63 |
+
enumerable: true,
|
| 64 |
+
get: function get() {
|
| 65 |
+
return _nodeHelpers.objectInstruction;
|
| 66 |
+
}
|
| 67 |
+
});
|
| 68 |
+
Object.defineProperty(exports, "traverse", {
|
| 69 |
+
enumerable: true,
|
| 70 |
+
get: function get() {
|
| 71 |
+
return _traverse.traverse;
|
| 72 |
+
}
|
| 73 |
+
});
|
| 74 |
+
Object.defineProperty(exports, "signatures", {
|
| 75 |
+
enumerable: true,
|
| 76 |
+
get: function get() {
|
| 77 |
+
return _signatures.signatures;
|
| 78 |
+
}
|
| 79 |
+
});
|
| 80 |
+
Object.defineProperty(exports, "cloneNode", {
|
| 81 |
+
enumerable: true,
|
| 82 |
+
get: function get() {
|
| 83 |
+
return _clone.cloneNode;
|
| 84 |
+
}
|
| 85 |
+
});
|
| 86 |
+
Object.defineProperty(exports, "moduleContextFromModuleAST", {
|
| 87 |
+
enumerable: true,
|
| 88 |
+
get: function get() {
|
| 89 |
+
return _astModuleToModuleContext.moduleContextFromModuleAST;
|
| 90 |
+
}
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
var _nodes = require("./nodes");
|
| 94 |
+
|
| 95 |
+
Object.keys(_nodes).forEach(function (key) {
|
| 96 |
+
if (key === "default" || key === "__esModule") return;
|
| 97 |
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
| 98 |
+
if (key in exports && exports[key] === _nodes[key]) return;
|
| 99 |
+
Object.defineProperty(exports, key, {
|
| 100 |
+
enumerable: true,
|
| 101 |
+
get: function get() {
|
| 102 |
+
return _nodes[key];
|
| 103 |
+
}
|
| 104 |
+
});
|
| 105 |
+
});
|
| 106 |
+
|
| 107 |
+
var _nodeHelpers = require("./node-helpers.js");
|
| 108 |
+
|
| 109 |
+
var _traverse = require("./traverse");
|
| 110 |
+
|
| 111 |
+
var _signatures = require("./signatures");
|
| 112 |
+
|
| 113 |
+
var _utils = require("./utils");
|
| 114 |
+
|
| 115 |
+
Object.keys(_utils).forEach(function (key) {
|
| 116 |
+
if (key === "default" || key === "__esModule") return;
|
| 117 |
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
| 118 |
+
if (key in exports && exports[key] === _utils[key]) return;
|
| 119 |
+
Object.defineProperty(exports, key, {
|
| 120 |
+
enumerable: true,
|
| 121 |
+
get: function get() {
|
| 122 |
+
return _utils[key];
|
| 123 |
+
}
|
| 124 |
+
});
|
| 125 |
+
});
|
| 126 |
+
|
| 127 |
+
var _clone = require("./clone");
|
| 128 |
+
|
| 129 |
+
var _astModuleToModuleContext = require("./transform/ast-module-to-module-context");
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/node-helpers.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.numberLiteralFromRaw = numberLiteralFromRaw;
|
| 7 |
+
exports.instruction = instruction;
|
| 8 |
+
exports.objectInstruction = objectInstruction;
|
| 9 |
+
exports.withLoc = withLoc;
|
| 10 |
+
exports.withRaw = withRaw;
|
| 11 |
+
exports.funcParam = funcParam;
|
| 12 |
+
exports.indexLiteral = indexLiteral;
|
| 13 |
+
exports.memIndexLiteral = memIndexLiteral;
|
| 14 |
+
|
| 15 |
+
var _helperNumbers = require("@webassemblyjs/helper-numbers");
|
| 16 |
+
|
| 17 |
+
var _nodes = require("./nodes");
|
| 18 |
+
|
| 19 |
+
function numberLiteralFromRaw(rawValue) {
|
| 20 |
+
var instructionType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "i32";
|
| 21 |
+
var original = rawValue; // Remove numeric separators _
|
| 22 |
+
|
| 23 |
+
if (typeof rawValue === "string") {
|
| 24 |
+
rawValue = rawValue.replace(/_/g, "");
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
if (typeof rawValue === "number") {
|
| 28 |
+
return (0, _nodes.numberLiteral)(rawValue, String(original));
|
| 29 |
+
} else {
|
| 30 |
+
switch (instructionType) {
|
| 31 |
+
case "i32":
|
| 32 |
+
{
|
| 33 |
+
return (0, _nodes.numberLiteral)((0, _helperNumbers.parse32I)(rawValue), String(original));
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
case "u32":
|
| 37 |
+
{
|
| 38 |
+
return (0, _nodes.numberLiteral)((0, _helperNumbers.parseU32)(rawValue), String(original));
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
case "i64":
|
| 42 |
+
{
|
| 43 |
+
return (0, _nodes.longNumberLiteral)((0, _helperNumbers.parse64I)(rawValue), String(original));
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
case "f32":
|
| 47 |
+
{
|
| 48 |
+
return (0, _nodes.floatLiteral)((0, _helperNumbers.parse32F)(rawValue), (0, _helperNumbers.isNanLiteral)(rawValue), (0, _helperNumbers.isInfLiteral)(rawValue), String(original));
|
| 49 |
+
}
|
| 50 |
+
// f64
|
| 51 |
+
|
| 52 |
+
default:
|
| 53 |
+
{
|
| 54 |
+
return (0, _nodes.floatLiteral)((0, _helperNumbers.parse64F)(rawValue), (0, _helperNumbers.isNanLiteral)(rawValue), (0, _helperNumbers.isInfLiteral)(rawValue), String(original));
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
function instruction(id) {
|
| 61 |
+
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
| 62 |
+
var namedArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
| 63 |
+
return (0, _nodes.instr)(id, undefined, args, namedArgs);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
function objectInstruction(id, object) {
|
| 67 |
+
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
| 68 |
+
var namedArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
| 69 |
+
return (0, _nodes.instr)(id, object, args, namedArgs);
|
| 70 |
+
}
|
| 71 |
+
/**
|
| 72 |
+
* Decorators
|
| 73 |
+
*/
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
function withLoc(n, end, start) {
|
| 77 |
+
var loc = {
|
| 78 |
+
start: start,
|
| 79 |
+
end: end
|
| 80 |
+
};
|
| 81 |
+
n.loc = loc;
|
| 82 |
+
return n;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function withRaw(n, raw) {
|
| 86 |
+
n.raw = raw;
|
| 87 |
+
return n;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
function funcParam(valtype, id) {
|
| 91 |
+
return {
|
| 92 |
+
id: id,
|
| 93 |
+
valtype: valtype
|
| 94 |
+
};
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
function indexLiteral(value) {
|
| 98 |
+
// $FlowIgnore
|
| 99 |
+
var x = numberLiteralFromRaw(value, "u32");
|
| 100 |
+
return x;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
function memIndexLiteral(value) {
|
| 104 |
+
// $FlowIgnore
|
| 105 |
+
var x = numberLiteralFromRaw(value, "u32");
|
| 106 |
+
return x;
|
| 107 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/node-path.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.createPath = createPath;
|
| 7 |
+
|
| 8 |
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
| 9 |
+
|
| 10 |
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
| 11 |
+
|
| 12 |
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
| 13 |
+
|
| 14 |
+
function findParent(_ref, cb) {
|
| 15 |
+
var parentPath = _ref.parentPath;
|
| 16 |
+
|
| 17 |
+
if (parentPath == null) {
|
| 18 |
+
throw new Error("node is root");
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
var currentPath = parentPath;
|
| 22 |
+
|
| 23 |
+
while (cb(currentPath) !== false) {
|
| 24 |
+
// Hit the root node, stop
|
| 25 |
+
// $FlowIgnore
|
| 26 |
+
if (currentPath.parentPath == null) {
|
| 27 |
+
return null;
|
| 28 |
+
} // $FlowIgnore
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
currentPath = currentPath.parentPath;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return currentPath.node;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function insertBefore(context, newNode) {
|
| 38 |
+
return insert(context, newNode);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
function insertAfter(context, newNode) {
|
| 42 |
+
return insert(context, newNode, 1);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function insert(_ref2, newNode) {
|
| 46 |
+
var node = _ref2.node,
|
| 47 |
+
inList = _ref2.inList,
|
| 48 |
+
parentPath = _ref2.parentPath,
|
| 49 |
+
parentKey = _ref2.parentKey;
|
| 50 |
+
var indexOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
| 51 |
+
|
| 52 |
+
if (!inList) {
|
| 53 |
+
throw new Error('inList' + " error: " + ("insert can only be used for nodes that are within lists" || "unknown"));
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
if (!(parentPath != null)) {
|
| 57 |
+
throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown"));
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
// $FlowIgnore
|
| 61 |
+
var parentList = parentPath.node[parentKey];
|
| 62 |
+
var indexInList = parentList.findIndex(function (n) {
|
| 63 |
+
return n === node;
|
| 64 |
+
});
|
| 65 |
+
parentList.splice(indexInList + indexOffset, 0, newNode);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
function remove(_ref3) {
|
| 69 |
+
var node = _ref3.node,
|
| 70 |
+
parentKey = _ref3.parentKey,
|
| 71 |
+
parentPath = _ref3.parentPath;
|
| 72 |
+
|
| 73 |
+
if (!(parentPath != null)) {
|
| 74 |
+
throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown"));
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
// $FlowIgnore
|
| 78 |
+
var parentNode = parentPath.node; // $FlowIgnore
|
| 79 |
+
|
| 80 |
+
var parentProperty = parentNode[parentKey];
|
| 81 |
+
|
| 82 |
+
if (Array.isArray(parentProperty)) {
|
| 83 |
+
// $FlowIgnore
|
| 84 |
+
parentNode[parentKey] = parentProperty.filter(function (n) {
|
| 85 |
+
return n !== node;
|
| 86 |
+
});
|
| 87 |
+
} else {
|
| 88 |
+
// $FlowIgnore
|
| 89 |
+
delete parentNode[parentKey];
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
node._deleted = true;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
function stop(context) {
|
| 96 |
+
context.shouldStop = true;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
function replaceWith(context, newNode) {
|
| 100 |
+
// $FlowIgnore
|
| 101 |
+
var parentNode = context.parentPath.node; // $FlowIgnore
|
| 102 |
+
|
| 103 |
+
var parentProperty = parentNode[context.parentKey];
|
| 104 |
+
|
| 105 |
+
if (Array.isArray(parentProperty)) {
|
| 106 |
+
var indexInList = parentProperty.findIndex(function (n) {
|
| 107 |
+
return n === context.node;
|
| 108 |
+
});
|
| 109 |
+
parentProperty.splice(indexInList, 1, newNode);
|
| 110 |
+
} else {
|
| 111 |
+
// $FlowIgnore
|
| 112 |
+
parentNode[context.parentKey] = newNode;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
context.node._deleted = true;
|
| 116 |
+
context.node = newNode;
|
| 117 |
+
} // bind the context to the first argument of node operations
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
function bindNodeOperations(operations, context) {
|
| 121 |
+
var keys = Object.keys(operations);
|
| 122 |
+
var boundOperations = {};
|
| 123 |
+
keys.forEach(function (key) {
|
| 124 |
+
boundOperations[key] = operations[key].bind(null, context);
|
| 125 |
+
});
|
| 126 |
+
return boundOperations;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
function createPathOperations(context) {
|
| 130 |
+
// $FlowIgnore
|
| 131 |
+
return bindNodeOperations({
|
| 132 |
+
findParent: findParent,
|
| 133 |
+
replaceWith: replaceWith,
|
| 134 |
+
remove: remove,
|
| 135 |
+
insertBefore: insertBefore,
|
| 136 |
+
insertAfter: insertAfter,
|
| 137 |
+
stop: stop
|
| 138 |
+
}, context);
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
function createPath(context) {
|
| 142 |
+
var path = _objectSpread({}, context); // $FlowIgnore
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
Object.assign(path, createPathOperations(path)); // $FlowIgnore
|
| 146 |
+
|
| 147 |
+
return path;
|
| 148 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/nodes.js
ADDED
|
@@ -0,0 +1,1144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.module = _module;
|
| 7 |
+
exports.moduleMetadata = moduleMetadata;
|
| 8 |
+
exports.moduleNameMetadata = moduleNameMetadata;
|
| 9 |
+
exports.functionNameMetadata = functionNameMetadata;
|
| 10 |
+
exports.localNameMetadata = localNameMetadata;
|
| 11 |
+
exports.binaryModule = binaryModule;
|
| 12 |
+
exports.quoteModule = quoteModule;
|
| 13 |
+
exports.sectionMetadata = sectionMetadata;
|
| 14 |
+
exports.producersSectionMetadata = producersSectionMetadata;
|
| 15 |
+
exports.producerMetadata = producerMetadata;
|
| 16 |
+
exports.producerMetadataVersionedName = producerMetadataVersionedName;
|
| 17 |
+
exports.loopInstruction = loopInstruction;
|
| 18 |
+
exports.instr = instr;
|
| 19 |
+
exports.ifInstruction = ifInstruction;
|
| 20 |
+
exports.stringLiteral = stringLiteral;
|
| 21 |
+
exports.numberLiteral = numberLiteral;
|
| 22 |
+
exports.longNumberLiteral = longNumberLiteral;
|
| 23 |
+
exports.floatLiteral = floatLiteral;
|
| 24 |
+
exports.elem = elem;
|
| 25 |
+
exports.indexInFuncSection = indexInFuncSection;
|
| 26 |
+
exports.valtypeLiteral = valtypeLiteral;
|
| 27 |
+
exports.typeInstruction = typeInstruction;
|
| 28 |
+
exports.start = start;
|
| 29 |
+
exports.globalType = globalType;
|
| 30 |
+
exports.leadingComment = leadingComment;
|
| 31 |
+
exports.blockComment = blockComment;
|
| 32 |
+
exports.data = data;
|
| 33 |
+
exports.global = global;
|
| 34 |
+
exports.table = table;
|
| 35 |
+
exports.memory = memory;
|
| 36 |
+
exports.funcImportDescr = funcImportDescr;
|
| 37 |
+
exports.moduleImport = moduleImport;
|
| 38 |
+
exports.moduleExportDescr = moduleExportDescr;
|
| 39 |
+
exports.moduleExport = moduleExport;
|
| 40 |
+
exports.limit = limit;
|
| 41 |
+
exports.signature = signature;
|
| 42 |
+
exports.program = program;
|
| 43 |
+
exports.identifier = identifier;
|
| 44 |
+
exports.blockInstruction = blockInstruction;
|
| 45 |
+
exports.callInstruction = callInstruction;
|
| 46 |
+
exports.callIndirectInstruction = callIndirectInstruction;
|
| 47 |
+
exports.byteArray = byteArray;
|
| 48 |
+
exports.func = func;
|
| 49 |
+
exports.internalBrUnless = internalBrUnless;
|
| 50 |
+
exports.internalGoto = internalGoto;
|
| 51 |
+
exports.internalCallExtern = internalCallExtern;
|
| 52 |
+
exports.internalEndAndReturn = internalEndAndReturn;
|
| 53 |
+
exports.assertInternalCallExtern = exports.assertInternalGoto = exports.assertInternalBrUnless = exports.assertFunc = exports.assertByteArray = exports.assertCallIndirectInstruction = exports.assertCallInstruction = exports.assertBlockInstruction = exports.assertIdentifier = exports.assertProgram = exports.assertSignature = exports.assertLimit = exports.assertModuleExport = exports.assertModuleExportDescr = exports.assertModuleImport = exports.assertFuncImportDescr = exports.assertMemory = exports.assertTable = exports.assertGlobal = exports.assertData = exports.assertBlockComment = exports.assertLeadingComment = exports.assertGlobalType = exports.assertStart = exports.assertTypeInstruction = exports.assertValtypeLiteral = exports.assertIndexInFuncSection = exports.assertElem = exports.assertFloatLiteral = exports.assertLongNumberLiteral = exports.assertNumberLiteral = exports.assertStringLiteral = exports.assertIfInstruction = exports.assertInstr = exports.assertLoopInstruction = exports.assertProducerMetadataVersionedName = exports.assertProducerMetadata = exports.assertProducersSectionMetadata = exports.assertSectionMetadata = exports.assertQuoteModule = exports.assertBinaryModule = exports.assertLocalNameMetadata = exports.assertFunctionNameMetadata = exports.assertModuleNameMetadata = exports.assertModuleMetadata = exports.assertModule = exports.isIntrinsic = exports.isImportDescr = exports.isNumericLiteral = exports.isExpression = exports.isInstruction = exports.isBlock = exports.isNode = exports.isInternalEndAndReturn = exports.isInternalCallExtern = exports.isInternalGoto = exports.isInternalBrUnless = exports.isFunc = exports.isByteArray = exports.isCallIndirectInstruction = exports.isCallInstruction = exports.isBlockInstruction = exports.isIdentifier = exports.isProgram = exports.isSignature = exports.isLimit = exports.isModuleExport = exports.isModuleExportDescr = exports.isModuleImport = exports.isFuncImportDescr = exports.isMemory = exports.isTable = exports.isGlobal = exports.isData = exports.isBlockComment = exports.isLeadingComment = exports.isGlobalType = exports.isStart = exports.isTypeInstruction = exports.isValtypeLiteral = exports.isIndexInFuncSection = exports.isElem = exports.isFloatLiteral = exports.isLongNumberLiteral = exports.isNumberLiteral = exports.isStringLiteral = exports.isIfInstruction = exports.isInstr = exports.isLoopInstruction = exports.isProducerMetadataVersionedName = exports.isProducerMetadata = exports.isProducersSectionMetadata = exports.isSectionMetadata = exports.isQuoteModule = exports.isBinaryModule = exports.isLocalNameMetadata = exports.isFunctionNameMetadata = exports.isModuleNameMetadata = exports.isModuleMetadata = exports.isModule = void 0;
|
| 54 |
+
exports.nodeAndUnionTypes = exports.unionTypesMap = exports.assertInternalEndAndReturn = void 0;
|
| 55 |
+
|
| 56 |
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
| 57 |
+
|
| 58 |
+
// THIS FILE IS AUTOGENERATED
|
| 59 |
+
// see scripts/generateNodeUtils.js
|
| 60 |
+
function isTypeOf(t) {
|
| 61 |
+
return function (n) {
|
| 62 |
+
return n.type === t;
|
| 63 |
+
};
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
function assertTypeOf(t) {
|
| 67 |
+
return function (n) {
|
| 68 |
+
return function () {
|
| 69 |
+
if (!(n.type === t)) {
|
| 70 |
+
throw new Error('n.type === t' + " error: " + (undefined || "unknown"));
|
| 71 |
+
}
|
| 72 |
+
}();
|
| 73 |
+
};
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
function _module(id, fields, metadata) {
|
| 77 |
+
if (id !== null && id !== undefined) {
|
| 78 |
+
if (!(typeof id === "string")) {
|
| 79 |
+
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
if (!(_typeof(fields) === "object" && typeof fields.length !== "undefined")) {
|
| 84 |
+
throw new Error('typeof fields === "object" && typeof fields.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
var node = {
|
| 88 |
+
type: "Module",
|
| 89 |
+
id: id,
|
| 90 |
+
fields: fields
|
| 91 |
+
};
|
| 92 |
+
|
| 93 |
+
if (typeof metadata !== "undefined") {
|
| 94 |
+
node.metadata = metadata;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
return node;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
function moduleMetadata(sections, functionNames, localNames, producers) {
|
| 101 |
+
if (!(_typeof(sections) === "object" && typeof sections.length !== "undefined")) {
|
| 102 |
+
throw new Error('typeof sections === "object" && typeof sections.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
if (functionNames !== null && functionNames !== undefined) {
|
| 106 |
+
if (!(_typeof(functionNames) === "object" && typeof functionNames.length !== "undefined")) {
|
| 107 |
+
throw new Error('typeof functionNames === "object" && typeof functionNames.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
if (localNames !== null && localNames !== undefined) {
|
| 112 |
+
if (!(_typeof(localNames) === "object" && typeof localNames.length !== "undefined")) {
|
| 113 |
+
throw new Error('typeof localNames === "object" && typeof localNames.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
if (producers !== null && producers !== undefined) {
|
| 118 |
+
if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) {
|
| 119 |
+
throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
var node = {
|
| 124 |
+
type: "ModuleMetadata",
|
| 125 |
+
sections: sections
|
| 126 |
+
};
|
| 127 |
+
|
| 128 |
+
if (typeof functionNames !== "undefined" && functionNames.length > 0) {
|
| 129 |
+
node.functionNames = functionNames;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
if (typeof localNames !== "undefined" && localNames.length > 0) {
|
| 133 |
+
node.localNames = localNames;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
if (typeof producers !== "undefined" && producers.length > 0) {
|
| 137 |
+
node.producers = producers;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
return node;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
function moduleNameMetadata(value) {
|
| 144 |
+
if (!(typeof value === "string")) {
|
| 145 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
var node = {
|
| 149 |
+
type: "ModuleNameMetadata",
|
| 150 |
+
value: value
|
| 151 |
+
};
|
| 152 |
+
return node;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
function functionNameMetadata(value, index) {
|
| 156 |
+
if (!(typeof value === "string")) {
|
| 157 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
if (!(typeof index === "number")) {
|
| 161 |
+
throw new Error('typeof index === "number"' + " error: " + ("Argument index must be of type number, given: " + _typeof(index) || "unknown"));
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
var node = {
|
| 165 |
+
type: "FunctionNameMetadata",
|
| 166 |
+
value: value,
|
| 167 |
+
index: index
|
| 168 |
+
};
|
| 169 |
+
return node;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
function localNameMetadata(value, localIndex, functionIndex) {
|
| 173 |
+
if (!(typeof value === "string")) {
|
| 174 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
if (!(typeof localIndex === "number")) {
|
| 178 |
+
throw new Error('typeof localIndex === "number"' + " error: " + ("Argument localIndex must be of type number, given: " + _typeof(localIndex) || "unknown"));
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
if (!(typeof functionIndex === "number")) {
|
| 182 |
+
throw new Error('typeof functionIndex === "number"' + " error: " + ("Argument functionIndex must be of type number, given: " + _typeof(functionIndex) || "unknown"));
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
var node = {
|
| 186 |
+
type: "LocalNameMetadata",
|
| 187 |
+
value: value,
|
| 188 |
+
localIndex: localIndex,
|
| 189 |
+
functionIndex: functionIndex
|
| 190 |
+
};
|
| 191 |
+
return node;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
function binaryModule(id, blob) {
|
| 195 |
+
if (id !== null && id !== undefined) {
|
| 196 |
+
if (!(typeof id === "string")) {
|
| 197 |
+
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
if (!(_typeof(blob) === "object" && typeof blob.length !== "undefined")) {
|
| 202 |
+
throw new Error('typeof blob === "object" && typeof blob.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
var node = {
|
| 206 |
+
type: "BinaryModule",
|
| 207 |
+
id: id,
|
| 208 |
+
blob: blob
|
| 209 |
+
};
|
| 210 |
+
return node;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
function quoteModule(id, string) {
|
| 214 |
+
if (id !== null && id !== undefined) {
|
| 215 |
+
if (!(typeof id === "string")) {
|
| 216 |
+
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
if (!(_typeof(string) === "object" && typeof string.length !== "undefined")) {
|
| 221 |
+
throw new Error('typeof string === "object" && typeof string.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
var node = {
|
| 225 |
+
type: "QuoteModule",
|
| 226 |
+
id: id,
|
| 227 |
+
string: string
|
| 228 |
+
};
|
| 229 |
+
return node;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
function sectionMetadata(section, startOffset, size, vectorOfSize) {
|
| 233 |
+
if (!(typeof startOffset === "number")) {
|
| 234 |
+
throw new Error('typeof startOffset === "number"' + " error: " + ("Argument startOffset must be of type number, given: " + _typeof(startOffset) || "unknown"));
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
var node = {
|
| 238 |
+
type: "SectionMetadata",
|
| 239 |
+
section: section,
|
| 240 |
+
startOffset: startOffset,
|
| 241 |
+
size: size,
|
| 242 |
+
vectorOfSize: vectorOfSize
|
| 243 |
+
};
|
| 244 |
+
return node;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
function producersSectionMetadata(producers) {
|
| 248 |
+
if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) {
|
| 249 |
+
throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
var node = {
|
| 253 |
+
type: "ProducersSectionMetadata",
|
| 254 |
+
producers: producers
|
| 255 |
+
};
|
| 256 |
+
return node;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
function producerMetadata(language, processedBy, sdk) {
|
| 260 |
+
if (!(_typeof(language) === "object" && typeof language.length !== "undefined")) {
|
| 261 |
+
throw new Error('typeof language === "object" && typeof language.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
if (!(_typeof(processedBy) === "object" && typeof processedBy.length !== "undefined")) {
|
| 265 |
+
throw new Error('typeof processedBy === "object" && typeof processedBy.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
if (!(_typeof(sdk) === "object" && typeof sdk.length !== "undefined")) {
|
| 269 |
+
throw new Error('typeof sdk === "object" && typeof sdk.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
var node = {
|
| 273 |
+
type: "ProducerMetadata",
|
| 274 |
+
language: language,
|
| 275 |
+
processedBy: processedBy,
|
| 276 |
+
sdk: sdk
|
| 277 |
+
};
|
| 278 |
+
return node;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
function producerMetadataVersionedName(name, version) {
|
| 282 |
+
if (!(typeof name === "string")) {
|
| 283 |
+
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
if (!(typeof version === "string")) {
|
| 287 |
+
throw new Error('typeof version === "string"' + " error: " + ("Argument version must be of type string, given: " + _typeof(version) || "unknown"));
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
var node = {
|
| 291 |
+
type: "ProducerMetadataVersionedName",
|
| 292 |
+
name: name,
|
| 293 |
+
version: version
|
| 294 |
+
};
|
| 295 |
+
return node;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
function loopInstruction(label, resulttype, instr) {
|
| 299 |
+
if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) {
|
| 300 |
+
throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
var node = {
|
| 304 |
+
type: "LoopInstruction",
|
| 305 |
+
id: "loop",
|
| 306 |
+
label: label,
|
| 307 |
+
resulttype: resulttype,
|
| 308 |
+
instr: instr
|
| 309 |
+
};
|
| 310 |
+
return node;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
function instr(id, object, args, namedArgs) {
|
| 314 |
+
if (!(typeof id === "string")) {
|
| 315 |
+
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
if (!(_typeof(args) === "object" && typeof args.length !== "undefined")) {
|
| 319 |
+
throw new Error('typeof args === "object" && typeof args.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
var node = {
|
| 323 |
+
type: "Instr",
|
| 324 |
+
id: id,
|
| 325 |
+
args: args
|
| 326 |
+
};
|
| 327 |
+
|
| 328 |
+
if (typeof object !== "undefined") {
|
| 329 |
+
node.object = object;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
if (typeof namedArgs !== "undefined" && Object.keys(namedArgs).length !== 0) {
|
| 333 |
+
node.namedArgs = namedArgs;
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
return node;
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
function ifInstruction(testLabel, test, result, consequent, alternate) {
|
| 340 |
+
if (!(_typeof(test) === "object" && typeof test.length !== "undefined")) {
|
| 341 |
+
throw new Error('typeof test === "object" && typeof test.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
if (!(_typeof(consequent) === "object" && typeof consequent.length !== "undefined")) {
|
| 345 |
+
throw new Error('typeof consequent === "object" && typeof consequent.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
if (!(_typeof(alternate) === "object" && typeof alternate.length !== "undefined")) {
|
| 349 |
+
throw new Error('typeof alternate === "object" && typeof alternate.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
var node = {
|
| 353 |
+
type: "IfInstruction",
|
| 354 |
+
id: "if",
|
| 355 |
+
testLabel: testLabel,
|
| 356 |
+
test: test,
|
| 357 |
+
result: result,
|
| 358 |
+
consequent: consequent,
|
| 359 |
+
alternate: alternate
|
| 360 |
+
};
|
| 361 |
+
return node;
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
function stringLiteral(value) {
|
| 365 |
+
if (!(typeof value === "string")) {
|
| 366 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
var node = {
|
| 370 |
+
type: "StringLiteral",
|
| 371 |
+
value: value
|
| 372 |
+
};
|
| 373 |
+
return node;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
function numberLiteral(value, raw) {
|
| 377 |
+
if (!(typeof value === "number")) {
|
| 378 |
+
throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown"));
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
if (!(typeof raw === "string")) {
|
| 382 |
+
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
var node = {
|
| 386 |
+
type: "NumberLiteral",
|
| 387 |
+
value: value,
|
| 388 |
+
raw: raw
|
| 389 |
+
};
|
| 390 |
+
return node;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
function longNumberLiteral(value, raw) {
|
| 394 |
+
if (!(typeof raw === "string")) {
|
| 395 |
+
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
var node = {
|
| 399 |
+
type: "LongNumberLiteral",
|
| 400 |
+
value: value,
|
| 401 |
+
raw: raw
|
| 402 |
+
};
|
| 403 |
+
return node;
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
function floatLiteral(value, nan, inf, raw) {
|
| 407 |
+
if (!(typeof value === "number")) {
|
| 408 |
+
throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown"));
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
if (nan !== null && nan !== undefined) {
|
| 412 |
+
if (!(typeof nan === "boolean")) {
|
| 413 |
+
throw new Error('typeof nan === "boolean"' + " error: " + ("Argument nan must be of type boolean, given: " + _typeof(nan) || "unknown"));
|
| 414 |
+
}
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
if (inf !== null && inf !== undefined) {
|
| 418 |
+
if (!(typeof inf === "boolean")) {
|
| 419 |
+
throw new Error('typeof inf === "boolean"' + " error: " + ("Argument inf must be of type boolean, given: " + _typeof(inf) || "unknown"));
|
| 420 |
+
}
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
if (!(typeof raw === "string")) {
|
| 424 |
+
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
var node = {
|
| 428 |
+
type: "FloatLiteral",
|
| 429 |
+
value: value,
|
| 430 |
+
raw: raw
|
| 431 |
+
};
|
| 432 |
+
|
| 433 |
+
if (nan === true) {
|
| 434 |
+
node.nan = true;
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
if (inf === true) {
|
| 438 |
+
node.inf = true;
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
return node;
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
function elem(table, offset, funcs) {
|
| 445 |
+
if (!(_typeof(offset) === "object" && typeof offset.length !== "undefined")) {
|
| 446 |
+
throw new Error('typeof offset === "object" && typeof offset.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
if (!(_typeof(funcs) === "object" && typeof funcs.length !== "undefined")) {
|
| 450 |
+
throw new Error('typeof funcs === "object" && typeof funcs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
var node = {
|
| 454 |
+
type: "Elem",
|
| 455 |
+
table: table,
|
| 456 |
+
offset: offset,
|
| 457 |
+
funcs: funcs
|
| 458 |
+
};
|
| 459 |
+
return node;
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
function indexInFuncSection(index) {
|
| 463 |
+
var node = {
|
| 464 |
+
type: "IndexInFuncSection",
|
| 465 |
+
index: index
|
| 466 |
+
};
|
| 467 |
+
return node;
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
function valtypeLiteral(name) {
|
| 471 |
+
var node = {
|
| 472 |
+
type: "ValtypeLiteral",
|
| 473 |
+
name: name
|
| 474 |
+
};
|
| 475 |
+
return node;
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
function typeInstruction(id, functype) {
|
| 479 |
+
var node = {
|
| 480 |
+
type: "TypeInstruction",
|
| 481 |
+
id: id,
|
| 482 |
+
functype: functype
|
| 483 |
+
};
|
| 484 |
+
return node;
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
function start(index) {
|
| 488 |
+
var node = {
|
| 489 |
+
type: "Start",
|
| 490 |
+
index: index
|
| 491 |
+
};
|
| 492 |
+
return node;
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
function globalType(valtype, mutability) {
|
| 496 |
+
var node = {
|
| 497 |
+
type: "GlobalType",
|
| 498 |
+
valtype: valtype,
|
| 499 |
+
mutability: mutability
|
| 500 |
+
};
|
| 501 |
+
return node;
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
function leadingComment(value) {
|
| 505 |
+
if (!(typeof value === "string")) {
|
| 506 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
var node = {
|
| 510 |
+
type: "LeadingComment",
|
| 511 |
+
value: value
|
| 512 |
+
};
|
| 513 |
+
return node;
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
function blockComment(value) {
|
| 517 |
+
if (!(typeof value === "string")) {
|
| 518 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 519 |
+
}
|
| 520 |
+
|
| 521 |
+
var node = {
|
| 522 |
+
type: "BlockComment",
|
| 523 |
+
value: value
|
| 524 |
+
};
|
| 525 |
+
return node;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
function data(memoryIndex, offset, init) {
|
| 529 |
+
var node = {
|
| 530 |
+
type: "Data",
|
| 531 |
+
memoryIndex: memoryIndex,
|
| 532 |
+
offset: offset,
|
| 533 |
+
init: init
|
| 534 |
+
};
|
| 535 |
+
return node;
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
function global(globalType, init, name) {
|
| 539 |
+
if (!(_typeof(init) === "object" && typeof init.length !== "undefined")) {
|
| 540 |
+
throw new Error('typeof init === "object" && typeof init.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
var node = {
|
| 544 |
+
type: "Global",
|
| 545 |
+
globalType: globalType,
|
| 546 |
+
init: init,
|
| 547 |
+
name: name
|
| 548 |
+
};
|
| 549 |
+
return node;
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
function table(elementType, limits, name, elements) {
|
| 553 |
+
if (!(limits.type === "Limit")) {
|
| 554 |
+
throw new Error('limits.type === "Limit"' + " error: " + ("Argument limits must be of type Limit, given: " + limits.type || "unknown"));
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
if (elements !== null && elements !== undefined) {
|
| 558 |
+
if (!(_typeof(elements) === "object" && typeof elements.length !== "undefined")) {
|
| 559 |
+
throw new Error('typeof elements === "object" && typeof elements.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 560 |
+
}
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
var node = {
|
| 564 |
+
type: "Table",
|
| 565 |
+
elementType: elementType,
|
| 566 |
+
limits: limits,
|
| 567 |
+
name: name
|
| 568 |
+
};
|
| 569 |
+
|
| 570 |
+
if (typeof elements !== "undefined" && elements.length > 0) {
|
| 571 |
+
node.elements = elements;
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
return node;
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
function memory(limits, id) {
|
| 578 |
+
var node = {
|
| 579 |
+
type: "Memory",
|
| 580 |
+
limits: limits,
|
| 581 |
+
id: id
|
| 582 |
+
};
|
| 583 |
+
return node;
|
| 584 |
+
}
|
| 585 |
+
|
| 586 |
+
function funcImportDescr(id, signature) {
|
| 587 |
+
var node = {
|
| 588 |
+
type: "FuncImportDescr",
|
| 589 |
+
id: id,
|
| 590 |
+
signature: signature
|
| 591 |
+
};
|
| 592 |
+
return node;
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
function moduleImport(module, name, descr) {
|
| 596 |
+
if (!(typeof module === "string")) {
|
| 597 |
+
throw new Error('typeof module === "string"' + " error: " + ("Argument module must be of type string, given: " + _typeof(module) || "unknown"));
|
| 598 |
+
}
|
| 599 |
+
|
| 600 |
+
if (!(typeof name === "string")) {
|
| 601 |
+
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
var node = {
|
| 605 |
+
type: "ModuleImport",
|
| 606 |
+
module: module,
|
| 607 |
+
name: name,
|
| 608 |
+
descr: descr
|
| 609 |
+
};
|
| 610 |
+
return node;
|
| 611 |
+
}
|
| 612 |
+
|
| 613 |
+
function moduleExportDescr(exportType, id) {
|
| 614 |
+
var node = {
|
| 615 |
+
type: "ModuleExportDescr",
|
| 616 |
+
exportType: exportType,
|
| 617 |
+
id: id
|
| 618 |
+
};
|
| 619 |
+
return node;
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
function moduleExport(name, descr) {
|
| 623 |
+
if (!(typeof name === "string")) {
|
| 624 |
+
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
var node = {
|
| 628 |
+
type: "ModuleExport",
|
| 629 |
+
name: name,
|
| 630 |
+
descr: descr
|
| 631 |
+
};
|
| 632 |
+
return node;
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
function limit(min, max, shared) {
|
| 636 |
+
if (!(typeof min === "number")) {
|
| 637 |
+
throw new Error('typeof min === "number"' + " error: " + ("Argument min must be of type number, given: " + _typeof(min) || "unknown"));
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
if (max !== null && max !== undefined) {
|
| 641 |
+
if (!(typeof max === "number")) {
|
| 642 |
+
throw new Error('typeof max === "number"' + " error: " + ("Argument max must be of type number, given: " + _typeof(max) || "unknown"));
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
if (shared !== null && shared !== undefined) {
|
| 647 |
+
if (!(typeof shared === "boolean")) {
|
| 648 |
+
throw new Error('typeof shared === "boolean"' + " error: " + ("Argument shared must be of type boolean, given: " + _typeof(shared) || "unknown"));
|
| 649 |
+
}
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
var node = {
|
| 653 |
+
type: "Limit",
|
| 654 |
+
min: min
|
| 655 |
+
};
|
| 656 |
+
|
| 657 |
+
if (typeof max !== "undefined") {
|
| 658 |
+
node.max = max;
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
if (shared === true) {
|
| 662 |
+
node.shared = true;
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
return node;
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
function signature(params, results) {
|
| 669 |
+
if (!(_typeof(params) === "object" && typeof params.length !== "undefined")) {
|
| 670 |
+
throw new Error('typeof params === "object" && typeof params.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
if (!(_typeof(results) === "object" && typeof results.length !== "undefined")) {
|
| 674 |
+
throw new Error('typeof results === "object" && typeof results.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 675 |
+
}
|
| 676 |
+
|
| 677 |
+
var node = {
|
| 678 |
+
type: "Signature",
|
| 679 |
+
params: params,
|
| 680 |
+
results: results
|
| 681 |
+
};
|
| 682 |
+
return node;
|
| 683 |
+
}
|
| 684 |
+
|
| 685 |
+
function program(body) {
|
| 686 |
+
if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
|
| 687 |
+
throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
var node = {
|
| 691 |
+
type: "Program",
|
| 692 |
+
body: body
|
| 693 |
+
};
|
| 694 |
+
return node;
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
function identifier(value, raw) {
|
| 698 |
+
if (!(typeof value === "string")) {
|
| 699 |
+
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
if (raw !== null && raw !== undefined) {
|
| 703 |
+
if (!(typeof raw === "string")) {
|
| 704 |
+
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
| 705 |
+
}
|
| 706 |
+
}
|
| 707 |
+
|
| 708 |
+
var node = {
|
| 709 |
+
type: "Identifier",
|
| 710 |
+
value: value
|
| 711 |
+
};
|
| 712 |
+
|
| 713 |
+
if (typeof raw !== "undefined") {
|
| 714 |
+
node.raw = raw;
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
return node;
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
function blockInstruction(label, instr, result) {
|
| 721 |
+
if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) {
|
| 722 |
+
throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 723 |
+
}
|
| 724 |
+
|
| 725 |
+
var node = {
|
| 726 |
+
type: "BlockInstruction",
|
| 727 |
+
id: "block",
|
| 728 |
+
label: label,
|
| 729 |
+
instr: instr,
|
| 730 |
+
result: result
|
| 731 |
+
};
|
| 732 |
+
return node;
|
| 733 |
+
}
|
| 734 |
+
|
| 735 |
+
function callInstruction(index, instrArgs, numeric) {
|
| 736 |
+
if (instrArgs !== null && instrArgs !== undefined) {
|
| 737 |
+
if (!(_typeof(instrArgs) === "object" && typeof instrArgs.length !== "undefined")) {
|
| 738 |
+
throw new Error('typeof instrArgs === "object" && typeof instrArgs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 739 |
+
}
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
var node = {
|
| 743 |
+
type: "CallInstruction",
|
| 744 |
+
id: "call",
|
| 745 |
+
index: index
|
| 746 |
+
};
|
| 747 |
+
|
| 748 |
+
if (typeof instrArgs !== "undefined" && instrArgs.length > 0) {
|
| 749 |
+
node.instrArgs = instrArgs;
|
| 750 |
+
}
|
| 751 |
+
|
| 752 |
+
if (typeof numeric !== "undefined") {
|
| 753 |
+
node.numeric = numeric;
|
| 754 |
+
}
|
| 755 |
+
|
| 756 |
+
return node;
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
function callIndirectInstruction(signature, intrs) {
|
| 760 |
+
if (intrs !== null && intrs !== undefined) {
|
| 761 |
+
if (!(_typeof(intrs) === "object" && typeof intrs.length !== "undefined")) {
|
| 762 |
+
throw new Error('typeof intrs === "object" && typeof intrs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 763 |
+
}
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
var node = {
|
| 767 |
+
type: "CallIndirectInstruction",
|
| 768 |
+
id: "call_indirect",
|
| 769 |
+
signature: signature
|
| 770 |
+
};
|
| 771 |
+
|
| 772 |
+
if (typeof intrs !== "undefined" && intrs.length > 0) {
|
| 773 |
+
node.intrs = intrs;
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
return node;
|
| 777 |
+
}
|
| 778 |
+
|
| 779 |
+
function byteArray(values) {
|
| 780 |
+
if (!(_typeof(values) === "object" && typeof values.length !== "undefined")) {
|
| 781 |
+
throw new Error('typeof values === "object" && typeof values.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 782 |
+
}
|
| 783 |
+
|
| 784 |
+
var node = {
|
| 785 |
+
type: "ByteArray",
|
| 786 |
+
values: values
|
| 787 |
+
};
|
| 788 |
+
return node;
|
| 789 |
+
}
|
| 790 |
+
|
| 791 |
+
function func(name, signature, body, isExternal, metadata) {
|
| 792 |
+
if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
|
| 793 |
+
throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
| 794 |
+
}
|
| 795 |
+
|
| 796 |
+
if (isExternal !== null && isExternal !== undefined) {
|
| 797 |
+
if (!(typeof isExternal === "boolean")) {
|
| 798 |
+
throw new Error('typeof isExternal === "boolean"' + " error: " + ("Argument isExternal must be of type boolean, given: " + _typeof(isExternal) || "unknown"));
|
| 799 |
+
}
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
var node = {
|
| 803 |
+
type: "Func",
|
| 804 |
+
name: name,
|
| 805 |
+
signature: signature,
|
| 806 |
+
body: body
|
| 807 |
+
};
|
| 808 |
+
|
| 809 |
+
if (isExternal === true) {
|
| 810 |
+
node.isExternal = true;
|
| 811 |
+
}
|
| 812 |
+
|
| 813 |
+
if (typeof metadata !== "undefined") {
|
| 814 |
+
node.metadata = metadata;
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
return node;
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
function internalBrUnless(target) {
|
| 821 |
+
if (!(typeof target === "number")) {
|
| 822 |
+
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
| 823 |
+
}
|
| 824 |
+
|
| 825 |
+
var node = {
|
| 826 |
+
type: "InternalBrUnless",
|
| 827 |
+
target: target
|
| 828 |
+
};
|
| 829 |
+
return node;
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
function internalGoto(target) {
|
| 833 |
+
if (!(typeof target === "number")) {
|
| 834 |
+
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
var node = {
|
| 838 |
+
type: "InternalGoto",
|
| 839 |
+
target: target
|
| 840 |
+
};
|
| 841 |
+
return node;
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
function internalCallExtern(target) {
|
| 845 |
+
if (!(typeof target === "number")) {
|
| 846 |
+
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
| 847 |
+
}
|
| 848 |
+
|
| 849 |
+
var node = {
|
| 850 |
+
type: "InternalCallExtern",
|
| 851 |
+
target: target
|
| 852 |
+
};
|
| 853 |
+
return node;
|
| 854 |
+
}
|
| 855 |
+
|
| 856 |
+
function internalEndAndReturn() {
|
| 857 |
+
var node = {
|
| 858 |
+
type: "InternalEndAndReturn"
|
| 859 |
+
};
|
| 860 |
+
return node;
|
| 861 |
+
}
|
| 862 |
+
|
| 863 |
+
var isModule = isTypeOf("Module");
|
| 864 |
+
exports.isModule = isModule;
|
| 865 |
+
var isModuleMetadata = isTypeOf("ModuleMetadata");
|
| 866 |
+
exports.isModuleMetadata = isModuleMetadata;
|
| 867 |
+
var isModuleNameMetadata = isTypeOf("ModuleNameMetadata");
|
| 868 |
+
exports.isModuleNameMetadata = isModuleNameMetadata;
|
| 869 |
+
var isFunctionNameMetadata = isTypeOf("FunctionNameMetadata");
|
| 870 |
+
exports.isFunctionNameMetadata = isFunctionNameMetadata;
|
| 871 |
+
var isLocalNameMetadata = isTypeOf("LocalNameMetadata");
|
| 872 |
+
exports.isLocalNameMetadata = isLocalNameMetadata;
|
| 873 |
+
var isBinaryModule = isTypeOf("BinaryModule");
|
| 874 |
+
exports.isBinaryModule = isBinaryModule;
|
| 875 |
+
var isQuoteModule = isTypeOf("QuoteModule");
|
| 876 |
+
exports.isQuoteModule = isQuoteModule;
|
| 877 |
+
var isSectionMetadata = isTypeOf("SectionMetadata");
|
| 878 |
+
exports.isSectionMetadata = isSectionMetadata;
|
| 879 |
+
var isProducersSectionMetadata = isTypeOf("ProducersSectionMetadata");
|
| 880 |
+
exports.isProducersSectionMetadata = isProducersSectionMetadata;
|
| 881 |
+
var isProducerMetadata = isTypeOf("ProducerMetadata");
|
| 882 |
+
exports.isProducerMetadata = isProducerMetadata;
|
| 883 |
+
var isProducerMetadataVersionedName = isTypeOf("ProducerMetadataVersionedName");
|
| 884 |
+
exports.isProducerMetadataVersionedName = isProducerMetadataVersionedName;
|
| 885 |
+
var isLoopInstruction = isTypeOf("LoopInstruction");
|
| 886 |
+
exports.isLoopInstruction = isLoopInstruction;
|
| 887 |
+
var isInstr = isTypeOf("Instr");
|
| 888 |
+
exports.isInstr = isInstr;
|
| 889 |
+
var isIfInstruction = isTypeOf("IfInstruction");
|
| 890 |
+
exports.isIfInstruction = isIfInstruction;
|
| 891 |
+
var isStringLiteral = isTypeOf("StringLiteral");
|
| 892 |
+
exports.isStringLiteral = isStringLiteral;
|
| 893 |
+
var isNumberLiteral = isTypeOf("NumberLiteral");
|
| 894 |
+
exports.isNumberLiteral = isNumberLiteral;
|
| 895 |
+
var isLongNumberLiteral = isTypeOf("LongNumberLiteral");
|
| 896 |
+
exports.isLongNumberLiteral = isLongNumberLiteral;
|
| 897 |
+
var isFloatLiteral = isTypeOf("FloatLiteral");
|
| 898 |
+
exports.isFloatLiteral = isFloatLiteral;
|
| 899 |
+
var isElem = isTypeOf("Elem");
|
| 900 |
+
exports.isElem = isElem;
|
| 901 |
+
var isIndexInFuncSection = isTypeOf("IndexInFuncSection");
|
| 902 |
+
exports.isIndexInFuncSection = isIndexInFuncSection;
|
| 903 |
+
var isValtypeLiteral = isTypeOf("ValtypeLiteral");
|
| 904 |
+
exports.isValtypeLiteral = isValtypeLiteral;
|
| 905 |
+
var isTypeInstruction = isTypeOf("TypeInstruction");
|
| 906 |
+
exports.isTypeInstruction = isTypeInstruction;
|
| 907 |
+
var isStart = isTypeOf("Start");
|
| 908 |
+
exports.isStart = isStart;
|
| 909 |
+
var isGlobalType = isTypeOf("GlobalType");
|
| 910 |
+
exports.isGlobalType = isGlobalType;
|
| 911 |
+
var isLeadingComment = isTypeOf("LeadingComment");
|
| 912 |
+
exports.isLeadingComment = isLeadingComment;
|
| 913 |
+
var isBlockComment = isTypeOf("BlockComment");
|
| 914 |
+
exports.isBlockComment = isBlockComment;
|
| 915 |
+
var isData = isTypeOf("Data");
|
| 916 |
+
exports.isData = isData;
|
| 917 |
+
var isGlobal = isTypeOf("Global");
|
| 918 |
+
exports.isGlobal = isGlobal;
|
| 919 |
+
var isTable = isTypeOf("Table");
|
| 920 |
+
exports.isTable = isTable;
|
| 921 |
+
var isMemory = isTypeOf("Memory");
|
| 922 |
+
exports.isMemory = isMemory;
|
| 923 |
+
var isFuncImportDescr = isTypeOf("FuncImportDescr");
|
| 924 |
+
exports.isFuncImportDescr = isFuncImportDescr;
|
| 925 |
+
var isModuleImport = isTypeOf("ModuleImport");
|
| 926 |
+
exports.isModuleImport = isModuleImport;
|
| 927 |
+
var isModuleExportDescr = isTypeOf("ModuleExportDescr");
|
| 928 |
+
exports.isModuleExportDescr = isModuleExportDescr;
|
| 929 |
+
var isModuleExport = isTypeOf("ModuleExport");
|
| 930 |
+
exports.isModuleExport = isModuleExport;
|
| 931 |
+
var isLimit = isTypeOf("Limit");
|
| 932 |
+
exports.isLimit = isLimit;
|
| 933 |
+
var isSignature = isTypeOf("Signature");
|
| 934 |
+
exports.isSignature = isSignature;
|
| 935 |
+
var isProgram = isTypeOf("Program");
|
| 936 |
+
exports.isProgram = isProgram;
|
| 937 |
+
var isIdentifier = isTypeOf("Identifier");
|
| 938 |
+
exports.isIdentifier = isIdentifier;
|
| 939 |
+
var isBlockInstruction = isTypeOf("BlockInstruction");
|
| 940 |
+
exports.isBlockInstruction = isBlockInstruction;
|
| 941 |
+
var isCallInstruction = isTypeOf("CallInstruction");
|
| 942 |
+
exports.isCallInstruction = isCallInstruction;
|
| 943 |
+
var isCallIndirectInstruction = isTypeOf("CallIndirectInstruction");
|
| 944 |
+
exports.isCallIndirectInstruction = isCallIndirectInstruction;
|
| 945 |
+
var isByteArray = isTypeOf("ByteArray");
|
| 946 |
+
exports.isByteArray = isByteArray;
|
| 947 |
+
var isFunc = isTypeOf("Func");
|
| 948 |
+
exports.isFunc = isFunc;
|
| 949 |
+
var isInternalBrUnless = isTypeOf("InternalBrUnless");
|
| 950 |
+
exports.isInternalBrUnless = isInternalBrUnless;
|
| 951 |
+
var isInternalGoto = isTypeOf("InternalGoto");
|
| 952 |
+
exports.isInternalGoto = isInternalGoto;
|
| 953 |
+
var isInternalCallExtern = isTypeOf("InternalCallExtern");
|
| 954 |
+
exports.isInternalCallExtern = isInternalCallExtern;
|
| 955 |
+
var isInternalEndAndReturn = isTypeOf("InternalEndAndReturn");
|
| 956 |
+
exports.isInternalEndAndReturn = isInternalEndAndReturn;
|
| 957 |
+
|
| 958 |
+
var isNode = function isNode(node) {
|
| 959 |
+
return isModule(node) || isModuleMetadata(node) || isModuleNameMetadata(node) || isFunctionNameMetadata(node) || isLocalNameMetadata(node) || isBinaryModule(node) || isQuoteModule(node) || isSectionMetadata(node) || isProducersSectionMetadata(node) || isProducerMetadata(node) || isProducerMetadataVersionedName(node) || isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isElem(node) || isIndexInFuncSection(node) || isValtypeLiteral(node) || isTypeInstruction(node) || isStart(node) || isGlobalType(node) || isLeadingComment(node) || isBlockComment(node) || isData(node) || isGlobal(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node) || isModuleImport(node) || isModuleExportDescr(node) || isModuleExport(node) || isLimit(node) || isSignature(node) || isProgram(node) || isIdentifier(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node) || isByteArray(node) || isFunc(node) || isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node);
|
| 960 |
+
};
|
| 961 |
+
|
| 962 |
+
exports.isNode = isNode;
|
| 963 |
+
|
| 964 |
+
var isBlock = function isBlock(node) {
|
| 965 |
+
return isLoopInstruction(node) || isBlockInstruction(node) || isFunc(node);
|
| 966 |
+
};
|
| 967 |
+
|
| 968 |
+
exports.isBlock = isBlock;
|
| 969 |
+
|
| 970 |
+
var isInstruction = function isInstruction(node) {
|
| 971 |
+
return isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isTypeInstruction(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node);
|
| 972 |
+
};
|
| 973 |
+
|
| 974 |
+
exports.isInstruction = isInstruction;
|
| 975 |
+
|
| 976 |
+
var isExpression = function isExpression(node) {
|
| 977 |
+
return isInstr(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isValtypeLiteral(node) || isIdentifier(node);
|
| 978 |
+
};
|
| 979 |
+
|
| 980 |
+
exports.isExpression = isExpression;
|
| 981 |
+
|
| 982 |
+
var isNumericLiteral = function isNumericLiteral(node) {
|
| 983 |
+
return isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node);
|
| 984 |
+
};
|
| 985 |
+
|
| 986 |
+
exports.isNumericLiteral = isNumericLiteral;
|
| 987 |
+
|
| 988 |
+
var isImportDescr = function isImportDescr(node) {
|
| 989 |
+
return isGlobalType(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node);
|
| 990 |
+
};
|
| 991 |
+
|
| 992 |
+
exports.isImportDescr = isImportDescr;
|
| 993 |
+
|
| 994 |
+
var isIntrinsic = function isIntrinsic(node) {
|
| 995 |
+
return isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node);
|
| 996 |
+
};
|
| 997 |
+
|
| 998 |
+
exports.isIntrinsic = isIntrinsic;
|
| 999 |
+
var assertModule = assertTypeOf("Module");
|
| 1000 |
+
exports.assertModule = assertModule;
|
| 1001 |
+
var assertModuleMetadata = assertTypeOf("ModuleMetadata");
|
| 1002 |
+
exports.assertModuleMetadata = assertModuleMetadata;
|
| 1003 |
+
var assertModuleNameMetadata = assertTypeOf("ModuleNameMetadata");
|
| 1004 |
+
exports.assertModuleNameMetadata = assertModuleNameMetadata;
|
| 1005 |
+
var assertFunctionNameMetadata = assertTypeOf("FunctionNameMetadata");
|
| 1006 |
+
exports.assertFunctionNameMetadata = assertFunctionNameMetadata;
|
| 1007 |
+
var assertLocalNameMetadata = assertTypeOf("LocalNameMetadata");
|
| 1008 |
+
exports.assertLocalNameMetadata = assertLocalNameMetadata;
|
| 1009 |
+
var assertBinaryModule = assertTypeOf("BinaryModule");
|
| 1010 |
+
exports.assertBinaryModule = assertBinaryModule;
|
| 1011 |
+
var assertQuoteModule = assertTypeOf("QuoteModule");
|
| 1012 |
+
exports.assertQuoteModule = assertQuoteModule;
|
| 1013 |
+
var assertSectionMetadata = assertTypeOf("SectionMetadata");
|
| 1014 |
+
exports.assertSectionMetadata = assertSectionMetadata;
|
| 1015 |
+
var assertProducersSectionMetadata = assertTypeOf("ProducersSectionMetadata");
|
| 1016 |
+
exports.assertProducersSectionMetadata = assertProducersSectionMetadata;
|
| 1017 |
+
var assertProducerMetadata = assertTypeOf("ProducerMetadata");
|
| 1018 |
+
exports.assertProducerMetadata = assertProducerMetadata;
|
| 1019 |
+
var assertProducerMetadataVersionedName = assertTypeOf("ProducerMetadataVersionedName");
|
| 1020 |
+
exports.assertProducerMetadataVersionedName = assertProducerMetadataVersionedName;
|
| 1021 |
+
var assertLoopInstruction = assertTypeOf("LoopInstruction");
|
| 1022 |
+
exports.assertLoopInstruction = assertLoopInstruction;
|
| 1023 |
+
var assertInstr = assertTypeOf("Instr");
|
| 1024 |
+
exports.assertInstr = assertInstr;
|
| 1025 |
+
var assertIfInstruction = assertTypeOf("IfInstruction");
|
| 1026 |
+
exports.assertIfInstruction = assertIfInstruction;
|
| 1027 |
+
var assertStringLiteral = assertTypeOf("StringLiteral");
|
| 1028 |
+
exports.assertStringLiteral = assertStringLiteral;
|
| 1029 |
+
var assertNumberLiteral = assertTypeOf("NumberLiteral");
|
| 1030 |
+
exports.assertNumberLiteral = assertNumberLiteral;
|
| 1031 |
+
var assertLongNumberLiteral = assertTypeOf("LongNumberLiteral");
|
| 1032 |
+
exports.assertLongNumberLiteral = assertLongNumberLiteral;
|
| 1033 |
+
var assertFloatLiteral = assertTypeOf("FloatLiteral");
|
| 1034 |
+
exports.assertFloatLiteral = assertFloatLiteral;
|
| 1035 |
+
var assertElem = assertTypeOf("Elem");
|
| 1036 |
+
exports.assertElem = assertElem;
|
| 1037 |
+
var assertIndexInFuncSection = assertTypeOf("IndexInFuncSection");
|
| 1038 |
+
exports.assertIndexInFuncSection = assertIndexInFuncSection;
|
| 1039 |
+
var assertValtypeLiteral = assertTypeOf("ValtypeLiteral");
|
| 1040 |
+
exports.assertValtypeLiteral = assertValtypeLiteral;
|
| 1041 |
+
var assertTypeInstruction = assertTypeOf("TypeInstruction");
|
| 1042 |
+
exports.assertTypeInstruction = assertTypeInstruction;
|
| 1043 |
+
var assertStart = assertTypeOf("Start");
|
| 1044 |
+
exports.assertStart = assertStart;
|
| 1045 |
+
var assertGlobalType = assertTypeOf("GlobalType");
|
| 1046 |
+
exports.assertGlobalType = assertGlobalType;
|
| 1047 |
+
var assertLeadingComment = assertTypeOf("LeadingComment");
|
| 1048 |
+
exports.assertLeadingComment = assertLeadingComment;
|
| 1049 |
+
var assertBlockComment = assertTypeOf("BlockComment");
|
| 1050 |
+
exports.assertBlockComment = assertBlockComment;
|
| 1051 |
+
var assertData = assertTypeOf("Data");
|
| 1052 |
+
exports.assertData = assertData;
|
| 1053 |
+
var assertGlobal = assertTypeOf("Global");
|
| 1054 |
+
exports.assertGlobal = assertGlobal;
|
| 1055 |
+
var assertTable = assertTypeOf("Table");
|
| 1056 |
+
exports.assertTable = assertTable;
|
| 1057 |
+
var assertMemory = assertTypeOf("Memory");
|
| 1058 |
+
exports.assertMemory = assertMemory;
|
| 1059 |
+
var assertFuncImportDescr = assertTypeOf("FuncImportDescr");
|
| 1060 |
+
exports.assertFuncImportDescr = assertFuncImportDescr;
|
| 1061 |
+
var assertModuleImport = assertTypeOf("ModuleImport");
|
| 1062 |
+
exports.assertModuleImport = assertModuleImport;
|
| 1063 |
+
var assertModuleExportDescr = assertTypeOf("ModuleExportDescr");
|
| 1064 |
+
exports.assertModuleExportDescr = assertModuleExportDescr;
|
| 1065 |
+
var assertModuleExport = assertTypeOf("ModuleExport");
|
| 1066 |
+
exports.assertModuleExport = assertModuleExport;
|
| 1067 |
+
var assertLimit = assertTypeOf("Limit");
|
| 1068 |
+
exports.assertLimit = assertLimit;
|
| 1069 |
+
var assertSignature = assertTypeOf("Signature");
|
| 1070 |
+
exports.assertSignature = assertSignature;
|
| 1071 |
+
var assertProgram = assertTypeOf("Program");
|
| 1072 |
+
exports.assertProgram = assertProgram;
|
| 1073 |
+
var assertIdentifier = assertTypeOf("Identifier");
|
| 1074 |
+
exports.assertIdentifier = assertIdentifier;
|
| 1075 |
+
var assertBlockInstruction = assertTypeOf("BlockInstruction");
|
| 1076 |
+
exports.assertBlockInstruction = assertBlockInstruction;
|
| 1077 |
+
var assertCallInstruction = assertTypeOf("CallInstruction");
|
| 1078 |
+
exports.assertCallInstruction = assertCallInstruction;
|
| 1079 |
+
var assertCallIndirectInstruction = assertTypeOf("CallIndirectInstruction");
|
| 1080 |
+
exports.assertCallIndirectInstruction = assertCallIndirectInstruction;
|
| 1081 |
+
var assertByteArray = assertTypeOf("ByteArray");
|
| 1082 |
+
exports.assertByteArray = assertByteArray;
|
| 1083 |
+
var assertFunc = assertTypeOf("Func");
|
| 1084 |
+
exports.assertFunc = assertFunc;
|
| 1085 |
+
var assertInternalBrUnless = assertTypeOf("InternalBrUnless");
|
| 1086 |
+
exports.assertInternalBrUnless = assertInternalBrUnless;
|
| 1087 |
+
var assertInternalGoto = assertTypeOf("InternalGoto");
|
| 1088 |
+
exports.assertInternalGoto = assertInternalGoto;
|
| 1089 |
+
var assertInternalCallExtern = assertTypeOf("InternalCallExtern");
|
| 1090 |
+
exports.assertInternalCallExtern = assertInternalCallExtern;
|
| 1091 |
+
var assertInternalEndAndReturn = assertTypeOf("InternalEndAndReturn");
|
| 1092 |
+
exports.assertInternalEndAndReturn = assertInternalEndAndReturn;
|
| 1093 |
+
var unionTypesMap = {
|
| 1094 |
+
Module: ["Node"],
|
| 1095 |
+
ModuleMetadata: ["Node"],
|
| 1096 |
+
ModuleNameMetadata: ["Node"],
|
| 1097 |
+
FunctionNameMetadata: ["Node"],
|
| 1098 |
+
LocalNameMetadata: ["Node"],
|
| 1099 |
+
BinaryModule: ["Node"],
|
| 1100 |
+
QuoteModule: ["Node"],
|
| 1101 |
+
SectionMetadata: ["Node"],
|
| 1102 |
+
ProducersSectionMetadata: ["Node"],
|
| 1103 |
+
ProducerMetadata: ["Node"],
|
| 1104 |
+
ProducerMetadataVersionedName: ["Node"],
|
| 1105 |
+
LoopInstruction: ["Node", "Block", "Instruction"],
|
| 1106 |
+
Instr: ["Node", "Expression", "Instruction"],
|
| 1107 |
+
IfInstruction: ["Node", "Instruction"],
|
| 1108 |
+
StringLiteral: ["Node", "Expression"],
|
| 1109 |
+
NumberLiteral: ["Node", "NumericLiteral", "Expression"],
|
| 1110 |
+
LongNumberLiteral: ["Node", "NumericLiteral", "Expression"],
|
| 1111 |
+
FloatLiteral: ["Node", "NumericLiteral", "Expression"],
|
| 1112 |
+
Elem: ["Node"],
|
| 1113 |
+
IndexInFuncSection: ["Node"],
|
| 1114 |
+
ValtypeLiteral: ["Node", "Expression"],
|
| 1115 |
+
TypeInstruction: ["Node", "Instruction"],
|
| 1116 |
+
Start: ["Node"],
|
| 1117 |
+
GlobalType: ["Node", "ImportDescr"],
|
| 1118 |
+
LeadingComment: ["Node"],
|
| 1119 |
+
BlockComment: ["Node"],
|
| 1120 |
+
Data: ["Node"],
|
| 1121 |
+
Global: ["Node"],
|
| 1122 |
+
Table: ["Node", "ImportDescr"],
|
| 1123 |
+
Memory: ["Node", "ImportDescr"],
|
| 1124 |
+
FuncImportDescr: ["Node", "ImportDescr"],
|
| 1125 |
+
ModuleImport: ["Node"],
|
| 1126 |
+
ModuleExportDescr: ["Node"],
|
| 1127 |
+
ModuleExport: ["Node"],
|
| 1128 |
+
Limit: ["Node"],
|
| 1129 |
+
Signature: ["Node"],
|
| 1130 |
+
Program: ["Node"],
|
| 1131 |
+
Identifier: ["Node", "Expression"],
|
| 1132 |
+
BlockInstruction: ["Node", "Block", "Instruction"],
|
| 1133 |
+
CallInstruction: ["Node", "Instruction"],
|
| 1134 |
+
CallIndirectInstruction: ["Node", "Instruction"],
|
| 1135 |
+
ByteArray: ["Node"],
|
| 1136 |
+
Func: ["Node", "Block"],
|
| 1137 |
+
InternalBrUnless: ["Node", "Intrinsic"],
|
| 1138 |
+
InternalGoto: ["Node", "Intrinsic"],
|
| 1139 |
+
InternalCallExtern: ["Node", "Intrinsic"],
|
| 1140 |
+
InternalEndAndReturn: ["Node", "Intrinsic"]
|
| 1141 |
+
};
|
| 1142 |
+
exports.unionTypesMap = unionTypesMap;
|
| 1143 |
+
var nodeAndUnionTypes = ["Module", "ModuleMetadata", "ModuleNameMetadata", "FunctionNameMetadata", "LocalNameMetadata", "BinaryModule", "QuoteModule", "SectionMetadata", "ProducersSectionMetadata", "ProducerMetadata", "ProducerMetadataVersionedName", "LoopInstruction", "Instr", "IfInstruction", "StringLiteral", "NumberLiteral", "LongNumberLiteral", "FloatLiteral", "Elem", "IndexInFuncSection", "ValtypeLiteral", "TypeInstruction", "Start", "GlobalType", "LeadingComment", "BlockComment", "Data", "Global", "Table", "Memory", "FuncImportDescr", "ModuleImport", "ModuleExportDescr", "ModuleExport", "Limit", "Signature", "Program", "Identifier", "BlockInstruction", "CallInstruction", "CallIndirectInstruction", "ByteArray", "Func", "InternalBrUnless", "InternalGoto", "InternalCallExtern", "InternalEndAndReturn", "Node", "Block", "Instruction", "Expression", "NumericLiteral", "ImportDescr", "Intrinsic"];
|
| 1144 |
+
exports.nodeAndUnionTypes = nodeAndUnionTypes;
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/signatures.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.signatures = void 0;
|
| 7 |
+
|
| 8 |
+
function sign(input, output) {
|
| 9 |
+
return [input, output];
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
var u32 = "u32";
|
| 13 |
+
var i32 = "i32";
|
| 14 |
+
var i64 = "i64";
|
| 15 |
+
var f32 = "f32";
|
| 16 |
+
var f64 = "f64";
|
| 17 |
+
|
| 18 |
+
var vector = function vector(t) {
|
| 19 |
+
var vecType = [t]; // $FlowIgnore
|
| 20 |
+
|
| 21 |
+
vecType.vector = true;
|
| 22 |
+
return vecType;
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
var controlInstructions = {
|
| 26 |
+
unreachable: sign([], []),
|
| 27 |
+
nop: sign([], []),
|
| 28 |
+
// block ?
|
| 29 |
+
// loop ?
|
| 30 |
+
// if ?
|
| 31 |
+
// if else ?
|
| 32 |
+
br: sign([u32], []),
|
| 33 |
+
br_if: sign([u32], []),
|
| 34 |
+
br_table: sign(vector(u32), []),
|
| 35 |
+
"return": sign([], []),
|
| 36 |
+
call: sign([u32], []),
|
| 37 |
+
call_indirect: sign([u32], [])
|
| 38 |
+
};
|
| 39 |
+
var parametricInstructions = {
|
| 40 |
+
drop: sign([], []),
|
| 41 |
+
select: sign([], [])
|
| 42 |
+
};
|
| 43 |
+
var variableInstructions = {
|
| 44 |
+
get_local: sign([u32], []),
|
| 45 |
+
set_local: sign([u32], []),
|
| 46 |
+
tee_local: sign([u32], []),
|
| 47 |
+
get_global: sign([u32], []),
|
| 48 |
+
set_global: sign([u32], [])
|
| 49 |
+
};
|
| 50 |
+
var memoryInstructions = {
|
| 51 |
+
"i32.load": sign([u32, u32], [i32]),
|
| 52 |
+
"i64.load": sign([u32, u32], []),
|
| 53 |
+
"f32.load": sign([u32, u32], []),
|
| 54 |
+
"f64.load": sign([u32, u32], []),
|
| 55 |
+
"i32.load8_s": sign([u32, u32], [i32]),
|
| 56 |
+
"i32.load8_u": sign([u32, u32], [i32]),
|
| 57 |
+
"i32.load16_s": sign([u32, u32], [i32]),
|
| 58 |
+
"i32.load16_u": sign([u32, u32], [i32]),
|
| 59 |
+
"i64.load8_s": sign([u32, u32], [i64]),
|
| 60 |
+
"i64.load8_u": sign([u32, u32], [i64]),
|
| 61 |
+
"i64.load16_s": sign([u32, u32], [i64]),
|
| 62 |
+
"i64.load16_u": sign([u32, u32], [i64]),
|
| 63 |
+
"i64.load32_s": sign([u32, u32], [i64]),
|
| 64 |
+
"i64.load32_u": sign([u32, u32], [i64]),
|
| 65 |
+
"i32.store": sign([u32, u32], []),
|
| 66 |
+
"i64.store": sign([u32, u32], []),
|
| 67 |
+
"f32.store": sign([u32, u32], []),
|
| 68 |
+
"f64.store": sign([u32, u32], []),
|
| 69 |
+
"i32.store8": sign([u32, u32], []),
|
| 70 |
+
"i32.store16": sign([u32, u32], []),
|
| 71 |
+
"i64.store8": sign([u32, u32], []),
|
| 72 |
+
"i64.store16": sign([u32, u32], []),
|
| 73 |
+
"i64.store32": sign([u32, u32], []),
|
| 74 |
+
current_memory: sign([], []),
|
| 75 |
+
grow_memory: sign([], [])
|
| 76 |
+
};
|
| 77 |
+
var numericInstructions = {
|
| 78 |
+
"i32.const": sign([i32], [i32]),
|
| 79 |
+
"i64.const": sign([i64], [i64]),
|
| 80 |
+
"f32.const": sign([f32], [f32]),
|
| 81 |
+
"f64.const": sign([f64], [f64]),
|
| 82 |
+
"i32.eqz": sign([i32], [i32]),
|
| 83 |
+
"i32.eq": sign([i32, i32], [i32]),
|
| 84 |
+
"i32.ne": sign([i32, i32], [i32]),
|
| 85 |
+
"i32.lt_s": sign([i32, i32], [i32]),
|
| 86 |
+
"i32.lt_u": sign([i32, i32], [i32]),
|
| 87 |
+
"i32.gt_s": sign([i32, i32], [i32]),
|
| 88 |
+
"i32.gt_u": sign([i32, i32], [i32]),
|
| 89 |
+
"i32.le_s": sign([i32, i32], [i32]),
|
| 90 |
+
"i32.le_u": sign([i32, i32], [i32]),
|
| 91 |
+
"i32.ge_s": sign([i32, i32], [i32]),
|
| 92 |
+
"i32.ge_u": sign([i32, i32], [i32]),
|
| 93 |
+
"i64.eqz": sign([i64], [i64]),
|
| 94 |
+
"i64.eq": sign([i64, i64], [i32]),
|
| 95 |
+
"i64.ne": sign([i64, i64], [i32]),
|
| 96 |
+
"i64.lt_s": sign([i64, i64], [i32]),
|
| 97 |
+
"i64.lt_u": sign([i64, i64], [i32]),
|
| 98 |
+
"i64.gt_s": sign([i64, i64], [i32]),
|
| 99 |
+
"i64.gt_u": sign([i64, i64], [i32]),
|
| 100 |
+
"i64.le_s": sign([i64, i64], [i32]),
|
| 101 |
+
"i64.le_u": sign([i64, i64], [i32]),
|
| 102 |
+
"i64.ge_s": sign([i64, i64], [i32]),
|
| 103 |
+
"i64.ge_u": sign([i64, i64], [i32]),
|
| 104 |
+
"f32.eq": sign([f32, f32], [i32]),
|
| 105 |
+
"f32.ne": sign([f32, f32], [i32]),
|
| 106 |
+
"f32.lt": sign([f32, f32], [i32]),
|
| 107 |
+
"f32.gt": sign([f32, f32], [i32]),
|
| 108 |
+
"f32.le": sign([f32, f32], [i32]),
|
| 109 |
+
"f32.ge": sign([f32, f32], [i32]),
|
| 110 |
+
"f64.eq": sign([f64, f64], [i32]),
|
| 111 |
+
"f64.ne": sign([f64, f64], [i32]),
|
| 112 |
+
"f64.lt": sign([f64, f64], [i32]),
|
| 113 |
+
"f64.gt": sign([f64, f64], [i32]),
|
| 114 |
+
"f64.le": sign([f64, f64], [i32]),
|
| 115 |
+
"f64.ge": sign([f64, f64], [i32]),
|
| 116 |
+
"i32.clz": sign([i32], [i32]),
|
| 117 |
+
"i32.ctz": sign([i32], [i32]),
|
| 118 |
+
"i32.popcnt": sign([i32], [i32]),
|
| 119 |
+
"i32.add": sign([i32, i32], [i32]),
|
| 120 |
+
"i32.sub": sign([i32, i32], [i32]),
|
| 121 |
+
"i32.mul": sign([i32, i32], [i32]),
|
| 122 |
+
"i32.div_s": sign([i32, i32], [i32]),
|
| 123 |
+
"i32.div_u": sign([i32, i32], [i32]),
|
| 124 |
+
"i32.rem_s": sign([i32, i32], [i32]),
|
| 125 |
+
"i32.rem_u": sign([i32, i32], [i32]),
|
| 126 |
+
"i32.and": sign([i32, i32], [i32]),
|
| 127 |
+
"i32.or": sign([i32, i32], [i32]),
|
| 128 |
+
"i32.xor": sign([i32, i32], [i32]),
|
| 129 |
+
"i32.shl": sign([i32, i32], [i32]),
|
| 130 |
+
"i32.shr_s": sign([i32, i32], [i32]),
|
| 131 |
+
"i32.shr_u": sign([i32, i32], [i32]),
|
| 132 |
+
"i32.rotl": sign([i32, i32], [i32]),
|
| 133 |
+
"i32.rotr": sign([i32, i32], [i32]),
|
| 134 |
+
"i64.clz": sign([i64], [i64]),
|
| 135 |
+
"i64.ctz": sign([i64], [i64]),
|
| 136 |
+
"i64.popcnt": sign([i64], [i64]),
|
| 137 |
+
"i64.add": sign([i64, i64], [i64]),
|
| 138 |
+
"i64.sub": sign([i64, i64], [i64]),
|
| 139 |
+
"i64.mul": sign([i64, i64], [i64]),
|
| 140 |
+
"i64.div_s": sign([i64, i64], [i64]),
|
| 141 |
+
"i64.div_u": sign([i64, i64], [i64]),
|
| 142 |
+
"i64.rem_s": sign([i64, i64], [i64]),
|
| 143 |
+
"i64.rem_u": sign([i64, i64], [i64]),
|
| 144 |
+
"i64.and": sign([i64, i64], [i64]),
|
| 145 |
+
"i64.or": sign([i64, i64], [i64]),
|
| 146 |
+
"i64.xor": sign([i64, i64], [i64]),
|
| 147 |
+
"i64.shl": sign([i64, i64], [i64]),
|
| 148 |
+
"i64.shr_s": sign([i64, i64], [i64]),
|
| 149 |
+
"i64.shr_u": sign([i64, i64], [i64]),
|
| 150 |
+
"i64.rotl": sign([i64, i64], [i64]),
|
| 151 |
+
"i64.rotr": sign([i64, i64], [i64]),
|
| 152 |
+
"f32.abs": sign([f32], [f32]),
|
| 153 |
+
"f32.neg": sign([f32], [f32]),
|
| 154 |
+
"f32.ceil": sign([f32], [f32]),
|
| 155 |
+
"f32.floor": sign([f32], [f32]),
|
| 156 |
+
"f32.trunc": sign([f32], [f32]),
|
| 157 |
+
"f32.nearest": sign([f32], [f32]),
|
| 158 |
+
"f32.sqrt": sign([f32], [f32]),
|
| 159 |
+
"f32.add": sign([f32, f32], [f32]),
|
| 160 |
+
"f32.sub": sign([f32, f32], [f32]),
|
| 161 |
+
"f32.mul": sign([f32, f32], [f32]),
|
| 162 |
+
"f32.div": sign([f32, f32], [f32]),
|
| 163 |
+
"f32.min": sign([f32, f32], [f32]),
|
| 164 |
+
"f32.max": sign([f32, f32], [f32]),
|
| 165 |
+
"f32.copysign": sign([f32, f32], [f32]),
|
| 166 |
+
"f64.abs": sign([f64], [f64]),
|
| 167 |
+
"f64.neg": sign([f64], [f64]),
|
| 168 |
+
"f64.ceil": sign([f64], [f64]),
|
| 169 |
+
"f64.floor": sign([f64], [f64]),
|
| 170 |
+
"f64.trunc": sign([f64], [f64]),
|
| 171 |
+
"f64.nearest": sign([f64], [f64]),
|
| 172 |
+
"f64.sqrt": sign([f64], [f64]),
|
| 173 |
+
"f64.add": sign([f64, f64], [f64]),
|
| 174 |
+
"f64.sub": sign([f64, f64], [f64]),
|
| 175 |
+
"f64.mul": sign([f64, f64], [f64]),
|
| 176 |
+
"f64.div": sign([f64, f64], [f64]),
|
| 177 |
+
"f64.min": sign([f64, f64], [f64]),
|
| 178 |
+
"f64.max": sign([f64, f64], [f64]),
|
| 179 |
+
"f64.copysign": sign([f64, f64], [f64]),
|
| 180 |
+
"i32.wrap/i64": sign([i64], [i32]),
|
| 181 |
+
"i32.trunc_s/f32": sign([f32], [i32]),
|
| 182 |
+
"i32.trunc_u/f32": sign([f32], [i32]),
|
| 183 |
+
"i32.trunc_s/f64": sign([f32], [i32]),
|
| 184 |
+
"i32.trunc_u/f64": sign([f64], [i32]),
|
| 185 |
+
"i64.extend_s/i32": sign([i32], [i64]),
|
| 186 |
+
"i64.extend_u/i32": sign([i32], [i64]),
|
| 187 |
+
"i64.trunc_s/f32": sign([f32], [i64]),
|
| 188 |
+
"i64.trunc_u/f32": sign([f32], [i64]),
|
| 189 |
+
"i64.trunc_s/f64": sign([f64], [i64]),
|
| 190 |
+
"i64.trunc_u/f64": sign([f64], [i64]),
|
| 191 |
+
"f32.convert_s/i32": sign([i32], [f32]),
|
| 192 |
+
"f32.convert_u/i32": sign([i32], [f32]),
|
| 193 |
+
"f32.convert_s/i64": sign([i64], [f32]),
|
| 194 |
+
"f32.convert_u/i64": sign([i64], [f32]),
|
| 195 |
+
"f32.demote/f64": sign([f64], [f32]),
|
| 196 |
+
"f64.convert_s/i32": sign([i32], [f64]),
|
| 197 |
+
"f64.convert_u/i32": sign([i32], [f64]),
|
| 198 |
+
"f64.convert_s/i64": sign([i64], [f64]),
|
| 199 |
+
"f64.convert_u/i64": sign([i64], [f64]),
|
| 200 |
+
"f64.promote/f32": sign([f32], [f64]),
|
| 201 |
+
"i32.reinterpret/f32": sign([f32], [i32]),
|
| 202 |
+
"i64.reinterpret/f64": sign([f64], [i64]),
|
| 203 |
+
"f32.reinterpret/i32": sign([i32], [f32]),
|
| 204 |
+
"f64.reinterpret/i64": sign([i64], [f64])
|
| 205 |
+
};
|
| 206 |
+
var signatures = Object.assign({}, controlInstructions, parametricInstructions, variableInstructions, memoryInstructions, numericInstructions);
|
| 207 |
+
exports.signatures = signatures;
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/transform/ast-module-to-module-context/index.js
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.moduleContextFromModuleAST = moduleContextFromModuleAST;
|
| 7 |
+
exports.ModuleContext = void 0;
|
| 8 |
+
|
| 9 |
+
var _nodes = require("../../nodes.js");
|
| 10 |
+
|
| 11 |
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
| 12 |
+
|
| 13 |
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
| 14 |
+
|
| 15 |
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
| 16 |
+
|
| 17 |
+
function moduleContextFromModuleAST(m) {
|
| 18 |
+
var moduleContext = new ModuleContext();
|
| 19 |
+
|
| 20 |
+
if (!(m.type === "Module")) {
|
| 21 |
+
throw new Error('m.type === "Module"' + " error: " + (undefined || "unknown"));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
m.fields.forEach(function (field) {
|
| 25 |
+
switch (field.type) {
|
| 26 |
+
case "Start":
|
| 27 |
+
{
|
| 28 |
+
moduleContext.setStart(field.index);
|
| 29 |
+
break;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
case "TypeInstruction":
|
| 33 |
+
{
|
| 34 |
+
moduleContext.addType(field);
|
| 35 |
+
break;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
case "Func":
|
| 39 |
+
{
|
| 40 |
+
moduleContext.addFunction(field);
|
| 41 |
+
break;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
case "Global":
|
| 45 |
+
{
|
| 46 |
+
moduleContext.defineGlobal(field);
|
| 47 |
+
break;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
case "ModuleImport":
|
| 51 |
+
{
|
| 52 |
+
switch (field.descr.type) {
|
| 53 |
+
case "GlobalType":
|
| 54 |
+
{
|
| 55 |
+
moduleContext.importGlobal(field.descr.valtype, field.descr.mutability);
|
| 56 |
+
break;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
case "Memory":
|
| 60 |
+
{
|
| 61 |
+
moduleContext.addMemory(field.descr.limits.min, field.descr.limits.max);
|
| 62 |
+
break;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
case "FuncImportDescr":
|
| 66 |
+
{
|
| 67 |
+
moduleContext.importFunction(field.descr);
|
| 68 |
+
break;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
case "Table":
|
| 72 |
+
{
|
| 73 |
+
// FIXME(sven): not implemented yet
|
| 74 |
+
break;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
default:
|
| 78 |
+
throw new Error("Unsupported ModuleImport of type " + JSON.stringify(field.descr.type));
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
break;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
case "Memory":
|
| 85 |
+
{
|
| 86 |
+
moduleContext.addMemory(field.limits.min, field.limits.max);
|
| 87 |
+
break;
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
});
|
| 91 |
+
return moduleContext;
|
| 92 |
+
}
|
| 93 |
+
/**
|
| 94 |
+
* Module context for type checking
|
| 95 |
+
*/
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
var ModuleContext = /*#__PURE__*/function () {
|
| 99 |
+
function ModuleContext() {
|
| 100 |
+
_classCallCheck(this, ModuleContext);
|
| 101 |
+
|
| 102 |
+
this.funcs = [];
|
| 103 |
+
this.funcsOffsetByIdentifier = [];
|
| 104 |
+
this.types = [];
|
| 105 |
+
this.globals = [];
|
| 106 |
+
this.globalsOffsetByIdentifier = [];
|
| 107 |
+
this.mems = []; // Current stack frame
|
| 108 |
+
|
| 109 |
+
this.locals = [];
|
| 110 |
+
this.labels = [];
|
| 111 |
+
this["return"] = [];
|
| 112 |
+
this.debugName = "unknown";
|
| 113 |
+
this.start = null;
|
| 114 |
+
}
|
| 115 |
+
/**
|
| 116 |
+
* Set start segment
|
| 117 |
+
*/
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
_createClass(ModuleContext, [{
|
| 121 |
+
key: "setStart",
|
| 122 |
+
value: function setStart(index) {
|
| 123 |
+
this.start = index.value;
|
| 124 |
+
}
|
| 125 |
+
/**
|
| 126 |
+
* Get start function
|
| 127 |
+
*/
|
| 128 |
+
|
| 129 |
+
}, {
|
| 130 |
+
key: "getStart",
|
| 131 |
+
value: function getStart() {
|
| 132 |
+
return this.start;
|
| 133 |
+
}
|
| 134 |
+
/**
|
| 135 |
+
* Reset the active stack frame
|
| 136 |
+
*/
|
| 137 |
+
|
| 138 |
+
}, {
|
| 139 |
+
key: "newContext",
|
| 140 |
+
value: function newContext(debugName, expectedResult) {
|
| 141 |
+
this.locals = [];
|
| 142 |
+
this.labels = [expectedResult];
|
| 143 |
+
this["return"] = expectedResult;
|
| 144 |
+
this.debugName = debugName;
|
| 145 |
+
}
|
| 146 |
+
/**
|
| 147 |
+
* Functions
|
| 148 |
+
*/
|
| 149 |
+
|
| 150 |
+
}, {
|
| 151 |
+
key: "addFunction",
|
| 152 |
+
value: function addFunction(func) {
|
| 153 |
+
/* eslint-disable */
|
| 154 |
+
// $FlowIgnore
|
| 155 |
+
var _ref = func.signature || {},
|
| 156 |
+
_ref$params = _ref.params,
|
| 157 |
+
args = _ref$params === void 0 ? [] : _ref$params,
|
| 158 |
+
_ref$results = _ref.results,
|
| 159 |
+
result = _ref$results === void 0 ? [] : _ref$results;
|
| 160 |
+
/* eslint-enable */
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
args = args.map(function (arg) {
|
| 164 |
+
return arg.valtype;
|
| 165 |
+
});
|
| 166 |
+
this.funcs.push({
|
| 167 |
+
args: args,
|
| 168 |
+
result: result
|
| 169 |
+
});
|
| 170 |
+
|
| 171 |
+
if (typeof func.name !== "undefined") {
|
| 172 |
+
// $FlowIgnore
|
| 173 |
+
this.funcsOffsetByIdentifier[func.name.value] = this.funcs.length - 1;
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
}, {
|
| 177 |
+
key: "importFunction",
|
| 178 |
+
value: function importFunction(funcimport) {
|
| 179 |
+
if ((0, _nodes.isSignature)(funcimport.signature)) {
|
| 180 |
+
// eslint-disable-next-line prefer-const
|
| 181 |
+
var _funcimport$signature = funcimport.signature,
|
| 182 |
+
args = _funcimport$signature.params,
|
| 183 |
+
result = _funcimport$signature.results;
|
| 184 |
+
args = args.map(function (arg) {
|
| 185 |
+
return arg.valtype;
|
| 186 |
+
});
|
| 187 |
+
this.funcs.push({
|
| 188 |
+
args: args,
|
| 189 |
+
result: result
|
| 190 |
+
});
|
| 191 |
+
} else {
|
| 192 |
+
if (!(0, _nodes.isNumberLiteral)(funcimport.signature)) {
|
| 193 |
+
throw new Error('isNumberLiteral(funcimport.signature)' + " error: " + (undefined || "unknown"));
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
var typeId = funcimport.signature.value;
|
| 197 |
+
|
| 198 |
+
if (!this.hasType(typeId)) {
|
| 199 |
+
throw new Error('this.hasType(typeId)' + " error: " + (undefined || "unknown"));
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
var signature = this.getType(typeId);
|
| 203 |
+
this.funcs.push({
|
| 204 |
+
args: signature.params.map(function (arg) {
|
| 205 |
+
return arg.valtype;
|
| 206 |
+
}),
|
| 207 |
+
result: signature.results
|
| 208 |
+
});
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
if (typeof funcimport.id !== "undefined") {
|
| 212 |
+
// imports are first, we can assume their index in the array
|
| 213 |
+
this.funcsOffsetByIdentifier[funcimport.id.value] = this.funcs.length - 1;
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
}, {
|
| 217 |
+
key: "hasFunction",
|
| 218 |
+
value: function hasFunction(index) {
|
| 219 |
+
return typeof this.getFunction(index) !== "undefined";
|
| 220 |
+
}
|
| 221 |
+
}, {
|
| 222 |
+
key: "getFunction",
|
| 223 |
+
value: function getFunction(index) {
|
| 224 |
+
if (typeof index !== "number") {
|
| 225 |
+
throw new Error("getFunction only supported for number index");
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
return this.funcs[index];
|
| 229 |
+
}
|
| 230 |
+
}, {
|
| 231 |
+
key: "getFunctionOffsetByIdentifier",
|
| 232 |
+
value: function getFunctionOffsetByIdentifier(name) {
|
| 233 |
+
if (!(typeof name === "string")) {
|
| 234 |
+
throw new Error('typeof name === "string"' + " error: " + (undefined || "unknown"));
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
return this.funcsOffsetByIdentifier[name];
|
| 238 |
+
}
|
| 239 |
+
/**
|
| 240 |
+
* Labels
|
| 241 |
+
*/
|
| 242 |
+
|
| 243 |
+
}, {
|
| 244 |
+
key: "addLabel",
|
| 245 |
+
value: function addLabel(result) {
|
| 246 |
+
this.labels.unshift(result);
|
| 247 |
+
}
|
| 248 |
+
}, {
|
| 249 |
+
key: "hasLabel",
|
| 250 |
+
value: function hasLabel(index) {
|
| 251 |
+
return this.labels.length > index && index >= 0;
|
| 252 |
+
}
|
| 253 |
+
}, {
|
| 254 |
+
key: "getLabel",
|
| 255 |
+
value: function getLabel(index) {
|
| 256 |
+
return this.labels[index];
|
| 257 |
+
}
|
| 258 |
+
}, {
|
| 259 |
+
key: "popLabel",
|
| 260 |
+
value: function popLabel() {
|
| 261 |
+
this.labels.shift();
|
| 262 |
+
}
|
| 263 |
+
/**
|
| 264 |
+
* Locals
|
| 265 |
+
*/
|
| 266 |
+
|
| 267 |
+
}, {
|
| 268 |
+
key: "hasLocal",
|
| 269 |
+
value: function hasLocal(index) {
|
| 270 |
+
return typeof this.getLocal(index) !== "undefined";
|
| 271 |
+
}
|
| 272 |
+
}, {
|
| 273 |
+
key: "getLocal",
|
| 274 |
+
value: function getLocal(index) {
|
| 275 |
+
return this.locals[index];
|
| 276 |
+
}
|
| 277 |
+
}, {
|
| 278 |
+
key: "addLocal",
|
| 279 |
+
value: function addLocal(type) {
|
| 280 |
+
this.locals.push(type);
|
| 281 |
+
}
|
| 282 |
+
/**
|
| 283 |
+
* Types
|
| 284 |
+
*/
|
| 285 |
+
|
| 286 |
+
}, {
|
| 287 |
+
key: "addType",
|
| 288 |
+
value: function addType(type) {
|
| 289 |
+
if (!(type.functype.type === "Signature")) {
|
| 290 |
+
throw new Error('type.functype.type === "Signature"' + " error: " + (undefined || "unknown"));
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
this.types.push(type.functype);
|
| 294 |
+
}
|
| 295 |
+
}, {
|
| 296 |
+
key: "hasType",
|
| 297 |
+
value: function hasType(index) {
|
| 298 |
+
return this.types[index] !== undefined;
|
| 299 |
+
}
|
| 300 |
+
}, {
|
| 301 |
+
key: "getType",
|
| 302 |
+
value: function getType(index) {
|
| 303 |
+
return this.types[index];
|
| 304 |
+
}
|
| 305 |
+
/**
|
| 306 |
+
* Globals
|
| 307 |
+
*/
|
| 308 |
+
|
| 309 |
+
}, {
|
| 310 |
+
key: "hasGlobal",
|
| 311 |
+
value: function hasGlobal(index) {
|
| 312 |
+
return this.globals.length > index && index >= 0;
|
| 313 |
+
}
|
| 314 |
+
}, {
|
| 315 |
+
key: "getGlobal",
|
| 316 |
+
value: function getGlobal(index) {
|
| 317 |
+
return this.globals[index].type;
|
| 318 |
+
}
|
| 319 |
+
}, {
|
| 320 |
+
key: "getGlobalOffsetByIdentifier",
|
| 321 |
+
value: function getGlobalOffsetByIdentifier(name) {
|
| 322 |
+
if (!(typeof name === "string")) {
|
| 323 |
+
throw new Error('typeof name === "string"' + " error: " + (undefined || "unknown"));
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
// $FlowIgnore
|
| 327 |
+
return this.globalsOffsetByIdentifier[name];
|
| 328 |
+
}
|
| 329 |
+
}, {
|
| 330 |
+
key: "defineGlobal",
|
| 331 |
+
value: function defineGlobal(global) {
|
| 332 |
+
var type = global.globalType.valtype;
|
| 333 |
+
var mutability = global.globalType.mutability;
|
| 334 |
+
this.globals.push({
|
| 335 |
+
type: type,
|
| 336 |
+
mutability: mutability
|
| 337 |
+
});
|
| 338 |
+
|
| 339 |
+
if (typeof global.name !== "undefined") {
|
| 340 |
+
// $FlowIgnore
|
| 341 |
+
this.globalsOffsetByIdentifier[global.name.value] = this.globals.length - 1;
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
}, {
|
| 345 |
+
key: "importGlobal",
|
| 346 |
+
value: function importGlobal(type, mutability) {
|
| 347 |
+
this.globals.push({
|
| 348 |
+
type: type,
|
| 349 |
+
mutability: mutability
|
| 350 |
+
});
|
| 351 |
+
}
|
| 352 |
+
}, {
|
| 353 |
+
key: "isMutableGlobal",
|
| 354 |
+
value: function isMutableGlobal(index) {
|
| 355 |
+
return this.globals[index].mutability === "var";
|
| 356 |
+
}
|
| 357 |
+
}, {
|
| 358 |
+
key: "isImmutableGlobal",
|
| 359 |
+
value: function isImmutableGlobal(index) {
|
| 360 |
+
return this.globals[index].mutability === "const";
|
| 361 |
+
}
|
| 362 |
+
/**
|
| 363 |
+
* Memories
|
| 364 |
+
*/
|
| 365 |
+
|
| 366 |
+
}, {
|
| 367 |
+
key: "hasMemory",
|
| 368 |
+
value: function hasMemory(index) {
|
| 369 |
+
return this.mems.length > index && index >= 0;
|
| 370 |
+
}
|
| 371 |
+
}, {
|
| 372 |
+
key: "addMemory",
|
| 373 |
+
value: function addMemory(min, max) {
|
| 374 |
+
this.mems.push({
|
| 375 |
+
min: min,
|
| 376 |
+
max: max
|
| 377 |
+
});
|
| 378 |
+
}
|
| 379 |
+
}, {
|
| 380 |
+
key: "getMemory",
|
| 381 |
+
value: function getMemory(index) {
|
| 382 |
+
return this.mems[index];
|
| 383 |
+
}
|
| 384 |
+
}]);
|
| 385 |
+
|
| 386 |
+
return ModuleContext;
|
| 387 |
+
}();
|
| 388 |
+
|
| 389 |
+
exports.ModuleContext = ModuleContext;
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/transform/denormalize-type-references/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.transform = transform;
|
| 7 |
+
|
| 8 |
+
var t = require("../../index"); // func and call_indirect instructions can either define a signature inline, or
|
| 9 |
+
// reference a signature, e.g.
|
| 10 |
+
//
|
| 11 |
+
// ;; inline signature
|
| 12 |
+
// (func (result i64)
|
| 13 |
+
// (i64.const 2)
|
| 14 |
+
// )
|
| 15 |
+
// ;; signature reference
|
| 16 |
+
// (type (func (result i64)))
|
| 17 |
+
// (func (type 0)
|
| 18 |
+
// (i64.const 2))
|
| 19 |
+
// )
|
| 20 |
+
//
|
| 21 |
+
// this AST transform denormalises the type references, making all signatures within the module
|
| 22 |
+
// inline.
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
function transform(ast) {
|
| 26 |
+
var typeInstructions = [];
|
| 27 |
+
t.traverse(ast, {
|
| 28 |
+
TypeInstruction: function TypeInstruction(_ref) {
|
| 29 |
+
var node = _ref.node;
|
| 30 |
+
typeInstructions.push(node);
|
| 31 |
+
}
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
if (!typeInstructions.length) {
|
| 35 |
+
return;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
function denormalizeSignature(signature) {
|
| 39 |
+
// signature referenced by identifier
|
| 40 |
+
if (signature.type === "Identifier") {
|
| 41 |
+
var identifier = signature;
|
| 42 |
+
var typeInstruction = typeInstructions.find(function (t) {
|
| 43 |
+
return t.id.type === identifier.type && t.id.value === identifier.value;
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
if (!typeInstruction) {
|
| 47 |
+
throw new Error("A type instruction reference was not found ".concat(JSON.stringify(signature)));
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
return typeInstruction.functype;
|
| 51 |
+
} // signature referenced by index
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if (signature.type === "NumberLiteral") {
|
| 55 |
+
var signatureRef = signature;
|
| 56 |
+
var _typeInstruction = typeInstructions[signatureRef.value];
|
| 57 |
+
return _typeInstruction.functype;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
return signature;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
t.traverse(ast, {
|
| 64 |
+
Func: function (_Func) {
|
| 65 |
+
function Func(_x) {
|
| 66 |
+
return _Func.apply(this, arguments);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
Func.toString = function () {
|
| 70 |
+
return _Func.toString();
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
return Func;
|
| 74 |
+
}(function (_ref2) {
|
| 75 |
+
var node = _ref2.node;
|
| 76 |
+
node.signature = denormalizeSignature(node.signature);
|
| 77 |
+
}),
|
| 78 |
+
CallIndirectInstruction: function CallIndirectInstruction(_ref3) {
|
| 79 |
+
var node = _ref3.node;
|
| 80 |
+
node.signature = denormalizeSignature(node.signature);
|
| 81 |
+
}
|
| 82 |
+
});
|
| 83 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/transform/wast-identifier-to-index/index.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.transform = transform;
|
| 7 |
+
|
| 8 |
+
var _index = require("../../index");
|
| 9 |
+
|
| 10 |
+
var _astModuleToModuleContext = require("../ast-module-to-module-context");
|
| 11 |
+
|
| 12 |
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
| 13 |
+
|
| 14 |
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
| 15 |
+
|
| 16 |
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
| 17 |
+
|
| 18 |
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
| 19 |
+
|
| 20 |
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
| 21 |
+
|
| 22 |
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
| 23 |
+
|
| 24 |
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
| 25 |
+
|
| 26 |
+
// FIXME(sven): do the same with all block instructions, must be more generic here
|
| 27 |
+
function newUnexpectedFunction(i) {
|
| 28 |
+
return new Error("unknown function at offset: " + i);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function transform(ast) {
|
| 32 |
+
var module = null;
|
| 33 |
+
(0, _index.traverse)(ast, {
|
| 34 |
+
Module: function (_Module) {
|
| 35 |
+
function Module(_x) {
|
| 36 |
+
return _Module.apply(this, arguments);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
Module.toString = function () {
|
| 40 |
+
return _Module.toString();
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
return Module;
|
| 44 |
+
}(function (path) {
|
| 45 |
+
module = path.node;
|
| 46 |
+
})
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
if (module == null) {
|
| 50 |
+
throw new Error("Module not foudn in program");
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
var moduleContext = (0, _astModuleToModuleContext.moduleContextFromModuleAST)(module); // Transform the actual instruction in function bodies
|
| 54 |
+
|
| 55 |
+
(0, _index.traverse)(ast, {
|
| 56 |
+
Func: function (_Func) {
|
| 57 |
+
function Func(_x2) {
|
| 58 |
+
return _Func.apply(this, arguments);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
Func.toString = function () {
|
| 62 |
+
return _Func.toString();
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
return Func;
|
| 66 |
+
}(function (path) {
|
| 67 |
+
transformFuncPath(path, moduleContext);
|
| 68 |
+
}),
|
| 69 |
+
Start: function (_Start) {
|
| 70 |
+
function Start(_x3) {
|
| 71 |
+
return _Start.apply(this, arguments);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
Start.toString = function () {
|
| 75 |
+
return _Start.toString();
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
return Start;
|
| 79 |
+
}(function (path) {
|
| 80 |
+
var index = path.node.index;
|
| 81 |
+
|
| 82 |
+
if ((0, _index.isIdentifier)(index) === true) {
|
| 83 |
+
var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value);
|
| 84 |
+
|
| 85 |
+
if (typeof offsetInModule === "undefined") {
|
| 86 |
+
throw newUnexpectedFunction(index.value);
|
| 87 |
+
} // Replace the index Identifier
|
| 88 |
+
// $FlowIgnore: reference?
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
path.node.index = (0, _index.numberLiteralFromRaw)(offsetInModule);
|
| 92 |
+
}
|
| 93 |
+
})
|
| 94 |
+
});
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
function transformFuncPath(funcPath, moduleContext) {
|
| 98 |
+
var funcNode = funcPath.node;
|
| 99 |
+
var signature = funcNode.signature;
|
| 100 |
+
|
| 101 |
+
if (signature.type !== "Signature") {
|
| 102 |
+
throw new Error("Function signatures must be denormalised before execution");
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
var params = signature.params; // Add func locals in the context
|
| 106 |
+
|
| 107 |
+
params.forEach(function (p) {
|
| 108 |
+
return moduleContext.addLocal(p.valtype);
|
| 109 |
+
});
|
| 110 |
+
(0, _index.traverse)(funcNode, {
|
| 111 |
+
Instr: function (_Instr) {
|
| 112 |
+
function Instr(_x4) {
|
| 113 |
+
return _Instr.apply(this, arguments);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
Instr.toString = function () {
|
| 117 |
+
return _Instr.toString();
|
| 118 |
+
};
|
| 119 |
+
|
| 120 |
+
return Instr;
|
| 121 |
+
}(function (instrPath) {
|
| 122 |
+
var instrNode = instrPath.node;
|
| 123 |
+
/**
|
| 124 |
+
* Local access
|
| 125 |
+
*/
|
| 126 |
+
|
| 127 |
+
if (instrNode.id === "get_local" || instrNode.id === "set_local" || instrNode.id === "tee_local") {
|
| 128 |
+
var _instrNode$args = _slicedToArray(instrNode.args, 1),
|
| 129 |
+
firstArg = _instrNode$args[0];
|
| 130 |
+
|
| 131 |
+
if (firstArg.type === "Identifier") {
|
| 132 |
+
var offsetInParams = params.findIndex(function (_ref) {
|
| 133 |
+
var id = _ref.id;
|
| 134 |
+
return id === firstArg.value;
|
| 135 |
+
});
|
| 136 |
+
|
| 137 |
+
if (offsetInParams === -1) {
|
| 138 |
+
throw new Error("".concat(firstArg.value, " not found in ").concat(instrNode.id, ": not declared in func params"));
|
| 139 |
+
} // Replace the Identifer node by our new NumberLiteral node
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
instrNode.args[0] = (0, _index.numberLiteralFromRaw)(offsetInParams);
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
/**
|
| 146 |
+
* Global access
|
| 147 |
+
*/
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
if (instrNode.id === "get_global" || instrNode.id === "set_global") {
|
| 151 |
+
var _instrNode$args2 = _slicedToArray(instrNode.args, 1),
|
| 152 |
+
_firstArg = _instrNode$args2[0];
|
| 153 |
+
|
| 154 |
+
if ((0, _index.isIdentifier)(_firstArg) === true) {
|
| 155 |
+
var globalOffset = moduleContext.getGlobalOffsetByIdentifier( // $FlowIgnore: reference?
|
| 156 |
+
_firstArg.value);
|
| 157 |
+
|
| 158 |
+
if (typeof globalOffset === "undefined") {
|
| 159 |
+
// $FlowIgnore: reference?
|
| 160 |
+
throw new Error("global ".concat(_firstArg.value, " not found in module"));
|
| 161 |
+
} // Replace the Identifer node by our new NumberLiteral node
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
instrNode.args[0] = (0, _index.numberLiteralFromRaw)(globalOffset);
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
/**
|
| 168 |
+
* Labels lookup
|
| 169 |
+
*/
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
if (instrNode.id === "br") {
|
| 173 |
+
var _instrNode$args3 = _slicedToArray(instrNode.args, 1),
|
| 174 |
+
_firstArg2 = _instrNode$args3[0];
|
| 175 |
+
|
| 176 |
+
if ((0, _index.isIdentifier)(_firstArg2) === true) {
|
| 177 |
+
// if the labels is not found it is going to be replaced with -1
|
| 178 |
+
// which is invalid.
|
| 179 |
+
var relativeBlockCount = -1; // $FlowIgnore: reference?
|
| 180 |
+
|
| 181 |
+
instrPath.findParent(function (_ref2) {
|
| 182 |
+
var node = _ref2.node;
|
| 183 |
+
|
| 184 |
+
if ((0, _index.isBlock)(node)) {
|
| 185 |
+
relativeBlockCount++; // $FlowIgnore: reference?
|
| 186 |
+
|
| 187 |
+
var name = node.label || node.name;
|
| 188 |
+
|
| 189 |
+
if (_typeof(name) === "object") {
|
| 190 |
+
// $FlowIgnore: isIdentifier ensures that
|
| 191 |
+
if (name.value === _firstArg2.value) {
|
| 192 |
+
// Found it
|
| 193 |
+
return false;
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
if ((0, _index.isFunc)(node)) {
|
| 199 |
+
return false;
|
| 200 |
+
}
|
| 201 |
+
}); // Replace the Identifer node by our new NumberLiteral node
|
| 202 |
+
|
| 203 |
+
instrNode.args[0] = (0, _index.numberLiteralFromRaw)(relativeBlockCount);
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
}),
|
| 207 |
+
|
| 208 |
+
/**
|
| 209 |
+
* Func lookup
|
| 210 |
+
*/
|
| 211 |
+
CallInstruction: function (_CallInstruction) {
|
| 212 |
+
function CallInstruction(_x5) {
|
| 213 |
+
return _CallInstruction.apply(this, arguments);
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
CallInstruction.toString = function () {
|
| 217 |
+
return _CallInstruction.toString();
|
| 218 |
+
};
|
| 219 |
+
|
| 220 |
+
return CallInstruction;
|
| 221 |
+
}(function (_ref3) {
|
| 222 |
+
var node = _ref3.node;
|
| 223 |
+
var index = node.index;
|
| 224 |
+
|
| 225 |
+
if ((0, _index.isIdentifier)(index) === true) {
|
| 226 |
+
var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value);
|
| 227 |
+
|
| 228 |
+
if (typeof offsetInModule === "undefined") {
|
| 229 |
+
throw newUnexpectedFunction(index.value);
|
| 230 |
+
} // Replace the index Identifier
|
| 231 |
+
// $FlowIgnore: reference?
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
node.index = (0, _index.numberLiteralFromRaw)(offsetInModule);
|
| 235 |
+
}
|
| 236 |
+
})
|
| 237 |
+
});
|
| 238 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/traverse.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.traverse = traverse;
|
| 7 |
+
|
| 8 |
+
var _nodePath = require("./node-path");
|
| 9 |
+
|
| 10 |
+
var _nodes = require("./nodes");
|
| 11 |
+
|
| 12 |
+
// recursively walks the AST starting at the given node. The callback is invoked for
|
| 13 |
+
// and object that has a 'type' property.
|
| 14 |
+
function walk(context, callback) {
|
| 15 |
+
var stop = false;
|
| 16 |
+
|
| 17 |
+
function innerWalk(context, callback) {
|
| 18 |
+
if (stop) {
|
| 19 |
+
return;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
var node = context.node;
|
| 23 |
+
|
| 24 |
+
if (node === undefined) {
|
| 25 |
+
console.warn("traversing with an empty context");
|
| 26 |
+
return;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
if (node._deleted === true) {
|
| 30 |
+
return;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
var path = (0, _nodePath.createPath)(context);
|
| 34 |
+
callback(node.type, path);
|
| 35 |
+
|
| 36 |
+
if (path.shouldStop) {
|
| 37 |
+
stop = true;
|
| 38 |
+
return;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
Object.keys(node).forEach(function (prop) {
|
| 42 |
+
var value = node[prop];
|
| 43 |
+
|
| 44 |
+
if (value === null || value === undefined) {
|
| 45 |
+
return;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
var valueAsArray = Array.isArray(value) ? value : [value];
|
| 49 |
+
valueAsArray.forEach(function (childNode) {
|
| 50 |
+
if (typeof childNode.type === "string") {
|
| 51 |
+
var childContext = {
|
| 52 |
+
node: childNode,
|
| 53 |
+
parentKey: prop,
|
| 54 |
+
parentPath: path,
|
| 55 |
+
shouldStop: false,
|
| 56 |
+
inList: Array.isArray(value)
|
| 57 |
+
};
|
| 58 |
+
innerWalk(childContext, callback);
|
| 59 |
+
}
|
| 60 |
+
});
|
| 61 |
+
});
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
innerWalk(context, callback);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
var noop = function noop() {};
|
| 68 |
+
|
| 69 |
+
function traverse(node, visitors) {
|
| 70 |
+
var before = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
|
| 71 |
+
var after = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop;
|
| 72 |
+
Object.keys(visitors).forEach(function (visitor) {
|
| 73 |
+
if (!_nodes.nodeAndUnionTypes.includes(visitor)) {
|
| 74 |
+
throw new Error("Unexpected visitor ".concat(visitor));
|
| 75 |
+
}
|
| 76 |
+
});
|
| 77 |
+
var context = {
|
| 78 |
+
node: node,
|
| 79 |
+
inList: false,
|
| 80 |
+
shouldStop: false,
|
| 81 |
+
parentPath: null,
|
| 82 |
+
parentKey: null
|
| 83 |
+
};
|
| 84 |
+
walk(context, function (type, path) {
|
| 85 |
+
if (typeof visitors[type] === "function") {
|
| 86 |
+
before(type, path);
|
| 87 |
+
visitors[type](path);
|
| 88 |
+
after(type, path);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
var unionTypes = _nodes.unionTypesMap[type];
|
| 92 |
+
|
| 93 |
+
if (!unionTypes) {
|
| 94 |
+
throw new Error("Unexpected node type ".concat(type));
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
unionTypes.forEach(function (unionType) {
|
| 98 |
+
if (typeof visitors[unionType] === "function") {
|
| 99 |
+
before(unionType, path);
|
| 100 |
+
visitors[unionType](path);
|
| 101 |
+
after(unionType, path);
|
| 102 |
+
}
|
| 103 |
+
});
|
| 104 |
+
});
|
| 105 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/types/basic.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/types/nodes.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/lib/types/traverse.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/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+
exports.getSectionMetadata = getSectionMetadata;
|
| 8 |
+
exports.getSectionMetadatas = getSectionMetadatas;
|
| 9 |
+
exports.sortSectionMetadata = sortSectionMetadata;
|
| 10 |
+
exports.orderedInsertNode = orderedInsertNode;
|
| 11 |
+
exports.assertHasLoc = assertHasLoc;
|
| 12 |
+
exports.getEndOfSection = getEndOfSection;
|
| 13 |
+
exports.shiftLoc = shiftLoc;
|
| 14 |
+
exports.shiftSection = shiftSection;
|
| 15 |
+
exports.signatureForOpcode = signatureForOpcode;
|
| 16 |
+
exports.getUniqueNameGenerator = getUniqueNameGenerator;
|
| 17 |
+
exports.getStartByteOffset = getStartByteOffset;
|
| 18 |
+
exports.getEndByteOffset = getEndByteOffset;
|
| 19 |
+
exports.getFunctionBeginingByteOffset = getFunctionBeginingByteOffset;
|
| 20 |
+
exports.getEndBlockByteOffset = getEndBlockByteOffset;
|
| 21 |
+
exports.getStartBlockByteOffset = getStartBlockByteOffset;
|
| 22 |
+
|
| 23 |
+
var _signatures = require("./signatures");
|
| 24 |
+
|
| 25 |
+
var _traverse = require("./traverse");
|
| 26 |
+
|
| 27 |
+
var _helperWasmBytecode = _interopRequireWildcard(require("@webassemblyjs/helper-wasm-bytecode"));
|
| 28 |
+
|
| 29 |
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
| 30 |
+
|
| 31 |
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
| 32 |
+
|
| 33 |
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
| 34 |
+
|
| 35 |
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
| 36 |
+
|
| 37 |
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
| 38 |
+
|
| 39 |
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
| 40 |
+
|
| 41 |
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
| 42 |
+
|
| 43 |
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
| 44 |
+
|
| 45 |
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
| 46 |
+
|
| 47 |
+
function isAnonymous(ident) {
|
| 48 |
+
return ident.raw === "";
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function getSectionMetadata(ast, name) {
|
| 52 |
+
var section;
|
| 53 |
+
(0, _traverse.traverse)(ast, {
|
| 54 |
+
SectionMetadata: function (_SectionMetadata) {
|
| 55 |
+
function SectionMetadata(_x) {
|
| 56 |
+
return _SectionMetadata.apply(this, arguments);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
SectionMetadata.toString = function () {
|
| 60 |
+
return _SectionMetadata.toString();
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
return SectionMetadata;
|
| 64 |
+
}(function (_ref) {
|
| 65 |
+
var node = _ref.node;
|
| 66 |
+
|
| 67 |
+
if (node.section === name) {
|
| 68 |
+
section = node;
|
| 69 |
+
}
|
| 70 |
+
})
|
| 71 |
+
});
|
| 72 |
+
return section;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
function getSectionMetadatas(ast, name) {
|
| 76 |
+
var sections = [];
|
| 77 |
+
(0, _traverse.traverse)(ast, {
|
| 78 |
+
SectionMetadata: function (_SectionMetadata2) {
|
| 79 |
+
function SectionMetadata(_x2) {
|
| 80 |
+
return _SectionMetadata2.apply(this, arguments);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
SectionMetadata.toString = function () {
|
| 84 |
+
return _SectionMetadata2.toString();
|
| 85 |
+
};
|
| 86 |
+
|
| 87 |
+
return SectionMetadata;
|
| 88 |
+
}(function (_ref2) {
|
| 89 |
+
var node = _ref2.node;
|
| 90 |
+
|
| 91 |
+
if (node.section === name) {
|
| 92 |
+
sections.push(node);
|
| 93 |
+
}
|
| 94 |
+
})
|
| 95 |
+
});
|
| 96 |
+
return sections;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
function sortSectionMetadata(m) {
|
| 100 |
+
if (m.metadata == null) {
|
| 101 |
+
console.warn("sortSectionMetadata: no metadata to sort");
|
| 102 |
+
return;
|
| 103 |
+
} // $FlowIgnore
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
m.metadata.sections.sort(function (a, b) {
|
| 107 |
+
var aId = _helperWasmBytecode["default"].sections[a.section];
|
| 108 |
+
var bId = _helperWasmBytecode["default"].sections[b.section];
|
| 109 |
+
|
| 110 |
+
if (typeof aId !== "number" || typeof bId !== "number") {
|
| 111 |
+
throw new Error("Section id not found");
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
return aId - bId;
|
| 115 |
+
});
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
function orderedInsertNode(m, n) {
|
| 119 |
+
assertHasLoc(n);
|
| 120 |
+
var didInsert = false;
|
| 121 |
+
|
| 122 |
+
if (n.type === "ModuleExport") {
|
| 123 |
+
m.fields.push(n);
|
| 124 |
+
return;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
m.fields = m.fields.reduce(function (acc, field) {
|
| 128 |
+
var fieldEndCol = Infinity;
|
| 129 |
+
|
| 130 |
+
if (field.loc != null) {
|
| 131 |
+
// $FlowIgnore
|
| 132 |
+
fieldEndCol = field.loc.end.column;
|
| 133 |
+
} // $FlowIgnore: assertHasLoc ensures that
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
if (didInsert === false && n.loc.start.column < fieldEndCol) {
|
| 137 |
+
didInsert = true;
|
| 138 |
+
acc.push(n);
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
acc.push(field);
|
| 142 |
+
return acc;
|
| 143 |
+
}, []); // Handles empty modules or n is the last element
|
| 144 |
+
|
| 145 |
+
if (didInsert === false) {
|
| 146 |
+
m.fields.push(n);
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
function assertHasLoc(n) {
|
| 151 |
+
if (n.loc == null || n.loc.start == null || n.loc.end == null) {
|
| 152 |
+
throw new Error("Internal failure: node (".concat(JSON.stringify(n.type), ") has no location information"));
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
function getEndOfSection(s) {
|
| 157 |
+
assertHasLoc(s.size);
|
| 158 |
+
return s.startOffset + s.size.value + (s.size.loc.end.column - s.size.loc.start.column);
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
function shiftLoc(node, delta) {
|
| 162 |
+
// $FlowIgnore
|
| 163 |
+
node.loc.start.column += delta; // $FlowIgnore
|
| 164 |
+
|
| 165 |
+
node.loc.end.column += delta;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
function shiftSection(ast, node, delta) {
|
| 169 |
+
if (node.type !== "SectionMetadata") {
|
| 170 |
+
throw new Error("Can not shift node " + JSON.stringify(node.type));
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
node.startOffset += delta;
|
| 174 |
+
|
| 175 |
+
if (_typeof(node.size.loc) === "object") {
|
| 176 |
+
shiftLoc(node.size, delta);
|
| 177 |
+
} // Custom sections doesn't have vectorOfSize
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
if (_typeof(node.vectorOfSize) === "object" && _typeof(node.vectorOfSize.loc) === "object") {
|
| 181 |
+
shiftLoc(node.vectorOfSize, delta);
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
var sectionName = node.section; // shift node locations within that section
|
| 185 |
+
|
| 186 |
+
(0, _traverse.traverse)(ast, {
|
| 187 |
+
Node: function Node(_ref3) {
|
| 188 |
+
var node = _ref3.node;
|
| 189 |
+
var section = (0, _helperWasmBytecode.getSectionForNode)(node);
|
| 190 |
+
|
| 191 |
+
if (section === sectionName && _typeof(node.loc) === "object") {
|
| 192 |
+
shiftLoc(node, delta);
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
});
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
function signatureForOpcode(object, name) {
|
| 199 |
+
var opcodeName = name;
|
| 200 |
+
|
| 201 |
+
if (object !== undefined && object !== "") {
|
| 202 |
+
opcodeName = object + "." + name;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
var sign = _signatures.signatures[opcodeName];
|
| 206 |
+
|
| 207 |
+
if (sign == undefined) {
|
| 208 |
+
// TODO: Uncomment this when br_table and others has been done
|
| 209 |
+
//throw new Error("Invalid opcode: "+opcodeName);
|
| 210 |
+
return [object, object];
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
return sign[0];
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
function getUniqueNameGenerator() {
|
| 217 |
+
var inc = {};
|
| 218 |
+
return function () {
|
| 219 |
+
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "temp";
|
| 220 |
+
|
| 221 |
+
if (!(prefix in inc)) {
|
| 222 |
+
inc[prefix] = 0;
|
| 223 |
+
} else {
|
| 224 |
+
inc[prefix] = inc[prefix] + 1;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
return prefix + "_" + inc[prefix];
|
| 228 |
+
};
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
function getStartByteOffset(n) {
|
| 232 |
+
// $FlowIgnore
|
| 233 |
+
if (typeof n.loc === "undefined" || typeof n.loc.start === "undefined") {
|
| 234 |
+
throw new Error( // $FlowIgnore
|
| 235 |
+
"Can not get byte offset without loc informations, node: " + String(n.id));
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
return n.loc.start.column;
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
function getEndByteOffset(n) {
|
| 242 |
+
// $FlowIgnore
|
| 243 |
+
if (typeof n.loc === "undefined" || typeof n.loc.end === "undefined") {
|
| 244 |
+
throw new Error("Can not get byte offset without loc informations, node: " + n.type);
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
return n.loc.end.column;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
function getFunctionBeginingByteOffset(n) {
|
| 251 |
+
if (!(n.body.length > 0)) {
|
| 252 |
+
throw new Error('n.body.length > 0' + " error: " + (undefined || "unknown"));
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
var _n$body = _slicedToArray(n.body, 1),
|
| 256 |
+
firstInstruction = _n$body[0];
|
| 257 |
+
|
| 258 |
+
return getStartByteOffset(firstInstruction);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
function getEndBlockByteOffset(n) {
|
| 262 |
+
// $FlowIgnore
|
| 263 |
+
if (!(n.instr.length > 0 || n.body.length > 0)) {
|
| 264 |
+
throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown"));
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
var lastInstruction;
|
| 268 |
+
|
| 269 |
+
if (n.instr) {
|
| 270 |
+
// $FlowIgnore
|
| 271 |
+
lastInstruction = n.instr[n.instr.length - 1];
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
if (n.body) {
|
| 275 |
+
// $FlowIgnore
|
| 276 |
+
lastInstruction = n.body[n.body.length - 1];
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
if (!(_typeof(lastInstruction) === "object")) {
|
| 280 |
+
throw new Error('typeof lastInstruction === "object"' + " error: " + (undefined || "unknown"));
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
// $FlowIgnore
|
| 284 |
+
return getStartByteOffset(lastInstruction);
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
function getStartBlockByteOffset(n) {
|
| 288 |
+
// $FlowIgnore
|
| 289 |
+
if (!(n.instr.length > 0 || n.body.length > 0)) {
|
| 290 |
+
throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown"));
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
var fistInstruction;
|
| 294 |
+
|
| 295 |
+
if (n.instr) {
|
| 296 |
+
// $FlowIgnore
|
| 297 |
+
var _n$instr = _slicedToArray(n.instr, 1);
|
| 298 |
+
|
| 299 |
+
fistInstruction = _n$instr[0];
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
if (n.body) {
|
| 303 |
+
// $FlowIgnore
|
| 304 |
+
var _n$body2 = _slicedToArray(n.body, 1);
|
| 305 |
+
|
| 306 |
+
fistInstruction = _n$body2[0];
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
if (!(_typeof(fistInstruction) === "object")) {
|
| 310 |
+
throw new Error('typeof fistInstruction === "object"' + " error: " + (undefined || "unknown"));
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
// $FlowIgnore
|
| 314 |
+
return getStartByteOffset(fistInstruction);
|
| 315 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@webassemblyjs/ast",
|
| 3 |
+
"version": "1.14.1",
|
| 4 |
+
"description": "AST utils for webassemblyjs",
|
| 5 |
+
"keywords": [
|
| 6 |
+
"webassembly",
|
| 7 |
+
"javascript",
|
| 8 |
+
"ast"
|
| 9 |
+
],
|
| 10 |
+
"main": "lib/index.js",
|
| 11 |
+
"module": "esm/index.js",
|
| 12 |
+
"author": "Sven Sauleau",
|
| 13 |
+
"license": "MIT",
|
| 14 |
+
"dependencies": {
|
| 15 |
+
"@webassemblyjs/helper-numbers": "1.13.2",
|
| 16 |
+
"@webassemblyjs/helper-wasm-bytecode": "1.13.2"
|
| 17 |
+
},
|
| 18 |
+
"repository": {
|
| 19 |
+
"type": "git",
|
| 20 |
+
"url": "https://github.com/xtuc/webassemblyjs.git"
|
| 21 |
+
},
|
| 22 |
+
"publishConfig": {
|
| 23 |
+
"access": "public"
|
| 24 |
+
},
|
| 25 |
+
"devDependencies": {
|
| 26 |
+
"@webassemblyjs/helper-test-framework": "1.14.1",
|
| 27 |
+
"array.prototype.flatmap": "^1.2.1",
|
| 28 |
+
"dump-exports": "^0.1.0",
|
| 29 |
+
"mamacro": "^0.0.7"
|
| 30 |
+
},
|
| 31 |
+
"gitHead": "25d52b1296e151ac56244a7c3886661e6b4a69ea"
|
| 32 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/scripts/generateNodeUtils.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const definitions = require("../src/definitions");
|
| 2 |
+
const flatMap = require("array.prototype.flatmap");
|
| 3 |
+
const {
|
| 4 |
+
typeSignature,
|
| 5 |
+
iterateProps,
|
| 6 |
+
mapProps,
|
| 7 |
+
filterProps,
|
| 8 |
+
unique,
|
| 9 |
+
} = require("./util");
|
| 10 |
+
|
| 11 |
+
const stdout = process.stdout;
|
| 12 |
+
|
| 13 |
+
const jsTypes = ["string", "number", "boolean"];
|
| 14 |
+
|
| 15 |
+
const quote = (value) => `"${value}"`;
|
| 16 |
+
|
| 17 |
+
function params(fields) {
|
| 18 |
+
const optionalDefault = (field) =>
|
| 19 |
+
field.default ? ` = ${field.default}` : "";
|
| 20 |
+
return mapProps(fields)
|
| 21 |
+
.map((field) => `${typeSignature(field)}${optionalDefault(field)}`)
|
| 22 |
+
.join(",");
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
function assertParamType({ assertNodeType, array, name, type }) {
|
| 26 |
+
if (array) {
|
| 27 |
+
// TODO - assert contents of array?
|
| 28 |
+
return `assert(typeof ${name} === "object" && typeof ${name}.length !== "undefined")\n`;
|
| 29 |
+
} else {
|
| 30 |
+
if (jsTypes.includes(type)) {
|
| 31 |
+
return `assert(
|
| 32 |
+
typeof ${name} === "${type}",
|
| 33 |
+
"Argument ${name} must be of type ${type}, given: " + typeof ${name}
|
| 34 |
+
)`;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
if (assertNodeType === true) {
|
| 38 |
+
return `assert(
|
| 39 |
+
${name}.type === "${type}",
|
| 40 |
+
"Argument ${name} must be of type ${type}, given: " + ${name}.type
|
| 41 |
+
)`;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
return "";
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
function assertParam(meta) {
|
| 49 |
+
const paramAssertion = assertParamType(meta);
|
| 50 |
+
|
| 51 |
+
if (paramAssertion === "") {
|
| 52 |
+
return "";
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
if (meta.maybe || meta.optional) {
|
| 56 |
+
return `
|
| 57 |
+
if (${meta.name} !== null && ${meta.name} !== undefined) {
|
| 58 |
+
${paramAssertion};
|
| 59 |
+
}
|
| 60 |
+
`;
|
| 61 |
+
} else {
|
| 62 |
+
return paramAssertion;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
function assertParams(fields) {
|
| 67 |
+
return mapProps(fields).map(assertParam).join("\n");
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
function buildObject(typeDef) {
|
| 71 |
+
const optionalField = (meta) => {
|
| 72 |
+
if (meta.array) {
|
| 73 |
+
// omit optional array properties if the constructor function was supplied
|
| 74 |
+
// with an empty array
|
| 75 |
+
return `
|
| 76 |
+
if (typeof ${meta.name} !== "undefined" && ${meta.name}.length > 0) {
|
| 77 |
+
node.${meta.name} = ${meta.name};
|
| 78 |
+
}
|
| 79 |
+
`;
|
| 80 |
+
} else if (meta.type === "Object") {
|
| 81 |
+
// omit optional object properties if they have no keys
|
| 82 |
+
return `
|
| 83 |
+
if (typeof ${meta.name} !== "undefined" && Object.keys(${meta.name}).length !== 0) {
|
| 84 |
+
node.${meta.name} = ${meta.name};
|
| 85 |
+
}
|
| 86 |
+
`;
|
| 87 |
+
} else if (meta.type === "boolean") {
|
| 88 |
+
// omit optional boolean properties if they are not true
|
| 89 |
+
return `
|
| 90 |
+
if (${meta.name} === true) {
|
| 91 |
+
node.${meta.name} = true;
|
| 92 |
+
}
|
| 93 |
+
`;
|
| 94 |
+
} else {
|
| 95 |
+
return `
|
| 96 |
+
if (typeof ${meta.name} !== "undefined") {
|
| 97 |
+
node.${meta.name} = ${meta.name};
|
| 98 |
+
}
|
| 99 |
+
`;
|
| 100 |
+
}
|
| 101 |
+
};
|
| 102 |
+
|
| 103 |
+
const fields = mapProps(typeDef.fields)
|
| 104 |
+
.filter((f) => !f.optional && !f.constant)
|
| 105 |
+
.map((f) => f.name);
|
| 106 |
+
|
| 107 |
+
const constants = mapProps(typeDef.fields)
|
| 108 |
+
.filter((f) => f.constant)
|
| 109 |
+
.map((f) => `${f.name}: "${f.value}"`);
|
| 110 |
+
|
| 111 |
+
return `
|
| 112 |
+
const node: ${typeDef.flowTypeName || typeDef.name} = {
|
| 113 |
+
type: "${typeDef.name}",
|
| 114 |
+
${constants.concat(fields).join(",")}
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
${mapProps(typeDef.fields)
|
| 118 |
+
.filter((f) => f.optional)
|
| 119 |
+
.map(optionalField)
|
| 120 |
+
.join("")}
|
| 121 |
+
`;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
function lowerCamelCase(name) {
|
| 125 |
+
return name.substring(0, 1).toLowerCase() + name.substring(1);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
function generate() {
|
| 129 |
+
stdout.write(`
|
| 130 |
+
// @flow
|
| 131 |
+
|
| 132 |
+
// THIS FILE IS AUTOGENERATED
|
| 133 |
+
// see scripts/generateNodeUtils.js
|
| 134 |
+
|
| 135 |
+
import { assert } from "mamacro";
|
| 136 |
+
|
| 137 |
+
function isTypeOf(t: string) {
|
| 138 |
+
return (n: Node) => n.type === t;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
function assertTypeOf(t: string) {
|
| 142 |
+
return (n: Node) => assert(n.type === t);
|
| 143 |
+
}
|
| 144 |
+
`);
|
| 145 |
+
|
| 146 |
+
// Node builders
|
| 147 |
+
iterateProps(definitions, (typeDefinition) => {
|
| 148 |
+
stdout.write(`
|
| 149 |
+
export function ${lowerCamelCase(typeDefinition.name)} (
|
| 150 |
+
${params(filterProps(typeDefinition.fields, (f) => !f.constant))}
|
| 151 |
+
): ${typeDefinition.name} {
|
| 152 |
+
|
| 153 |
+
${assertParams(filterProps(typeDefinition.fields, (f) => !f.constant))}
|
| 154 |
+
${buildObject(typeDefinition)}
|
| 155 |
+
|
| 156 |
+
return node;
|
| 157 |
+
}
|
| 158 |
+
`);
|
| 159 |
+
});
|
| 160 |
+
|
| 161 |
+
// Node testers
|
| 162 |
+
iterateProps(definitions, (typeDefinition) => {
|
| 163 |
+
stdout.write(`
|
| 164 |
+
export const is${typeDefinition.name}: ((n: Node) => boolean) =
|
| 165 |
+
isTypeOf("${typeDefinition.name}");
|
| 166 |
+
`);
|
| 167 |
+
});
|
| 168 |
+
|
| 169 |
+
// Node union type testers
|
| 170 |
+
const unionTypes = unique(
|
| 171 |
+
flatMap(
|
| 172 |
+
mapProps(definitions).filter((d) => d.unionType),
|
| 173 |
+
(d) => d.unionType
|
| 174 |
+
)
|
| 175 |
+
);
|
| 176 |
+
unionTypes.forEach((unionType) => {
|
| 177 |
+
stdout.write(
|
| 178 |
+
`
|
| 179 |
+
export const is${unionType} = (node: Node): boolean => ` +
|
| 180 |
+
mapProps(definitions)
|
| 181 |
+
.filter((d) => d.unionType && d.unionType.includes(unionType))
|
| 182 |
+
.map((d) => `is${d.name}(node) `)
|
| 183 |
+
.join("||") +
|
| 184 |
+
";\n\n"
|
| 185 |
+
);
|
| 186 |
+
});
|
| 187 |
+
|
| 188 |
+
// Node assertion
|
| 189 |
+
iterateProps(definitions, (typeDefinition) => {
|
| 190 |
+
stdout.write(`
|
| 191 |
+
export const assert${typeDefinition.name}: ((n: Node) => void) =
|
| 192 |
+
assertTypeOf("${typeDefinition.name}");
|
| 193 |
+
`);
|
| 194 |
+
});
|
| 195 |
+
|
| 196 |
+
// a map from node type to its set of union types
|
| 197 |
+
stdout.write(
|
| 198 |
+
`
|
| 199 |
+
export const unionTypesMap = {` +
|
| 200 |
+
mapProps(definitions)
|
| 201 |
+
.filter((d) => d.unionType)
|
| 202 |
+
.map((t) => `"${t.name}": [${t.unionType.map(quote).join(",")}]\n`) +
|
| 203 |
+
`};
|
| 204 |
+
`
|
| 205 |
+
);
|
| 206 |
+
|
| 207 |
+
// an array of all node and union types
|
| 208 |
+
stdout.write(
|
| 209 |
+
`
|
| 210 |
+
export const nodeAndUnionTypes = [` +
|
| 211 |
+
mapProps(definitions)
|
| 212 |
+
.map((t) => `"${t.name}"`)
|
| 213 |
+
.concat(unionTypes.map(quote))
|
| 214 |
+
.join(",") +
|
| 215 |
+
`];`
|
| 216 |
+
);
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
generate();
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/scripts/generateTypeDefinitions.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const definitions = require("../src/definitions");
|
| 2 |
+
const flatMap = require("array.prototype.flatmap");
|
| 3 |
+
const { typeSignature, mapProps, iterateProps, unique } = require("./util");
|
| 4 |
+
|
| 5 |
+
const stdout = process.stdout;
|
| 6 |
+
|
| 7 |
+
function params(fields) {
|
| 8 |
+
return mapProps(fields).map(typeSignature).join(",");
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function generate() {
|
| 12 |
+
stdout.write(`
|
| 13 |
+
// @flow
|
| 14 |
+
/* eslint no-unused-vars: off */
|
| 15 |
+
|
| 16 |
+
// THIS FILE IS AUTOGENERATED
|
| 17 |
+
// see scripts/generateTypeDefinitions.js
|
| 18 |
+
`);
|
| 19 |
+
|
| 20 |
+
// generate union types
|
| 21 |
+
const unionTypes = unique(
|
| 22 |
+
flatMap(
|
| 23 |
+
mapProps(definitions).filter((d) => d.unionType),
|
| 24 |
+
(d) => d.unionType
|
| 25 |
+
)
|
| 26 |
+
);
|
| 27 |
+
unionTypes.forEach((unionType) => {
|
| 28 |
+
stdout.write(
|
| 29 |
+
`type ${unionType} = ` +
|
| 30 |
+
mapProps(definitions)
|
| 31 |
+
.filter((d) => d.unionType && d.unionType.includes(unionType))
|
| 32 |
+
.map((d) => d.name)
|
| 33 |
+
.join("|") +
|
| 34 |
+
";\n\n"
|
| 35 |
+
);
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
// generate the type definitions
|
| 39 |
+
iterateProps(definitions, (typeDef) => {
|
| 40 |
+
stdout.write(`type ${typeDef.name} = {
|
| 41 |
+
...BaseNode,
|
| 42 |
+
type: "${typeDef.name}",
|
| 43 |
+
${params(typeDef.fields)}
|
| 44 |
+
};\n\n`);
|
| 45 |
+
});
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
generate();
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/ast/scripts/util.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function iterateProps(obj, iterator) {
|
| 2 |
+
Object.keys(obj).forEach((key) => iterator({ ...obj[key], name: key }));
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
function mapProps(obj) {
|
| 6 |
+
return Object.keys(obj).map((key) => ({ ...obj[key], name: key }));
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
function filterProps(obj, filter) {
|
| 10 |
+
const ret = {};
|
| 11 |
+
Object.keys(obj).forEach((key) => {
|
| 12 |
+
if (filter(obj[key])) {
|
| 13 |
+
ret[key] = obj[key];
|
| 14 |
+
}
|
| 15 |
+
});
|
| 16 |
+
return ret;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function typeSignature(meta) {
|
| 20 |
+
const type = meta.array ? `Array<${meta.type}>` : meta.type;
|
| 21 |
+
if (meta.optional) {
|
| 22 |
+
return `${meta.name}?: ${type}`;
|
| 23 |
+
} else if (meta.maybe) {
|
| 24 |
+
return `${meta.name}: ?${type}`;
|
| 25 |
+
} else {
|
| 26 |
+
return `${meta.name}: ${type}`;
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
const unique = (items) => Array.from(new Set(items));
|
| 31 |
+
|
| 32 |
+
module.exports = {
|
| 33 |
+
iterateProps,
|
| 34 |
+
mapProps,
|
| 35 |
+
filterProps,
|
| 36 |
+
typeSignature,
|
| 37 |
+
unique,
|
| 38 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2017 Mauro Bringolf
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Parser function for floating point hexadecimals
|
| 2 |
+
|
| 3 |
+
[]()
|
| 4 |
+
[]()
|
| 5 |
+
[]()
|
| 6 |
+
|
| 7 |
+
> A JavaScript function to parse floating point hexadecimals as defined by the [WebAssembly specification](https://webassembly.github.io/spec/core/text/values.html#text-hexfloat).
|
| 8 |
+
|
| 9 |
+
## Usage
|
| 10 |
+
|
| 11 |
+
```javascript
|
| 12 |
+
import parseHexFloat from '@webassemblyjs/floating-point-hex-parser'
|
| 13 |
+
|
| 14 |
+
parseHexFloat('0x1p-1') // 0.5
|
| 15 |
+
parseHexFloat('0x1.921fb54442d18p+2') // 6.283185307179586
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
## Tests
|
| 19 |
+
|
| 20 |
+
This module is tested in two ways. The first one is through a small set of test cases that can be found in [test/regular.test.js](https://github.com/maurobringolf/@webassemblyjs/floating-point-hex-parser/blob/master/test/regular.test.js). The second one is non-deterministic (sometimes called *fuzzing*):
|
| 21 |
+
|
| 22 |
+
1. Generate a random IEEE754 double precision value `x`.
|
| 23 |
+
1. Compute its representation `y` in floating point hexadecimal format using the C standard library function `printf` since C supports this format.
|
| 24 |
+
1. Give both values to JS testcase and see if `parseHexFloat(y) === x`.
|
| 25 |
+
|
| 26 |
+
By default one `npm test` run tests 100 random samples. If you want to do more, you can set the environment variable `FUZZ_AMOUNT` to whatever number of runs you'd like. Because it uses one child process for each sample, it is really slow though. For more details about the randomized tests see [the source](https://github.com/maurobringolf/@webassemblyjs/floating-point-hex-parser/tree/master/test/fuzzing).
|
| 27 |
+
|
| 28 |
+
## Links
|
| 29 |
+
|
| 30 |
+
* [maurobringolf.ch/2017/12/hexadecimal-floating-point-notation/](https://maurobringolf.ch/2017/12/hexadecimal-floating-point-notation/)
|
| 31 |
+
|
| 32 |
+
* [github.com/xtuc/js-webassembly-interpreter/issues/32](https://github.com/xtuc/js-webassembly-interpreter/issues/32)
|
| 33 |
+
|
| 34 |
+
* [github.com/WebAssembly/design/issues/292](https://github.com/WebAssembly/design/issues/292)
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/esm/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export default function parse(input) {
|
| 2 |
+
input = input.toUpperCase();
|
| 3 |
+
var splitIndex = input.indexOf("P");
|
| 4 |
+
var mantissa, exponent;
|
| 5 |
+
|
| 6 |
+
if (splitIndex !== -1) {
|
| 7 |
+
mantissa = input.substring(0, splitIndex);
|
| 8 |
+
exponent = parseInt(input.substring(splitIndex + 1));
|
| 9 |
+
} else {
|
| 10 |
+
mantissa = input;
|
| 11 |
+
exponent = 0;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
var dotIndex = mantissa.indexOf(".");
|
| 15 |
+
|
| 16 |
+
if (dotIndex !== -1) {
|
| 17 |
+
var integerPart = parseInt(mantissa.substring(0, dotIndex), 16);
|
| 18 |
+
var sign = Math.sign(integerPart);
|
| 19 |
+
integerPart = sign * integerPart;
|
| 20 |
+
var fractionLength = mantissa.length - dotIndex - 1;
|
| 21 |
+
var fractionalPart = parseInt(mantissa.substring(dotIndex + 1), 16);
|
| 22 |
+
var fraction = fractionLength > 0 ? fractionalPart / Math.pow(16, fractionLength) : 0;
|
| 23 |
+
|
| 24 |
+
if (sign === 0) {
|
| 25 |
+
if (fraction === 0) {
|
| 26 |
+
mantissa = sign;
|
| 27 |
+
} else {
|
| 28 |
+
if (Object.is(sign, -0)) {
|
| 29 |
+
mantissa = -fraction;
|
| 30 |
+
} else {
|
| 31 |
+
mantissa = fraction;
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
} else {
|
| 35 |
+
mantissa = sign * (integerPart + fraction);
|
| 36 |
+
}
|
| 37 |
+
} else {
|
| 38 |
+
mantissa = parseInt(mantissa, 16);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
return mantissa * (splitIndex !== -1 ? Math.pow(2, exponent) : 1);
|
| 42 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/lib/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports["default"] = parse;
|
| 7 |
+
|
| 8 |
+
function parse(input) {
|
| 9 |
+
input = input.toUpperCase();
|
| 10 |
+
var splitIndex = input.indexOf("P");
|
| 11 |
+
var mantissa, exponent;
|
| 12 |
+
|
| 13 |
+
if (splitIndex !== -1) {
|
| 14 |
+
mantissa = input.substring(0, splitIndex);
|
| 15 |
+
exponent = parseInt(input.substring(splitIndex + 1));
|
| 16 |
+
} else {
|
| 17 |
+
mantissa = input;
|
| 18 |
+
exponent = 0;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
var dotIndex = mantissa.indexOf(".");
|
| 22 |
+
|
| 23 |
+
if (dotIndex !== -1) {
|
| 24 |
+
var integerPart = parseInt(mantissa.substring(0, dotIndex), 16);
|
| 25 |
+
var sign = Math.sign(integerPart);
|
| 26 |
+
integerPart = sign * integerPart;
|
| 27 |
+
var fractionLength = mantissa.length - dotIndex - 1;
|
| 28 |
+
var fractionalPart = parseInt(mantissa.substring(dotIndex + 1), 16);
|
| 29 |
+
var fraction = fractionLength > 0 ? fractionalPart / Math.pow(16, fractionLength) : 0;
|
| 30 |
+
|
| 31 |
+
if (sign === 0) {
|
| 32 |
+
if (fraction === 0) {
|
| 33 |
+
mantissa = sign;
|
| 34 |
+
} else {
|
| 35 |
+
if (Object.is(sign, -0)) {
|
| 36 |
+
mantissa = -fraction;
|
| 37 |
+
} else {
|
| 38 |
+
mantissa = fraction;
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
} else {
|
| 42 |
+
mantissa = sign * (integerPart + fraction);
|
| 43 |
+
}
|
| 44 |
+
} else {
|
| 45 |
+
mantissa = parseInt(mantissa, 16);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
return mantissa * (splitIndex !== -1 ? Math.pow(2, exponent) : 1);
|
| 49 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/floating-point-hex-parser/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@webassemblyjs/floating-point-hex-parser",
|
| 3 |
+
"scripts": {
|
| 4 |
+
"build-fuzzer": "[ -f ./test/fuzzing/parse.out ] || gcc ./test/fuzzing/parse.c -o ./test/fuzzing/parse.out -lm -Wall"
|
| 5 |
+
},
|
| 6 |
+
"repository": {
|
| 7 |
+
"type": "git",
|
| 8 |
+
"url": "https://github.com/xtuc/webassemblyjs.git"
|
| 9 |
+
},
|
| 10 |
+
"publishConfig": {
|
| 11 |
+
"access": "public"
|
| 12 |
+
},
|
| 13 |
+
"version": "1.13.2",
|
| 14 |
+
"description": "A function to parse floating point hexadecimal strings as defined by the WebAssembly specification",
|
| 15 |
+
"main": "lib/index.js",
|
| 16 |
+
"module": "esm/index.js",
|
| 17 |
+
"keywords": [
|
| 18 |
+
"webassembly",
|
| 19 |
+
"floating-point"
|
| 20 |
+
],
|
| 21 |
+
"author": "Mauro Bringolf",
|
| 22 |
+
"license": "MIT",
|
| 23 |
+
"gitHead": "897aeb784f042a46a00626f1d1cca96159aa5db3"
|
| 24 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-api-error/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018 Sven Sauleau <sven@sauleau.com>
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-api-error/esm/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
| 2 |
+
|
| 3 |
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
| 4 |
+
|
| 5 |
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
| 6 |
+
|
| 7 |
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
| 8 |
+
|
| 9 |
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
| 10 |
+
|
| 11 |
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
| 12 |
+
|
| 13 |
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
| 14 |
+
|
| 15 |
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
| 16 |
+
|
| 17 |
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
| 18 |
+
|
| 19 |
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
| 20 |
+
|
| 21 |
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
| 22 |
+
|
| 23 |
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
| 24 |
+
|
| 25 |
+
export var RuntimeError = /*#__PURE__*/function (_Error) {
|
| 26 |
+
_inherits(RuntimeError, _Error);
|
| 27 |
+
|
| 28 |
+
var _super = _createSuper(RuntimeError);
|
| 29 |
+
|
| 30 |
+
function RuntimeError() {
|
| 31 |
+
_classCallCheck(this, RuntimeError);
|
| 32 |
+
|
| 33 |
+
return _super.apply(this, arguments);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
return RuntimeError;
|
| 37 |
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
| 38 |
+
export var CompileError = /*#__PURE__*/function (_Error2) {
|
| 39 |
+
_inherits(CompileError, _Error2);
|
| 40 |
+
|
| 41 |
+
var _super2 = _createSuper(CompileError);
|
| 42 |
+
|
| 43 |
+
function CompileError() {
|
| 44 |
+
_classCallCheck(this, CompileError);
|
| 45 |
+
|
| 46 |
+
return _super2.apply(this, arguments);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
return CompileError;
|
| 50 |
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
| 51 |
+
export var LinkError = /*#__PURE__*/function (_Error3) {
|
| 52 |
+
_inherits(LinkError, _Error3);
|
| 53 |
+
|
| 54 |
+
var _super3 = _createSuper(LinkError);
|
| 55 |
+
|
| 56 |
+
function LinkError() {
|
| 57 |
+
_classCallCheck(this, LinkError);
|
| 58 |
+
|
| 59 |
+
return _super3.apply(this, arguments);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
return LinkError;
|
| 63 |
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-api-error/lib/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
| 4 |
+
|
| 5 |
+
Object.defineProperty(exports, "__esModule", {
|
| 6 |
+
value: true
|
| 7 |
+
});
|
| 8 |
+
exports.LinkError = exports.CompileError = exports.RuntimeError = void 0;
|
| 9 |
+
|
| 10 |
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
| 11 |
+
|
| 12 |
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
| 13 |
+
|
| 14 |
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
| 15 |
+
|
| 16 |
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
| 17 |
+
|
| 18 |
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
| 19 |
+
|
| 20 |
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
| 21 |
+
|
| 22 |
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
| 23 |
+
|
| 24 |
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
| 25 |
+
|
| 26 |
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
| 27 |
+
|
| 28 |
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
| 29 |
+
|
| 30 |
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
| 31 |
+
|
| 32 |
+
var RuntimeError = /*#__PURE__*/function (_Error) {
|
| 33 |
+
_inherits(RuntimeError, _Error);
|
| 34 |
+
|
| 35 |
+
var _super = _createSuper(RuntimeError);
|
| 36 |
+
|
| 37 |
+
function RuntimeError() {
|
| 38 |
+
_classCallCheck(this, RuntimeError);
|
| 39 |
+
|
| 40 |
+
return _super.apply(this, arguments);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
return RuntimeError;
|
| 44 |
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
| 45 |
+
|
| 46 |
+
exports.RuntimeError = RuntimeError;
|
| 47 |
+
|
| 48 |
+
var CompileError = /*#__PURE__*/function (_Error2) {
|
| 49 |
+
_inherits(CompileError, _Error2);
|
| 50 |
+
|
| 51 |
+
var _super2 = _createSuper(CompileError);
|
| 52 |
+
|
| 53 |
+
function CompileError() {
|
| 54 |
+
_classCallCheck(this, CompileError);
|
| 55 |
+
|
| 56 |
+
return _super2.apply(this, arguments);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
return CompileError;
|
| 60 |
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
| 61 |
+
|
| 62 |
+
exports.CompileError = CompileError;
|
| 63 |
+
|
| 64 |
+
var LinkError = /*#__PURE__*/function (_Error3) {
|
| 65 |
+
_inherits(LinkError, _Error3);
|
| 66 |
+
|
| 67 |
+
var _super3 = _createSuper(LinkError);
|
| 68 |
+
|
| 69 |
+
function LinkError() {
|
| 70 |
+
_classCallCheck(this, LinkError);
|
| 71 |
+
|
| 72 |
+
return _super3.apply(this, arguments);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
return LinkError;
|
| 76 |
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
| 77 |
+
|
| 78 |
+
exports.LinkError = LinkError;
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-api-error/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@webassemblyjs/helper-api-error",
|
| 3 |
+
"version": "1.13.2",
|
| 4 |
+
"description": "Common API errors",
|
| 5 |
+
"main": "lib/index.js",
|
| 6 |
+
"module": "esm/index.js",
|
| 7 |
+
"author": "Sven Sauleau",
|
| 8 |
+
"license": "MIT",
|
| 9 |
+
"repository": {
|
| 10 |
+
"type": "git",
|
| 11 |
+
"url": "https://github.com/xtuc/webassemblyjs.git",
|
| 12 |
+
"directory": "packages/helper-api-error"
|
| 13 |
+
},
|
| 14 |
+
"publishConfig": {
|
| 15 |
+
"access": "public"
|
| 16 |
+
},
|
| 17 |
+
"gitHead": "897aeb784f042a46a00626f1d1cca96159aa5db3"
|
| 18 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018 Sven Sauleau <sven@sauleau.com>
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/esm/compare.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// this are dev dependencies
|
| 2 |
+
var diff = require("jest-diff");
|
| 3 |
+
|
| 4 |
+
var _require = require("jest-diff/build/constants"),
|
| 5 |
+
NO_DIFF_MESSAGE = _require.NO_DIFF_MESSAGE;
|
| 6 |
+
|
| 7 |
+
var _require2 = require("@webassemblyjs/wasm-parser"),
|
| 8 |
+
decode = _require2.decode;
|
| 9 |
+
|
| 10 |
+
var oldConsoleLog = console.log;
|
| 11 |
+
export function compareArrayBuffers(l, r) {
|
| 12 |
+
/**
|
| 13 |
+
* Decode left
|
| 14 |
+
*/
|
| 15 |
+
var bufferL = "";
|
| 16 |
+
|
| 17 |
+
console.log = function () {
|
| 18 |
+
for (var _len = arguments.length, texts = new Array(_len), _key = 0; _key < _len; _key++) {
|
| 19 |
+
texts[_key] = arguments[_key];
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
return bufferL += texts.join("") + "\n";
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
try {
|
| 26 |
+
decode(l, {
|
| 27 |
+
dump: true
|
| 28 |
+
});
|
| 29 |
+
} catch (e) {
|
| 30 |
+
console.error(bufferL);
|
| 31 |
+
console.error(e);
|
| 32 |
+
throw e;
|
| 33 |
+
}
|
| 34 |
+
/**
|
| 35 |
+
* Decode right
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
var bufferR = "";
|
| 40 |
+
|
| 41 |
+
console.log = function () {
|
| 42 |
+
for (var _len2 = arguments.length, texts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
| 43 |
+
texts[_key2] = arguments[_key2];
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return bufferR += texts.join("") + "\n";
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
try {
|
| 50 |
+
decode(r, {
|
| 51 |
+
dump: true
|
| 52 |
+
});
|
| 53 |
+
} catch (e) {
|
| 54 |
+
console.error(bufferR);
|
| 55 |
+
console.error(e);
|
| 56 |
+
throw e;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
console.log = oldConsoleLog;
|
| 60 |
+
var out = diff(bufferL, bufferR);
|
| 61 |
+
|
| 62 |
+
if (out !== null && out !== NO_DIFF_MESSAGE) {
|
| 63 |
+
throw new Error("\n" + out);
|
| 64 |
+
}
|
| 65 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/esm/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
| 2 |
+
|
| 3 |
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
| 4 |
+
|
| 5 |
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
| 6 |
+
|
| 7 |
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
| 8 |
+
|
| 9 |
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
| 10 |
+
|
| 11 |
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
| 12 |
+
|
| 13 |
+
function concatUint8Arrays() {
|
| 14 |
+
for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) {
|
| 15 |
+
arrays[_key] = arguments[_key];
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
var totalLength = arrays.reduce(function (a, b) {
|
| 19 |
+
return a + b.length;
|
| 20 |
+
}, 0);
|
| 21 |
+
var result = new Uint8Array(totalLength);
|
| 22 |
+
var offset = 0;
|
| 23 |
+
|
| 24 |
+
for (var _i = 0, _arrays = arrays; _i < _arrays.length; _i++) {
|
| 25 |
+
var arr = _arrays[_i];
|
| 26 |
+
|
| 27 |
+
if (arr instanceof Uint8Array === false) {
|
| 28 |
+
throw new Error("arr must be of type Uint8Array");
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
result.set(arr, offset);
|
| 32 |
+
offset += arr.length;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
return result;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
export function overrideBytesInBuffer(buffer, startLoc, endLoc, newBytes) {
|
| 39 |
+
var beforeBytes = buffer.slice(0, startLoc);
|
| 40 |
+
var afterBytes = buffer.slice(endLoc, buffer.length); // replacement is empty, we can omit it
|
| 41 |
+
|
| 42 |
+
if (newBytes.length === 0) {
|
| 43 |
+
return concatUint8Arrays(beforeBytes, afterBytes);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
var replacement = Uint8Array.from(newBytes);
|
| 47 |
+
return concatUint8Arrays(beforeBytes, replacement, afterBytes);
|
| 48 |
+
}
|
| 49 |
+
export function makeBuffer() {
|
| 50 |
+
for (var _len2 = arguments.length, splitedBytes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
| 51 |
+
splitedBytes[_key2] = arguments[_key2];
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
// $FlowIgnore
|
| 55 |
+
var bytes = [].concat.apply([], splitedBytes);
|
| 56 |
+
return new Uint8Array(bytes).buffer;
|
| 57 |
+
}
|
| 58 |
+
export function fromHexdump(str) {
|
| 59 |
+
var lines = str.split("\n"); // remove any leading left whitespace
|
| 60 |
+
|
| 61 |
+
lines = lines.map(function (line) {
|
| 62 |
+
return line.trim();
|
| 63 |
+
});
|
| 64 |
+
var bytes = lines.reduce(function (acc, line) {
|
| 65 |
+
var cols = line.split(" "); // remove the offset, left column
|
| 66 |
+
|
| 67 |
+
cols.shift();
|
| 68 |
+
cols = cols.filter(function (x) {
|
| 69 |
+
return x !== "";
|
| 70 |
+
});
|
| 71 |
+
var bytes = cols.map(function (x) {
|
| 72 |
+
return parseInt(x, 16);
|
| 73 |
+
});
|
| 74 |
+
acc.push.apply(acc, _toConsumableArray(bytes));
|
| 75 |
+
return acc;
|
| 76 |
+
}, []);
|
| 77 |
+
return new Uint8Array(bytes);
|
| 78 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/lib/compare.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.compareArrayBuffers = compareArrayBuffers;
|
| 7 |
+
|
| 8 |
+
// this are dev dependencies
|
| 9 |
+
var diff = require("jest-diff");
|
| 10 |
+
|
| 11 |
+
var _require = require("jest-diff/build/constants"),
|
| 12 |
+
NO_DIFF_MESSAGE = _require.NO_DIFF_MESSAGE;
|
| 13 |
+
|
| 14 |
+
var _require2 = require("@webassemblyjs/wasm-parser"),
|
| 15 |
+
decode = _require2.decode;
|
| 16 |
+
|
| 17 |
+
var oldConsoleLog = console.log;
|
| 18 |
+
|
| 19 |
+
function compareArrayBuffers(l, r) {
|
| 20 |
+
/**
|
| 21 |
+
* Decode left
|
| 22 |
+
*/
|
| 23 |
+
var bufferL = "";
|
| 24 |
+
|
| 25 |
+
console.log = function () {
|
| 26 |
+
for (var _len = arguments.length, texts = new Array(_len), _key = 0; _key < _len; _key++) {
|
| 27 |
+
texts[_key] = arguments[_key];
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
return bufferL += texts.join("") + "\n";
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
try {
|
| 34 |
+
decode(l, {
|
| 35 |
+
dump: true
|
| 36 |
+
});
|
| 37 |
+
} catch (e) {
|
| 38 |
+
console.error(bufferL);
|
| 39 |
+
console.error(e);
|
| 40 |
+
throw e;
|
| 41 |
+
}
|
| 42 |
+
/**
|
| 43 |
+
* Decode right
|
| 44 |
+
*/
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
var bufferR = "";
|
| 48 |
+
|
| 49 |
+
console.log = function () {
|
| 50 |
+
for (var _len2 = arguments.length, texts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
| 51 |
+
texts[_key2] = arguments[_key2];
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
return bufferR += texts.join("") + "\n";
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
try {
|
| 58 |
+
decode(r, {
|
| 59 |
+
dump: true
|
| 60 |
+
});
|
| 61 |
+
} catch (e) {
|
| 62 |
+
console.error(bufferR);
|
| 63 |
+
console.error(e);
|
| 64 |
+
throw e;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
console.log = oldConsoleLog;
|
| 68 |
+
var out = diff(bufferL, bufferR);
|
| 69 |
+
|
| 70 |
+
if (out !== null && out !== NO_DIFF_MESSAGE) {
|
| 71 |
+
throw new Error("\n" + out);
|
| 72 |
+
}
|
| 73 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/@webassemblyjs/helper-buffer/lib/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.overrideBytesInBuffer = overrideBytesInBuffer;
|
| 7 |
+
exports.makeBuffer = makeBuffer;
|
| 8 |
+
exports.fromHexdump = fromHexdump;
|
| 9 |
+
|
| 10 |
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
| 11 |
+
|
| 12 |
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
| 13 |
+
|
| 14 |
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
| 15 |
+
|
| 16 |
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
| 17 |
+
|
| 18 |
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
| 19 |
+
|
| 20 |
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
| 21 |
+
|
| 22 |
+
function concatUint8Arrays() {
|
| 23 |
+
for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) {
|
| 24 |
+
arrays[_key] = arguments[_key];
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
var totalLength = arrays.reduce(function (a, b) {
|
| 28 |
+
return a + b.length;
|
| 29 |
+
}, 0);
|
| 30 |
+
var result = new Uint8Array(totalLength);
|
| 31 |
+
var offset = 0;
|
| 32 |
+
|
| 33 |
+
for (var _i = 0, _arrays = arrays; _i < _arrays.length; _i++) {
|
| 34 |
+
var arr = _arrays[_i];
|
| 35 |
+
|
| 36 |
+
if (arr instanceof Uint8Array === false) {
|
| 37 |
+
throw new Error("arr must be of type Uint8Array");
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
result.set(arr, offset);
|
| 41 |
+
offset += arr.length;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
return result;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function overrideBytesInBuffer(buffer, startLoc, endLoc, newBytes) {
|
| 48 |
+
var beforeBytes = buffer.slice(0, startLoc);
|
| 49 |
+
var afterBytes = buffer.slice(endLoc, buffer.length); // replacement is empty, we can omit it
|
| 50 |
+
|
| 51 |
+
if (newBytes.length === 0) {
|
| 52 |
+
return concatUint8Arrays(beforeBytes, afterBytes);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
var replacement = Uint8Array.from(newBytes);
|
| 56 |
+
return concatUint8Arrays(beforeBytes, replacement, afterBytes);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
function makeBuffer() {
|
| 60 |
+
for (var _len2 = arguments.length, splitedBytes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
| 61 |
+
splitedBytes[_key2] = arguments[_key2];
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// $FlowIgnore
|
| 65 |
+
var bytes = [].concat.apply([], splitedBytes);
|
| 66 |
+
return new Uint8Array(bytes).buffer;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
function fromHexdump(str) {
|
| 70 |
+
var lines = str.split("\n"); // remove any leading left whitespace
|
| 71 |
+
|
| 72 |
+
lines = lines.map(function (line) {
|
| 73 |
+
return line.trim();
|
| 74 |
+
});
|
| 75 |
+
var bytes = lines.reduce(function (acc, line) {
|
| 76 |
+
var cols = line.split(" "); // remove the offset, left column
|
| 77 |
+
|
| 78 |
+
cols.shift();
|
| 79 |
+
cols = cols.filter(function (x) {
|
| 80 |
+
return x !== "";
|
| 81 |
+
});
|
| 82 |
+
var bytes = cols.map(function (x) {
|
| 83 |
+
return parseInt(x, 16);
|
| 84 |
+
});
|
| 85 |
+
acc.push.apply(acc, _toConsumableArray(bytes));
|
| 86 |
+
return acc;
|
| 87 |
+
}, []);
|
| 88 |
+
return new Uint8Array(bytes);
|
| 89 |
+
}
|