Commit a34bbef3 authored by domenic's avatar domenic Committed by Commit bot

Show function <name>() { [native code] } for built-in classes

The existing logic would show the full source for all classes, even
built-in ones.

R=arv@chromium.org,dslomov@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1112113002

Cr-Commit-Position: refs/heads/master@{#28151}
parent 4b122b75
...@@ -1738,6 +1738,16 @@ SetUpNumber(); ...@@ -1738,6 +1738,16 @@ SetUpNumber();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Function // Function
function NativeCodeFunctionSourceString(func) {
var name = %FunctionGetName(func);
if (name) {
// Mimic what KJS does.
return 'function ' + name + '() { [native code] }';
}
return 'function () { [native code] }';
}
function FunctionSourceString(func) { function FunctionSourceString(func) {
while (%IsJSFunctionProxy(func)) { while (%IsJSFunctionProxy(func)) {
func = %GetCallTrap(func); func = %GetCallTrap(func);
...@@ -1747,20 +1757,18 @@ function FunctionSourceString(func) { ...@@ -1747,20 +1757,18 @@ function FunctionSourceString(func) {
throw MakeTypeError(kNotGeneric, 'Function.prototype.toString'); throw MakeTypeError(kNotGeneric, 'Function.prototype.toString');
} }
if (%FunctionIsBuiltin(func)) {
return NativeCodeFunctionSourceString(func);
}
var classSource = %ClassGetSourceCode(func); var classSource = %ClassGetSourceCode(func);
if (IS_STRING(classSource)) { if (IS_STRING(classSource)) {
return classSource; return classSource;
} }
var source = %FunctionGetSourceCode(func); var source = %FunctionGetSourceCode(func);
if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { if (!IS_STRING(source)) {
var name = %FunctionGetName(func); return NativeCodeFunctionSourceString(func);
if (name) {
// Mimic what KJS does.
return 'function ' + name + '() { [native code] }';
} else {
return 'function () { [native code] }';
}
} }
if (%FunctionIsArrow(func)) { if (%FunctionIsArrow(func)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment