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
2 changes: 1 addition & 1 deletion napi/parser/bench.bench.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ for (const { filename, code } of fixtures) {
const ast = {
buffer,
sourceText: code,
sourceLen: sourceByteLen,
sourceByteLen,
sourceIsAscii: code.length === sourceByteLen,
nodes: null, // Initialized in bench functions
token: TOKEN,
Expand Down
10 changes: 5 additions & 5 deletions napi/parser/generated/deserialize/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@

module.exports = deserialize;

let uint8, uint32, float64, sourceText, sourceIsAscii, sourceLen;
let uint8, uint32, float64, sourceText, sourceIsAscii, sourceByteLen;

const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true }),
decodeStr = textDecoder.decode.bind(textDecoder),
{ fromCodePoint } = String;

function deserialize(buffer, sourceTextInput, sourceLenInput) {
function deserialize(buffer, sourceTextInput, sourceByteLenInput) {
uint8 = buffer;
uint32 = buffer.uint32;
float64 = buffer.float64;

sourceText = sourceTextInput;
sourceLen = sourceLenInput;
sourceIsAscii = sourceText.length === sourceLen;
sourceByteLen = sourceByteLenInput;
sourceIsAscii = sourceText.length === sourceByteLen;

const data = deserializeRawTransferData(uint32[536870906]);

Expand Down Expand Up @@ -4026,7 +4026,7 @@ function deserializeStr(pos) {
if (len === 0) return '';

pos = uint32[pos32];
if (sourceIsAscii && pos < sourceLen) return sourceText.substr(pos, len);
if (sourceIsAscii && pos < sourceByteLen) return sourceText.substr(pos, len);

// Longer strings use `TextDecoder`
// TODO: Find best switch-over point
Expand Down
10 changes: 5 additions & 5 deletions napi/parser/generated/deserialize/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@

module.exports = deserialize;

let uint8, uint32, float64, sourceText, sourceIsAscii, sourceLen;
let uint8, uint32, float64, sourceText, sourceIsAscii, sourceByteLen;

const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true }),
decodeStr = textDecoder.decode.bind(textDecoder),
{ fromCodePoint } = String;

function deserialize(buffer, sourceTextInput, sourceLenInput) {
function deserialize(buffer, sourceTextInput, sourceByteLenInput) {
uint8 = buffer;
uint32 = buffer.uint32;
float64 = buffer.float64;

sourceText = sourceTextInput;
sourceLen = sourceLenInput;
sourceIsAscii = sourceText.length === sourceLen;
sourceByteLen = sourceByteLenInput;
sourceIsAscii = sourceText.length === sourceByteLen;

const data = deserializeRawTransferData(uint32[536870906]);

Expand Down Expand Up @@ -4157,7 +4157,7 @@ function deserializeStr(pos) {
if (len === 0) return '';

pos = uint32[pos32];
if (sourceIsAscii && pos < sourceLen) return sourceText.substr(pos, len);
if (sourceIsAscii && pos < sourceByteLen) return sourceText.substr(pos, len);

// Longer strings use `TextDecoder`
// TODO: Find best switch-over point
Expand Down
2 changes: 1 addition & 1 deletion napi/parser/generated/lazy/constructors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12480,7 +12480,7 @@ function constructStr(pos, ast) {
if (len === 0) return '';

pos = uint32[pos32];
if (ast.sourceIsAscii && pos < ast.sourceLen) return ast.sourceText.substr(pos, len);
if (ast.sourceIsAscii && pos < ast.sourceByteLen) return ast.sourceText.substr(pos, len);

// Longer strings use `TextDecoder`
// TODO: Find best switch-over point
Expand Down
6 changes: 3 additions & 3 deletions napi/parser/raw-transfer/lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ const bufferRecycleRegistry = typeof FinalizationRegistry === 'undefined'
* @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`,
* and `dispose` and `visit` methods
*/
function construct(buffer, sourceText, sourceLen) {
function construct(buffer, sourceText, sourceByteLen) {
// Create AST object
const sourceIsAscii = sourceText.length === sourceLen;
const ast = { buffer, sourceText, sourceLen, sourceIsAscii, nodes: new Map(), token: TOKEN };
const sourceIsAscii = sourceText.length === sourceByteLen;
const ast = { buffer, sourceText, sourceByteLen, sourceIsAscii, nodes: new Map(), token: TOKEN };

// Register `ast` with the recycle registry so buffer is returned to cache
// when `ast` is garbage collected
Expand Down
10 changes: 5 additions & 5 deletions tasks/ast_tools/src/generators/raw_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,20 @@ fn generate_deserializers(consts: Constants, schema: &Schema, codegen: &Codegen)

module.exports = deserialize;

let uint8, uint32, float64, sourceText, sourceIsAscii, sourceLen;
let uint8, uint32, float64, sourceText, sourceIsAscii, sourceByteLen;

const textDecoder = new TextDecoder('utf-8', {{ ignoreBOM: true }}),
decodeStr = textDecoder.decode.bind(textDecoder),
{{ fromCodePoint }} = String;

function deserialize(buffer, sourceTextInput, sourceLenInput) {{
function deserialize(buffer, sourceTextInput, sourceByteLenInput) {{
uint8 = buffer;
uint32 = buffer.uint32;
float64 = buffer.float64;

sourceText = sourceTextInput;
sourceLen = sourceLenInput;
sourceIsAscii = sourceText.length === sourceLen;
sourceByteLen = sourceByteLenInput;
sourceIsAscii = sourceText.length === sourceByteLen;

const data = deserializeRawTransferData(uint32[{data_pointer_pos_32}]);

Expand Down Expand Up @@ -540,7 +540,7 @@ static STR_DESERIALIZER_BODY: &str = "
if (len === 0) return '';

pos = uint32[pos32];
if (sourceIsAscii && pos < sourceLen) return sourceText.substr(pos, len);
if (sourceIsAscii && pos < sourceByteLen) return sourceText.substr(pos, len);

// Longer strings use `TextDecoder`
// TODO: Find best switch-over point
Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/generators/raw_transfer_lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ static STR_DESERIALIZER_BODY: &str = "
if (len === 0) return '';

pos = uint32[pos32];
if (ast.sourceIsAscii && pos < ast.sourceLen) return ast.sourceText.substr(pos, len);
if (ast.sourceIsAscii && pos < ast.sourceByteLen) return ast.sourceText.substr(pos, len);

// Longer strings use `TextDecoder`
// TODO: Find best switch-over point
Expand Down
Loading