Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1/** @import { BaseNode, Command, Visitors, PrintOptions } from './types' */2import { encode } from '@jridgewell/sourcemap-codec';3import { Context, dedent, indent, margin, newline, space } from './context.js';4 5/** @type {(str: string) => string} str */6let btoa = () => {7 throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');8};9 10if (typeof window !== 'undefined' && typeof window.btoa === 'function') {11 btoa = (str) => window.btoa(unescape(encodeURIComponent(str)));12} else if (typeof Buffer === 'function') {13 btoa = (str) => Buffer.from(str, 'utf-8').toString('base64');14}15 16class SourceMap {17 version = 3;18 19 /** @type {string[]} */20 names = [];21 22 /**23 * @param {[number, number, number, number][][]} mappings24 * @param {PrintOptions} opts25 */26 constructor(mappings, opts) {27 this.sources = [opts.sourceMapSource || null];28 this.sourcesContent = [opts.sourceMapContent || null];29 this.mappings = opts.sourceMapEncodeMappings === false ? mappings : encode(mappings);30 }31 32 /**33 * Returns a JSON representation suitable for saving as a `*.map` file34 */35 toString() {36 return JSON.stringify(this);37 }38 39 /**40 * Returns a base64-encoded JSON representation suitable for inlining at the bottom of a file with `//# sourceMappingURL={...}`41 */42 toUrl() {43 return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());44 }45}46 47/**48 * @template {BaseNode} [T=BaseNode]49 * @param {T} node50 * @param {Visitors<T>} visitors51 * @param {PrintOptions} opts52 * @returns {{ code: string, map: any }} // TODO53 */54export function print(node, visitors, opts = {}) {55 /** @type {Command[]} */56 const commands = [];57 58 // @ts-expect-error some nonsense I don't understand59 const context = new Context(visitors, commands);60 61 context.visit(node);62 63 /** @typedef {[number, number, number, number]} Segment */64 65 let code = '';66 let current_column = 0;67 68 /** @type {Segment[][]} */69 let mappings = [];70 71 /** @type {Segment[]} */72 let current_line = [];73 74 /** @param {string} str */75 function append(str) {76 code += str;77 78 for (let i = 0; i < str.length; i += 1) {79 if (str[i] === '\n') {80 mappings.push(current_line);81 current_line = [];82 current_column = 0;83 } else {84 current_column += 1;85 }86 }87 }88 89 let current_newline = '\n';90 const indent_str = opts.indent ?? '\t';91 92 let needs_newline = false;93 let needs_margin = false;94 let needs_space = false;95 96 /** @param {Command} command */97 function run(command) {98 if (Array.isArray(command)) {99 for (let i = 0; i < command.length; i += 1) {100 run(command[i]);101 }102 return;103 }104 105 if (typeof command === 'number') {106 if (command === newline) {107 needs_newline = true;108 } else if (command === margin) {109 needs_margin = true;110 } else if (command === space) {111 needs_space = true;112 } else if (command === indent) {113 current_newline += indent_str;114 } else if (command === dedent) {115 current_newline = current_newline.slice(0, -indent_str.length);116 }117 118 return;119 }120 121 if (needs_newline) {122 append(needs_margin ? '\n' + current_newline : current_newline);123 } else if (needs_space) {124 append(' ');125 }126 127 needs_margin = needs_newline = needs_space = false;128 129 if (typeof command === 'string') {130 append(command);131 return;132 }133 134 if (command.type === 'Location') {135 current_line.push([136 current_column,137 0, // source index is always zero138 command.line - 1,139 command.column140 ]);141 }142 }143 144 for (let i = 0; i < commands.length; i += 1) {145 run(commands[i]);146 }147 148 mappings.push(current_line);149 150 /** @type {SourceMap} */151 let map;152 153 return {154 code,155 // create sourcemap lazily in case we don't need it156 get map() {157 return (map ??= new SourceMap(mappings, opts));158 }159 };160}161 162// it sucks that we have to export the class rather than just163// re-exporting it via public.d.ts, but otherwise TypeScript164// gets confused about private fields because it is really dumb!165export { Context };166 