Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions napi/parser/generated/lazy/constructors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ const { TOKEN, constructorError } = require('../../raw-transfer/lazy-common.js')

const constructors = {};

module.exports = { construct, constructors };

function construct(ast) {
// (2 * 1024 * 1024 * 1024 - 16) >> 2
const metadataPos32 = 536870908;
return new RawTransferData(ast.buffer.uint32[metadataPos32], ast);
}
module.exports = constructors;

const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true }),
decodeStr = textDecoder.decode.bind(textDecoder),
Expand Down
2 changes: 1 addition & 1 deletion napi/parser/generated/lazy/walk.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const {
JSDocNullableType,
JSDocNonNullableType,
JSDocUnknownType,
} = require('./constructors.js').constructors;
} = require('./constructors.js');

module.exports = walkProgram;

Expand Down
12 changes: 6 additions & 6 deletions napi/parser/raw-transfer/lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { parseSyncRawImpl, parseAsyncRawImpl, returnBufferToCache } = require('./common.js'),
{ TOKEN } = require('./lazy-common.js'),
constructLazyData = require('../generated/lazy/constructors.js').construct,
{ RawTransferData } = require('../generated/lazy/constructors.js'),
walkProgram = require('../generated/lazy/walk.js'),
{ Visitor, getVisitorsArr } = require('./visitor.js');

Expand Down Expand Up @@ -104,7 +104,10 @@ function construct(buffer, sourceText, sourceLen) {
bufferRecycleRegistry.register(ast, buffer, ast);

// Get root data class instance
const data = constructLazyData(ast);
// (2 * 1024 * 1024 * 1024 - 16) >> 2
const metadataPos32 = 536870908;
const rawDataPos = buffer.uint32[metadataPos32];
const data = new RawTransferData(rawDataPos, ast);

return {
get program() {
Expand All @@ -121,10 +124,7 @@ function construct(buffer, sourceText, sourceLen) {
},
dispose: dispose.bind(null, ast),
visit(visitor) {
// (2 * 1024 * 1024 * 1024 - 16) >> 2
const metadataPos32 = 536870908;
const pos = buffer.uint32[metadataPos32];
walkProgram(pos, ast, getVisitorsArr(visitor));
walkProgram(rawDataPos, ast, getVisitorsArr(visitor));
},
};
}
Expand Down
10 changes: 2 additions & 8 deletions tasks/ast_tools/src/generators/raw_transfer_lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ static CONSTRUCT_PRELUDE: &str = "

const constructors = {};

module.exports = { construct, constructors };

function construct(ast) {
// (2 * 1024 * 1024 * 1024 - 16) >> 2
const metadataPos32 = 536870908;
return new RawTransferData(ast.buffer.uint32[metadataPos32], ast);
}
module.exports = constructors;

const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true }),
decodeStr = textDecoder.decode.bind(textDecoder),
Expand Down Expand Up @@ -182,7 +176,7 @@ fn generate(

const {{
{constructor_names}
}} = require('./constructors.js').constructors;
}} = require('./constructors.js');

module.exports = walkProgram;

Expand Down
Loading