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

Side by Side Diff: src/api.cc

Issue 106763002: Get information about original function from bound function (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Correct API + add a test Created 7 years 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 4287 matching lines...) Expand 10 before | Expand all | Expand 10 after
4298 4298
4299 4299
4300 int Function::ScriptId() const { 4300 int Function::ScriptId() const {
4301 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4301 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4302 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; 4302 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId;
4303 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4303 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4304 return script->id()->value(); 4304 return script->id()->value();
4305 } 4305 }
4306 4306
4307 4307
4308 Local<v8::Function> Function::GetBoundFunction() const {
4309 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4310 if (!func->shared()->bound()) {
4311 return Utils::ToLocal(func);
4312 }
4313 i::Handle<i::FixedArray> bound_args = i::Handle<i::FixedArray>(
4314 i::FixedArray::cast(func->function_bindings()));
4315 i::Handle<i::Object> original(
4316 i::JSReceiver::cast(bound_args->get(i::JSFunction::kBoundFunctionIndex)),
4317 i::Isolate::Current());
4318 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(original));
4319 }
4320
4321
4308 int String::Length() const { 4322 int String::Length() const {
4309 i::Handle<i::String> str = Utils::OpenHandle(this); 4323 i::Handle<i::String> str = Utils::OpenHandle(this);
4310 return str->length(); 4324 return str->length();
4311 } 4325 }
4312 4326
4313 4327
4314 bool String::IsOneByte() const { 4328 bool String::IsOneByte() const {
4315 i::Handle<i::String> str = Utils::OpenHandle(this); 4329 i::Handle<i::String> str = Utils::OpenHandle(this);
4316 return str->HasOnlyOneByteChars(); 4330 return str->HasOnlyOneByteChars();
4317 } 4331 }
(...skipping 3462 matching lines...) Expand 10 before | Expand all | Expand 10 after
7780 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7794 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7781 Address callback_address = 7795 Address callback_address =
7782 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7796 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7783 VMState<EXTERNAL> state(isolate); 7797 VMState<EXTERNAL> state(isolate);
7784 ExternalCallbackScope call_scope(isolate, callback_address); 7798 ExternalCallbackScope call_scope(isolate, callback_address);
7785 callback(info); 7799 callback(info);
7786 } 7800 }
7787 7801
7788 7802
7789 } } // namespace v8::internal 7803 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698