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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 10834096: Added Dart_FunctionEnclosingClassOrLibrary. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 months 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 2766 matching lines...) Expand 10 before | Expand all | Expand 10 after
2777 func_name = func.name(); 2777 func_name = func.name();
2778 bool is_setter = Field::IsSetterName(func_name); 2778 bool is_setter = Field::IsSetterName(func_name);
2779 func_name = IdentifierPrettyName(isolate, func_name); 2779 func_name = IdentifierPrettyName(isolate, func_name);
2780 if (is_setter) { 2780 if (is_setter) {
2781 func_name = AddExternalSetterSuffix(func_name); 2781 func_name = AddExternalSetterSuffix(func_name);
2782 } 2782 }
2783 return Api::NewHandle(isolate, func_name.raw()); 2783 return Api::NewHandle(isolate, func_name.raw());
2784 } 2784 }
2785 2785
2786 2786
2787 DART_EXPORT Dart_Handle Dart_FunctionEnclosingClassOrLibrary(
2788 Dart_Handle function) {
2789 Isolate* isolate = Isolate::Current();
2790 DARTSCOPE(isolate);
2791 const Function& func = Api::UnwrapFunctionHandle(isolate, function);
2792 if (func.IsNull()) {
2793 RETURN_TYPE_ERROR(isolate, function, Function);
2794 }
Ivan Posva 2012/07/31 23:38:58 if (func.IsError()) { return function; }
rmacnak 2012/08/01 17:21:55 If I add that test with an ASSERT(false), that pat
turnidge 2012/08/01 17:59:42 Checking for an error handle isn't required here.
Ivan Posva 2012/08/01 20:43:55 Thanks for the clarification. The difference betwe
2795 const Class& owner = Class::Handle(func.owner());
2796 ASSERT(!owner.IsNull());
2797 if (owner.IsTopLevel()) {
2798 // Top-level functions are implemented as members of a hidden class. We hide
2799 // that class here and instead answer the library.
2800 #if defined(DEBUG)
2801 const Library& lib = Library::Handle(owner.library());
2802 if (lib.IsNull()) {
2803 ASSERT(owner.IsDynamicClass() || owner.IsVoidClass());
2804 }
2805 #endif
2806 return Api::NewHandle(isolate, owner.library());
2807 } else {
2808 return Api::NewHandle(isolate, owner.raw());
2809 }
2810 }
2811
2812
2787 DART_EXPORT Dart_Handle Dart_FunctionIsAbstract(Dart_Handle function, 2813 DART_EXPORT Dart_Handle Dart_FunctionIsAbstract(Dart_Handle function,
2788 bool* is_abstract) { 2814 bool* is_abstract) {
2789 Isolate* isolate = Isolate::Current(); 2815 Isolate* isolate = Isolate::Current();
2790 DARTSCOPE(isolate); 2816 DARTSCOPE(isolate);
2791 if (is_abstract == NULL) { 2817 if (is_abstract == NULL) {
2792 RETURN_NULL_ERROR(is_abstract); 2818 RETURN_NULL_ERROR(is_abstract);
2793 } 2819 }
2794 const Function& func = Api::UnwrapFunctionHandle(isolate, function); 2820 const Function& func = Api::UnwrapFunctionHandle(isolate, function);
2795 if (func.IsNull()) { 2821 if (func.IsNull()) {
2796 RETURN_TYPE_ERROR(isolate, function, Function); 2822 RETURN_TYPE_ERROR(isolate, function, Function);
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
4176 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { 4202 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) {
4177 Dart::set_perf_events_writer(function); 4203 Dart::set_perf_events_writer(function);
4178 } 4204 }
4179 4205
4180 4206
4181 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { 4207 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) {
4182 Dart::set_flow_graph_writer(function); 4208 Dart::set_flow_graph_writer(function);
4183 } 4209 }
4184 4210
4185 } // namespace dart 4211 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698