blob: e1ad32d114b3f11ab17cda4ab95dbcb1d79be1f5 [file] [log] [blame]
Carl Shapiro1fb86202011-06-27 17:43:13 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#include "src/runtime.h"
4
Carl Shapiro61e019d2011-07-14 16:53:09 -07005#include "src/class_linker.h"
6#include "src/heap.h"
7#include "src/thread.h"
8
Carl Shapiro1fb86202011-06-27 17:43:13 -07009namespace art {
10
Carl Shapiro61e019d2011-07-14 16:53:09 -070011Runtime::~Runtime() {
12 // TODO: use a smart pointer instead.
13 delete class_linker_;
14 delete heap_;
15 delete thread_list_;
16}
17
18Runtime* 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
28bool 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 Shapiro1fb86202011-06-27 17:43:13 -070035 return true;
36}
37
Carl Shapiro61e019d2011-07-14 16:53:09 -070038bool AttachCurrentThread() {
39 LOG(FATAL) << "Unimplemented";
40 return false;
41}
42
43bool DetachCurrentThread() {
44 LOG(FATAL) << "Unimplemented";
45 return false;
Carl Shapiro1fb86202011-06-27 17:43:13 -070046}
47
48} // namespace art