OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 5205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5216 if (!function->bound_target_function()->IsJSFunction()) return prefix; | 5216 if (!function->bound_target_function()->IsJSFunction()) return prefix; |
5217 Handle<JSFunction> target(JSFunction::cast(function->bound_target_function()), | 5217 Handle<JSFunction> target(JSFunction::cast(function->bound_target_function()), |
5218 isolate); | 5218 isolate); |
5219 Handle<Object> target_name = JSFunction::GetName(isolate, target); | 5219 Handle<Object> target_name = JSFunction::GetName(isolate, target); |
5220 if (!target_name->IsString()) return prefix; | 5220 if (!target_name->IsString()) return prefix; |
5221 Factory* factory = isolate->factory(); | 5221 Factory* factory = isolate->factory(); |
5222 return factory->NewConsString(prefix, Handle<String>::cast(target_name)); | 5222 return factory->NewConsString(prefix, Handle<String>::cast(target_name)); |
5223 } | 5223 } |
5224 | 5224 |
5225 // static | 5225 // static |
| 5226 Handle<Object> JSFunction::GetPrototype(Isolate* isolate, |
| 5227 Handle<JSFunction> function) { |
| 5228 DCHECK(function->IsConstructor() || function->shared()->is_generator()); |
| 5229 if (!function->has_prototype()) { |
| 5230 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function); |
| 5231 JSFunction::SetPrototype(function, proto); |
| 5232 } |
| 5233 return handle(function->prototype(), isolate); |
| 5234 } |
| 5235 |
| 5236 // static |
5226 Handle<Object> JSFunction::GetName(Isolate* isolate, | 5237 Handle<Object> JSFunction::GetName(Isolate* isolate, |
5227 Handle<JSFunction> function) { | 5238 Handle<JSFunction> function) { |
5228 if (function->shared()->name_should_print_as_anonymous()) { | 5239 if (function->shared()->name_should_print_as_anonymous()) { |
5229 return isolate->factory()->anonymous_string(); | 5240 return isolate->factory()->anonymous_string(); |
5230 } | 5241 } |
5231 return handle(function->shared()->name(), isolate); | 5242 return handle(function->shared()->name(), isolate); |
5232 } | 5243 } |
5233 | 5244 |
5234 // static | 5245 // static |
5235 MaybeHandle<Smi> JSFunction::GetLength(Isolate* isolate, | 5246 MaybeHandle<Smi> JSFunction::GetLength(Isolate* isolate, |
(...skipping 13639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18875 } else { | 18886 } else { |
18876 // Old-style generators. | 18887 // Old-style generators. |
18877 int offset = continuation(); | 18888 int offset = continuation(); |
18878 CHECK(0 <= offset && offset < function()->code()->instruction_size()); | 18889 CHECK(0 <= offset && offset < function()->code()->instruction_size()); |
18879 return function()->code()->SourcePosition(offset); | 18890 return function()->code()->SourcePosition(offset); |
18880 } | 18891 } |
18881 } | 18892 } |
18882 | 18893 |
18883 } // namespace internal | 18894 } // namespace internal |
18884 } // namespace v8 | 18895 } // namespace v8 |
OLD | NEW |