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

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

Issue 20066004: Change the return value of setField to be in line with non-reflective assignments. Complete unwrapp… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 #include "include/dart_debugger_api.h" 6 #include "include/dart_debugger_api.h"
7 #include "include/dart_mirrors_api.h" 7 #include "include/dart_mirrors_api.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef. 9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef.
10 #include "vm/bootstrap_natives.h" 10 #include "vm/bootstrap_natives.h"
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 } 1164 }
1165 1165
1166 1166
1167 void HandleMirrorsMessage(Isolate* isolate, 1167 void HandleMirrorsMessage(Isolate* isolate,
1168 Dart_Port reply_port, 1168 Dart_Port reply_port,
1169 const Instance& message) { 1169 const Instance& message) {
1170 UNIMPLEMENTED(); 1170 UNIMPLEMENTED();
1171 } 1171 }
1172 1172
1173 1173
1174 // TODO(11742): This is transitional.
1175 static RawInstance* Reflect(const Instance& reflectee) {
1176 Isolate* isolate = Isolate::Current();
1177 DARTSCOPE(isolate);
1178 return Instance::RawCast(
1179 Api::UnwrapHandle(
1180 CreateInstanceMirror(
1181 Api::NewHandle(isolate, reflectee.raw()))));
1182 }
1183
1184
1185 static void ThrowMirroredUnhandledError(const Error& original_error) {
1186 const UnhandledException& unhandled_ex =
1187 UnhandledException::Cast(original_error);
1188 Instance& exc = Instance::Handle(unhandled_ex.exception());
1189 Instance& stack = Instance::Handle(unhandled_ex.stacktrace());
1190
1191 Object& exc_string_or_error =
1192 Object::Handle(DartLibraryCalls::ToString(exc));
1193 String& exc_string = String::Handle();
1194 // Ignore any errors that might occur in toString.
1195 if (exc_string_or_error.IsString()) {
1196 exc_string ^= exc_string_or_error.raw();
1197 }
1198
1199 Instance& mirror_on_exc = Instance::Handle(Reflect(exc));
1200
1201 Array& args = Array::Handle(Array::New(3));
1202 args.SetAt(0, mirror_on_exc);
1203 args.SetAt(1, exc_string);
1204 args.SetAt(2, stack);
1205
1206 Exceptions::ThrowByType(Exceptions::kMirroredUncaughtExceptionError, args);
1207 UNREACHABLE();
1208 }
1209
1210
1211 static void ThrowMirroredCompilationError(const String& message) { 1174 static void ThrowMirroredCompilationError(const String& message) {
1212 Array& args = Array::Handle(Array::New(1)); 1175 Array& args = Array::Handle(Array::New(1));
1213 args.SetAt(0, message); 1176 args.SetAt(0, message);
1214 1177
1215 Exceptions::ThrowByType(Exceptions::kMirroredCompilationError, args); 1178 Exceptions::ThrowByType(Exceptions::kMirroredCompilationError, args);
1216 UNREACHABLE(); 1179 UNREACHABLE();
1217 } 1180 }
1218 1181
1219 1182
1220 static void ThrowInvokeError(const Error& error) { 1183 static void ThrowInvokeError(const Error& error) {
1221 if (error.IsUnhandledException()) {
1222 // An ordinary runtime error.
1223 ThrowMirroredUnhandledError(error);
1224 }
1225 if (error.IsLanguageError()) { 1184 if (error.IsLanguageError()) {
1226 // A compilation error that was delayed by lazy compilation. 1185 // A compilation error that was delayed by lazy compilation.
1227 const LanguageError& compilation_error = LanguageError::Cast(error); 1186 const LanguageError& compilation_error = LanguageError::Cast(error);
1228 String& message = String::Handle(compilation_error.message()); 1187 String& message = String::Handle(compilation_error.message());
1229 ThrowMirroredCompilationError(message); 1188 ThrowMirroredCompilationError(message);
1189 UNREACHABLE();
1230 } 1190 }
1191 Exceptions::PropagateError(error);
1231 UNREACHABLE(); 1192 UNREACHABLE();
1232 } 1193 }
1233 1194
1234 1195
1235 static bool FieldIsUninitialized(const Field& field) { 1196 static bool FieldIsUninitialized(const Field& field) {
1236 ASSERT(!field.IsNull()); 1197 ASSERT(!field.IsNull());
1237 1198
1238 // Return getter method for uninitialized fields, rather than the 1199 // Return getter method for uninitialized fields, rather than the
1239 // field object, since the value in the field object will not be 1200 // field object, since the value in the field object will not be
1240 // initialized until the first time the getter is invoked. 1201 // initialized until the first time the getter is invoked.
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 1887
1927 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1888 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1928 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1889 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1929 const Field& field = Field::Handle(ref.GetFieldReferent()); 1890 const Field& field = Field::Handle(ref.GetFieldReferent());
1930 1891
1931 const AbstractType& type = AbstractType::Handle(field.type()); 1892 const AbstractType& type = AbstractType::Handle(field.type());
1932 return CreateTypeMirror(type); 1893 return CreateTypeMirror(type);
1933 } 1894 }
1934 1895
1935 } // namespace dart 1896 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | runtime/tests/vm/dart/isolate_mirror_local_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698