Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // ------------------------------------------------------------------- | 5 // ------------------------------------------------------------------- |
| 6 | 6 |
| 7 var kMessages = { | 7 var kMessages = { |
| 8 // Error | 8 // Error |
| 9 cyclic_proto: ["Cyclic __proto__ value"], | 9 cyclic_proto: ["Cyclic __proto__ value"], |
| 10 code_gen_from_strings: ["%0"], | 10 code_gen_from_strings: ["%0"], |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 if (IS_NULL(obj)) return 'null'; | 216 if (IS_NULL(obj)) return 'null'; |
| 217 if (IS_FUNCTION(obj)) { | 217 if (IS_FUNCTION(obj)) { |
| 218 var str = %_CallFunction(obj, FunctionToString); | 218 var str = %_CallFunction(obj, FunctionToString); |
| 219 if (str.length > 128) { | 219 if (str.length > 128) { |
| 220 str = %_SubString(str, 0, 111) + "...<omitted>..." + | 220 str = %_SubString(str, 0, 111) + "...<omitted>..." + |
| 221 %_SubString(str, str.length - 2, str.length); | 221 %_SubString(str, str.length - 2, str.length); |
| 222 } | 222 } |
| 223 return str; | 223 return str; |
| 224 } | 224 } |
| 225 if (IS_SYMBOL(obj)) return %_CallFunction(obj, SymbolToString); | 225 if (IS_SYMBOL(obj)) return %_CallFunction(obj, SymbolToString); |
| 226 if (IS_OBJECT(obj) && %GetDataProperty(obj, "toString") === ObjectToString) { | 226 if (IS_OBJECT(obj) && %GetDataProperty(obj, "toString") === DefaultObjectToStr ing) { |
|
Dmitry Lomov (no reviews)
2014/10/21 06:11:53
Line length
caitp (gmail)
2014/10/21 14:54:45
Acknowledged.
| |
| 227 var constructor = %GetDataProperty(obj, "constructor"); | 227 var constructor = %GetDataProperty(obj, "constructor"); |
| 228 if (typeof constructor == "function") { | 228 if (typeof constructor == "function") { |
| 229 var constructorName = constructor.name; | 229 var constructorName = constructor.name; |
| 230 if (IS_STRING(constructorName) && constructorName !== "") { | 230 if (IS_STRING(constructorName) && constructorName !== "") { |
| 231 return "#<" + constructorName + ">"; | 231 return "#<" + constructorName + ">"; |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 if (CanBeSafelyTreatedAsAnErrorObject(obj)) { | 235 if (CanBeSafelyTreatedAsAnErrorObject(obj)) { |
| 236 return %_CallFunction(obj, ErrorToString); | 236 return %_CallFunction(obj, ErrorToString); |
| 237 } | 237 } |
| 238 | |
| 238 return %_CallFunction(obj, ObjectToString); | 239 return %_CallFunction(obj, ObjectToString); |
| 239 } | 240 } |
| 240 | 241 |
| 241 // To determine whether we can safely stringify an object using ErrorToString | 242 // To determine whether we can safely stringify an object using ErrorToString |
| 242 // without the risk of side-effects, we need to check whether the object is | 243 // without the risk of side-effects, we need to check whether the object is |
| 243 // either an instance of a native error type (via '%_ClassOf'), or has $Error | 244 // either an instance of a native error type (via '%_ClassOf'), or has $Error |
| 244 // in its prototype chain and hasn't overwritten 'toString' with something | 245 // in its prototype chain and hasn't overwritten 'toString' with something |
| 245 // strange and unusual. | 246 // strange and unusual. |
| 246 function CanBeSafelyTreatedAsAnErrorObject(obj) { | 247 function CanBeSafelyTreatedAsAnErrorObject(obj) { |
| 247 switch (%_ClassOf(obj)) { | 248 switch (%_ClassOf(obj)) { |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1300 function SetUpStackOverflowBoilerplate() { | 1301 function SetUpStackOverflowBoilerplate() { |
| 1301 var boilerplate = MakeRangeError('stack_overflow', []); | 1302 var boilerplate = MakeRangeError('stack_overflow', []); |
| 1302 | 1303 |
| 1303 %DefineAccessorPropertyUnchecked( | 1304 %DefineAccessorPropertyUnchecked( |
| 1304 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1305 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
| 1305 | 1306 |
| 1306 return boilerplate; | 1307 return boilerplate; |
| 1307 } | 1308 } |
| 1308 | 1309 |
| 1309 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1310 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
| OLD | NEW |