| 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" |
| 11 #include "vm/object.h" | 11 #include "vm/object.h" |
| 12 #include "vm/object_store.h" | 12 #include "vm/object_store.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 DEFINE_FLAG(bool, print_bootstrap, false, "Print the bootstrap source."); | 16 DEFINE_FLAG(bool, print_bootstrap, false, "Print the bootstrap source."); |
| 17 | 17 |
| 18 | 18 |
| 19 RawScript* Bootstrap::LoadScript() { | 19 RawScript* Bootstrap::LoadScript() { |
| 20 const String& url = String::Handle(String::New("bootstrap", Heap::kOld)); | 20 const String& url = String::Handle(String::New("bootstrap", Heap::kOld)); |
| 21 const String& src = String::Handle(String::New(corelib_source_, Heap::kOld)); | 21 const String& src = String::Handle(String::New(corelib_source_, Heap::kOld)); |
| 22 | 22 |
| 23 const Script& result = | 23 const Script& result = |
| 24 Script::Handle(Script::New(url, src, RawScript::kSource)); | 24 Script::Handle(Script::New(url, src, RawScript::kSourceTag)); |
| 25 return result.raw(); | 25 return result.raw(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 | 28 |
| 29 RawScript* Bootstrap::LoadImplScript() { | 29 RawScript* Bootstrap::LoadImplScript() { |
| 30 const String& url = String::Handle(String::New("bootstrap_impl", | 30 const String& url = String::Handle(String::New("bootstrap_impl", |
| 31 Heap::kOld)); | 31 Heap::kOld)); |
| 32 const String& src = String::Handle(String::New(corelib_impl_source_, | 32 const String& src = String::Handle(String::New(corelib_impl_source_, |
| 33 Heap::kOld)); | 33 Heap::kOld)); |
| 34 | 34 |
| 35 const Script& result = | 35 const Script& result = |
| 36 Script::Handle(Script::New(url, src, RawScript::kSource)); | 36 Script::Handle(Script::New(url, src, RawScript::kSourceTag)); |
| 37 return result.raw(); | 37 return result.raw(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 RawScript* Bootstrap::LoadMathScript() { | 41 RawScript* Bootstrap::LoadMathScript() { |
| 42 const String& url = String::Handle(String::New("dart:math", Heap::kOld)); | 42 const String& url = String::Handle(String::New("dart:math", Heap::kOld)); |
| 43 const String& src = String::Handle(String::New(math_source_, Heap::kOld)); | 43 const String& src = String::Handle(String::New(math_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::kSourceTag)); |
| 47 return result.raw(); | 47 return result.raw(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 | 50 |
| 51 RawScript* Bootstrap::LoadIsolateScript() { | 51 RawScript* Bootstrap::LoadIsolateScript() { |
| 52 const String& url = String::Handle(String::New("dart:isolate", Heap::kOld)); | 52 const String& url = String::Handle(String::New("dart:isolate", Heap::kOld)); |
| 53 const String& src = String::Handle(String::New(isolate_source_, Heap::kOld)); | 53 const String& src = String::Handle(String::New(isolate_source_, Heap::kOld)); |
| 54 | 54 |
| 55 const Script& result = | 55 const Script& result = |
| 56 Script::Handle(Script::New(url, src, RawScript::kSource)); | 56 Script::Handle(Script::New(url, src, RawScript::kSourceTag)); |
| 57 return result.raw(); | 57 return result.raw(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 RawScript* Bootstrap::LoadMirrorsScript() { | 61 RawScript* Bootstrap::LoadMirrorsScript() { |
| 62 const String& url = String::Handle(String::New("dart:mirrors", Heap::kOld)); | 62 const String& url = String::Handle(String::New("dart:mirrors", Heap::kOld)); |
| 63 const String& src = String::Handle(String::New(mirrors_source_, Heap::kOld)); | 63 const String& src = String::Handle(String::New(mirrors_source_, Heap::kOld)); |
| 64 | 64 |
| 65 const Script& result = | 65 const Script& result = |
| 66 Script::Handle(Script::New(url, src, RawScript::kSource)); | 66 Script::Handle(Script::New(url, src, RawScript::kSourceTag)); |
| 67 return result.raw(); | 67 return result.raw(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 | 70 |
| 71 RawError* Bootstrap::Compile(const Library& library, const Script& script) { | 71 RawError* Bootstrap::Compile(const Library& library, const Script& script) { |
| 72 if (FLAG_print_bootstrap) { | 72 if (FLAG_print_bootstrap) { |
| 73 OS::Print("Bootstrap source '%s':\n%s\n", | 73 OS::Print("Bootstrap source '%s':\n%s\n", |
| 74 String::Handle(script.url()).ToCString(), | 74 String::Handle(script.url()).ToCString(), |
| 75 String::Handle(script.Source()).ToCString()); | 75 String::Handle(script.Source()).ToCString()); |
| 76 } | 76 } |
| 77 library.SetLoadInProgress(); | 77 library.SetLoadInProgress(); |
| 78 const Error& error = Error::Handle(Compiler::Compile(library, script)); | 78 const Error& error = Error::Handle(Compiler::Compile(library, script)); |
| 79 if (error.IsNull()) { | 79 if (error.IsNull()) { |
| 80 library.SetLoaded(); | 80 library.SetLoaded(); |
| 81 } else { | 81 } else { |
| 82 library.SetLoadError(); | 82 library.SetLoadError(); |
| 83 } | 83 } |
| 84 return error.raw(); | 84 return error.raw(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace dart | 87 } // namespace dart |
| OLD | NEW |