@cobol-ts/cursor-loader-cobol 0.0.6 → 0.0.8
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/src/cobol.compiled.array.length.d.ts +4 -0
- package/dist/src/cobol.compiled.array.length.js +35 -0
- package/dist/src/cobol.compiled.array.length.js.map +1 -0
- package/dist/src/cobol.file.node.d.ts +4 -2
- package/dist/src/cobol.file.node.js +5 -4
- package/dist/src/cobol.file.node.js.map +1 -1
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -20,4 +20,5 @@ __exportStar(require("./src/cobol.file.node"), exports);
|
|
|
20
20
|
__exportStar(require("./src/cobol.occurs.clause"), exports);
|
|
21
21
|
__exportStar(require("./src/cobol.parser"), exports);
|
|
22
22
|
__exportStar(require("./src/cobol.registration"), exports);
|
|
23
|
+
__exportStar(require("./src/cobol.compiled.array.length"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAwC;AACxC,0DAAuC;AACvC,wDAAqC;AACrC,4DAAyC;AACzC,qDAAkC;AAClC,2DAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAwC;AACxC,0DAAuC;AACvC,wDAAqC;AACrC,4DAAyC;AACzC,qDAAkC;AAClC,2DAAwC;AAGxC,oEAAiD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type CobolProjectionPath } from './cobol.projection.path';
|
|
2
|
+
import type { CobolProjectionDetails, CobolRepresentation } from './cobol.parser';
|
|
3
|
+
/** Direct array-length access from a root-compiled path and enclosing indexes. */
|
|
4
|
+
export declare function cobolCompiledArrayLength(record: CobolRepresentation, details: CobolProjectionDetails, path: CobolProjectionPath, indices: readonly number[]): number;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cobolCompiledArrayLength = cobolCompiledArrayLength;
|
|
4
|
+
const cobol_projection_symbolic_1 = require("./cobol.projection.symbolic");
|
|
5
|
+
const cobol_representation_1 = require("./cobol.representation");
|
|
6
|
+
const cobol_occurs_clause_1 = require("./cobol.occurs.clause");
|
|
7
|
+
/** Direct array-length access from a root-compiled path and enclosing indexes. */
|
|
8
|
+
function cobolCompiledArrayLength(record, details, path, indices) {
|
|
9
|
+
const occurs = (0, cobol_occurs_clause_1.findOccursClause)(path.node.source.clauses);
|
|
10
|
+
if (path.node.kind !== 'group' || occurs?.kind !== 'occurs')
|
|
11
|
+
throw new Error('Compiled COBOL array path must select an OCCURS group');
|
|
12
|
+
if (!('symbolic' in path)) {
|
|
13
|
+
const dimensions = path.runtimeDimensions;
|
|
14
|
+
if (dimensions.length !== indices.length + 1)
|
|
15
|
+
throw new Error(`Expected ${dimensions.length - 1} enclosing COBOL occurrence indexes, got ${indices.length}`);
|
|
16
|
+
// Only the enclosing dimensions require bounds checks; the current
|
|
17
|
+
// table's fixed count is known from the compiled layout.
|
|
18
|
+
for (let i = 0; i < indices.length; i++) {
|
|
19
|
+
const index = indices[i], count = dimensions[i].count;
|
|
20
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= count)
|
|
21
|
+
throw new RangeError(`OCCURS index ${index} outside 0..${count - 1}`);
|
|
22
|
+
}
|
|
23
|
+
return dimensions[dimensions.length - 1].count;
|
|
24
|
+
}
|
|
25
|
+
const p = (0, cobol_representation_1.physical)(record), state = p.recordState;
|
|
26
|
+
// Scratch is owned by the current physical record. This is a root access:
|
|
27
|
+
// parent-relative compiled paths must never be passed here.
|
|
28
|
+
if (path.relativeSteps.length !== path.steps.length)
|
|
29
|
+
throw new Error('Compiled array access requires a root-executable COBOL path');
|
|
30
|
+
const scratch = state.scalarScratch ?? (state.scalarScratch = { physical: p, originBits: 0, enclosingIndices: [] });
|
|
31
|
+
const resolver = (0, cobol_representation_1.countResolver)(details, p);
|
|
32
|
+
(0, cobol_projection_symbolic_1.selectSymbolicInto)((0, cobol_representation_1.symbolicView)(record), path, resolver, indices, scratch);
|
|
33
|
+
return (0, cobol_projection_symbolic_1.activeCount)(path.node, resolver, scratch.enclosingIndices);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=cobol.compiled.array.length.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cobol.compiled.array.length.js","sourceRoot":"","sources":["../../src/cobol.compiled.array.length.ts"],"names":[],"mappings":";;AAOA,4DA6BC;AAnCD,2EAA0E;AAC1E,iEAA0E;AAC1E,+DAAsD;AAGtD,kFAAkF;AAClF,SAAgB,wBAAwB,CACpC,MAA0B,EAAC,OAA8B,EAAC,IAAwB,EAClF,OAAyB;IAEzB,MAAM,MAAM,GAAC,IAAA,sCAAgB,EAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACvD,IAAG,IAAI,CAAC,IAAI,CAAC,IAAI,KAAG,OAAO,IAAE,MAAM,EAAE,IAAI,KAAG,QAAQ;QAChD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAA;IAC5E,IAAG,CAAC,CAAC,UAAU,IAAI,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,UAAU,GAAC,IAAI,CAAC,iBAAiB,CAAA;QACvC,IAAG,UAAU,CAAC,MAAM,KAAG,OAAO,CAAC,MAAM,GAAC,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,YAAY,UAAU,CAAC,MAAM,GAAC,CAAC,4CAA4C,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;QAChH,mEAAmE;QACnE,yDA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AA;AACnE,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { type CobolLayoutOptions } from '@cobol-ts/layout';
|
|
|
3
3
|
import { type CobolDecodeOptions } from '@cobol-ts/codec';
|
|
4
4
|
import { type CursorFileDefinition, type FileCursorResult } from '@cobol-ts/cursor-file';
|
|
5
5
|
import type { RecordObjectPool } from '@cobol-ts/cursor-record';
|
|
6
|
-
import { type CobolFraming } from './cobol.parser';
|
|
6
|
+
import { type CobolFraming, type CobolRepresentation, type CobolDecodedDetails } from './cobol.parser';
|
|
7
7
|
/** Input paths are filenames, not COBOL text or precompiled descriptors. */
|
|
8
8
|
export type CobolFileOptions<TProjection> = Readonly<{
|
|
9
9
|
filename: string;
|
|
@@ -19,6 +19,8 @@ export type CobolFileOptions<TProjection> = Readonly<{
|
|
|
19
19
|
metrics?: IPutMetrics;
|
|
20
20
|
/** Opt-in shared-binding native arrays for eligible small ODO tables. */
|
|
21
21
|
experimentalSharedOdoArrays?: boolean;
|
|
22
|
+
/** Once per opened source, before the first record. */
|
|
23
|
+
onPrepared?: (details: CobolDecodedDetails) => void;
|
|
22
24
|
}>;
|
|
23
25
|
/**
|
|
24
26
|
* Open an FB or RDW-framed COBOL file as borrowed, lazy projections.
|
|
@@ -34,4 +36,4 @@ export declare function readCobolFile<TProjection>(options: CobolFileOptions<TPr
|
|
|
34
36
|
* usable only until the synchronous callback returns. Return false to stop.
|
|
35
37
|
* All COBOL setup and field decoding is identical to readCobolFile().
|
|
36
38
|
*/
|
|
37
|
-
export declare function scanCobolFile<TProjection>(options: CobolFileOptions<TProjection>, onRecord: (row: TProjection) => void | boolean): Promise<void>;
|
|
39
|
+
export declare function scanCobolFile<TProjection>(options: CobolFileOptions<TProjection>, onRecord: (row: TProjection, parsed: CobolRepresentation) => void | boolean): Promise<void>;
|
|
@@ -8,7 +8,7 @@ const copybook_1 = require("@cobol-ts/copybook");
|
|
|
8
8
|
const layout_1 = require("@cobol-ts/layout");
|
|
9
9
|
const errors_1 = require("@cobol-ts/errors");
|
|
10
10
|
const cursor_file_1 = require("@cobol-ts/cursor-file");
|
|
11
|
-
const
|
|
11
|
+
const cursor_file_2 = require("@cobol-ts/cursor-file");
|
|
12
12
|
const cobol_parser_1 = require("./cobol.parser");
|
|
13
13
|
const cobol_registration_1 = require("./cobol.registration");
|
|
14
14
|
/**
|
|
@@ -30,7 +30,7 @@ async function* readCobolFile(options) {
|
|
|
30
30
|
yield* (0, cursor_file_1.createThrowingFileCursor)({ filename: options.filename, fileType: 'cobol', projection: options.projection }, file, {
|
|
31
31
|
parsers: (0, cobol_registration_1.createCobolParserRegistry)(details),
|
|
32
32
|
bufferSize: options.bufferSize ?? 64 * 1024,
|
|
33
|
-
fillFileBuffer:
|
|
33
|
+
fillFileBuffer: cursor_file_2.fillNodeFileBuffer,
|
|
34
34
|
metrics: options.metrics,
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -49,14 +49,15 @@ async function scanCobolFile(options, onRecord) {
|
|
|
49
49
|
const layout = (0, errors_1.valueOrThrow)((0, layout_1.compileCobolLayout)(ast, (0, node_path_1.basename)(options.copybook), options.layoutOptions));
|
|
50
50
|
const details = { ...(0, errors_1.valueOrThrow)((0, cobol_parser_1.createCobolDecodedFramedDetails)(layout, options.framing, options.decodeOptions)), metrics: options.metrics,
|
|
51
51
|
experimentalSharedOdoArrays: options.experimentalSharedOdoArrays };
|
|
52
|
+
options.onPrepared?.(details);
|
|
52
53
|
const file = await (0, promises_1.open)(options.filename, 'r');
|
|
53
54
|
try {
|
|
54
55
|
await (0, cursor_file_1.scanThrowingFileCursor)({ filename: options.filename, fileType: 'cobol', projection: options.projection }, file, { parsers: (0, cobol_registration_1.createCobolParserRegistry)(details),
|
|
55
56
|
bufferSize: options.bufferSize ?? 64 * 1024,
|
|
56
|
-
fillFileBuffer:
|
|
57
|
+
fillFileBuffer: cursor_file_2.fillNodeFileBuffer,
|
|
57
58
|
recordPool: options.recordPool,
|
|
58
59
|
byteBufferPool: options.byteBufferPool,
|
|
59
|
-
metrics: options.metrics }, onRecord);
|
|
60
|
+
metrics: options.metrics }, (row, parsed) => onRecord(row, parsed));
|
|
60
61
|
}
|
|
61
62
|
finally {
|
|
62
63
|
await file.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cobol.file.node.js","sourceRoot":"","sources":["../../src/cobol.file.node.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"cobol.file.node.js","sourceRoot":"","sources":["../../src/cobol.file.node.ts"],"names":[],"mappings":";;AA6CA,sCAwBC;AAOD,sCA0BC;AArGD,+CAAgD;AAChD,yCAAmC;AACnC,iDAAiD;AACjD,6CAA6E;AAC7E,6CAA8C;AAE9C,uDAK+B;AAC/B,uDAAyD;AAEzD,iDAAsI;AACtI,6DAA+D;AAqB/D;;;;;;;GAOG;AACI,KAAK,SAAS,CAAC,CAAC,aAAa,CAChC,OAAsC;IAEtC,MAAM,IAAI,GAAG,MAAM,IAAA,mBAAQ,EAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,IAAA,qBAAY,EAAC,IAAA,wBAAa,EAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,IAAA,2BAAkB,EAAC,GAAG,EAAE,IAAA,oBAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IACxG,MAAM,OAAO,GAAG,EAAC,GAAG,IAAA,qBAAY,EAAC,IAAA,8CAA+B,EAAC,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,EAAC,OAAO,EAAC,OAAO,CAAC,OAAO;QACrI,2BAA2B,EAAC,OAAO,CAAC,2BAA2B,EAAC,CAAC;IAErE,MAAM,IAAI,GAAG,MAAM,IAAA,eAAI,EAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC/C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C,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC;QACD,MAAM,IAAA,oCAAsB,EACxB,EAAC,QAAQ,EAAC,OAAO,CAAC,QAAQ,EAAC,QAAQ,EAAC,OAAO,EAAC,UAAU,EAAC,OAAO,CAAC,UAAU,EAAC,EAC1E,IAAI,EACJ,EAAC,OAAO,EAAC,IAAA,8CAAyB,EAAC,OAAO,CAAC;YACvC,UAAU,EAAC,OAAO,CAAC,UAAU,IAAE,EAAE,GAAC,IAAI;YACtC,cAAc,EAAC,gCAAkB;YACjC,UAAU,EAAC,OAAO,CAAC,UAAU;YAC7B,cAAc,EAAC,OAAO,CAAC,cAAc;YACrC,OAAO,EAAC,OAAO,CAAC,OAAO,EAAC,EAC5B,CAAC,GAAG,EAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAC,MAA6B,CAAC,CAC9D,CAAC;IACN,CAAC;YAAS,CAAC;QACP,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/cursor-loader-cobol",
|
|
3
3
|
"description": "Fixed-length COBOL byte-backed parser with compiled occurrence paths and debug projections",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.8",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
7
7
|
"browserslist": {
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cobol-ts/cursor-loader-types": "0.0.
|
|
21
|
-
"@cobol-ts/layout": "0.0.
|
|
22
|
-
"@cobol-ts/errors": "0.0.
|
|
23
|
-
"@cobol-ts/copybook": "0.0.
|
|
24
|
-
"@cobol-ts/size": "0.0.
|
|
25
|
-
"@cobol-ts/cursor-projection": "0.0.
|
|
26
|
-
"@cobol-ts/cursor-file": "0.0.
|
|
27
|
-
"@cobol-ts/arrays": "0.0.
|
|
28
|
-
"@cobol-ts/codec": "0.0.
|
|
29
|
-
"@cobol-ts/metrics": "0.0.
|
|
20
|
+
"@cobol-ts/cursor-loader-types": "0.0.8",
|
|
21
|
+
"@cobol-ts/layout": "0.0.8",
|
|
22
|
+
"@cobol-ts/errors": "0.0.8",
|
|
23
|
+
"@cobol-ts/copybook": "0.0.8",
|
|
24
|
+
"@cobol-ts/size": "0.0.8",
|
|
25
|
+
"@cobol-ts/cursor-projection": "0.0.8",
|
|
26
|
+
"@cobol-ts/cursor-file": "0.0.8",
|
|
27
|
+
"@cobol-ts/arrays": "0.0.8",
|
|
28
|
+
"@cobol-ts/codec": "0.0.8",
|
|
29
|
+
"@cobol-ts/metrics": "0.0.8"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"typescript": "^5.2.2",
|