<commit_before>const transform = require('babel-core').transform
const t = require("babel-types")


function Compiler(){
    
}
Compiler.prototype.compile = function(code, options){
    var plugin = getPlugin(options.scriptId, code)
    var babelResult = transform(code, {
        plugins: [plugin.plugin]
    })
    return {
        code: babelResult.code,
        locations: plugin.locations
    }
}

function getPlugin(scriptId, js){
    var valueIdCounter = 1;

    function getValueId(loc){
        const id = valueIdCounter
        pp.locations[id] = loc
        valueIdCounter++;
        return id
    }

    function hasParent(type, path) {
        var parentPath = path
        while (parentPath = path.parentPath) {
            if (parentPath.node.type === type) {
                return true
            }
        }
        return false
    }

    var pp = {
        plugin: plugin,
        locations: {}
    }
    return pp;

    function plugin(){
        return {
            visitor: {
                ReturnStatement: function(path){
                    if (path.node.ignore) {return}
                    if (!path.node.argument) {return}
                    path.node.ignore = true
                    path.node.argument = makeRecordValueCall(
                        path.node,
                        path.node.argument,
                        null,
                        "returnStatement"
                    )
                },
                FunctionExpression: handleFn,
                FunctionDeclaration: handleFn,
                CallExpression: function(path){
                    if (path.node.ignore) {return}
                    path.node.ignore = true
                    path.replaceWith(makeRecordValueCall(
                        path.node.callee,
                        path.node,
                        null,
                        "call"
                    ))

                },
                AssignmentExpression: function(path){
                    var call = makeRecordValueCall(
                        path.node.left,
                        path.node.right
                    )
                    path.node.right = call
                },
                MemberExpression: function(path){
                    if (path.parent.type === "MemberExpression") {
                        return;
                    }
                    if (path.parent.type === "AssignmentExpression") {
                        return;
                    }
                    if (path.parent.type === "UpdateExpression") {
                        return;
                    }
                    if (path.parent.type === "CallExpression" && path.node === path.parent.callee) {
                        return;
                    }
                    if (path.node.ignore) {return}
                    path.node.ignore = true
                    path.replaceWith(
                        makeRecordValueCall(
                            path.node.property,
                            path.node,<commit_msg>Track data on initial variable values.<commit_after>const transform = require('babel-core').transform
const t = require("babel-types")


function Compiler(){
    
}
Compiler.prototype.compile = function(code, options){
    var plugin = getPlugin(options.scriptId, code)
    var babelResult = transform(code, {
        plugins: [plugin.plugin]
    })
    return {
        code: babelResult.code,
        locations: plugin.locations
    }
}

function getPlugin(scriptId, js){
    var valueIdCounter = 1;

    function getValueId(loc){
        const id = valueIdCounter
        pp.locations[id] = loc
        valueIdCounter++;
        return id
    }

    function hasParent(type, path) {
        var parentPath = path
        while (parentPath = path.parentPath) {
            if (parentPath.node.type === type) {
                return true
            }
        }
        return false
    }

    var pp = {
        plugin: plugin,
        locations: {}
    }
    return pp;

    function plugin(){
        return {
            visitor: {
                ReturnStatement: function(path){
                    if (path.node.ignore) {return}
                    if (!path.node.argument) {return}
                    path.node.ignore = true
                    path.node.argument = makeRecordValueCall(
                        path.node,
                        path.node.argument,
                        null,
                        "returnStatement"
                    )
                },
                FunctionExpression: handleFn,
                FunctionDeclaration: handleFn,
                CallExpression: function(path){
                    if (path.node.ignore) {return}
                    path.node.ignore = true
                    path.replaceWith(makeRecordValueCall(
                        path.node.callee,
                        path.node,
                        null,
                        "call"
                    ))

                },
                AssignmentExpression: function(path){
                    var call = makeRecordValueCall(
                        path.node.left,
                        path.node.right
                    )
                    path.node.right = call
                },
                VariableDeclarator: function(path){
                    if (!path.node.init) {return}
                    var call = makeRecordValueCall(
                        path.node.id,
                        path.node.init
                    )
                    path.node.init = call
                },
                MemberExpression: function(path){
                    if (path.parent.type === "MemberExpression") {
                        return;
                    }
                    if (path.parent.type === "AssignmentExpression") {
                        return;
                    }
                    if (path.parent.type === "UpdateExpression") {
                        return;
                    }
                    if (path.parent.type === "CallExpression" && path.node === path.parent.callee) {
                        return;
                    }
                    if (path.node.ignore) {return}
                    path.node.ignore = true
                    path.replaceWith(
                        makeRecordValueCall(
                            path.node.property,
                            path.node,
{'fraction_non_alphanumeric': 0.08630073083501788, 'fraction_numerical': 0.00031099362463069506, 'mean_word_length': 1.0118861432593056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6224955', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1401, 'n_words': 292}