| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 // Store the error function in both the global object | 621 // Store the error function in both the global object |
| 622 // and the runtime object. The function is fetched | 622 // and the runtime object. The function is fetched |
| 623 // from the runtime object when throwing errors from | 623 // from the runtime object when throwing errors from |
| 624 // within the runtime system to avoid strange side | 624 // within the runtime system to avoid strange side |
| 625 // effects when overwriting the error functions from | 625 // effects when overwriting the error functions from |
| 626 // user code. | 626 // user code. |
| 627 var name = f.name; | 627 var name = f.name; |
| 628 %SetProperty(global, name, f, DONT_ENUM); | 628 %SetProperty(global, name, f, DONT_ENUM); |
| 629 this['$' + name] = f; | 629 this['$' + name] = f; |
| 630 // Configure the error function. | 630 // Configure the error function. |
| 631 // prototype of 'Error' must be as default: new Object(). | 631 if (name == 'Error') { |
| 632 if (name != 'Error') %FunctionSetPrototype(f, new $Error()); | 632 // The prototype of the Error object must itself be an error. |
| 633 // However, it can't be an instance of the Error object because |
| 634 // it hasn't been properly configured yet. Instead we create a |
| 635 // special not-a-true-error-but-close-enough object. |
| 636 function ErrorPrototype() {} |
| 637 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); |
| 638 %FunctionSetPrototype(f, new ErrorPrototype()); |
| 639 } else { |
| 640 %FunctionSetPrototype(f, new $Error()); |
| 641 } |
| 633 %FunctionSetInstanceClassName(f, 'Error'); | 642 %FunctionSetInstanceClassName(f, 'Error'); |
| 634 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); | 643 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); |
| 635 f.prototype.name = name; | 644 f.prototype.name = name; |
| 636 %SetCode(f, function(m) { | 645 %SetCode(f, function(m) { |
| 637 if (%IsConstructCall()) { | 646 if (%IsConstructCall()) { |
| 638 if (m === kAddMessageAccessorsMarker) { | 647 if (m === kAddMessageAccessorsMarker) { |
| 639 DefineOneShotAccessor(this, 'message', function (obj) { | 648 DefineOneShotAccessor(this, 'message', function (obj) { |
| 640 return FormatMessage({type: obj.type, args: obj.arguments}); | 649 return FormatMessage({type: obj.type, args: obj.arguments}); |
| 641 }); | 650 }); |
| 642 } else if (!IS_UNDEFINED(m)) { | 651 } else if (!IS_UNDEFINED(m)) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 667 return this.name + ": " + FormatMessage({ type: type, args: this.arguments }
); | 676 return this.name + ": " + FormatMessage({ type: type, args: this.arguments }
); |
| 668 } | 677 } |
| 669 var message = this.message; | 678 var message = this.message; |
| 670 return this.name + (message ? (": " + message) : ""); | 679 return this.name + (message ? (": " + message) : ""); |
| 671 }, DONT_ENUM); | 680 }, DONT_ENUM); |
| 672 | 681 |
| 673 | 682 |
| 674 // Boilerplate for exceptions for stack overflows. Used from | 683 // Boilerplate for exceptions for stack overflows. Used from |
| 675 // Top::StackOverflow(). | 684 // Top::StackOverflow(). |
| 676 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 685 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
| OLD | NEW |