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; } }
/// <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()); }
/// <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())); }
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)); }
public static object Concat(JsString left, JsString right) { return new JsString(left, right); }
private void Flatten() { var sb = new StringBuilder(); Flatten(sb, _before); Flatten(sb, _after); _value = sb.ToString(); _before = null; _after = null; }
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; } }
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); }