Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 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::kSource)); |
| 37 return result.raw(); | 37 return result.raw(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 static RawObject* InitLibrary(const char* url_str, | |
| 42 const char* source_str) { | |
| 43 const String& url = String::Handle(String::NewSymbol(url_str)); | |
| 44 const String& source = String::Handle(String::New(source_str, | |
| 45 Heap::kOld)); | |
| 46 const Library& lib = Library::Handle(Library::New(url)); | |
| 47 lib.Register(); | |
| 48 const Script& script = | |
| 49 Script::Handle(Script::New(url, source, RawScript::kSource)); | |
| 50 const Error& error = Error::Handle(Bootstrap::Compile(lib, script)); | |
| 51 if (!error.IsNull()) { | |
| 52 return error.raw(); | |
| 53 } else { | |
| 54 return lib.raw(); | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 | |
| 59 RawError* Bootstrap::InitAdditionalLibraries() { | |
| 60 Object& result = Object::Handle(); | |
| 61 result = InitLibrary("dart:mirrors", mirrors_source_); | |
| 62 if (result.IsError()) { | |
| 63 Error& error = Error::Handle(); | |
| 64 error ^= result.raw(); | |
| 65 return error.raw(); | |
|
siva
2012/02/18 01:25:55
Instead of defining functions to return RawError*
turnidge
2012/03/07 20:00:14
This function went away in refactor. Point taken
| |
| 66 } else { | |
| 67 Library& lib = Library::Handle(); | |
| 68 lib ^= result.raw(); | |
| 69 Isolate::Current()->object_store()->set_mirrors_library(lib); | |
| 70 } | |
| 71 return Error::null(); | |
| 72 } | |
| 73 | |
| 74 | |
| 41 RawError* Bootstrap::Compile(const Library& library, const Script& script) { | 75 RawError* Bootstrap::Compile(const Library& library, const Script& script) { |
| 42 if (FLAG_print_bootstrap) { | 76 if (FLAG_print_bootstrap) { |
| 43 OS::Print("Bootstrap source '%s':\n%s\n", | 77 OS::Print("Bootstrap source '%s':\n%s\n", |
| 44 String::Handle(script.url()).ToCString(), | 78 String::Handle(script.url()).ToCString(), |
| 45 String::Handle(script.source()).ToCString()); | 79 String::Handle(script.source()).ToCString()); |
| 46 } | 80 } |
| 47 library.SetLoadInProgress(); | 81 library.SetLoadInProgress(); |
| 48 const Error& error = Error::Handle(Compiler::Compile(library, script)); | 82 const Error& error = Error::Handle(Compiler::Compile(library, script)); |
| 49 if (error.IsNull()) { | 83 if (error.IsNull()) { |
| 50 library.SetLoaded(); | 84 library.SetLoaded(); |
| 85 } else { | |
| 86 library.SetLoadError(); | |
| 51 } | 87 } |
| 52 return error.raw(); | 88 return error.raw(); |
| 53 } | 89 } |
| 54 | 90 |
| 55 } // namespace dart | 91 } // namespace dart |
| OLD | NEW |