OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 "use strict"; | 5 "use strict"; |
6 | 6 |
7 String.prototype.startsWith = function (str) { | 7 String.prototype.startsWith = function (str) { |
8 if (str.length > this.length) { | 8 if (str.length > this.length) { |
9 return false; | 9 return false; |
10 } | 10 } |
(...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 {}.hasOwnProperty.call(x, i) ? Stringify(x[i], depth - 1) : ""); | 1990 {}.hasOwnProperty.call(x, i) ? Stringify(x[i], depth - 1) : ""); |
1991 } | 1991 } |
1992 return "[" + elems.join(", ") + "]"; | 1992 return "[" + elems.join(", ") + "]"; |
1993 } | 1993 } |
1994 try { | 1994 try { |
1995 var string = String(x); | 1995 var string = String(x); |
1996 if (string && string !== "[object Object]") return string; | 1996 if (string && string !== "[object Object]") return string; |
1997 } catch(e) {} | 1997 } catch(e) {} |
1998 var props = []; | 1998 var props = []; |
1999 var names = Object.getOwnPropertyNames(x); | 1999 var names = Object.getOwnPropertyNames(x); |
2000 if (Object.getOwnPropertySymbols) { | 2000 names = names.concat(Object.getOwnPropertySymbols(x)); |
2001 // FLAG_harmony_symbols is turned on. | |
2002 names = names.concat(Object.getOwnPropertySymbols(x)); | |
2003 } | |
2004 for (var i in names) { | 2001 for (var i in names) { |
2005 var name = names[i]; | 2002 var name = names[i]; |
2006 var desc = Object.getOwnPropertyDescriptor(x, name); | 2003 var desc = Object.getOwnPropertyDescriptor(x, name); |
2007 if (IS_UNDEFINED(desc)) continue; | 2004 if (IS_UNDEFINED(desc)) continue; |
2008 if (IS_SYMBOL(name)) name = "[" + Stringify(name) + "]"; | 2005 if (IS_SYMBOL(name)) name = "[" + Stringify(name) + "]"; |
2009 if ("value" in desc) { | 2006 if ("value" in desc) { |
2010 props.push(name + ": " + Stringify(desc.value, depth - 1)); | 2007 props.push(name + ": " + Stringify(desc.value, depth - 1)); |
2011 } | 2008 } |
2012 if (desc.get) { | 2009 if (desc.get) { |
2013 var getter = Stringify(desc.get); | 2010 var getter = Stringify(desc.get); |
2014 props.push("get " + name + getter.slice(getter.indexOf('('))); | 2011 props.push("get " + name + getter.slice(getter.indexOf('('))); |
2015 } | 2012 } |
2016 if (desc.set) { | 2013 if (desc.set) { |
2017 var setter = Stringify(desc.set); | 2014 var setter = Stringify(desc.set); |
2018 props.push("set " + name + setter.slice(setter.indexOf('('))); | 2015 props.push("set " + name + setter.slice(setter.indexOf('('))); |
2019 } | 2016 } |
2020 } | 2017 } |
2021 return "{" + props.join(", ") + "}"; | 2018 return "{" + props.join(", ") + "}"; |
2022 default: | 2019 default: |
2023 return "[crazy non-standard shit]"; | 2020 return "[crazy non-standard shit]"; |
2024 } | 2021 } |
2025 } | 2022 } |
OLD | NEW |