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

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

Issue 28053005: Hide MirroredCompilationErrror behind a flag until post-1.0. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 "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,
20 "Wrap compilation errors that occur during reflective access in a "
21 "MirroredCompilationError, rather than suspending the isolate.");
22
19 static RawInstance* CreateMirror(const String& mirror_class_name, 23 static RawInstance* CreateMirror(const String& mirror_class_name,
20 const Array& constructor_arguments) { 24 const Array& constructor_arguments) {
21 const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); 25 const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary());
22 const String& constructor_name = Symbols::Dot(); 26 const String& constructor_name = Symbols::Dot();
23 27
24 const Object& result = Object::Handle( 28 const Object& result = Object::Handle(
25 DartLibraryCalls::InstanceCreate(mirrors_lib, 29 DartLibraryCalls::InstanceCreate(mirrors_lib,
26 mirror_class_name, 30 mirror_class_name,
27 constructor_name, 31 constructor_name,
28 constructor_arguments)); 32 constructor_arguments));
29 ASSERT(!result.IsError()); 33 ASSERT(!result.IsError());
30 return Instance::Cast(result).raw(); 34 return Instance::Cast(result).raw();
31 } 35 }
32 36
33 37
34 static void ThrowMirroredCompilationError(const String& message) { 38 static void ThrowMirroredCompilationError(const String& message) {
35 Array& args = Array::Handle(Array::New(1)); 39 Array& args = Array::Handle(Array::New(1));
36 args.SetAt(0, message); 40 args.SetAt(0, message);
37 41
38 Exceptions::ThrowByType(Exceptions::kMirroredCompilationError, args); 42 Exceptions::ThrowByType(Exceptions::kMirroredCompilationError, args);
39 UNREACHABLE(); 43 UNREACHABLE();
40 } 44 }
41 45
42 46
43 static void ThrowInvokeError(const Error& error) { 47 static void ThrowInvokeError(const Error& error) {
44 if (error.IsLanguageError()) { 48 if (FLAG_use_mirrored_compilation_error && error.IsLanguageError()) {
45 // A compilation error that was delayed by lazy compilation. 49 // A compilation error that was delayed by lazy compilation.
46 const LanguageError& compilation_error = LanguageError::Cast(error); 50 const LanguageError& compilation_error = LanguageError::Cast(error);
47 String& message = String::Handle(compilation_error.message()); 51 String& message = String::Handle(compilation_error.message());
48 ThrowMirroredCompilationError(message); 52 ThrowMirroredCompilationError(message);
49 UNREACHABLE(); 53 UNREACHABLE();
50 } 54 }
51 Exceptions::PropagateError(error); 55 Exceptions::PropagateError(error);
52 UNREACHABLE(); 56 UNREACHABLE();
53 } 57 }
54 58
(...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 } 1970 }
1967 1971
1968 1972
1969 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1973 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1970 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1974 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1971 const Field& field = Field::Handle(ref.GetFieldReferent()); 1975 const Field& field = Field::Handle(ref.GetFieldReferent());
1972 return field.type(); 1976 return field.type();
1973 } 1977 }
1974 1978
1975 } // namespace dart 1979 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698