first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import type { JavaScriptLinked } from './types';
export declare class CodegenStepExecJs {
readonly js: string;
constructor(js: string);
}
type JsonSerializerStep = CodegenStepExecJs | unknown;
export interface CodegenOptions<Linkable = Record<string, unknown>> {
args?: string[];
name?: string;
prologue?: string;
epilogue?: string | (() => string);
processSteps?: (steps: JsonSerializerStep[]) => CodegenStepExecJs[];
linkable?: Linkable;
}
export type CodegenGenerateOptions = Pick<CodegenOptions, 'name' | 'args' | 'prologue' | 'epilogue'>;
export declare class Codegen<Fn extends (...deps: any[]) => any = (...deps: unknown[]) => unknown, Linkable = Record<string, unknown>> {
protected steps: JsonSerializerStep[];
options: Required<CodegenOptions<Linkable>>;
constructor(opts: CodegenOptions<Linkable>);
js(js: string): void;
var(expression?: string): string;
if(condition: string, then: () => void, otherwise?: () => void): void;
while(condition: string, block: () => void): void;
doWhile(block: () => void, condition: string): void;
switch(expression: string, cases: [match: string | number | boolean | null, block: () => void, noBreak?: boolean][], def?: () => void): void;
return(expression: string): void;
step(step: unknown): void;
protected registerCounter: number;
getRegister(): string;
r(): string;
protected dependencies: unknown[];
protected dependencyNames: string[];
linkDependency(dep: unknown, name?: string): string;
linkDependencies(deps: unknown[]): string[];
protected linked: {
[key: string]: 1;
};
link(name: keyof Linkable): void;
protected constants: string[];
protected constantNames: string[];
addConstant(constant: string, name?: string): string;
addConstants(constants: string[]): string[];
generate(opts?: CodegenGenerateOptions): JavaScriptLinked<Fn>;
compile(opts?: CodegenGenerateOptions): Fn;
}
export {};
+131
View File
@@ -0,0 +1,131 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Codegen = exports.CodegenStepExecJs = void 0;
const _1 = require(".");
class CodegenStepExecJs {
constructor(js) {
this.js = js;
}
}
exports.CodegenStepExecJs = CodegenStepExecJs;
class Codegen {
constructor(opts) {
this.steps = [];
this.dependencies = [];
this.dependencyNames = [];
this.linked = {};
this.constants = [];
this.constantNames = [];
this.options = {
args: ['r0'],
name: '',
prologue: '',
epilogue: '',
processSteps: (steps) => steps.filter((step) => step instanceof CodegenStepExecJs),
linkable: {},
...opts,
};
this.registerCounter = this.options.args.length;
}
js(js) {
this.steps.push(new CodegenStepExecJs(js));
}
var(expression) {
const r = this.getRegister();
if (expression)
this.js('var ' + r + ' = ' + expression + ';');
else
this.js('var ' + r + ';');
return r;
}
if(condition, then, otherwise) {
this.js('if (' + condition + ') {');
then();
if (otherwise) {
this.js('} else {');
otherwise();
}
this.js('}');
}
while(condition, block) {
this.js('while (' + condition + ') {');
block();
this.js('}');
}
doWhile(block, condition) {
this.js('do {');
block();
this.js('} while (' + condition + ');');
}
switch(expression, cases, def) {
this.js('switch (' + expression + ') {');
for (const [match, block, noBreak] of cases) {
this.js('case ' + match + ': {');
block();
if (!noBreak)
this.js('break;');
this.js('}');
}
if (def) {
this.js('default: {');
def();
this.js('}');
}
this.js('}');
}
return(expression) {
this.js('return ' + expression + ';');
}
step(step) {
this.steps.push(step);
}
getRegister() {
return `r${this.registerCounter++}`;
}
r() {
return this.getRegister();
}
linkDependency(dep, name = 'd' + this.dependencies.length) {
this.dependencies.push(dep);
this.dependencyNames.push(name);
return name;
}
linkDependencies(deps) {
return deps.map((dep) => this.linkDependency(dep));
}
link(name) {
if (this.linked[name])
return;
this.linked[name] = 1;
this.linkDependency(this.options.linkable[name], name);
}
addConstant(constant, name = 'c' + this.constants.length) {
this.constants.push(constant);
this.constantNames.push(name);
return name;
}
addConstants(constants) {
return constants.map((constant) => this.addConstant(constant));
}
generate(opts = {}) {
const { name, args, prologue, epilogue } = { ...this.options, ...opts };
const steps = this.options.processSteps(this.steps);
const js = `(function(${this.dependencyNames.join(', ')}) {
${this.constants.map((constant, index) => `var ${this.constantNames[index]} = (${constant});`).join('\n')}
return ${name ? `function ${name}` : 'function'}(${args.join(',')}){
${prologue}
${steps.map((step) => step.js).join('\n')}
${typeof epilogue === 'function' ? epilogue() : epilogue || ''}
}})`;
return {
deps: this.dependencies,
js: js,
};
}
compile(opts) {
const closure = this.generate(opts);
return (0, _1.compileClosure)(closure);
}
}
exports.Codegen = Codegen;
//# sourceMappingURL=Codegen.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Codegen.js","sourceRoot":"","sources":["../src/Codegen.ts"],"names":[],"mappings":";;;AAAA,wBAAiC;AAMjC,MAAa,iBAAiB;IAC5B,YAA4B,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;IAAG,CAAC;CAC3C;AAFD,8CAEC;AA0ED,MAAa,OAAO;IAUlB,YAAY,IAA8B;QALhC,UAAK,GAAyB,EAAE,CAAC;QAiHjC,iBAAY,GAAc,EAAE,CAAC;QAC7B,oBAAe,GAAa,EAAE,CAAC;QA2B/B,WAAM,GAAuB,EAAE,CAAC;QAgBhC,cAAS,GAAa,EAAE,CAAC;QACzB,kBAAa,GAAa,EAAE,CAAC;QAxJrC,IAAI,CAAC,OAAO,GAAG;YACb,IAAI,EAAE,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,EAAE;YACR,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE,EAAE;YACZ,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY,iBAAiB,CAAwB;YACzG,QAAQ,EAAE,EAAc;YACxB,GAAG,IAAI;SACR,CAAC;QACF,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;IAClD,CAAC;IAKM,EAAE,CAAC,EAAU;QAClB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC;IAEM,GAAG,CAAC,UAAmB;QAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAA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B,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;EAC9D,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE;IAC1D,CAAC;QAED,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,YAAY;YACvB,EAAE,EAAE,EAAgC;SACrC,CAAC;IACJ,CAAC;IAOM,OAAO,CAAC,IAA6B;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,IAAA,iBAAc,EAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACF;AAjOD,0BAiOC"}
+4
View File
@@ -0,0 +1,4 @@
import { JavaScriptLinked } from '.';
import { JavaScript } from './types';
export declare const compile: <T>(js: JavaScript<T>) => T;
export declare const compileClosure: <T>(fn: JavaScriptLinked<T, any>) => T;
+8
View File
@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compileClosure = exports.compile = void 0;
const compile = (js) => eval(js);
exports.compile = compile;
const compileClosure = (fn) => (0, exports.compile)(fn.js)(...fn.deps);
exports.compileClosure = compileClosure;
//# sourceMappingURL=compile.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":";;;AAIO,MAAM,OAAO,GAAG,CAAI,EAAiB,EAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAAhD,QAAA,OAAO,WAAyC;AAEtD,MAAM,cAAc,GAAG,CAAI,EAA4B,EAAK,EAAE,CAAC,IAAA,eAAO,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AAApF,QAAA,cAAc,kBAAsE"}
+1
View File
@@ -0,0 +1 @@
export declare const dynamicFunction: <F extends (...args: any[]) => any>(implementation: F) => [fn: F, set: (fn: F) => void];
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dynamicFunction = void 0;
const dynamicFunction = (implementation) => {
const proxy = ((...args) => implementation(...args));
const set = (f) => {
implementation = f;
};
return [proxy, set];
};
exports.dynamicFunction = dynamicFunction;
//# sourceMappingURL=dynamicFunction.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"dynamicFunction.js","sourceRoot":"","sources":["../src/dynamicFunction.ts"],"names":[],"mappings":";;;AAOO,MAAM,eAAe,GAAG,CAC7B,cAAiB,EACc,EAAE;IACjC,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAM,CAAC;IAC1D,MAAM,GAAG,GAAG,CAAC,CAAI,EAAE,EAAE;QACnB,cAAc,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC;IACF,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACtB,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B"}
+3
View File
@@ -0,0 +1,3 @@
export * from './types';
export * from './compile';
export * from './Codegen';
+7
View File
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./types"), exports);
tslib_1.__exportStar(require("./compile"), exports);
tslib_1.__exportStar(require("./Codegen"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,oDAA0B;AAC1B,oDAA0B"}
+1
View File
@@ -0,0 +1 @@
export declare const createSwitch: <F extends (...args: any[]) => any>(fn: F, codegen: () => F) => F;
+16
View File
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSwitch = void 0;
const dynamicFunction_1 = require("./dynamicFunction");
const createSwitch = (fn, codegen) => {
let counter = 0;
const [proxy, set] = (0, dynamicFunction_1.dynamicFunction)((...args) => {
if (counter > 2)
set(codegen());
counter++;
return fn(...args);
});
return proxy;
};
exports.createSwitch = createSwitch;
//# sourceMappingURL=switch.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../src/switch.ts"],"names":[],"mappings":";;;AAAA,uDAAkD;AAM3C,MAAM,YAAY,GAAG,CAAoC,EAAK,EAAE,OAAgB,EAAK,EAAE;IAC5F,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,IAAA,iCAAe,EAAC,CAAC,GAAG,IAAI,EAAE,EAAE;QAC/C,IAAI,OAAO,GAAG,CAAC;YAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAChC,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,OAAO,KAAU,CAAC;AACpB,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB"}
+9
View File
@@ -0,0 +1,9 @@
export type Brand<T, B, N extends string> = T & {
[K in N]: B;
};
export type JavaScript<T> = Brand<string, T, 'JavaScript'>;
export type JavaScriptClosure<Js, D extends unknown[] = unknown[]> = JavaScript<(...deps: D) => Js>;
export interface JavaScriptLinked<Js, Dependencies extends unknown[] = unknown[]> {
deps: Dependencies;
js: JavaScriptClosure<Js, Dependencies>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
+11
View File
@@ -0,0 +1,11 @@
export declare class JsExpression {
private expression;
private _wasUsed;
private _expression?;
private _listeners;
constructor(expression: () => string);
get wasUsed(): boolean;
use(): string;
chain(use: (expr: string) => string): JsExpression;
addListener(listener: (expr: string) => void): void;
}
+30
View File
@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsExpression = void 0;
class JsExpression {
constructor(expression) {
this.expression = expression;
this._wasUsed = false;
this._listeners = [];
}
get wasUsed() {
return this._wasUsed;
}
use() {
if (this._wasUsed)
return this._expression;
this._wasUsed = true;
const expression = (this._expression = this.expression());
for (const listener of this._listeners)
listener(expression);
return expression;
}
chain(use) {
return new JsExpression(() => use(this.use()));
}
addListener(listener) {
this._listeners.push(listener);
}
}
exports.JsExpression = JsExpression;
//# sourceMappingURL=JsExpression.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"JsExpression.js","sourceRoot":"","sources":["../../src/util/JsExpression.ts"],"names":[],"mappings":";;;AAcA,MAAa,YAAY;IAKvB,YAAoB,UAAwB;QAAxB,eAAU,GAAV,UAAU,CAAc;QAJpC,aAAQ,GAAY,KAAK,CAAC;QAE1B,eAAU,GAA+B,EAAE,CAAC;IAEL,CAAC;IAEhD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEM,GAAG;QACR,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC,WAAY,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAC1D,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU;YAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC7D,OAAO,UAAU,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,GAA6B;QACxC,OAAO,IAAI,YAAY,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAEM,WAAW,CAAC,QAAgC;QACjD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF;AA1BD,oCA0BC"}
+1
View File
@@ -0,0 +1 @@
export declare const emitStringMatch: (expression: string, offset: string, match: string) => string;
+11
View File
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.emitStringMatch = void 0;
const emitStringMatch = (expression, offset, match) => {
const conditions = [];
for (let i = 0; i < match.length; i++)
conditions.push(`${match.charCodeAt(i)} === ${expression}.charCodeAt(${offset} + ${i})`);
return conditions.join(' && ');
};
exports.emitStringMatch = emitStringMatch;
//# sourceMappingURL=helpers.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/util/helpers.ts"],"names":[],"mappings":";;;AAAO,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAE,MAAc,EAAE,KAAa,EAAE,EAAE;IACnF,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QACnC,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,UAAU,eAAe,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3F,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC;AALW,QAAA,eAAe,mBAK1B"}
+1
View File
@@ -0,0 +1 @@
export declare const normalizeAccessor: (accessor: string) => string;
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeAccessor = void 0;
const normalizeAccessor = (accessor) => {
if (/^[a-z_][a-z_0-9]*$/i.test(accessor)) {
return '.' + accessor;
}
else {
return `[${JSON.stringify(accessor)}]`;
}
};
exports.normalizeAccessor = normalizeAccessor;
//# sourceMappingURL=normalizeAccessor.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"normalizeAccessor.js","sourceRoot":"","sources":["../../src/util/normalizeAccessor.ts"],"names":[],"mappings":";;;AAAO,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC5D,IAAI,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzC,OAAO,GAAG,GAAG,QAAQ,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;IACzC,CAAC;AACH,CAAC,CAAC;AANW,QAAA,iBAAiB,qBAM5B"}