OLD | NEW |
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" |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 Instance::null_instance()); | 1294 Instance::null_instance()); |
1295 } | 1295 } |
1296 | 1296 |
1297 | 1297 |
1298 DEFINE_NATIVE_ENTRY(TypeVariableMirror_upper_bound, 1) { | 1298 DEFINE_NATIVE_ENTRY(TypeVariableMirror_upper_bound, 1) { |
1299 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0)); | 1299 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0)); |
1300 return param.bound(); | 1300 return param.bound(); |
1301 } | 1301 } |
1302 | 1302 |
1303 | 1303 |
| 1304 DEFINE_NATIVE_ENTRY(Mirrors_evalInLibraryWithPrivateKey, 2) { |
| 1305 GET_NON_NULL_NATIVE_ARGUMENT(String, expression, arguments->NativeArgAt(0)); |
| 1306 GET_NATIVE_ARGUMENT(String, private_key, arguments->NativeArgAt(1)); |
| 1307 |
| 1308 const GrowableObjectArray& libraries = |
| 1309 GrowableObjectArray::Handle(isolate->object_store()->libraries()); |
| 1310 const int num_libraries = libraries.Length(); |
| 1311 Library& each_library = Library::Handle(); |
| 1312 Library& ctxt_library = Library::Handle(); |
| 1313 String& library_key = String::Handle(); |
| 1314 |
| 1315 for (int i = 0; i < num_libraries; i++) { |
| 1316 each_library ^= libraries.At(i); |
| 1317 library_key = each_library.private_key(); |
| 1318 if (library_key.Equals(private_key)) { |
| 1319 ctxt_library = each_library.raw(); |
| 1320 break; |
| 1321 } |
| 1322 } |
| 1323 if (ctxt_library.IsNull()) { |
| 1324 ctxt_library = Library::CoreLibrary(); |
| 1325 } |
| 1326 return ctxt_library.Evaluate(expression); |
| 1327 } |
| 1328 |
1304 DEFINE_NATIVE_ENTRY(TypedefMirror_declaration, 1) { | 1329 DEFINE_NATIVE_ENTRY(TypedefMirror_declaration, 1) { |
1305 GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0)); | 1330 GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0)); |
1306 const Class& cls = Class::Handle(type.type_class()); | 1331 const Class& cls = Class::Handle(type.type_class()); |
1307 // We represent typedefs as non-canonical signature classes. | 1332 // We represent typedefs as non-canonical signature classes. |
1308 ASSERT(cls.IsSignatureClass() && !cls.IsCanonicalSignatureClass()); | 1333 ASSERT(cls.IsSignatureClass() && !cls.IsCanonicalSignatureClass()); |
1309 return CreateTypedefMirror(cls, | 1334 return CreateTypedefMirror(cls, |
1310 AbstractType::Handle(cls.DeclarationType()), | 1335 AbstractType::Handle(cls.DeclarationType()), |
1311 Bool::True(), // is_declaration | 1336 Bool::True(), // is_declaration |
1312 Object::null_instance()); | 1337 Object::null_instance()); |
1313 } | 1338 } |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2062 | 2087 |
2063 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) { | 2088 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) { |
2064 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 2089 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
2065 const Field& field = Field::Handle(ref.GetFieldReferent()); | 2090 const Field& field = Field::Handle(ref.GetFieldReferent()); |
2066 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); | 2091 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); |
2067 const AbstractType& type = AbstractType::Handle(field.type()); | 2092 const AbstractType& type = AbstractType::Handle(field.type()); |
2068 return InstantiateType(type, instantiator); | 2093 return InstantiateType(type, instantiator); |
2069 } | 2094 } |
2070 | 2095 |
2071 } // namespace dart | 2096 } // namespace dart |
OLD | NEW |