@oseo/backend-c 0.1.0-canary.0 → 0.1.0-canary.370
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIT-LICENSE.txt +1 -1
- package/README.md +59 -147
- package/dist/bounded-body.d.ts.map +1 -1
- package/dist/bounded-body.js.map +1 -1
- package/dist/emitted-c.d.ts +1 -1
- package/dist/emitted-c.d.ts.map +1 -1
- package/dist/emitted-c.js +24 -2
- package/dist/emitted-c.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/regexp-program.d.ts.map +1 -1
- package/dist/regexp-program.js.map +1 -1
- package/package.json +2 -2
package/MIT-LICENSE.txt
CHANGED
package/README.md
CHANGED
|
@@ -1,147 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
the
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
the runtime. It does not consult HIR or source syntax.
|
|
61
|
-
|
|
62
|
-
Value-slot discovery scans MIR argument IDs iteratively, so source-level call
|
|
63
|
-
size does not become a JavaScript call-stack limit during C emission. Generated
|
|
64
|
-
entry code passes diagnostic source identifiers with their UTF-8 byte lengths.
|
|
65
|
-
|
|
66
|
-
M2 guard failures and checked-addition overflow branch to the same emitted
|
|
67
|
-
generic addition block. The hit path uses private inline runtime primitives and
|
|
68
|
-
does not call generic addition or allocate. Block parameters carry the selected
|
|
69
|
-
result into one ordinary continuation.
|
|
70
|
-
|
|
71
|
-
M3 named property reads likewise preserve MIR-owned object and shape guards, a
|
|
72
|
-
fixed-slot hit, one generic fallback, and a block-parameter join. The runtime
|
|
73
|
-
exposes only private cache tests, fixed-slot loads, and cache updates to the C
|
|
74
|
-
backend. A named cache belongs to one static key site, so its hit path does not
|
|
75
|
-
allocate or materialize the property key.
|
|
76
|
-
|
|
77
|
-
Pending throws carry their diagnostic location and message through generated
|
|
78
|
-
completion slots, so intervening `finally` operations cannot overwrite an
|
|
79
|
-
unhandled exception's report.
|
|
80
|
-
|
|
81
|
-
Iterator operations keep the iterator, captured next method, and yielded value
|
|
82
|
-
in distinct root slots. Generated close blocks consult the stored completion
|
|
83
|
-
kind so `IteratorClose` preserves the required throw precedence.
|
|
84
|
-
|
|
85
|
-
Dynamic array accumulation emits runtime value and hole append operations.
|
|
86
|
-
Array spread steps its captured iterator method in MIR control-flow blocks and
|
|
87
|
-
returns abrupt acquisition, step, and append results without synthesizing a
|
|
88
|
-
close block.
|
|
89
|
-
|
|
90
|
-
Call and constructor spread use the same iterator control flow while appending
|
|
91
|
-
values to a GC-traced argument list. Generated invocations borrow the list count
|
|
92
|
-
and stable value pointer only for the call. Fixed-arity paths keep their
|
|
93
|
-
positional arguments.
|
|
94
|
-
|
|
95
|
-
Array binding lowering associates iterator get, next, and close operations with
|
|
96
|
-
a backend-local done bit. Exhaustion suppresses later steps and close calls.
|
|
97
|
-
Generated cleanup blocks close only a still-open iterator and preserve an
|
|
98
|
-
in-flight throw over a close failure.
|
|
99
|
-
|
|
100
|
-
Object binding lowering emits the MIR-owned coercibility check before computed
|
|
101
|
-
keys, then uses the existing property-key and generic property-read operations.
|
|
102
|
-
Nested patterns reuse the same binding targets and abrupt-completion path.
|
|
103
|
-
|
|
104
|
-
Catch parameter lowering captures the pending thrown value and resets every
|
|
105
|
-
catch cell. It runs the same recursive binding path before entering the body.
|
|
106
|
-
Pattern failures retain iterator cleanup and continue through an enclosing
|
|
107
|
-
`finally`.
|
|
108
|
-
|
|
109
|
-
`for-of` declaration patterns reuse that binding path after each outer iterator
|
|
110
|
-
step. Generated code resets lexical cells per iteration and writes hoisted `var`
|
|
111
|
-
cells in place. When initialization fails, generated code closes nested
|
|
112
|
-
iterators before the outer iterator.
|
|
113
|
-
|
|
114
|
-
`for-of` assignment patterns reuse the existing-target path after each outer
|
|
115
|
-
step. They add no target cells. A checked identifier or member write failure
|
|
116
|
-
closes nested pattern iterators before the outer iterator.
|
|
117
|
-
|
|
118
|
-
Standalone destructuring assignment reuses the same recursive path. That path
|
|
119
|
-
includes checked writes to existing identifier cells and property writes
|
|
120
|
-
through member references evaluated before the corresponding source value.
|
|
121
|
-
Generated code preserves the original right-hand value as the expression
|
|
122
|
-
result. It routes an immutable, imported, member-reference, or member-write
|
|
123
|
-
failure through every active array-pattern close block.
|
|
124
|
-
|
|
125
|
-
Compound assignment emits the existing binding or property read, binary
|
|
126
|
-
operation, and checked write sequence against one retained reference. Logical
|
|
127
|
-
forms branch before emitting the right operand and write. They preserve the
|
|
128
|
-
current value on the short path without adding a runtime ABI operation.
|
|
129
|
-
|
|
130
|
-
Update expressions emit the same checked binding or member read and write
|
|
131
|
-
operations around numeric coercion and arithmetic by one. A postfix form keeps
|
|
132
|
-
the coerced previous value in its root slot across the write. A prefix form
|
|
133
|
-
returns the assigned value. Member forms retain one object and raw key
|
|
134
|
-
evaluation but emit separate property-key conversions for the read and write. A
|
|
135
|
-
nullish-base check precedes those conversions.
|
|
136
|
-
|
|
137
|
-
M4 whole-graph programs allocate shared module cells and namespaces before
|
|
138
|
-
executing dependency-ordered bodies. Generated functions register one shared
|
|
139
|
-
code-identity dispatcher used by dynamic calls, promise executors, reactions,
|
|
140
|
-
and asynchronous continuations. Promise, timer, and top-level await MIR targets
|
|
141
|
-
remain runtime calls, so generated C does not own job queues or scheduler
|
|
142
|
-
policy.
|
|
143
|
-
|
|
144
|
-
Guaranteed-rejected frames use a C preprocessor branch to omit their bodies
|
|
145
|
-
before sanitizer IR construction. Entry points retain their runtime charge.
|
|
146
|
-
Callable charges use `OSEO_CALLABLE_FRAME_COST`, whose multiplier is supplied
|
|
147
|
-
by the toolchain; scripts retain their compact-root and binding-access charge.
|
|
1
|
+
`@oseo/backend-c`
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
`@oseo/backend-c` emits deterministic C11 from Oseo's mid-level intermediate
|
|
5
|
+
representation (MIR). It does not parse JavaScript, choose runtime inputs, or
|
|
6
|
+
invoke a C compiler. If you only want to inspect the C for a JavaScript or
|
|
7
|
+
TypeScript file, run `oseo build FILE --emit-c` with the [Oseo CLI].
|
|
8
|
+
|
|
9
|
+
[Oseo CLI]: https://github.com/dahlia/oseo/blob/main/docs/using/cli.md
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Emit C from MIR
|
|
13
|
+
---------------
|
|
14
|
+
|
|
15
|
+
If you already have a `MirProgram` from [`@oseo/compiler`], install the
|
|
16
|
+
backend:
|
|
17
|
+
|
|
18
|
+
~~~~ sh
|
|
19
|
+
npm install @oseo/backend-c
|
|
20
|
+
~~~~
|
|
21
|
+
|
|
22
|
+
Or, in a Deno project:
|
|
23
|
+
|
|
24
|
+
~~~~ sh
|
|
25
|
+
deno add jsr:@oseo/backend-c
|
|
26
|
+
~~~~
|
|
27
|
+
|
|
28
|
+
~~~~ js
|
|
29
|
+
import { cBackend } from "@oseo/backend-c";
|
|
30
|
+
|
|
31
|
+
const output = cBackend.emit(mir);
|
|
32
|
+
console.log(output.source);
|
|
33
|
+
~~~~
|
|
34
|
+
|
|
35
|
+
`output.source` is the standalone C translation unit. To build an executable,
|
|
36
|
+
compile the generated C and link it with the matching [Oseo C runtime]. If
|
|
37
|
+
`output.compilationUnits` is present, compile those files instead of the
|
|
38
|
+
standalone file and keep it beside them under `output.sourceName` for their
|
|
39
|
+
includes.
|
|
40
|
+
The [Oseo CLI] handles these steps for you. See the
|
|
41
|
+
[backend implementation notes] for how the emitter bounds native stack and
|
|
42
|
+
compiler memory use.
|
|
43
|
+
|
|
44
|
+
[`@oseo/compiler`]: https://github.com/dahlia/oseo/tree/main/packages/compiler
|
|
45
|
+
[Oseo C runtime]: https://github.com/dahlia/oseo/tree/main/packages/runtime-c
|
|
46
|
+
[backend implementation notes]: https://github.com/dahlia/oseo/blob/main/docs/development/package-backend-c.md
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
License
|
|
50
|
+
-------
|
|
51
|
+
|
|
52
|
+
The backend logic is licensed under GPL-3.0-or-later. The Oseo-authored C
|
|
53
|
+
templates and support that the backend contributes to its output are
|
|
54
|
+
[MIT-licensed]. The output includes the applicable notices; it does not put
|
|
55
|
+
your program under either license. See the [runtime linking decision] for
|
|
56
|
+
the separate terms that apply when the Oseo runtime is linked in.
|
|
57
|
+
|
|
58
|
+
[MIT-licensed]: https://github.com/dahlia/oseo/blob/main/packages/backend-c/MIT-LICENSE.txt
|
|
59
|
+
[runtime linking decision]: https://github.com/dahlia/oseo/blob/main/docs/adr/0021-runtime-linking-exception.md
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-body.d.ts","names":[],"sources":["../src/bounded-body.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"bounded-body.d.ts","names":[],"sources":["../src/bounded-body.ts"],"mappings":";;cA6Ba;;;EAKX,OAAO;;MAUH;;;iBAMU,SAAS,gBAAgB;;UASxB;WACN;WACA;;;iBAYK,cACd,gBACA,SAAS,QACT,iBAAiB;;;;;;;iBAmBH,UACd,0BACA,cACA,mBACA,oBACA,yBACA,QAAQ,WACR,qBACC"}
|
package/dist/bounded-body.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-body.js","names":["#bytes","#unit"],"sources":["../src/bounded-body.ts"],"sourcesContent":["// Fixed C output templates in this file are MIT (../MIT-LICENSE.txt).\n// Compiler logic is GPL-3.0-or-later (../LICENSE).\n\n/** Maximum executable C text assigned to one outlined native helper. */\nconst chunkBytes = 16_384;\n\n/** Keep compiler IR retention bounded across many outlined helpers. */\nexport class BodyUnits {\n #unit = 1;\n #bytes = 0;\n\n /** Assign consecutive definitions to bounded compiler translation units. */\n assign(bytes: number): number {\n if (this.#bytes + bytes > 262_144 && this.#bytes > 0) {\n this.#unit += 1;\n this.#bytes = 0;\n }\n this.#bytes += bytes;\n return this.#unit;\n }\n\n /** Number of supplemental compiler units, excluding the launcher. */\n get count(): number {\n return this.#unit;\n }\n}\n\n/** Standalone emission includes everything; build wrappers select one unit. */\nexport function bodyUnit(source: string, unit: number): string {\n return (\n `#if !defined(OSEO_C_BODY_UNIT) || OSEO_C_BODY_UNIT == ${unit}\\n` +\n source +\n \"\\n#endif\\n\"\n );\n}\n\n/** The owner retains roots and completion storage across outlined calls. */\nexport interface BoundedBody {\n readonly declarations: string;\n readonly execution: string;\n}\n\n/** Mask literals before inspecting the backend's own generated C syntax. */\nfunction syntax(source: string): string {\n return source.replace(\n /\"(?:\\\\[\\s\\S]|[^\"\\\\])*\"|'(?:\\\\[\\s\\S]|[^'\\\\])*'/gu,\n (literal) => \" \".repeat(literal.length),\n );\n}\n\n/** Apply replacements only to syntax, preserving bytes inside C literals. */\nexport function replaceSyntax(\n source: string,\n pattern: RegExp,\n replacement: (...groups: string[]) => string,\n): string {\n const masked = syntax(source);\n let result = \"\";\n let start = 0;\n for (const match of masked.matchAll(pattern)) {\n result += source.slice(start, match.index);\n result += replacement(...match.slice(1));\n start = match.index + match[0].length;\n }\n return result + source.slice(start);\n}\n\n/**\n * Outline large generated bodies without adding language calls or roots.\n * Helpers return a continuation index to an iterative owner. Every automatic\n * scalar lives in that owner's state, and static data keeps one identity.\n * Only backend-produced C is inspected; no user source is parsed here.\n */\nexport function boundBody(\n lines: readonly string[],\n name: string,\n frameCost: string,\n generator: boolean,\n usesCompletion: boolean,\n units?: BodyUnits,\n ownerUnit = 0,\n): BoundedBody | undefined {\n if (lines.reduce((size, line) => size + line.length, 0) <= chunkBytes) {\n return undefined;\n }\n const statements: string[] = [];\n let depth = 0;\n let pending: string[] = [];\n for (const line of lines) {\n pending.push(line);\n const masked = syntax(line);\n for (const character of masked) {\n if (character === \"{\") depth += 1;\n if (character === \"}\") depth -= 1;\n }\n if (depth === 0) {\n statements.push(pending.join(\"\\n\"));\n pending = [];\n }\n }\n if (depth !== 0 || pending.length !== 0) {\n throw new Error(\"Generated C body has unbalanced statement scopes.\");\n }\n const fields = new Map<string, string>();\n const statics: string[] = [];\n const staticNames: string[] = [];\n const chunks: string[][] = [[]];\n const labels = new Map<string, number>();\n let bytes = 0;\n for (let unit of statements) {\n const masked = syntax(unit);\n if (/^\\s*static\\s/u.test(masked)) {\n const identifier = masked.match(\n /^\\s*static\\s+(?:const\\s+)?\\w+\\s*(?:\\*\\s*const\\s*)?(\\w+)\\s*(?:\\[|=)/u,\n )?.[1];\n if (identifier == null) {\n throw new Error(\"Generated static data has no owned identifier.\");\n }\n staticNames.push(identifier);\n statics.push(unit);\n continue;\n }\n const label = masked.match(/^\\s*(bb\\d+|abrupt):;?\\s*$/u)?.[1];\n if (label != null) {\n if (chunks.at(-1)!.length > 0) chunks.push([]);\n labels.set(label, chunks.length - 1);\n bytes = 0;\n continue;\n }\n unit = replaceSyntax(\n unit,\n new RegExp(\n \"\\\\b((?:bool|int64_t|size_t|OseoFunctionEntry\\\\s+volatile)\\\\s+|\" +\n \"const OseoValue\\\\s*\\\\*\\\\s*)(\\\\w+)\",\n \"gu\",\n ),\n (type, identifier) => {\n fields.set(identifier!, type!.trim());\n return identifier!;\n },\n );\n // A declaration without an initializer becomes a harmless read.\n unit = replaceSyntax(\n unit,\n /^\\s*(fast_\\d+);$/gu,\n (identifier) => ` (void)${identifier};`,\n );\n unit = replaceSyntax(\n unit,\n /\\boseo_roots_release\\(context, &frame\\);/gu,\n () => \"\",\n );\n if (bytes + unit.length > chunkBytes && chunks.at(-1)!.length > 0) {\n chunks.push([]);\n bytes = 0;\n }\n chunks.at(-1)!.push(unit);\n bytes += unit.length;\n }\n const typeName = `${name}_state`;\n const shared = [\n \"roots\",\n \"result\",\n \"callee\",\n \"receiver\",\n \"argument_count\",\n \"arguments\",\n \"new_target\",\n \"generator\",\n \"completion\",\n ];\n const aliases = [\n ...shared.map((field) => `#define ${field} (body->${field})`),\n \"#define frame (*body->frame)\",\n ...[...fields.keys()].map((field) => `#define ${field} (body->${field})`),\n ...staticNames.map((field) => `#define ${field} ${name}_${field}`),\n ];\n const helpers = chunks.map((chunk, index) => {\n let source = chunk.join(\"\\n\");\n source = replaceSyntax(source, /\\bgoto\\s+(bb\\d+|abrupt);/gu, (label) => {\n const target = labels.get(label!);\n if (target == null) throw new Error(`Missing C label ${label}.`);\n return `return ${target}u;`;\n });\n source = replaceSyntax(\n source,\n /\\breturn result;/gu,\n () => \"return SIZE_MAX;\",\n );\n const helper = `${units == null ? \"static \" : \"\"}size_t ${name}_${index}(\n OseoContext *context, ${typeName} *body\n) {\n (void)context;\n (void)body;\n${source}\n return ${index + 1 < chunks.length ? `${index + 1}u` : \"SIZE_MAX\"};\n}`;\n return units == null\n ? helper\n : bodyUnit(helper, units.assign(source.length));\n });\n const staticData = statics.map((source) => {\n if (units == null) return source;\n const masked = syntax(source);\n const equals = masked.indexOf(\"=\");\n const declaration = source\n .slice(0, equals)\n .replace(/\\bstatic\\s/u, \"extern \");\n return `#if !defined(OSEO_C_BODY_UNIT) || OSEO_C_BODY_UNIT == ${ownerUnit}\n${source.replace(/\\bstatic\\s/u, \"\")}\n#else\n${declaration};\n#endif`;\n });\n const table = `static size_t (*const ${name}_chunks[])(\n OseoContext *, ${typeName} *\n) = {\n${chunks.map((_, index) => ` ${name}_${index},`).join(\"\\n\")}\n};`;\n const declarations = `#if ${frameCost} <= OSEO_MAX_ACTIVE_FRAME_SLOTS\ntypedef struct {\n OseoRootFrame *frame;\n OseoValue *roots;\n OseoResult result;\n OseoValue callee, receiver, new_target, generator;\n size_t argument_count;\n const OseoValue *arguments;\n OseoCompletionRecord *completion;\n${[...fields].map(([field, type]) => ` ${type} ${field};`).join(\"\\n\")}\n} ${typeName};\n${aliases.join(\"\\n\")}\n${staticData.join(\"\\n\")}\n${\n units == null\n ? \"\"\n : chunks\n .map(\n (_, index) =>\n `size_t ${name}_${index}(OseoContext *, ${typeName} *);`,\n )\n .join(\"\\n\")\n}\n${helpers.join(\"\\n\")}\n${[...shared, \"frame\", ...fields.keys(), ...staticNames]\n .map((field) => `#undef ${field}`)\n .join(\"\\n\")}\n${units == null ? table : bodyUnit(table, ownerUnit)}\n#endif\n`;\n const release = generator ? \"\" : \" oseo_roots_release(context, &frame);\\n\";\n const execution = ` ${typeName} body = {\n .frame = ${generator ? \"NULL\" : \"&frame\"},\n .roots = roots, .result = result,\n .callee = callee, .receiver = receiver,\n .argument_count = ${generator ? \"0u\" : \"argument_count\"},\n .arguments = ${generator ? \"NULL\" : \"arguments\"},\n .new_target = ${generator ? \"oseo_undefined()\" : \"new_target\"},\n .generator = ${generator ? \"generator\" : \"oseo_undefined()\"},\n .completion = ${usesCompletion ? \"completion\" : \"NULL\"}\n };\n size_t continuation = 0u;\n while (continuation != SIZE_MAX) {\n continuation = ${name}_chunks[continuation](context, &body);\n }\n${release} return body.result;\n`;\n return { declarations, execution };\n}\n"],"mappings":";;AAIA,MAAM,aAAa;;AAGnB,IAAa,YAAb,MAAuB;CACrB,QAAQ;CACR,SAAS;;CAGT,OAAO,OAAuB;EAC5B,IAAI,KAAKA,SAAS,QAAQ,UAAW,KAAKA,SAAS,GAAG;GACpD,KAAKC,SAA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C,CAAC,KAAK,IAAI,EAAE;IACrE,SAAS;EACX,QAAQ,KAAK,IAAI,EAAE;EACnB,WAAW,KAAK,IAAI,EAAE;EAEtB,SAAS,OACL,KACA,OACG,KACE,GAAG,UACF,UAAU,KAAK,GAAG,MAAM,kBAAkB,SAAS,KACvD,CAAC,CACA,KAAK,IAAI,EACjB;EACC,QAAQ,KAAK,IAAI,EAAE;EACnB;GAAC,GAAG;GAAQ;GAAS,GAAG,OAAO,KAAK;GAAG,GAAG;EAAW,CAAC,CACrD,KAAK,UAAU,UAAU,OAAO,CAAC,CACjC,KAAK,IAAI,EAAE;EACZ,SAAS,OAAO,QAAQ,SAAS,OAAO,SAAS,EAAE;;;EAoB5B,kBAhBE,SAAS;mBACjB,YAAY,SAAS,SAAS;;;4BAGrB,YAAY,OAAO,iBAAiB;uBACzC,YAAY,SAAS,YAAY;wBAChC,YAAY,qBAAqB,aAAa;uBAC/C,YAAY,cAAc,mBAAmB;wBAC5C,iBAAiB,eAAe,OAAO;;;;yBAItC,KAAK;;EAbZ,YAAY,KAAK,6CAezB;;CAEyB;AACnC"}
|
|
1
|
+
{"version":3,"file":"bounded-body.js","names":["#bytes","#unit"],"sources":["../src/bounded-body.ts"],"sourcesContent":["/*\n * Oseo, an ahead-of-time compiler for JavaScript and TypeScript.\n * Copyright (C) 2026 Hong Minhee <https://hongminhee.org/>\n *\n * The fixed C templates incorporated into compiled programs are under\n * the MIT license. The GPL notice covers the surrounding code. See\n * docs/runtime-support-surface.md for the licensing boundary.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <https://www.gnu.org/licenses/>.\n */\n\n// Fixed C output templates in this file are MIT (../MIT-LICENSE.txt).\n// Compiler logic is GPL-3.0-or-later (../LICENSE).\n\n/** Maximum executable C text assigned to one outlined native helper. */\nconst chunkBytes = 16_384;\n\n/** Keep compiler IR retention bounded across many outlined helpers. */\nexport class BodyUnits {\n #unit = 1;\n #bytes = 0;\n\n /** Assign consecutive definitions to bounded compiler translation units. */\n assign(bytes: number): number {\n if (this.#bytes + bytes > 262_144 && this.#bytes > 0) {\n this.#unit += 1;\n this.#bytes = 0;\n }\n this.#bytes += bytes;\n return this.#unit;\n }\n\n /** Number of supplemental compiler units, excluding the launcher. */\n get count(): number {\n return this.#unit;\n }\n}\n\n/** Standalone emission includes everything; build wrappers select one unit. */\nexport function bodyUnit(source: string, unit: number): string {\n return (\n `#if !defined(OSEO_C_BODY_UNIT) || OSEO_C_BODY_UNIT == ${unit}\\n` +\n source +\n \"\\n#endif\\n\"\n );\n}\n\n/** The owner retains roots and completion storage across outlined calls. */\nexport interface BoundedBody {\n readonly declarations: string;\n readonly execution: string;\n}\n\n/** Mask literals before inspecting the backend's own generated C syntax. */\nfunction syntax(source: string): string {\n return source.replace(\n /\"(?:\\\\[\\s\\S]|[^\"\\\\])*\"|'(?:\\\\[\\s\\S]|[^'\\\\])*'/gu,\n (literal) => \" \".repeat(literal.length),\n );\n}\n\n/** Apply replacements only to syntax, preserving bytes inside C literals. */\nexport function replaceSyntax(\n source: string,\n pattern: RegExp,\n replacement: (...groups: string[]) => string,\n): string {\n const masked = syntax(source);\n let result = \"\";\n let start = 0;\n for (const match of masked.matchAll(pattern)) {\n result += source.slice(start, match.index);\n result += replacement(...match.slice(1));\n start = match.index + match[0].length;\n }\n return result + source.slice(start);\n}\n\n/**\n * Outline large generated bodies without adding language calls or roots.\n * Helpers return a continuation index to an iterative owner. Every automatic\n * scalar lives in that owner's state, and static data keeps one identity.\n * Only backend-produced C is inspected; no user source is parsed here.\n */\nexport function boundBody(\n lines: readonly string[],\n name: string,\n frameCost: string,\n generator: boolean,\n usesCompletion: boolean,\n units?: BodyUnits,\n ownerUnit = 0,\n): BoundedBody | undefined {\n if (lines.reduce((size, line) => size + line.length, 0) <= chunkBytes) {\n return undefined;\n }\n const statements: string[] = [];\n let depth = 0;\n let pending: string[] = [];\n for (const line of lines) {\n pending.push(line);\n const masked = syntax(line);\n for (const character of masked) {\n if (character === \"{\") depth += 1;\n if (character === \"}\") depth -= 1;\n }\n if (depth === 0) {\n statements.push(pending.join(\"\\n\"));\n pending = [];\n }\n }\n if (depth !== 0 || pending.length !== 0) {\n throw new Error(\"Generated C body has unbalanced statement scopes.\");\n }\n const fields = new Map<string, string>();\n const statics: string[] = [];\n const staticNames: string[] = [];\n const chunks: string[][] = [[]];\n const labels = new Map<string, number>();\n let bytes = 0;\n for (let unit of statements) {\n const masked = syntax(unit);\n if (/^\\s*static\\s/u.test(masked)) {\n const identifier = masked.match(\n /^\\s*static\\s+(?:const\\s+)?\\w+\\s*(?:\\*\\s*const\\s*)?(\\w+)\\s*(?:\\[|=)/u,\n )?.[1];\n if (identifier == null) {\n throw new Error(\"Generated static data has no owned identifier.\");\n }\n staticNames.push(identifier);\n statics.push(unit);\n continue;\n }\n const label = masked.match(/^\\s*(bb\\d+|abrupt):;?\\s*$/u)?.[1];\n if (label != null) {\n if (chunks.at(-1)!.length > 0) chunks.push([]);\n labels.set(label, chunks.length - 1);\n bytes = 0;\n continue;\n }\n unit = replaceSyntax(\n unit,\n new RegExp(\n \"\\\\b((?:bool|int64_t|size_t|OseoFunctionEntry\\\\s+volatile)\\\\s+|\" +\n \"const OseoValue\\\\s*\\\\*\\\\s*)(\\\\w+)\",\n \"gu\",\n ),\n (type, identifier) => {\n fields.set(identifier!, type!.trim());\n return identifier!;\n },\n );\n // A declaration without an initializer becomes a harmless read.\n unit = replaceSyntax(\n unit,\n /^\\s*(fast_\\d+);$/gu,\n (identifier) => ` (void)${identifier};`,\n );\n unit = replaceSyntax(\n unit,\n /\\boseo_roots_release\\(context, &frame\\);/gu,\n () => \"\",\n );\n if (bytes + unit.length > chunkBytes && chunks.at(-1)!.length > 0) {\n chunks.push([]);\n bytes = 0;\n }\n chunks.at(-1)!.push(unit);\n bytes += unit.length;\n }\n const typeName = `${name}_state`;\n const shared = [\n \"roots\",\n \"result\",\n \"callee\",\n \"receiver\",\n \"argument_count\",\n \"arguments\",\n \"new_target\",\n \"generator\",\n \"completion\",\n ];\n const aliases = [\n ...shared.map((field) => `#define ${field} (body->${field})`),\n \"#define frame (*body->frame)\",\n ...[...fields.keys()].map((field) => `#define ${field} (body->${field})`),\n ...staticNames.map((field) => `#define ${field} ${name}_${field}`),\n ];\n const helpers = chunks.map((chunk, index) => {\n let source = chunk.join(\"\\n\");\n source = replaceSyntax(source, /\\bgoto\\s+(bb\\d+|abrupt);/gu, (label) => {\n const target = labels.get(label!);\n if (target == null) throw new Error(`Missing C label ${label}.`);\n return `return ${target}u;`;\n });\n source = replaceSyntax(\n source,\n /\\breturn result;/gu,\n () => \"return SIZE_MAX;\",\n );\n const helper = `${units == null ? \"static \" : \"\"}size_t ${name}_${index}(\n OseoContext *context, ${typeName} *body\n) {\n (void)context;\n (void)body;\n${source}\n return ${index + 1 < chunks.length ? `${index + 1}u` : \"SIZE_MAX\"};\n}`;\n return units == null\n ? helper\n : bodyUnit(helper, units.assign(source.length));\n });\n const staticData = statics.map((source) => {\n if (units == null) return source;\n const masked = syntax(source);\n const equals = masked.indexOf(\"=\");\n const declaration = source\n .slice(0, equals)\n .replace(/\\bstatic\\s/u, \"extern \");\n return `#if !defined(OSEO_C_BODY_UNIT) || OSEO_C_BODY_UNIT == ${ownerUnit}\n${source.replace(/\\bstatic\\s/u, \"\")}\n#else\n${declaration};\n#endif`;\n });\n const table = `static size_t (*const ${name}_chunks[])(\n OseoContext *, ${typeName} *\n) = {\n${chunks.map((_, index) => ` ${name}_${index},`).join(\"\\n\")}\n};`;\n const declarations = `#if ${frameCost} <= OSEO_MAX_ACTIVE_FRAME_SLOTS\ntypedef struct {\n OseoRootFrame *frame;\n OseoValue *roots;\n OseoResult result;\n OseoValue callee, receiver, new_target, generator;\n size_t argument_count;\n const OseoValue *arguments;\n OseoCompletionRecord *completion;\n${[...fields].map(([field, type]) => ` ${type} ${field};`).join(\"\\n\")}\n} ${typeName};\n${aliases.join(\"\\n\")}\n${staticData.join(\"\\n\")}\n${\n units == null\n ? \"\"\n : chunks\n .map(\n (_, index) =>\n `size_t ${name}_${index}(OseoContext *, ${typeName} *);`,\n )\n .join(\"\\n\")\n}\n${helpers.join(\"\\n\")}\n${[...shared, \"frame\", ...fields.keys(), ...staticNames]\n .map((field) => `#undef ${field}`)\n .join(\"\\n\")}\n${units == null ? table : bodyUnit(table, ownerUnit)}\n#endif\n`;\n const release = generator ? \"\" : \" oseo_roots_release(context, &frame);\\n\";\n const execution = ` ${typeName} body = {\n .frame = ${generator ? \"NULL\" : \"&frame\"},\n .roots = roots, .result = result,\n .callee = callee, .receiver = receiver,\n .argument_count = ${generator ? \"0u\" : \"argument_count\"},\n .arguments = ${generator ? \"NULL\" : \"arguments\"},\n .new_target = ${generator ? \"oseo_undefined()\" : \"new_target\"},\n .generator = ${generator ? \"generator\" : \"oseo_undefined()\"},\n .completion = ${usesCompletion ? \"completion\" : \"NULL\"}\n };\n size_t continuation = 0u;\n while (continuation != SIZE_MAX) {\n continuation = ${name}_chunks[continuation](context, &body);\n }\n${release} return body.result;\n`;\n return { declarations, execution };\n}\n"],"mappings":";;AA0BA,MAAM,aAAa;;AAGnB,IAAa,YAAb,MAAuB;CACrB,QAAQ;CACR,SAAS;;CAGT,OAAO,OAAuB;EAC5B,IAAI,KAAKA,SAAS,QAAQ,UAAW,KAAKA,SAAS,GAAG;GACpD,KAAKC,SAAS;GACd,KAAKD,SAAS;EAChB;EACA,KAAKA,UAAU;EACf,OAAO,KAAKC;CACd;;CAGA,IAAI,QAAgB;EAClB,OAAO,KAAKA;CACd;AACF;;AAGA,SAAgB,SAAS,QAAgB,MAAsB;CAC7D,OACE,yDAAyD,KAAK,MAC9D,SACA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AC,CACA,KAAK,IAAI,EACjB;EACC,QAAQ,KAAK,IAAI,EAAE;EACnB;GAAC,GAAG;GAAQ;GAAS,GAAG,OAAO,KAAK;GAAG,GAAG;EAAW,CAAC,CACrD,KAAK,UAAU,UAAU,OAAO,CAAC,CACjC,KAAK,IAAI,EAAE;EACZ,SAAS,OAAO,QAAQ,SAAS,OAAO,SAAS,EAAE;;;EAoB5B,kBAhBE,SAAS;mBACjB,YAAY,SAAS,SAAS;;;4BAGrB,YAAY,OAAO,iBAAiB;uBACzC,YAAY,SAAS,YAAY;wBAChC,YAAY,qBAAqB,aAAa;uBAC/C,YAAY,cAAc,mBAAmB;wBAC5C,iBAAiB,eAAe,OAAO;;;;yBAItC,KAAK;;EAbZ,YAAY,KAAK,6CAezB;;CAEyB;AACnC"}
|
package/dist/emitted-c.d.ts
CHANGED
|
@@ -670,7 +670,7 @@ declare const emittedC: {
|
|
|
670
670
|
readonly source: readonly [readonly ["#include \"oseo_runtime.h\"\n\n#include <math.h>\n#in", "clude <stddef.h>\n#include <stdint.h>\n#include <s", "tdlib.h>\n\n"], readonly [""], readonly ["\n\n"], readonly ["\n\n"], readonly [""], readonly ["\nint main(int argc, char **argv) {\n OseoContext context;\n O", "seoResult result;\n"], readonly [""], readonly [" oseo_context_init(\n &context, \""], readonly ["\", "], readonly ["u);\n oseo_process_start(&context, argc, argv);\n", " oseo_context_set_function_dispatcher(\n ", " &context, oseo_dispatch_function);\n"], readonly [""], readonly [" result = oseo_frame_enter(\n &context,", " "], readonly ["u);\n if (result.status == OSEO_STATUS_NORMAL)", " {\n result = oseo_function_script(\n ", " &context, oseo_undefined(), oseo_undefined", "(), 0u,\n NULL, oseo_undefined());\n ", " oseo_frame_leave(\n &context, "], readonly ["u);\n }\n if (result.status == OSEO_STATUS_N", "ORMAL) {\n result = oseo_event_loop_run(\n ", " &context, result.value);\n } else {\n", " result = oseo_entr", "y_task_checkpoint(&context, result);\n }\n i", "f (result.status != OSEO_STATUS_NORMAL) {\n ", " oseo_context_print_thrown(&context, result.val", "ue);\n oseo_context_destroy(&context);\n ", " return 1;\n }\n"], readonly [" int status = oseo_process_finish(&context);\n", " oseo_context_destroy(&context);\n return status;\n}\n"]];
|
|
671
671
|
};
|
|
672
672
|
};
|
|
673
|
-
declare const emittedCNotice = "/*\nOseo-authored output support only (SPDX-License-Identifier: MIT).\nMIT License\n\nCopyright (c) 2026 Hong Minhee
|
|
673
|
+
declare const emittedCNotice = "/*\nOseo-authored output support only (SPDX-License-Identifier: MIT).\nMIT License\n\nCopyright (c) 2026 Hong Minhee <https://hongminhee.org/>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nUnicode-derived tables, where present (SPDX-License-Identifier: Unicode-3.0).\nUNICODE LICENSE V3\n\nCOPYRIGHT AND PERMISSION NOTICE\n\nCopyright © 1991-2026 Unicode, Inc.\n\nNOTICE TO USER: Carefully read the following legal agreement. BY\nDOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR\nSOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE\nTERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT\nDOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of data files and any associated documentation (the \"Data Files\") or\nsoftware and any associated documentation (the \"Software\") to deal in the\nData Files or Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, and/or sell\ncopies of the Data Files or Software, and to permit persons to whom the\nData Files or Software are furnished to do so, provided that either (a)\nthis copyright and permission notice appear with all copies of the Data\nFiles or Software, or (b) this copyright and permission notice appear in\nassociated Documentation.\n\nTHE DATA FILES AND SOFTWARE ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\nKIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF\nTHIRD PARTY RIGHTS.\n\nIN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE\nBE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,\nOR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA\nFILES OR SOFTWARE.\n\nExcept as contained in this notice, the name of a copyright holder shall\nnot be used in advertising or otherwise to promote the sale, use or other\ndealings in these Data Files or Software without prior written\nauthorization of the copyright holder.\n*/\n";
|
|
674
674
|
//#endregion
|
|
675
675
|
export { CFragment, emittedC, emittedCNotice };
|
|
676
676
|
//# sourceMappingURL=emitted-c.d.ts.map
|
package/dist/emitted-c.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitted-c.d.ts","names":[],"sources":["../src/emitted-c.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"emitted-c.d.ts","names":[],"sources":["../src/emitted-c.ts"],"mappings":";;;;;;;KAiCY;cAEC;WACX;aACE;aAKA;aACA;;WAEF;aACE;aACA;aACA;aACA;aACA;aACA;;WAEF;aACE;;WAEF;aACE;aAKA;;WAEF;aACE;aACA;aACA;aAKA;aAKA;aACA;aACA;aACA;aACA;aACA;aAKA;aAGA;aACA;aACA;aACA;aACA;aAGA;aACA;aACA;aACA;aAGA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aAMA;aACA;aAOA;aACA;aACA;aAKA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aAIA;aACA;aACA;aACA;aAIA;aAIA;aAMA;aACA;aACA;aACA;aAGA;aACA;aAGA;aAGA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aAIA;aAGA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAKF;aACE;aACA;aAKA;aACA;aACA;;WAWF;aACE;aACA;aACA;aAKA;aACA;aAKA;aASA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA;;WAEF;aACE;aAKA;aACA;;WAEF;aACE;aACA;aACA;aACA;aACA;aACA;aAIA;aAGA;aACA;aACA;aACA;;WAEF;aACE;aACA;;WAEF;aACE;;WAIF;aACE;aAIA;aAGA;aAGA;aAGA;aAIA;;WAUF;aACE;;WAKF;aACE;;WAIF;aACE;aAIA;;WAMF;aACE;aACA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aACA;aACA;;WAIF;aACE;aACA;;WAEF;aACE;aAGA;aACA;aAGA;aACA;aACA;aACA;aACA;aAIA;aAIA;aAIA;aAIA;aAIA;aAIA;aACA;aACA;aACA;aACA;aAGA;aACA;aAGA;aAGA;aAGA;aACA;aACA;aACA;aACA;aAIA;aACA;aAIA;aAIA;;WAEF;aACE;aAKA;;WAEF;aACE;aACA;aACA;aAIA;aACA;aACA;aACA;aAIA;aACA;aACA;aAIA;aAIA;aAIA;aACA;aAIA;aAIA;aAIA;aAGA;aAGA;aACA;aACA;;WAEF;aACE;aAIA;aAIA;aAGA;aAGA;aAIA;aACA;aAGA;aAMA;aAOA;aACA;aACA;aAGA;aAKA;aACA;aAKA;aAGA;aACA;aAGA;aAIA;aAKA;;WAEF;aACE;aACA;aAIA;aAIA;;WAKF;aACE;aAGA;aAGA;aAIA;;WAEF;aACE;;WAEF;aACE;aAGA;aACA;aACA;aAGA;aAGA;aAGA;aAGA;;WAEF;aACE;aAGA;aACA;aACA;aAGA;aAGA;aAGA;aAIA;aACA;aACA;aACA;aACA;aACA;aAGA;aACA;aACA;aACA;aACA;aACA;aACA;aAGA;aACA;;WAEF;aACE;aACA;aAGA;aAGA;aACA;;WAEF;aACE;aAeA;;WAiBF;aACE;aAmBA;;WAmBF;aACE;aACA;aAIA;aAMA;aACA;aAKA;aAQA;aAIA;aAUA;aAMA;aACA;aAKA;aACA;aAKA;aAOA;aACA;aACA;aAMA;;WAmCF;aACE;aACA;aAGA;aAGA;aAGA;aAGA;aAGA;aAGA;aAGA;;;cAmDS"}
|
package/dist/emitted-c.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
//#region src/emitted-c.ts
|
|
2
2
|
/*! SPDX-License-Identifier: MIT
|
|
3
|
-
*
|
|
3
|
+
* Oseo C templates incorporated into compiled programs.
|
|
4
|
+
*
|
|
5
|
+
* MIT License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2026 Hong Minhee <https://hongminhee.org/>
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in
|
|
17
|
+
* all copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
4
26
|
*/
|
|
5
27
|
const emittedC = {
|
|
6
28
|
normalReturn: {
|
|
@@ -1241,7 +1263,7 @@ const emittedCNotice = `/*
|
|
|
1241
1263
|
Oseo-authored output support only (SPDX-License-Identifier: MIT).
|
|
1242
1264
|
MIT License
|
|
1243
1265
|
|
|
1244
|
-
Copyright (c) 2026 Hong Minhee
|
|
1266
|
+
Copyright (c) 2026 Hong Minhee <https://hongminhee.org/>
|
|
1245
1267
|
|
|
1246
1268
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1247
1269
|
of this software and associated documentation files (the "Software"), to deal
|