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

Side by Side Diff: runtime/lib/mirrors.cc

Issue 52953002: Hide ClosureMirror.findInContext behind a flag for 1.0. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 1 month 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
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "lib/invocation_mirror.h" 5 #include "lib/invocation_mirror.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
11 #include "vm/object_store.h" 11 #include "vm/object_store.h"
12 #include "vm/parser.h" 12 #include "vm/parser.h"
13 #include "vm/port.h" 13 #include "vm/port.h"
14 #include "vm/resolver.h" 14 #include "vm/resolver.h"
15 #include "vm/symbols.h" 15 #include "vm/symbols.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 DEFINE_FLAG(bool, use_mirrored_compilation_error, false, 19 DEFINE_FLAG(bool, use_mirrored_compilation_error, false,
20 "Wrap compilation errors that occur during reflective access in a " 20 "Wrap compilation errors that occur during reflective access in a "
21 "MirroredCompilationError, rather than suspending the isolate."); 21 "MirroredCompilationError, rather than suspending the isolate.");
22 22
23 DEFINE_FLAG(bool, support_find_in_context, false,
24 "Experimental support for ClosureMirror.findInContext.");
25
23 static RawInstance* CreateMirror(const String& mirror_class_name, 26 static RawInstance* CreateMirror(const String& mirror_class_name,
24 const Array& constructor_arguments) { 27 const Array& constructor_arguments) {
25 const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); 28 const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary());
26 const String& constructor_name = Symbols::Dot(); 29 const String& constructor_name = Symbols::Dot();
27 30
28 const Object& result = Object::Handle( 31 const Object& result = Object::Handle(
29 DartLibraryCalls::InstanceCreate(mirrors_lib, 32 DartLibraryCalls::InstanceCreate(mirrors_lib,
30 mirror_class_name, 33 mirror_class_name,
31 constructor_name, 34 constructor_name,
32 constructor_arguments)); 35 constructor_arguments));
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 717
715 static RawInstance* LookupStaticFunctionOrFieldInClass( 718 static RawInstance* LookupStaticFunctionOrFieldInClass(
716 const Class& klass, 719 const Class& klass,
717 const String& lookup_name) { 720 const String& lookup_name) {
718 Instance& result = Instance::Handle( 721 Instance& result = Instance::Handle(
719 InvokeClassGetter(klass, lookup_name, false)); 722 InvokeClassGetter(klass, lookup_name, false));
720 if (result.raw() != Object::sentinel().raw()) { 723 if (result.raw() != Object::sentinel().raw()) {
721 return result.raw(); 724 return result.raw();
722 } 725 }
723 726
724 Function& func = Function::Handle(); 727 const Function& func =
725 Class& lookup_class = Class::Handle(klass.raw()); 728 Function::Handle(klass.LookupStaticFunction(lookup_name));
726 while (func.IsNull() && !lookup_class.IsNull()) {
727 func ^= lookup_class.LookupStaticFunction(lookup_name);
728 lookup_class = lookup_class.SuperClass();
729 }
730 if (!func.IsNull()) { 729 if (!func.IsNull()) {
731 const Function& closure_function = Function::Handle( 730 const Function& closure_function = Function::Handle(
732 func.ImplicitClosureFunction()); 731 func.ImplicitClosureFunction());
733 ASSERT(!closure_function.IsNull()); 732 ASSERT(!closure_function.IsNull());
734 return closure_function.ImplicitStaticClosure(); 733 return closure_function.ImplicitStaticClosure();
735 } 734 }
736 735
737 // Fall through case: Indicate that we didn't find any function or field using 736 // Fall through case: Indicate that we didn't find any function or field using
738 // a special null instance. This is different from a field being null. Callers 737 // a special null instance. This is different from a field being null. Callers
739 // make sure that this null does not leak into Dartland. 738 // make sure that this null does not leak into Dartland.
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 Object::Handle(DartEntry::InvokeClosure(args, args_descriptor)); 1416 Object::Handle(DartEntry::InvokeClosure(args, args_descriptor));
1418 if (result.IsError()) { 1417 if (result.IsError()) {
1419 ThrowInvokeError(Error::Cast(result)); 1418 ThrowInvokeError(Error::Cast(result));
1420 UNREACHABLE(); 1419 UNREACHABLE();
1421 } 1420 }
1422 return result.raw(); 1421 return result.raw();
1423 } 1422 }
1424 1423
1425 1424
1426 DEFINE_NATIVE_ENTRY(ClosureMirror_find_in_context, 2) { 1425 DEFINE_NATIVE_ENTRY(ClosureMirror_find_in_context, 2) {
1426 if (!FLAG_support_find_in_context) {
1427 return Object::empty_array().raw();
1428 }
1429
1427 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0)); 1430 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0));
1428 GET_NON_NULL_NATIVE_ARGUMENT(Array, lookup_parts, arguments->NativeArgAt(1)); 1431 GET_NON_NULL_NATIVE_ARGUMENT(Array, lookup_parts, arguments->NativeArgAt(1));
1429 ASSERT(lookup_parts.Length() >= 1 && lookup_parts.Length() <= 3); 1432 ASSERT(lookup_parts.Length() >= 1 && lookup_parts.Length() <= 3);
1430 1433
1431 if (!closure.IsClosure()) { 1434 if (!closure.IsClosure()) {
1432 const Array& result_tuple = Array::Handle(Array::New(2)); 1435 const Array& result_tuple = Array::Handle(Array::New(2));
1433 result_tuple.SetAt(0, Bool::False()); 1436 result_tuple.SetAt(0, Bool::False());
1434 return result_tuple.raw(); 1437 return result_tuple.raw();
1435 } 1438 }
1436 1439
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 } 1960 }
1958 1961
1959 1962
1960 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1963 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1961 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1964 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1962 const Field& field = Field::Handle(ref.GetFieldReferent()); 1965 const Field& field = Field::Handle(ref.GetFieldReferent());
1963 return field.type(); 1966 return field.type();
1964 } 1967 }
1965 1968
1966 } // namespace dart 1969 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698