| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/kernel_reader.h" | 5 #include "vm/kernel_reader.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/kernel_binary.h" | 10 #include "vm/kernel_binary.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 ReadLibrary(kernel_library); | 169 ReadLibrary(kernel_library); |
| 170 } | 170 } |
| 171 | 171 |
| 172 for (intptr_t i = 0; i < length; i++) { | 172 for (intptr_t i = 0; i < length; i++) { |
| 173 dart::Library& library = | 173 dart::Library& library = |
| 174 LookupLibrary(program_->libraries()[i]->canonical_name()); | 174 LookupLibrary(program_->libraries()[i]->canonical_name()); |
| 175 if (!library.Loaded()) library.SetLoaded(); | 175 if (!library.Loaded()) library.SetLoaded(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 if (ClassFinalizer::ProcessPendingClasses(/*from_kernel=*/true)) { | 178 if (ClassFinalizer::ProcessPendingClasses(/*from_kernel=*/true)) { |
| 179 // There is a function _getMainClosure in dart:_builtin that returns the | 179 // If 'main' is not found return a null library, this is the case |
| 180 // main procedure. Since the platform libraries are compiled before the | 180 // when bootstrapping is in progress. |
| 181 // program script, this function might need to be patched here. | |
| 182 | |
| 183 // If there is no main method then we have compiled a partial Kernel file | |
| 184 // and do not need to patch here. | |
| 185 NameIndex main = program_->main_method(); | 181 NameIndex main = program_->main_method(); |
| 186 if (main == -1) { | 182 if (main == -1) { |
| 187 return dart::Library::Handle(Z); | 183 return dart::Library::Handle(Z); |
| 188 } | 184 } |
| 189 | 185 |
| 190 // If the builtin library is not set in the object store, then we are | |
| 191 // bootstrapping and do not need to patch here. | |
| 192 dart::Library& builtin_library = | |
| 193 dart::Library::Handle(Z, I->object_store()->builtin_library()); | |
| 194 if (builtin_library.IsNull()) { | |
| 195 return dart::Library::Handle(Z); | |
| 196 } | |
| 197 | |
| 198 NameIndex main_library = H.EnclosingName(main); | 186 NameIndex main_library = H.EnclosingName(main); |
| 199 dart::Library& library = LookupLibrary(main_library); | 187 dart::Library& library = LookupLibrary(main_library); |
| 200 // Sanity check that we can find the main entrypoint. | 188 // Sanity check that we can find the main entrypoint. |
| 201 Object& main_obj = Object::Handle( | 189 ASSERT(library.LookupObjectAllowPrivate(H.DartSymbol("main")) != |
| 202 Z, library.LookupObjectAllowPrivate(H.DartSymbol("main"))); | 190 Object::null()); |
| 203 ASSERT(!main_obj.IsNull()); | |
| 204 | |
| 205 return library; | 191 return library; |
| 206 } | 192 } |
| 207 } | 193 } |
| 208 | 194 |
| 209 // Either class finalization failed or we caught a compile error. | 195 // Either class finalization failed or we caught a compile error. |
| 210 // In both cases sticky error would be set. | 196 // In both cases sticky error would be set. |
| 211 Error& error = Error::Handle(Z); | 197 Error& error = Error::Handle(Z); |
| 212 error = thread_->sticky_error(); | 198 error = thread_->sticky_error(); |
| 213 thread_->clear_sticky_error(); | 199 thread_->clear_sticky_error(); |
| 214 return error; | 200 return error; |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 initializer_fun.set_is_debuggable(false); | 906 initializer_fun.set_is_debuggable(false); |
| 921 initializer_fun.set_is_reflectable(false); | 907 initializer_fun.set_is_reflectable(false); |
| 922 initializer_fun.set_is_inlinable(false); | 908 initializer_fun.set_is_inlinable(false); |
| 923 return new (zone) ParsedFunction(thread, initializer_fun); | 909 return new (zone) ParsedFunction(thread, initializer_fun); |
| 924 } | 910 } |
| 925 | 911 |
| 926 | 912 |
| 927 } // namespace kernel | 913 } // namespace kernel |
| 928 } // namespace dart | 914 } // namespace dart |
| 929 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 915 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |