Inheritance: JsObject
示例#1
0
        private JsString(JsString before, JsString after)
        {
            _before = before;
            _after = after;

            _nodes = before._nodes + after._nodes + 1;

            // Flatten if we're going over the maximum number of nodes.

            if (_nodes > MaxNodes)
            {
                Flatten();
                _nodes = 0;
            }
        }
示例#2
0
 /// <summary>
 /// 15.5.4.3
 /// </summary>
 /// <param name="target"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public JsInstance ValueOfImpl(JsString target, JsInstance[] parameters) {
     return Global.StringClass.New(target.ToString());
 }
示例#3
0
 /// <summary>
 /// 15.5.4.3
 /// </summary>
 /// <param name="target"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public JsInstance ValueOfImpl(JsString target, JsInstance[] parameters)
 {
     return(Global.StringClass.New(target.ToString()));
 }
示例#4
0
 public static object Concat(JsString left, object right)
 {
     var rightString = right as string;
     if (rightString != null)
         return Concat(left, rightString);
     var rightJsString = right as JsString;
     if (rightJsString != null)
         return Concat(left, rightJsString);
     return Concat(left, JsValue.ToString(right));
 }
示例#5
0
 public static object Concat(JsString left, JsString right)
 {
     return new JsString(left, right);
 }
示例#6
0
        private void Flatten()
        {
            var sb = new StringBuilder();

            Flatten(sb, _before);
            Flatten(sb, _after);

            _value = sb.ToString();

            _before = null;
            _after = null;
        }
示例#7
0
        private static void Flatten(StringBuilder sb, JsString node)
        {
            while (true)
            {
                if (node._value != null)
                {
                    sb.Append(node._value);
                    break;
                }

                Flatten(sb, node._before);
                node = node._after;
            }
        }
示例#8
0
 public static object Concat(object left, JsString right)
 {
     var leftString = left as string;
     if (leftString != null)
         return Concat(leftString, right);
     var leftJsString = left as JsString;
     if (leftJsString != null)
         return Concat(leftJsString, right);
     return Concat(JsValue.ToString(left), right);
 }