OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/bootstrap.h" | 5 #include "vm/bootstrap.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 RawScript* Bootstrap::LoadIsolateScript() { | 41 RawScript* Bootstrap::LoadIsolateScript() { |
42 const String& url = String::Handle(String::New("dart:isolate", Heap::kOld)); | 42 const String& url = String::Handle(String::New("dart:isolate", Heap::kOld)); |
43 const String& src = String::Handle(String::New(isolate_source_, Heap::kOld)); | 43 const String& src = String::Handle(String::New(isolate_source_, Heap::kOld)); |
44 | 44 |
45 const Script& result = | 45 const Script& result = |
46 Script::Handle(Script::New(url, src, RawScript::kSource)); | 46 Script::Handle(Script::New(url, src, RawScript::kSource)); |
47 return result.raw(); | 47 return result.raw(); |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 RawScript* Bootstrap::LoadMirrorsScript() { | |
52 const String& url = String::Handle(String::New("dart:mirrors", Heap::kOld)); | |
53 const String& src = String::Handle(String::New(mirrors_source_, Heap::kOld)); | |
54 | |
55 const Script& result = | |
56 Script::Handle(Script::New(url, src, RawScript::kSource)); | |
57 return result.raw(); | |
58 } | |
59 | |
60 | |
61 static RawObject* InitLibrary(const char* url_str, | |
62 const char* source_str) { | |
63 const String& url = String::Handle(String::NewSymbol(url_str)); | |
64 const String& source = String::Handle(String::New(source_str, | |
65 Heap::kOld)); | |
66 const Library& lib = Library::Handle(Library::New(url)); | |
67 lib.Register(); | |
68 const Script& script = | |
69 Script::Handle(Script::New(url, source, RawScript::kSource)); | |
70 const Error& error = Error::Handle(Bootstrap::Compile(lib, script)); | |
71 if (!error.IsNull()) { | |
72 return error.raw(); | |
73 } else { | |
74 return lib.raw(); | |
75 } | |
76 } | |
siva
2012/03/08 22:24:02
InitLibrary is a static function in this file and
turnidge
2012/03/08 22:50:51
Done.
| |
77 | |
78 | |
51 RawError* Bootstrap::Compile(const Library& library, const Script& script) { | 79 RawError* Bootstrap::Compile(const Library& library, const Script& script) { |
52 if (FLAG_print_bootstrap) { | 80 if (FLAG_print_bootstrap) { |
53 OS::Print("Bootstrap source '%s':\n%s\n", | 81 OS::Print("Bootstrap source '%s':\n%s\n", |
54 String::Handle(script.url()).ToCString(), | 82 String::Handle(script.url()).ToCString(), |
55 String::Handle(script.source()).ToCString()); | 83 String::Handle(script.source()).ToCString()); |
56 } | 84 } |
57 library.SetLoadInProgress(); | 85 library.SetLoadInProgress(); |
58 const Error& error = Error::Handle(Compiler::Compile(library, script)); | 86 const Error& error = Error::Handle(Compiler::Compile(library, script)); |
59 if (error.IsNull()) { | 87 if (error.IsNull()) { |
60 library.SetLoaded(); | 88 library.SetLoaded(); |
61 } else { | 89 } else { |
62 library.SetLoadError(); | 90 library.SetLoadError(); |
63 } | 91 } |
64 return error.raw(); | 92 return error.raw(); |
65 } | 93 } |
66 | 94 |
67 } // namespace dart | 95 } // namespace dart |
OLD | NEW |