<commit_before>using NiL.JS.Core;
using System;
using System.Reflection;

namespace NiL.JS.Modules
{
    public sealed class ClassProxy : JSObject
    {
        private Type hostedType;

        private ClassProxy()
        {
            ValueType = ObjectValueType.Object;
            base.fieldGetter = getField;
        }

        public ClassProxy(Type host)
            : this()
        {
            hostedType = host;
            oValue = new Statements.ExternalFunction((x, y) =>
            {
                var res = new ClassProxy()
                {
                    hostedType = hostedType,
                    oValue = hostedType.GetConstructor(Type.EmptyTypes).Invoke(null)
                };
                if (x.prototype != null && x.prototype.ValueType == ObjectValueType.Object && x.prototype.oValue == hostedType)
                    x.Assign(res);
                return res;
            });
            ValueType = ObjectValueType.Statement;
            DefaultFieldGetter("prototype", false).Assign(new JSObject() { prototype = null, ValueType = ObjectValueType.Object, oValue = hostedType });
            base.fieldGetter = getField;
        }

        private static object[] convertArgs(IContextStatement[] source, int targetCount)
        {
            if (source == null)
                return null;
            object[] res = new object[targetCount];
            targetCount = System.Math.Min(targetCount, source.Length);
            for (int i = 0; i < targetCount; i++)
                res[i] = source[i].Invoke().Value;
            return res;
        }<commit_msg>Convert JS array to native array<commit_after>using NiL.JS.Core;
using System;
using System.Reflection;

namespace NiL.JS.Modules
{
    public sealed class ClassProxy : JSObject
    {
        private Type hostedType;

        private ClassProxy()
        {
            ValueType = ObjectValueType.Object;
            base.fieldGetter = getField;
        }

        public ClassProxy(Type host)
            : this()
        {
            hostedType = host;
            oValue = new Statements.ExternalFunction((x, y) =>
            {
                var res = new ClassProxy()
                {
                    hostedType = hostedType,
                    oValue = hostedType.GetConstructor(Type.EmptyTypes).Invoke(null)
                };
                if (x.prototype != null && x.prototype.ValueType == ObjectValueType.Object && x.prototype.oValue == hostedType)
                    x.Assign(res);
                return res;
            });
            ValueType = ObjectValueType.Statement;
            DefaultFieldGetter("prototype", false).Assign(new JSObject() { prototype = null, ValueType = ObjectValueType.Object, oValue = hostedType });
            base.fieldGetter = getField;
        }

        private static object[] convertArgs(IContextStatement[] source, int targetCount)
        {
            if (source == null)
                return null;
            object[] res = new object[targetCount];
            targetCount = System.Math.Min(targetCount, source.Length);
            for (int i = 0; i < targetCount; i++)
            {
                var obj = source[i].Invoke();
                var v = obj.Value;
                if (v == JS.Core.BaseTypes.JSArray.marker as object)
                {
                    var arg = new object[obj.GetField("length").iValue];
                    for (var j = 0; j < arg.Length; j++)
                        arg[j] = obj.GetField(j.ToString(), true).Value;
                    res[i] = arg;
                }
                else
                    res[i] = v;
            }
            return res;
        }
{'fraction_non_alphanumeric': 0.09918478260869565, 'fraction_numerical': 0.0008152173913043478, 'mean_word_length': 1.5040816326530613, 'pattern_counts': {'":': 0, '<': 6, '<?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': '6172854', 'n_tokens_mistral': 938, 'n_tokens_neox': 909, 'n_words': 219}