Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: src/v8natives.js

Issue 624013005: Classes: Add support for toString (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add type checks Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | test/mjsunit/harmony/classes.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file relies on the fact that the following declarations have been made 5 // This file relies on the fact that the following declarations have been made
6 // in runtime.js: 6 // in runtime.js:
7 // var $Object = global.Object; 7 // var $Object = global.Object;
8 // var $Boolean = global.Boolean; 8 // var $Boolean = global.Boolean;
9 // var $Number = global.Number; 9 // var $Number = global.Number;
10 // var $Function = global.Function; 10 // var $Function = global.Function;
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 1732
1733 function FunctionSourceString(func) { 1733 function FunctionSourceString(func) {
1734 while (%IsJSFunctionProxy(func)) { 1734 while (%IsJSFunctionProxy(func)) {
1735 func = %GetCallTrap(func); 1735 func = %GetCallTrap(func);
1736 } 1736 }
1737 1737
1738 if (!IS_FUNCTION(func)) { 1738 if (!IS_FUNCTION(func)) {
1739 throw new $TypeError('Function.prototype.toString is not generic'); 1739 throw new $TypeError('Function.prototype.toString is not generic');
1740 } 1740 }
1741 1741
1742 var classSource = %ClassGetSourceCode(func);
1743 if (IS_STRING(classSource)) {
1744 return classSource;
1745 }
1746
1742 var source = %FunctionGetSourceCode(func); 1747 var source = %FunctionGetSourceCode(func);
1743 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { 1748 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) {
1744 var name = %FunctionGetName(func); 1749 var name = %FunctionGetName(func);
1745 if (name) { 1750 if (name) {
1746 // Mimic what KJS does. 1751 // Mimic what KJS does.
1747 return 'function ' + name + '() { [native code] }'; 1752 return 'function ' + name + '() { [native code] }';
1748 } else { 1753 } else {
1749 return 'function () { [native code] }'; 1754 return 'function () { [native code] }';
1750 } 1755 }
1751 } 1756 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 } 1908 }
1904 if (!IS_SPEC_FUNCTION(method)) { 1909 if (!IS_SPEC_FUNCTION(method)) {
1905 throw MakeTypeError('not_iterable', [obj]); 1910 throw MakeTypeError('not_iterable', [obj]);
1906 } 1911 }
1907 var iterator = %_CallFunction(obj, method); 1912 var iterator = %_CallFunction(obj, method);
1908 if (!IS_SPEC_OBJECT(iterator)) { 1913 if (!IS_SPEC_OBJECT(iterator)) {
1909 throw MakeTypeError('not_an_iterator', [iterator]); 1914 throw MakeTypeError('not_an_iterator', [iterator]);
1910 } 1915 }
1911 return iterator; 1916 return iterator;
1912 } 1917 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | test/mjsunit/harmony/classes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698