mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-02-04 14:00:49 +00:00
nhj
more
This commit is contained in:
21
unified-ai-platform/node_modules/@webassemblyjs/helper-wasm-section/LICENSE
generated
vendored
Normal file
21
unified-ai-platform/node_modules/@webassemblyjs/helper-wasm-section/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Sven Sauleau <sven@sauleau.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
107
unified-ai-platform/node_modules/@webassemblyjs/helper-wasm-section/esm/create.js
generated
vendored
Normal file
107
unified-ai-platform/node_modules/@webassemblyjs/helper-wasm-section/esm/create.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
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); }
|
||||
|
||||
import { encodeNode } from "@webassemblyjs/wasm-gen";
|
||||
import { overrideBytesInBuffer } from "@webassemblyjs/helper-buffer";
|
||||
import constants from "@webassemblyjs/helper-wasm-bytecode";
|
||||
import * as t from "@webassemblyjs/ast";
|
||||
|
||||
function findLastSection(ast, forSection) {
|
||||
var targetSectionId = constants.sections[forSection]; // $FlowIgnore: metadata can not be empty
|
||||
|
||||
var moduleSections = ast.body[0].metadata.sections;
|
||||
var lastSection;
|
||||
var lastId = 0;
|
||||
|
||||
for (var i = 0, len = moduleSections.length; i < len; i++) {
|
||||
var section = moduleSections[i]; // Ignore custom section since they can actually occur everywhere
|
||||
|
||||
if (section.section === "custom") {
|
||||
continue;
|
||||
}
|
||||
|
||||
var sectionId = constants.sections[section.section];
|
||||
|
||||
if (targetSectionId > lastId && targetSectionId < sectionId) {
|
||||
return lastSection;
|
||||
}
|
||||
|
||||
lastId = sectionId;
|
||||
lastSection = section;
|
||||
}
|
||||
|
||||
return lastSection;
|
||||
}
|
||||
|
||||
export function createEmptySection(ast, uint8Buffer, section) {
|
||||
// previous section after which we are going to insert our section
|
||||
var lastSection = findLastSection(ast, section);
|
||||
var start, end;
|
||||
/**
|
||||
* It's the first section
|
||||
*/
|
||||
|
||||
if (lastSection == null || lastSection.section === "custom") {
|
||||
start = 8
|
||||
/* wasm header size */
|
||||
;
|
||||
end = start;
|
||||
} else {
|
||||
start = lastSection.startOffset + lastSection.size.value + 1;
|
||||
end = start;
|
||||
} // section id
|
||||
|
||||
|
||||
start += 1;
|
||||
var sizeStartLoc = {
|
||||
line: -1,
|
||||
column: start
|
||||
};
|
||||
var sizeEndLoc = {
|
||||
line: -1,
|
||||
column: start + 1
|
||||
}; // 1 byte for the empty vector
|
||||
|
||||
var size = t.withLoc(t.numberLiteralFromRaw(1), sizeEndLoc, sizeStartLoc);
|
||||
var vectorOfSizeStartLoc = {
|
||||
line: -1,
|
||||
column: sizeEndLoc.column
|
||||
};
|
||||
var vectorOfSizeEndLoc = {
|
||||
line: -1,
|
||||
column: sizeEndLoc.column + 1
|
||||
};
|
||||
var vectorOfSize = t.withLoc(t.numberLiteralFromRaw(0), vectorOfSizeEndLoc, vectorOfSizeStartLoc);
|
||||
var sectionMetadata = t.sectionMetadata(section, start, size, vectorOfSize);
|
||||
var sectionBytes = encodeNode(sectionMetadata);
|
||||
uint8Buffer = overrideBytesInBuffer(uint8Buffer, start - 1, end, sectionBytes); // Add section into the AST for later lookups
|
||||
|
||||
if (_typeof(ast.body[0].metadata) === "object") {
|
||||
// $FlowIgnore: metadata can not be empty
|
||||
ast.body[0].metadata.sections.push(sectionMetadata);
|
||||
t.sortSectionMetadata(ast.body[0]);
|
||||
}
|
||||
/**
|
||||
* Update AST
|
||||
*/
|
||||
// Once we hit our section every that is after needs to be shifted by the delta
|
||||
|
||||
|
||||
var deltaBytes = +sectionBytes.length;
|
||||
var encounteredSection = false;
|
||||
t.traverse(ast, {
|
||||
SectionMetadata: function SectionMetadata(path) {
|
||||
if (path.node.section === section) {
|
||||
encounteredSection = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (encounteredSection === true) {
|
||||
t.shiftSection(ast, path.node, deltaBytes);
|
||||
}
|
||||
}
|
||||
});
|
||||
return {
|
||||
uint8Buffer: uint8Buffer,
|
||||
sectionMetadata: sectionMetadata
|
||||
};
|
||||
}
|
||||
0
unified-ai-platform/node_modules/@webassemblyjs/helper-wasm-section/lib/create.js
generated
vendored
Normal file
0
unified-ai-platform/node_modules/@webassemblyjs/helper-wasm-section/lib/create.js
generated
vendored
Normal file
Reference in New Issue
Block a user