Ejemplo n.º 1
0
        // ECMA-262 section 15.4.4.5
        //private StringBuilder join(mdr.DArray array) { return join(array, null); }
        private StringBuilder join(mdr.DObject obj, string separator)
        {
            if (obj == null)
            {
                throw new ArgumentException("Object is null!");
            }

            if (separator == null)
            {
                separator = ",";
            }

            StringBuilder strBuilder  = new StringBuilder(string.Empty);
            var           lengthField = obj.GetFieldByFieldId(mdr.Runtime.Instance.LengthFieldId);
            var           length      = Operations.Convert.ToInt32.Run(ref lengthField);

            if (length == 0)
            {
                return(strBuilder);
            }

            var element_0 = obj.GetField(0);

            if (element_0.ValueType != mdr.ValueTypes.Undefined && element_0.ValueType != mdr.ValueTypes.Null)
            {
                strBuilder.Append(Operations.Convert.ToString.Run(ref element_0));
            }
            for (int k = 1; k < length; k++)
            {
                strBuilder.Append(separator);
                var element_k = obj.GetField(k);
                if (element_k.ValueType != mdr.ValueTypes.Undefined && element_k.ValueType != mdr.ValueTypes.Null)
                {
                    strBuilder.Append(Operations.Convert.ToString.Run(ref element_k));
                }
            }

            return(strBuilder);
        }