<commit_before>'use strict';

import { DebugProtocol } from 'vscode-debugprotocol';
import { cantorPairing, reverseCantorPairing } from './cantor';
import { Logger } from './log';

const log = Logger.create('VariablesMap');

export type VariablesReference = number;

export class VariablesContainer {
    public contextId: number;
    public variables: DebugProtocol.Variable[];

    constructor(contextId: number) {
        this.contextId = contextId;
        this.variables = [];
    }
}

export class VariablesMap {
    private variablesMap: Map<VariablesReference, VariablesContainer> = new Map();

    /**
     * Generates a unique reference for a variable based on his contextId, frameId and the hashValue of the variables name.
     * @param {number} contextId The context id.
     * @param {number} frameId The frame id.
     * @param {string} variableName The name of the variable.
     * @returns {VariablesReference} A unique variables reference.
     */
    public createReference(contextId: number, frameId: number, variableName: string): VariablesReference {
        if (variableName === '') {
            throw new Error('Variables name cannot be empty.');
        }

        let hash = 0;
        for (let i = 0; i < variableName.length; i++) {
            const charCode = variableName.charCodeAt(i);
            hash = ((hash << 5) - hash) + charCode;
            hash |= 0; // Convert to 32-bit integer
        }

        return cantorPairing(
            frameId,
            hash,
        );
    }<commit_msg>Do not pass undefined in function call<commit_after>'use strict';

import { DebugProtocol } from 'vscode-debugprotocol';
import { cantorPairing, reverseCantorPairing } from './cantor';
import { Logger } from './log';

const log = Logger.create('VariablesMap');

export type VariablesReference = number;

export class VariablesContainer {
    public contextId: number;
    public variables: DebugProtocol.Variable[];

    constructor(contextId: number) {
        this.contextId = contextId;
        this.variables = [];
    }
}

export class VariablesMap {
    private variablesMap: Map<VariablesReference, VariablesContainer> = new Map();

    /**
     * Generates a unique reference for a variable based on his contextId, frameId and the hashValue of the variables name.
     * @param {number} contextId The context id.
     * @param {number} frameId The frame id.
     * @param {string} variableName The name of the variable.
     * @returns {VariablesReference} A unique variables reference.
     */
    public createReference(contextId: number, frameId: number, variableName: string): VariablesReference {
        if (variableName === '') {
            throw new Error('Variables name cannot be empty.');
        }

        let hash = 0;
        for (let i = 0; i < variableName.length; i++) {
            const charCode = variableName.charCodeAt(i);
            hash = ((hash << 5) - hash) + charCode;
            hash |= 0; // Convert to 32-bit integer
        }

        return cantorPairing(frameId, hash);
    }
{'fraction_non_alphanumeric': 0.1039344262295082, 'fraction_numerical': 0.003934426229508197, 'mean_word_length': 2.7995018679950188, 'pattern_counts': {'":': 0, '<': 11, '<?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': '4398084', 'n_tokens_mistral': 822, 'n_tokens_neox': 794, 'n_words': 277}