| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/bootstrap_natives.h" | 9 #include "vm/bootstrap_natives.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| 11 #include "vm/dart_api_impl.h" | 11 #include "vm/dart_api_impl.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 14 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 DEFINE_FLAG(bool, print_bootstrap, false, "Print the bootstrap source."); | |
| 19 | |
| 20 #define INIT_LIBRARY(index, name, source, patch) \ | 18 #define INIT_LIBRARY(index, name, source, patch) \ |
| 21 { index, \ | 19 { index, \ |
| 22 "dart:"#name, source, \ | 20 "dart:"#name, source, \ |
| 23 "dart:"#name"-patch", patch } \ | 21 "dart:"#name"-patch", patch } \ |
| 24 | 22 |
| 25 typedef struct { | 23 typedef struct { |
| 26 intptr_t index_; | 24 intptr_t index_; |
| 27 const char* uri_; | 25 const char* uri_; |
| 28 const char** source_paths_; | 26 const char** source_paths_; |
| 29 const char* patch_uri_; | 27 const char* patch_uri_; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 139 } |
| 142 ASSERT(utf8_array != NULL); | 140 ASSERT(utf8_array != NULL); |
| 143 | 141 |
| 144 (*file_close)(stream); | 142 (*file_close)(stream); |
| 145 | 143 |
| 146 return String::FromUTF8(utf8_array, file_length); | 144 return String::FromUTF8(utf8_array, file_length); |
| 147 } | 145 } |
| 148 | 146 |
| 149 | 147 |
| 150 static RawError* Compile(const Library& library, const Script& script) { | 148 static RawError* Compile(const Library& library, const Script& script) { |
| 151 if (FLAG_print_bootstrap) { | |
| 152 OS::Print("Bootstrap source '%s':\n%s\n", | |
| 153 String::Handle(script.url()).ToCString(), | |
| 154 String::Handle(script.Source()).ToCString()); | |
| 155 } | |
| 156 bool update_lib_status = (script.kind() == RawScript::kScriptTag || | 149 bool update_lib_status = (script.kind() == RawScript::kScriptTag || |
| 157 script.kind() == RawScript::kLibraryTag); | 150 script.kind() == RawScript::kLibraryTag); |
| 158 if (update_lib_status) { | 151 if (update_lib_status) { |
| 159 library.SetLoadInProgress(); | 152 library.SetLoadInProgress(); |
| 160 } | 153 } |
| 161 const Error& error = Error::Handle(Compiler::Compile(library, script)); | 154 const Error& error = Error::Handle(Compiler::Compile(library, script)); |
| 162 if (update_lib_status) { | 155 if (update_lib_status) { |
| 163 if (error.IsNull()) { | 156 if (error.IsNull()) { |
| 164 library.SetLoaded(); | 157 library.SetLoaded(); |
| 165 } else { | 158 } else { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // Exit the Dart scope. | 324 // Exit the Dart scope. |
| 332 Dart_ExitScope(); | 325 Dart_ExitScope(); |
| 333 | 326 |
| 334 // Restore the library tag handler for the isolate. | 327 // Restore the library tag handler for the isolate. |
| 335 isolate->set_library_tag_handler(saved_tag_handler); | 328 isolate->set_library_tag_handler(saved_tag_handler); |
| 336 | 329 |
| 337 return error.raw(); | 330 return error.raw(); |
| 338 } | 331 } |
| 339 | 332 |
| 340 } // namespace dart | 333 } // namespace dart |
| OLD | NEW |