Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #include "src/runtime.h" |
| 4 | |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame^] | 5 | #include "src/class_linker.h" |
| 6 | #include "src/heap.h" |
| 7 | #include "src/thread.h" |
| 8 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 9 | namespace art { |
| 10 | |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame^] | 11 | Runtime::~Runtime() { |
| 12 | // TODO: use a smart pointer instead. |
| 13 | delete class_linker_; |
| 14 | delete heap_; |
| 15 | delete thread_list_; |
| 16 | } |
| 17 | |
| 18 | Runtime* Runtime::Create() { |
| 19 | scoped_ptr<Runtime> runtime(new Runtime()); |
| 20 | bool success = runtime->Init(); |
| 21 | if (!success) { |
| 22 | return NULL; |
| 23 | } else { |
| 24 | return runtime.release(); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | bool Runtime::Init() { |
| 29 | thread_list_ = ThreadList::Create(); |
| 30 | heap_ = Heap::Create(); |
| 31 | Thread::Init(); |
| 32 | Thread* current_thread = Thread::Attach(); |
| 33 | thread_list_->Register(current_thread); |
| 34 | class_linker_ = ClassLinker::Create(); |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 35 | return true; |
| 36 | } |
| 37 | |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame^] | 38 | bool AttachCurrentThread() { |
| 39 | LOG(FATAL) << "Unimplemented"; |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | bool DetachCurrentThread() { |
| 44 | LOG(FATAL) << "Unimplemented"; |
| 45 | return false; |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | } // namespace art |