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

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

Issue 16780008: Reified metadata in the VM (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/object.h » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 4330 matching lines...) Expand 10 before | Expand all | Expand 10 after
4341 if (!ret_obj.IsNull() && !ret_obj.IsInstance()) { 4341 if (!ret_obj.IsNull() && !ret_obj.IsInstance()) {
4342 FATAL1("Return value check failed: saw '%s' expected a dart Instance.", 4342 FATAL1("Return value check failed: saw '%s' expected a dart Instance.",
4343 ret_obj.ToCString()); 4343 ret_obj.ToCString());
4344 } 4344 }
4345 NoGCScope no_gc_scope; 4345 NoGCScope no_gc_scope;
4346 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 4346 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
4347 arguments->SetReturn(ret_obj); 4347 arguments->SetReturn(ret_obj);
4348 } 4348 }
4349 4349
4350 4350
4351 // --- Metadata ----
4352
4353 DART_EXPORT Dart_Handle Dart_GetMetadata(Dart_Handle object) {
4354 Isolate* isolate = Isolate::Current();
4355 CHECK_ISOLATE(isolate);
4356 DARTSCOPE(isolate);
4357 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
4358 Class& cls = Class::Handle(isolate);
4359 if (obj.IsClass()) {
4360 cls ^= obj.raw();
4361 } else if (obj.IsFunction()) {
4362 cls = Function::Cast(obj).origin();
4363 } else if (obj.IsField()) {
4364 cls = Field::Cast(obj).origin();
4365 } else {
4366 return Api::NewHandle(isolate, Object::empty_array().raw());
4367 }
4368 const Library& lib = Library::Handle(cls.library());
4369 return Api::NewHandle(isolate, lib.GetMetadata(obj));
4370 }
4371
4372
4351 // --- Scripts and Libraries --- 4373 // --- Scripts and Libraries ---
4352 4374
4353 4375
4354 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( 4376 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler(
4355 Dart_LibraryTagHandler handler) { 4377 Dart_LibraryTagHandler handler) {
4356 Isolate* isolate = Isolate::Current(); 4378 Isolate* isolate = Isolate::Current();
4357 CHECK_ISOLATE(isolate); 4379 CHECK_ISOLATE(isolate);
4358 isolate->set_library_tag_handler(handler); 4380 isolate->set_library_tag_handler(handler);
4359 return Api::Success(); 4381 return Api::Success();
4360 } 4382 }
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
4837 } 4859 }
4838 { 4860 {
4839 NoGCScope no_gc; 4861 NoGCScope no_gc;
4840 RawObject* raw_obj = obj.raw(); 4862 RawObject* raw_obj = obj.raw();
4841 isolate->heap()->SetPeer(raw_obj, peer); 4863 isolate->heap()->SetPeer(raw_obj, peer);
4842 } 4864 }
4843 return Api::Success(); 4865 return Api::Success();
4844 } 4866 }
4845 4867
4846 } // namespace dart 4868 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698