<commit_before>var PrivateMap = require('./PrivateMap');
var Enum = require("../Enum");
/**
 * ClassModes - An enumeration of the inheritability of defined Class types.
 *
 * @typedef {Enum} ClassModes
 * @prop {number} Default - Sets unrestricted inheritability for the new Class.
 * @prop {number} Abstract - Sets required inheritability for the new Class.
 * @prop {number} Final - Restricts all inheritability of the new Class.
 */
var ClassModes = new Enum("Default", ["Default", "Abstract", "Final"]);

var Class = (function() {
    const isProxy = Symbol("isProxy");
    const ProxyTarget = Symbol("ProxyTarget");
    const This = Symbol("This");
    var privMap = new PrivateMap();
    
    function extend(dest, src) {
        if (!dest || (["object", "function"].indexOf(typeof(dest)) === -1))
            throw new TypeError("Cannot extend a non-object.");

        if (src) {
            let keys = Object.getOwnPropertyNames(src).concat(Object.getOwnPropertySymbols(src));
            
            for (let key of keys) {
                let def = Object.getOwnPropertyDescriptor(src, key);
                Object.defineProperty(dest, key, def);
            }
        }
        return dest;
    }

    function isNativeFunction(obj) {
        obj = obj[ProxyTarget] || obj;
        return ((typeof(obj) == "function") && (obj instanceof Function) &&
                /^function\s+\w+\(\)\s+{\s+\[native\s+code\]\s+}$/.test(obj.toString()));
    }

    function findNativeBase(ancestor) {
        var retval = (isNativeFunction(ancestor)) ? ancestor : false;

        while (ancestor && !retval && (ancestor !== Object)) {
            let proto = ancestor.prototype;
            while (proto && (proto.constructor === ancestor)) {
                proto = Object.getPrototypeOf(proto)
            }
            ancestor = proto.constructor;
            retval = (isNativeFunction(ancestor)) ? ancestor : false;
        }

        return retval;
    }

    function makeLinks(obj) {
        var keys = Object.getOwnPropertyNames(obj)
                         .concat(Object.getOwnPropertySymbols(obj));
        var retval = {};
        
        function getProperty(key) { return obj[key]; }
        function setProperty(key, value) { obj[key] = value; }

        for (let key of keys) {
            Object.defineProperty(retval, key, {
                enumerable: true,
                get: getProperty.bind(undefined, key),
                set: setProperty.bind(undefined, key)
            });
        }

        return retval;
    }
    
    function Super(...args) {
        var parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));
        var parent = parentProto.constructor;
        var nativeBase = findNativeBase(parent);
        var retval;

        if ((nativeBase === parent) && (parent !== Object)) {
            retval = new parent(...args);
        }
        else if (parent === Object) {
            retval = this;
        }
        else {
            let pseudoThis = Object.assign(Object.create(parentProto), {[This]: this[This]});
            retval = parent.apply(pseudoThis, args) || this[This] || this;
            extend(retval, pseudoThis);
        }

        if (!!nativeBase && (parent !== Object)) {
            Object.setPrototypeOf(retval, Object.getPrototypeOf(this));
            Object.setPrototypeOf(this, Object.prototype);
            extend(retval, this);
            Object.setPrototypeOf(this, Object.getPrototypeOf(retval));
        }

        return retval;
    }

    function findConstructor(c) {
        var cString = (c[ProxyTarget] || c).toString();
        var cProto = c.prototype;
        var regex = /\Wconstructor\s*\(([^]*?)\)\s*\{([^]+\})/;
        var index = cString.search(regex);
        var matches = cString.match(regex);
        var retval = `function ${c.name}() {
            return privMap.init(Super.call(this));
        }`;
        
        if (index > -1) {
            let keys = Object.getOwnPropertyNames(cProto)
                             .concat(Object.getOwnPropertySymbols(cProto));
            retval = `function ${c.name}(${matches[1]}) {${matches[2]}`;
            
            let endIndex = retval.length;
            for (let key of keys) {
                if (key == "constructor")
                    continue;
                let fnRegex = new RegExp(`\\s((get|set|static|async)\\s+)*?(${key}|\\[".*"\\])\\s*\\(`, "m");
                let idx = retval.search(fnRegex);
                if ((idx > 15) && (idx < endIndex)) { //15 -> constructor(){}
                    endIndex = idx;
                }
            }

            if (endIndex === retval.length) { //Remove the end of class brace if we found no other fn's
                retval = retval.substring(0, retval.lastIndexOf("}", endIndex));
            }

            endIndex = retval.lastIndexOf("}", endIndex) + 1;
            retval = retval.substr(0, endIndex);
        }

        if (/\ssuper\(/.test(retval)) {
            retval = retval.replace(/this(\W)/mg, "retval$1")
                           .replace(/(\s)super\(([^;]*)\);/m, `$1var retval = privMap.init(Super.call(this, $2));`)
                           .replace(/\}$/, "\t\treturn retval;\n\t}");
        }
        return retval;        
    }

    var SymbolRef = (function() {
        const storage = [];
        return function SymbolRef(symbol, store) {
            var retval = storage.length;
            if (store) {
                storage.push(symbol);
            }
            else {
                if (symbol in storage) {
                    retval = storage[symbol];
                    delete storage[symbol];
                }
                else {
                    retval = void 0;
                }<commit_msg>Fixed issue with super()-less constructor. Refactored Super() to use Reflect.construct.<commit_after>var PrivateMap = require('./PrivateMap');
var Enum = require("../Enum");
/**
 * ClassModes - An enumeration of the inheritability of defined Class types.
 *
 * @typedef {Enum} ClassModes
 * @prop {number} Default - Sets unrestricted inheritability for the new Class.
 * @prop {number} Abstract - Sets required inheritability for the new Class.
 * @prop {number} Final - Restricts all inheritability of the new Class.
 */
var ClassModes = new Enum("Default", ["Default", "Abstract", "Final"]);

var Class = (function() {
    const isProxy = Symbol("isProxy");
    const ProxyTarget = Symbol("ProxyTarget");
    const This = Symbol("This");
    var privMap = new PrivateMap();
    
    function extend(dest, src) {
        if (!dest || (["object", "function"].indexOf(typeof(dest)) === -1))
            throw new TypeError("Cannot extend a non-object.");

        if (src) {
            let keys = Object.getOwnPropertyNames(src).concat(Object.getOwnPropertySymbols(src));
            
            for (let key of keys) {
                let def = Object.getOwnPropertyDescriptor(src, key);
                Object.defineProperty(dest, key, def);
            }
        }
        return dest;
    }

    function isNativeFunction(obj) {
        obj = obj[ProxyTarget] || obj;
        return ((typeof(obj) == "function") && (obj instanceof Function) &&
                /^function\s+\w+\(\)\s+{\s+\[native\s+code\]\s+}$/.test(obj.toString()));
    }

    function findNativeBase(ancestor) {
        var retval = (isNativeFunction(ancestor)) ? ancestor : false;

        while (ancestor && !retval && (ancestor !== Object)) {
            let proto = ancestor.prototype;
            while (proto && (proto.constructor === ancestor)) {
                proto = Object.getPrototypeOf(proto)
            }
            ancestor = proto.constructor;
            retval = (isNativeFunction(ancestor)) ? ancestor : false;
        }

        return retval;
    }

    function makeLinks(obj) {
        var keys = Object.getOwnPropertyNames(obj)
                         .concat(Object.getOwnPropertySymbols(obj));
        var retval = {};
        
        function getProperty(key) { return obj[key]; }
        function setProperty(key, value) { obj[key] = value; }

        for (let key of keys) {
            Object.defineProperty(retval, key, {
                enumerable: true,
                get: getProperty.bind(undefined, key),
                set: setProperty.bind(undefined, key)
            });
        }

        return retval;
    }
    
    function Super(...args) {
        var parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));
        var parent = parentProto.constructor;
        var retval = Reflect.construct(parent, args, parent);
        Object.setPrototypeOf(retval, Object.getPrototypeOf(this));
        return retval;
    }

    function findConstructor(c) {
        var cString = (c[ProxyTarget] || c).toString();
        var cProto = c.prototype;
        var regex = /\Wconstructor\s*\(([^]*?)\)\s*\{([^]+\})/;
        var index = cString.search(regex);
        var matches = cString.match(regex);
        var retval = `function ${c.name}() { return privMap.init(Super.call(this)); }`;
        
        if (index > -1) {
            let keys = Object.getOwnPropertyNames(cProto)
                             .concat(Object.getOwnPropertySymbols(cProto));
            retval = `function ${c.name}(${matches[1]}) {${matches[2]}`;
            
            let endIndex = retval.length;
            for (let key of keys) {
                if (key == "constructor")
                    continue;
                let fnRegex = new RegExp(`\\s((get|set|static|async)\\s+)*?(${key}|\\[".*"\\])\\s*\\(`, "m");
                let idx = retval.search(fnRegex);
                if ((idx > 15) && (idx < endIndex)) { //15 -> constructor(){}
                    endIndex = idx;
                }
            }

            if (endIndex === retval.length) { //Remove the end of class brace if we found no other fn's
                retval = retval.substring(0, retval.lastIndexOf("}", endIndex));
            }

            endIndex = retval.lastIndexOf("}", endIndex) + 1;
            retval = retval.substr(0, endIndex);
        }

        if (/\ssuper\(/.test(retval)) {
            retval = retval.replace(/this(\W)/mg, "retval$1")
                           .replace(/(\s)super\(([^;]*)\);/m, `$1var retval = privMap.init(Super.call(this, $2));`)
                           .replace(/\}$/, "\t\treturn retval;\n\t}");
        }
        else if (index > -1) {
            retval = retval.replace(/this(\W)/mg, "retval$1")
                           .replace(/((?:\W)constructor\s+\((?:\w+(?:\s*,\s*\w+)*)?\)\s*\{(\s+))/m, `$1var retval = privMap.init(Super.call(this));$2`)
                           .replace(/\}$/, "\t\treturn retval;\n\t}");
        }
        return retval;        
    }

    var SymbolRef = (function() {
        const storage = [];
        return function SymbolRef(symbol, store) {
            var retval = storage.length;
            if (store) {
                storage.push(symbol);
            }
            else {
                if (symbol in storage) {
                    retval = storage[symbol];
                    delete storage[symbol];
                }
                else {
                    retval = void 0;
                }
{'fraction_non_alphanumeric': 0.1476677032430031, 'fraction_numerical': 0.0030208796090626386, 'mean_word_length': 1.785449146250928, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '291950', 'n_tokens_mistral': 3141, 'n_tokens_neox': 3088, 'n_words': 720}