<commit_before>"use strict";

const defs    = require('./defs.js');
const CT      = defs.constant_types;

const LUAC_DATA    = "\x19\x93\r\n\x1a\n";
const LUAC_INT     = 0x5678;
const LUAC_NUM     = 370.5;
const LUAC_VERSION = Number.parseInt(defs.LUA_VERSION_MAJOR) * 16 + Number.parseInt(defs.LUA_VERSION_MINOR);
const LUAC_FORMAT  = 0;   /* this is the official format */

class DumpState {
    constructor() {
        this.L = null;
        this.write = null;
        this.data = null;
        this.strip = NaN;
        this.status = NaN;
    }
}

const DumpBlock = function(b, size, D) {
    if (D.status === 0 && size > 0)
        D.status = D.writer(D.L, b, size, D.data);
};

const DumpLiteral = function(s, D) {
    s = defs.to_luastring(s);
    DumpBlock(s, s.length, D);
};

const DumpByte = function(y, D) {
    DumpBlock([y], 1, D);
};

const DumpInt = function(x, D) {
    let dv = new DataView(new ArrayBuffer(4));
    dv.setInt32(0, x, true);
    let t = [];
    for (let i = 0; i < 4; i++)
        t.push(dv.getUint8(i, true));

    DumpBlock(t, 4, D);
};

const DumpInteger = function(x, D) {
    let dv = new DataView(new ArrayBuffer(4));
    dv.setInt32(0, x, true);
    let t = [];
    for (let i = 0; i < 4; i++)
        t.push(dv.getUint8(i, true));
    DumpBlock(t, 8, D);
};

const DumpNumber = function(x, D) {
    let dv = new DataView(new ArrayBuffer(8));
    dv.setFloat64(0, x, true);
    let t = [];
    for (let i = 0; i < 8; i++)
        t.push(dv.getUint8(i, true));

    DumpBlock(t, 8, D);
};

const DumpString = function(s, D) {
    if (s === null)
        DumpByte(0, D);
    else {
        let size = s.tsslen() + 1;
        let str = s.getstr();<commit_msg>ldump.js: fixed bad integer size in DumpInteger<commit_after>"use strict";

const defs    = require('./defs.js');
const CT      = defs.constant_types;

const LUAC_DATA    = "\x19\x93\r\n\x1a\n";
const LUAC_INT     = 0x5678;
const LUAC_NUM     = 370.5;
const LUAC_VERSION = Number.parseInt(defs.LUA_VERSION_MAJOR) * 16 + Number.parseInt(defs.LUA_VERSION_MINOR);
const LUAC_FORMAT  = 0;   /* this is the official format */

class DumpState {
    constructor() {
        this.L = null;
        this.write = null;
        this.data = null;
        this.strip = NaN;
        this.status = NaN;
    }
}

const DumpBlock = function(b, size, D) {
    if (D.status === 0 && size > 0)
        D.status = D.writer(D.L, b, size, D.data);
};

const DumpLiteral = function(s, D) {
    s = defs.to_luastring(s);
    DumpBlock(s, s.length, D);
};

const DumpByte = function(y, D) {
    DumpBlock([y], 1, D);
};

const DumpInt = function(x, D) {
    let dv = new DataView(new ArrayBuffer(4));
    dv.setInt32(0, x, true);
    let t = [];
    for (let i = 0; i < 4; i++)
        t.push(dv.getUint8(i, true));

    DumpBlock(t, 4, D);
};

const DumpInteger = function(x, D) {
    let dv = new DataView(new ArrayBuffer(4));
    dv.setInt32(0, x, true);
    let t = [];
    for (let i = 0; i < 4; i++)
        t.push(dv.getUint8(i, true));
    DumpBlock(t, 4, D);
};

const DumpNumber = function(x, D) {
    let dv = new DataView(new ArrayBuffer(8));
    dv.setFloat64(0, x, true);
    let t = [];
    for (let i = 0; i < 8; i++)
        t.push(dv.getUint8(i, true));

    DumpBlock(t, 8, D);
};

const DumpString = function(s, D) {
    if (s === null)
        DumpByte(0, D);
    else {
        let size = s.tsslen() + 1;
        let str = s.getstr();
{'fraction_non_alphanumeric': 0.16977829638273045, 'fraction_numerical': 0.026837806301050177, 'mean_word_length': 2.435871743486974, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7267270', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1362, 'n_words': 343}