Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: vm/bootstrap.cc

Issue 10834284: - Split Dart core libraries into shared sources and patch sources. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/bootstrap.h ('k') | vm/bootstrap_nocorelib.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(const char* url,
20 const String& url = String::Handle(String::New("bootstrap", Heap::kOld)); 20 const char* source,
21 const String& src = String::Handle(String::New(corelib_source_, Heap::kOld)); 21 bool patch) {
22 22 return Script::New(String::Handle(String::New(url, Heap::kOld)),
23 const Script& result = 23 String::Handle(String::New(source, Heap::kOld)),
24 Script::Handle(Script::New(url, src, RawScript::kSourceTag)); 24 patch ? RawScript::kPatchTag : RawScript::kSourceTag);
25 return result.raw();
26 } 25 }
27 26
28 27
29 RawScript* Bootstrap::LoadImplScript() { 28 RawScript* Bootstrap::LoadCoreScript(bool patch) {
30 const String& url = String::Handle(String::New("bootstrap_impl", 29 // TODO(iposva): Use proper library name.
31 Heap::kOld)); 30 const char* url = patch ? "dart:core-patch" : "bootstrap";
32 const String& src = String::Handle(String::New(corelib_impl_source_, 31 const char* source = patch ? corelib_patch_ : corelib_source_;
33 Heap::kOld)); 32 return LoadScript(url, source, patch);
34
35 const Script& result =
36 Script::Handle(Script::New(url, src, RawScript::kSourceTag));
37 return result.raw();
38 } 33 }
39 34
40 35
41 RawScript* Bootstrap::LoadMathScript() { 36 RawScript* Bootstrap::LoadCoreImplScript(bool patch) {
42 const String& url = String::Handle(String::New("dart:math", Heap::kOld)); 37 // TODO(iposva): Use proper library name.
43 const String& src = String::Handle(String::New(math_source_, Heap::kOld)); 38 const char* url = patch ? "dart:coreimpl-patch" : "bootstrap_impl";
44 39 const char* source = patch ? corelib_impl_patch_ : corelib_impl_source_;
45 const Script& result = 40 return LoadScript(url, source, patch);
46 Script::Handle(Script::New(url, src, RawScript::kSourceTag));
47 return result.raw();
48 } 41 }
49 42
50 43
51 RawScript* Bootstrap::LoadIsolateScript() { 44 RawScript* Bootstrap::LoadMathScript(bool patch) {
52 const String& url = String::Handle(String::New("dart:isolate", Heap::kOld)); 45 const char* url = patch ? "dart:math-patch" : "dart:math";
53 const String& src = String::Handle(String::New(isolate_source_, Heap::kOld)); 46 const char* source = patch ? math_patch_ : math_source_;
54 47 return LoadScript(url, source, patch);
55 const Script& result =
56 Script::Handle(Script::New(url, src, RawScript::kSourceTag));
57 return result.raw();
58 } 48 }
59 49
60 50
61 RawScript* Bootstrap::LoadMirrorsScript() { 51 RawScript* Bootstrap::LoadIsolateScript(bool patch) {
62 const String& url = String::Handle(String::New("dart:mirrors", Heap::kOld)); 52 const char* url = patch ? "dart:isolate-patch" : "dart:isolate";
63 const String& src = String::Handle(String::New(mirrors_source_, Heap::kOld)); 53 const char* source = patch ? isolate_patch_ : isolate_source_;
64 54 return LoadScript(url, source, patch);
65 const Script& result =
66 Script::Handle(Script::New(url, src, RawScript::kSourceTag));
67 return result.raw();
68 } 55 }
69 56
70 57
58 RawScript* Bootstrap::LoadMirrorsScript(bool patch) {
59 const char* url = patch ? "dart:mirrors-patch" : "dart:mirrors";
60 const char* source = patch ? mirrors_patch_ : mirrors_source_;
61 return LoadScript(url, source, patch);
62 }
63
64
71 RawError* Bootstrap::Compile(const Library& library, const Script& script) { 65 RawError* Bootstrap::Compile(const Library& library, const Script& script) {
72 if (FLAG_print_bootstrap) { 66 if (FLAG_print_bootstrap) {
73 OS::Print("Bootstrap source '%s':\n%s\n", 67 OS::Print("Bootstrap source '%s':\n%s\n",
74 String::Handle(script.url()).ToCString(), 68 String::Handle(script.url()).ToCString(),
75 String::Handle(script.Source()).ToCString()); 69 String::Handle(script.Source()).ToCString());
76 } 70 }
77 library.SetLoadInProgress(); 71 library.SetLoadInProgress();
78 const Error& error = Error::Handle(Compiler::Compile(library, script)); 72 const Error& error = Error::Handle(Compiler::Compile(library, script));
79 if (error.IsNull()) { 73 if (error.IsNull()) {
80 library.SetLoaded(); 74 library.SetLoaded();
81 } else { 75 } else {
82 library.SetLoadError(); 76 library.SetLoadError();
83 } 77 }
84 return error.raw(); 78 return error.raw();
85 } 79 }
86 80
87 } // namespace dart 81 } // namespace dart
OLDNEW
« no previous file with comments | « vm/bootstrap.h ('k') | vm/bootstrap_nocorelib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698