Commit 576ae4c1 authored by ager@chromium.org's avatar ager@chromium.org

Land change by Jan de Mooij to change the toString behavior of

|function|.toString() for builtin functions.

Review URL: http://codereview.chromium.org/209014

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2913 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b58abab2
...@@ -10,6 +10,7 @@ Alexandre Vassalotti <avassalotti@gmail.com> ...@@ -10,6 +10,7 @@ Alexandre Vassalotti <avassalotti@gmail.com>
Craig Schlenter <craig.schlenter@gmail.com> Craig Schlenter <craig.schlenter@gmail.com>
Daniel Andersson <kodandersson@gmail.com> Daniel Andersson <kodandersson@gmail.com>
Daniel James <dnljms@gmail.com> Daniel James <dnljms@gmail.com>
Jan de Mooij <jandemooij@gmail.com>
Jay Freeman <saurik@saurik.com> Jay Freeman <saurik@saurik.com>
Joel Stanley <joel.stan@gmail.com> Joel Stanley <joel.stan@gmail.com>
Matt Hanselman <mjhanselman@gmail.com> Matt Hanselman <mjhanselman@gmail.com>
......
...@@ -1208,6 +1208,14 @@ static Object* Runtime_FunctionIsAPIFunction(Arguments args) { ...@@ -1208,6 +1208,14 @@ static Object* Runtime_FunctionIsAPIFunction(Arguments args) {
: Heap::false_value(); : Heap::false_value();
} }
static Object* Runtime_FunctionIsBuiltin(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSFunction, f, args[0]);
return f->IsBuiltin() ? Heap::true_value() : Heap::false_value();
}
static Object* Runtime_SetCode(Arguments args) { static Object* Runtime_SetCode(Arguments args) {
HandleScope scope; HandleScope scope;
......
...@@ -171,6 +171,7 @@ namespace internal { ...@@ -171,6 +171,7 @@ namespace internal {
F(FunctionGetScriptSourcePosition, 1, 1) \ F(FunctionGetScriptSourcePosition, 1, 1) \
F(FunctionGetPositionForOffset, 2, 1) \ F(FunctionGetPositionForOffset, 2, 1) \
F(FunctionIsAPIFunction, 1, 1) \ F(FunctionIsAPIFunction, 1, 1) \
F(FunctionIsBuiltin, 1, 1) \
F(GetScript, 1, 1) \ F(GetScript, 1, 1) \
F(CollectStackTrace, 2, 1) \ F(CollectStackTrace, 2, 1) \
\ \
......
...@@ -524,7 +524,7 @@ function FunctionSourceString(func) { ...@@ -524,7 +524,7 @@ function FunctionSourceString(func) {
} }
var source = %FunctionGetSourceCode(func); var source = %FunctionGetSourceCode(func);
if (!IS_STRING(source)) { if (!IS_STRING(source) || %FunctionIsBuiltin(func)) {
var name = %FunctionGetName(func); var name = %FunctionGetName(func);
if (name) { if (name) {
// Mimic what KJS does. // Mimic what KJS does.
...@@ -534,12 +534,6 @@ function FunctionSourceString(func) { ...@@ -534,12 +534,6 @@ function FunctionSourceString(func) {
} }
} }
// Censor occurrences of internal calls. We do that for all
// functions and don't cache under the assumption that people rarly
// convert functions to strings. Note that we (apparently) can't
// use regular expression literals in natives files.
var regexp = ORIGINAL_REGEXP("%(\\w+\\()", "gm");
if (source.match(regexp)) source = source.replace(regexp, "$1");
var name = %FunctionGetName(func); var name = %FunctionGetName(func);
return 'function ' + name + source; return 'function ' + name + source;
} }
......
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