Commit c71eccf9 authored by yurys@chromium.org's avatar yurys@chromium.org

Expose v8::Function::IsBuiltin to public API.

This will be used by DevTools so that we could generate a better preview in console. Namely, we could assume that a preview of an object is lossless if all its member functions are builtin.

We also may want to expose this to DevTools users via remote debugging protocol in Debugger.FunctionDetails struct.

BUG=chromium:261470
R=mstarzinger@chromium.org, yurys@chromium.org, dcarney@chromium.org, yurys

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

Patch from Andrey Adaikin <aandrey@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17323 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 41318a27
......@@ -2489,6 +2489,11 @@ class V8_EXPORT Function : public Object {
*/
int GetScriptColumnNumber() const;
/**
* Tells whether this function is builtin.
*/
bool IsBuiltin() const;
/**
* Returns scriptId object.
*/
......
......@@ -4148,6 +4148,12 @@ int Function::GetScriptColumnNumber() const {
}
bool Function::IsBuiltin() const {
i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
return func->IsBuiltin();
}
Handle<Value> Function::GetScriptId() const {
i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
i::Isolate* isolate = func->GetIsolate();
......
......@@ -17537,6 +17537,23 @@ THREADED_TEST(ScriptColumnNumber) {
}
THREADED_TEST(FunctionIsBuiltin) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::Function> f;
f = v8::Local<v8::Function>::Cast(CompileRun("Math.floor"));
CHECK(f->IsBuiltin());
f = v8::Local<v8::Function>::Cast(CompileRun("Object"));
CHECK(f->IsBuiltin());
f = v8::Local<v8::Function>::Cast(CompileRun("Object.__defineSetter__"));
CHECK(f->IsBuiltin());
f = v8::Local<v8::Function>::Cast(CompileRun("Array.prototype.toString"));
CHECK(f->IsBuiltin());
f = v8::Local<v8::Function>::Cast(CompileRun("function a() {}; a;"));
CHECK(!f->IsBuiltin());
}
THREADED_TEST(FunctionGetScriptId) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
......
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