First step towards loading the core library scripts directly from the sources
instead of concatenating all the scripts and linking them into the executable. - Refactor the bootstrap script loading and compilation part to use a custom bootstrap library tag handler R=iposva@google.com Review URL: https://codereview.chromium.org//14520010 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22154 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
+190
-89
@@ -11,112 +11,142 @@
|
||||
#include "vm/dart_api_impl.h"
|
||||
#include "vm/object.h"
|
||||
#include "vm/object_store.h"
|
||||
#include "vm/symbols.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
DEFINE_FLAG(bool, print_bootstrap, false, "Print the bootstrap source.");
|
||||
|
||||
#define INIT_LIBRARY(index, name, source, patch) \
|
||||
{ index, \
|
||||
"dart:"#name, source, \
|
||||
"dart:"#name"-patch", patch } \
|
||||
|
||||
RawScript* Bootstrap::LoadScript(const char* url,
|
||||
const char* source,
|
||||
bool patch) {
|
||||
return Script::New(String::Handle(String::New(url, Heap::kOld)),
|
||||
String::Handle(String::New(source, Heap::kOld)),
|
||||
patch ? RawScript::kPatchTag : RawScript::kLibraryTag);
|
||||
typedef struct {
|
||||
intptr_t index_;
|
||||
const char* uri_;
|
||||
const char* source_;
|
||||
const char* patch_uri_;
|
||||
const char* patch_source_;
|
||||
} bootstrap_lib_props;
|
||||
|
||||
|
||||
static bootstrap_lib_props bootstrap_libraries[] = {
|
||||
INIT_LIBRARY(ObjectStore::kCore,
|
||||
core,
|
||||
Bootstrap::corelib_source_,
|
||||
Bootstrap::corelib_patch_),
|
||||
INIT_LIBRARY(ObjectStore::kAsync,
|
||||
async,
|
||||
Bootstrap::async_source_,
|
||||
Bootstrap::async_patch_),
|
||||
INIT_LIBRARY(ObjectStore::kCollection,
|
||||
collection,
|
||||
Bootstrap::collection_source_,
|
||||
Bootstrap::collection_patch_),
|
||||
INIT_LIBRARY(ObjectStore::kCollectionDev,
|
||||
_collection-dev,
|
||||
Bootstrap::collection_dev_source_,
|
||||
Bootstrap::collection_dev_patch_),
|
||||
INIT_LIBRARY(ObjectStore::kCrypto,
|
||||
crypto,
|
||||
Bootstrap::crypto_source_,
|
||||
NULL),
|
||||
INIT_LIBRARY(ObjectStore::kIsolate,
|
||||
isolate,
|
||||
Bootstrap::isolate_source_,
|
||||
Bootstrap::isolate_patch_),
|
||||
INIT_LIBRARY(ObjectStore::kJson,
|
||||
json,
|
||||
Bootstrap::json_source_,
|
||||
Bootstrap::json_patch_),
|
||||
INIT_LIBRARY(ObjectStore::kMath,
|
||||
math,
|
||||
Bootstrap::math_source_,
|
||||
Bootstrap::math_patch_),
|
||||
INIT_LIBRARY(ObjectStore::kMirrors,
|
||||
mirrors,
|
||||
Bootstrap::mirrors_source_,
|
||||
Bootstrap::mirrors_patch_),
|
||||
INIT_LIBRARY(ObjectStore::kTypedData,
|
||||
typed_data,
|
||||
Bootstrap::typed_data_source_,
|
||||
Bootstrap::typed_data_patch_),
|
||||
INIT_LIBRARY(ObjectStore::kUtf,
|
||||
utf,
|
||||
Bootstrap::utf_source_,
|
||||
NULL),
|
||||
INIT_LIBRARY(ObjectStore::kUri,
|
||||
uri,
|
||||
Bootstrap::uri_source_,
|
||||
NULL),
|
||||
|
||||
{ ObjectStore::kNone, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
static RawString* GetLibrarySource(intptr_t index, bool patch) {
|
||||
// TODO(asiva): Replace with actual read of the source file.
|
||||
const char* source = patch ? bootstrap_libraries[index].patch_source_ :
|
||||
bootstrap_libraries[index].source_;
|
||||
ASSERT(source != NULL);
|
||||
return String::New(source, Heap::kOld);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadAsyncScript(bool patch) {
|
||||
const char* url = patch ? "dart:async-patch" : "dart:async";
|
||||
const char* source = patch ? async_patch_ : async_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
static Dart_Handle LoadPartSource(Isolate* isolate,
|
||||
const Library& lib,
|
||||
const String& uri) {
|
||||
// TODO(asiva): For now we return an error here, once we start
|
||||
// loading libraries from the real source this would have to call the
|
||||
// file read callback here and invoke Compiler::Compile on it.
|
||||
return Dart_NewApiError("Unable to load source '%s' ", uri.ToCString());
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadCoreScript(bool patch) {
|
||||
// TODO(iposva): Use proper library name.
|
||||
const char* url = patch ? "dart:core-patch" : "bootstrap";
|
||||
const char* source = patch ? corelib_patch_ : corelib_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
static Dart_Handle BootstrapLibraryTagHandler(Dart_LibraryTag tag,
|
||||
Dart_Handle library,
|
||||
Dart_Handle uri) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
if (!Dart_IsLibrary(library)) {
|
||||
return Dart_NewApiError("not a library");
|
||||
}
|
||||
if (!Dart_IsString(uri)) {
|
||||
return Dart_NewApiError("uri is not a string");
|
||||
}
|
||||
const String& uri_str = Api::UnwrapStringHandle(isolate, uri);
|
||||
ASSERT(!uri_str.IsNull());
|
||||
bool is_dart_scheme_uri = uri_str.StartsWith(Symbols::DartScheme());
|
||||
if (!is_dart_scheme_uri) {
|
||||
// The bootstrap tag handler can only handle dart scheme uris.
|
||||
return Dart_NewApiError("Do not know how to load '%s' ",
|
||||
uri_str.ToCString());
|
||||
}
|
||||
if (tag == kCanonicalizeUrl) {
|
||||
// Dart Scheme URIs do not need any canonicalization.
|
||||
return uri;
|
||||
}
|
||||
if (tag == kImportTag) {
|
||||
// We expect the core bootstrap libraries to only import other
|
||||
// core bootstrap libraries.
|
||||
// We have precreated all the bootstrap library objects hence
|
||||
// we do not expect to be called back with the tag set to kImportTag.
|
||||
// The bootstrap process explicitly loads all the libraries one by one.
|
||||
return Dart_NewApiError("Invalid import of '%s' in a bootstrap library",
|
||||
uri_str.ToCString());
|
||||
}
|
||||
ASSERT(tag == kSourceTag);
|
||||
const Library& lib = Api::UnwrapLibraryHandle(isolate, library);
|
||||
ASSERT(!lib.IsNull());
|
||||
return LoadPartSource(isolate, lib, uri_str);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadCollectionScript(bool patch) {
|
||||
const char* url = patch ? "dart:collection-patch" : "dart:collection";
|
||||
const char* source = patch ? collection_patch_ : collection_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadCollectionDevScript(bool patch) {
|
||||
const char* url =
|
||||
patch ? "dart:_collection-dev-patch" : "dart:_collection-dev";
|
||||
const char* source = patch ? collection_dev_patch_ : collection_dev_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadCryptoScript(bool patch) {
|
||||
const char* url = patch ? "dart:crypto-patch" : "dart:crypto";
|
||||
const char* source = patch ? crypto_source_ : crypto_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadIsolateScript(bool patch) {
|
||||
const char* url = patch ? "dart:isolate-patch" : "dart:isolate";
|
||||
const char* source = patch ? isolate_patch_ : isolate_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadJsonScript(bool patch) {
|
||||
const char* url = patch ? "dart:json-patch" : "dart:json";
|
||||
const char* source = patch ? json_patch_ : json_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadMathScript(bool patch) {
|
||||
const char* url = patch ? "dart:math-patch" : "dart:math";
|
||||
const char* source = patch ? math_patch_ : math_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadMirrorsScript(bool patch) {
|
||||
const char* url = patch ? "dart:mirrors-patch" : "dart:mirrors";
|
||||
const char* source = patch ? mirrors_patch_ : mirrors_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadTypedDataScript(bool patch) {
|
||||
const char* url = patch ? "dart:typed_data_patch" : "dart:typed_data";
|
||||
const char* source = patch ? typed_data_patch_ : typed_data_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadUriScript(bool patch) {
|
||||
const char* url = patch ? "dart:uri-patch" : "dart:uri";
|
||||
const char* source = patch ? uri_source_ : uri_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadUtfScript(bool patch) {
|
||||
const char* url = patch ? "dart:utf-patch" : "dart:utf";
|
||||
const char* source = patch ? utf_source_ : utf_source_;
|
||||
return LoadScript(url, source, patch);
|
||||
}
|
||||
|
||||
|
||||
RawError* Bootstrap::Compile(const Library& library, const Script& script) {
|
||||
static RawError* Compile(const Library& library, const Script& script) {
|
||||
if (FLAG_print_bootstrap) {
|
||||
OS::Print("Bootstrap source '%s':\n%s\n",
|
||||
String::Handle(script.url()).ToCString(),
|
||||
String::Handle(script.Source()).ToCString());
|
||||
String::Handle(script.url()).ToCString(),
|
||||
String::Handle(script.Source()).ToCString());
|
||||
}
|
||||
library.SetLoadInProgress();
|
||||
const Error& error = Error::Handle(Compiler::Compile(library, script));
|
||||
@@ -128,4 +158,75 @@ RawError* Bootstrap::Compile(const Library& library, const Script& script) {
|
||||
return error.raw();
|
||||
}
|
||||
|
||||
|
||||
RawError* Bootstrap::LoadandCompileScripts() {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
String& uri = String::Handle();
|
||||
String& patch_uri = String::Handle();
|
||||
String& source = String::Handle();
|
||||
Script& script = Script::Handle();
|
||||
Library& lib = Library::Handle();
|
||||
Error& error = Error::Handle();
|
||||
Dart_LibraryTagHandler saved_tag_handler = isolate->library_tag_handler();
|
||||
|
||||
// Set the library tag handler for the isolate to the bootstrap
|
||||
// library tag handler so that we can load all the bootstrap libraries.
|
||||
isolate->set_library_tag_handler(BootstrapLibraryTagHandler);
|
||||
|
||||
// Enter the Dart Scope as we will be calling back into the library
|
||||
// tag handler when compiling the bootstrap libraries.
|
||||
Dart_EnterScope();
|
||||
|
||||
// Create library objects for all the bootstrap libraries.
|
||||
intptr_t i = 0;
|
||||
while (bootstrap_libraries[i].index_ != ObjectStore::kNone) {
|
||||
uri = Symbols::New(bootstrap_libraries[i].uri_);
|
||||
lib = Library::LookupLibrary(uri);
|
||||
if (lib.IsNull()) {
|
||||
lib = Library::NewLibraryHelper(uri, false);
|
||||
lib.Register();
|
||||
}
|
||||
isolate->object_store()->set_bootstrap_library(
|
||||
bootstrap_libraries[i].index_, lib);
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
// Load and compile bootstrap libraries.
|
||||
i = 0;
|
||||
while (bootstrap_libraries[i].index_ != ObjectStore::kNone) {
|
||||
uri = Symbols::New(bootstrap_libraries[i].uri_);
|
||||
lib = Library::LookupLibrary(uri);
|
||||
ASSERT(!lib.IsNull());
|
||||
source = GetLibrarySource(i, false);
|
||||
script = Script::New(uri, source, RawScript::kLibraryTag);
|
||||
error = Compile(lib, script);
|
||||
if (!error.IsNull()) {
|
||||
break;
|
||||
}
|
||||
// If a patch exists, load and patch the script.
|
||||
if (bootstrap_libraries[i].patch_source_ != NULL) {
|
||||
patch_uri = String::New(bootstrap_libraries[i].patch_uri_,
|
||||
Heap::kOld);
|
||||
source = GetLibrarySource(i, true);
|
||||
script = Script::New(patch_uri, source, RawScript::kPatchTag);
|
||||
error = lib.Patch(script);
|
||||
if (!error.IsNull()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
if (error.IsNull()) {
|
||||
SetupNativeResolver();
|
||||
}
|
||||
|
||||
// Exit the Dart scope.
|
||||
Dart_ExitScope();
|
||||
|
||||
// Restore the library tag handler for the isolate.
|
||||
isolate->set_library_tag_handler(saved_tag_handler);
|
||||
|
||||
return error.raw();
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
||||
+1
-19
@@ -10,31 +10,13 @@
|
||||
namespace dart {
|
||||
|
||||
// Forward declarations.
|
||||
class Library;
|
||||
class RawError;
|
||||
class RawScript;
|
||||
class Script;
|
||||
|
||||
class Bootstrap : public AllStatic {
|
||||
public:
|
||||
static RawScript* LoadAsyncScript(bool patch);
|
||||
static RawScript* LoadCoreScript(bool patch);
|
||||
static RawScript* LoadCollectionScript(bool patch);
|
||||
static RawScript* LoadCollectionDevScript(bool patch);
|
||||
static RawScript* LoadCryptoScript(bool patch);
|
||||
static RawScript* LoadIsolateScript(bool patch);
|
||||
static RawScript* LoadJsonScript(bool patch);
|
||||
static RawScript* LoadMathScript(bool patch);
|
||||
static RawScript* LoadMirrorsScript(bool patch);
|
||||
static RawScript* LoadTypedDataScript(bool patch);
|
||||
static RawScript* LoadUriScript(bool patch);
|
||||
static RawScript* LoadUtfScript(bool patch);
|
||||
static RawError* Compile(const Library& library, const Script& script);
|
||||
static RawError* LoadandCompileScripts();
|
||||
static void SetupNativeResolver();
|
||||
|
||||
private:
|
||||
static RawScript* LoadScript(const char* url, const char* source, bool patch);
|
||||
|
||||
static const char async_source_[];
|
||||
static const char async_patch_[];
|
||||
static const char corelib_source_[];
|
||||
|
||||
@@ -15,79 +15,7 @@ namespace dart {
|
||||
DEFINE_FLAG(bool, print_bootstrap, false, "Print the bootstrap source.");
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadAsyncScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadCoreScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadCollectionScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadCollectionDevScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadCryptoScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadIsolateScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadJsonScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadMathScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadMirrorsScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadTypedDataScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadUriScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawScript* Bootstrap::LoadUtfScript(bool is_patch) {
|
||||
UNREACHABLE();
|
||||
return Script::null();
|
||||
}
|
||||
|
||||
|
||||
RawError* Bootstrap::Compile(const Library& library, const Script& script) {
|
||||
RawError* Bootstrap::LoadandCompileScripts() {
|
||||
UNREACHABLE();
|
||||
return Error::null();
|
||||
}
|
||||
|
||||
+22
-67
@@ -677,31 +677,6 @@ void Object::RegisterPrivateClass(const Class& cls,
|
||||
}
|
||||
|
||||
|
||||
#define LOAD_LIBRARY(name, raw_name) \
|
||||
url = Symbols::Dart##name().raw(); \
|
||||
lib = Library::LookupLibrary(url); \
|
||||
if (lib.IsNull()) { \
|
||||
lib = Library::NewLibraryHelper(url, true); \
|
||||
lib.Register(); \
|
||||
} \
|
||||
isolate->object_store()->set_##raw_name##_library(lib); \
|
||||
|
||||
#define INIT_LIBRARY(name, raw_name, has_patch) \
|
||||
LOAD_LIBRARY(name, raw_name) \
|
||||
script = Bootstrap::Load##name##Script(false); \
|
||||
error = Bootstrap::Compile(lib, script); \
|
||||
if (!error.IsNull()) { \
|
||||
return error.raw(); \
|
||||
} \
|
||||
if (has_patch) { \
|
||||
script = Bootstrap::Load##name##Script(true); \
|
||||
error = lib.Patch(script); \
|
||||
if (!error.IsNull()) { \
|
||||
return error.raw(); \
|
||||
} \
|
||||
} \
|
||||
|
||||
|
||||
RawError* Object::Init(Isolate* isolate) {
|
||||
TIMERSCOPE(time_bootstrap);
|
||||
ObjectStore* object_store = isolate->object_store();
|
||||
@@ -709,10 +684,7 @@ RawError* Object::Init(Isolate* isolate) {
|
||||
Class& cls = Class::Handle();
|
||||
Type& type = Type::Handle();
|
||||
Array& array = Array::Handle();
|
||||
String& url = String::Handle();
|
||||
Library& lib = Library::Handle();
|
||||
Script& script = Script::Handle();
|
||||
Error& error = Error::Handle();
|
||||
|
||||
// All RawArray fields will be initialized to an empty array, therefore
|
||||
// initialize array class first.
|
||||
@@ -843,13 +815,14 @@ RawError* Object::Init(Isolate* isolate) {
|
||||
pending_classes.Add(cls, Heap::kOld);
|
||||
|
||||
// Initialize the base interfaces used by the core VM classes.
|
||||
script = Bootstrap::LoadCoreScript(false);
|
||||
|
||||
// Allocate and initialize the pre-allocated classes in the core library.
|
||||
// The script and token index of these pre-allocated classes is set up in
|
||||
// the parser when the corelib script is compiled (see
|
||||
// Parser::ParseClassDefinition).
|
||||
cls = Class::New<Instance>(kInstanceCid);
|
||||
object_store->set_object_class(cls);
|
||||
cls.set_name(Symbols::Object());
|
||||
cls.set_script(script);
|
||||
cls.set_is_prefinalized();
|
||||
core_lib.AddClass(cls);
|
||||
pending_classes.Add(cls, Heap::kOld);
|
||||
@@ -900,7 +873,13 @@ RawError* Object::Init(Isolate* isolate) {
|
||||
|
||||
// Pre-register the typed_data library so the native class implementations
|
||||
// can be hooked up before compiling it.
|
||||
LOAD_LIBRARY(TypedData, typed_data);
|
||||
lib = Library::LookupLibrary(Symbols::DartTypedData());
|
||||
if (lib.IsNull()) {
|
||||
lib = Library::NewLibraryHelper(Symbols::DartTypedData(), true);
|
||||
lib.Register();
|
||||
isolate->object_store()->set_bootstrap_library(ObjectStore::kTypedData,
|
||||
lib);
|
||||
}
|
||||
ASSERT(!lib.IsNull());
|
||||
ASSERT(lib.raw() == Library::TypedDataLibrary());
|
||||
const intptr_t typed_data_class_array_length =
|
||||
@@ -979,30 +958,26 @@ RawError* Object::Init(Isolate* isolate) {
|
||||
type = Type::NewNonParameterizedType(cls);
|
||||
object_store->set_number_type(type);
|
||||
|
||||
cls = Class::New<Instance>(Symbols::Int(), script, Scanner::kDummyTokenIndex);
|
||||
cls = Class::New<Instance>(kIllegalCid);
|
||||
RegisterClass(cls, Symbols::Int(), core_lib);
|
||||
pending_classes.Add(cls, Heap::kOld);
|
||||
type = Type::NewNonParameterizedType(cls);
|
||||
object_store->set_int_type(type);
|
||||
|
||||
cls = Class::New<Instance>(Symbols::Double(),
|
||||
script,
|
||||
Scanner::kDummyTokenIndex);
|
||||
cls = Class::New<Instance>(kIllegalCid);
|
||||
RegisterClass(cls, Symbols::Double(), core_lib);
|
||||
pending_classes.Add(cls, Heap::kOld);
|
||||
type = Type::NewNonParameterizedType(cls);
|
||||
object_store->set_double_type(type);
|
||||
|
||||
name = Symbols::New("String");
|
||||
cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex);
|
||||
cls = Class::New<Instance>(kIllegalCid);
|
||||
RegisterClass(cls, name, core_lib);
|
||||
pending_classes.Add(cls, Heap::kOld);
|
||||
type = Type::NewNonParameterizedType(cls);
|
||||
object_store->set_string_type(type);
|
||||
|
||||
cls = Class::New<Instance>(Symbols::List(),
|
||||
script,
|
||||
Scanner::kDummyTokenIndex);
|
||||
cls = Class::New<Instance>(kIllegalCid);
|
||||
RegisterClass(cls, Symbols::List(), core_lib);
|
||||
pending_classes.Add(cls, Heap::kOld);
|
||||
object_store->set_list_class(cls);
|
||||
@@ -1041,21 +1016,10 @@ RawError* Object::Init(Isolate* isolate) {
|
||||
|
||||
// Finish the initialization by compiling the bootstrap scripts containing the
|
||||
// base interfaces and the implementation of the internal classes.
|
||||
INIT_LIBRARY(Core, core, true);
|
||||
|
||||
INIT_LIBRARY(Async, async, true);
|
||||
INIT_LIBRARY(Collection, collection, true);
|
||||
INIT_LIBRARY(CollectionDev, collection_dev, true);
|
||||
INIT_LIBRARY(Crypto, crypto, false);
|
||||
INIT_LIBRARY(Isolate, isolate, true);
|
||||
INIT_LIBRARY(Json, json, true);
|
||||
INIT_LIBRARY(Math, math, true);
|
||||
INIT_LIBRARY(Mirrors, mirrors, true);
|
||||
INIT_LIBRARY(TypedData, typed_data, true);
|
||||
INIT_LIBRARY(Utf, utf, false);
|
||||
INIT_LIBRARY(Uri, uri, false);
|
||||
|
||||
Bootstrap::SetupNativeResolver();
|
||||
const Error& error = Error::Handle(Bootstrap::LoadandCompileScripts());
|
||||
if (!error.IsNull()) {
|
||||
return error.raw();
|
||||
}
|
||||
|
||||
// Remove the Object superclass cycle by setting the super type to null (not
|
||||
// to the type of null).
|
||||
@@ -1840,11 +1804,10 @@ RawClass* Class::New(intptr_t index) {
|
||||
}
|
||||
|
||||
|
||||
template <class FakeInstance>
|
||||
RawClass* Class::New(const String& name,
|
||||
const Script& script,
|
||||
intptr_t token_pos) {
|
||||
Class& result = Class::Handle(New<FakeInstance>(kIllegalCid));
|
||||
Class& result = Class::Handle(New<Instance>(kIllegalCid));
|
||||
result.set_name(name);
|
||||
result.set_script(script);
|
||||
result.set_token_pos(token_pos);
|
||||
@@ -1852,19 +1815,11 @@ RawClass* Class::New(const String& name,
|
||||
}
|
||||
|
||||
|
||||
RawClass* Class::New(const String& name,
|
||||
const Script& script,
|
||||
intptr_t token_pos) {
|
||||
Class& result = Class::Handle(New<Instance>(name, script, token_pos));
|
||||
return result.raw();
|
||||
}
|
||||
|
||||
|
||||
RawClass* Class::NewSignatureClass(const String& name,
|
||||
const Function& signature_function,
|
||||
const Script& script,
|
||||
intptr_t token_pos) {
|
||||
const Class& result = Class::Handle(New<Instance>(name, script, token_pos));
|
||||
const Class& result = Class::Handle(New(name, script, token_pos));
|
||||
const Type& super_type = Type::Handle(Type::ObjectType());
|
||||
ASSERT(!super_type.IsNull());
|
||||
// Instances of a signature class can only be closures.
|
||||
@@ -1919,7 +1874,7 @@ RawClass* Class::NewNativeWrapper(const Library& library,
|
||||
int field_count) {
|
||||
Class& cls = Class::Handle(library.LookupClass(name));
|
||||
if (cls.IsNull()) {
|
||||
cls = New<Instance>(name, Script::Handle(), Scanner::kDummyTokenIndex);
|
||||
cls = New(name, Script::Handle(), Scanner::kDummyTokenIndex);
|
||||
cls.SetFields(Object::empty_array());
|
||||
cls.SetFunctions(Object::empty_array());
|
||||
// Set super class to Object.
|
||||
@@ -6445,7 +6400,7 @@ void Library::InitCoreLibrary(Isolate* isolate) {
|
||||
const Library& core_lib =
|
||||
Library::Handle(Library::NewLibraryHelper(core_lib_url, false));
|
||||
core_lib.Register();
|
||||
isolate->object_store()->set_core_library(core_lib);
|
||||
isolate->object_store()->set_bootstrap_library(ObjectStore::kCore, core_lib);
|
||||
isolate->object_store()->set_root_library(Library::Handle());
|
||||
|
||||
// Hook up predefined classes without setting their library pointers. These
|
||||
|
||||
+2
-4
@@ -907,9 +907,6 @@ class Class : public Object {
|
||||
|
||||
// Allocate an instance class which has a VM implementation.
|
||||
template <class FakeInstance> static RawClass* New(intptr_t id);
|
||||
template <class FakeInstance> static RawClass* New(const String& name,
|
||||
const Script& script,
|
||||
intptr_t token_pos);
|
||||
|
||||
// Check the subtype or 'more specific' relationship.
|
||||
bool TypeTest(TypeTestKind test_kind,
|
||||
@@ -2223,12 +2220,13 @@ class Library : public Object {
|
||||
|
||||
FINAL_HEAP_OBJECT_IMPLEMENTATION(Library, Object);
|
||||
|
||||
friend class Object;
|
||||
friend class Bootstrap;
|
||||
friend class Class;
|
||||
friend class Debugger;
|
||||
friend class DictionaryIterator;
|
||||
friend class Isolate;
|
||||
friend class Namespace;
|
||||
friend class Object;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ ObjectStore::ObjectStore()
|
||||
async_library_(Library::null()),
|
||||
builtin_library_(Library::null()),
|
||||
core_library_(Library::null()),
|
||||
core_impl_library_(Library::null()),
|
||||
crypto_library_(Library::null()),
|
||||
isolate_library_(Library::null()),
|
||||
json_library_(Library::null()),
|
||||
|
||||
+70
-83
@@ -19,6 +19,22 @@ class ObjectPointerVisitor;
|
||||
// by snapshots eventually.
|
||||
class ObjectStore {
|
||||
public:
|
||||
enum {
|
||||
kNone = 0,
|
||||
kAsync,
|
||||
kCore,
|
||||
kCollection,
|
||||
kCollectionDev,
|
||||
kCrypto,
|
||||
kIsolate,
|
||||
kJson,
|
||||
kMath,
|
||||
kMirrors,
|
||||
kTypedData,
|
||||
kUtf,
|
||||
kUri,
|
||||
};
|
||||
|
||||
~ObjectStore();
|
||||
|
||||
RawClass* object_class() const {
|
||||
@@ -239,72 +255,65 @@ class ObjectStore {
|
||||
}
|
||||
|
||||
RawLibrary* async_library() const { return async_library_; }
|
||||
void set_async_library(const Library& value) {
|
||||
async_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* builtin_library() const {
|
||||
return builtin_library_;
|
||||
}
|
||||
void set_builtin_library(const Library& value) {
|
||||
builtin_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* builtin_library() const { return builtin_library_; }
|
||||
RawLibrary* core_library() const { return core_library_; }
|
||||
void set_core_library(const Library& value) {
|
||||
core_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* core_impl_library() const { return core_impl_library_; }
|
||||
void set_core_impl_library(const Library& value) {
|
||||
core_impl_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* collection_library() const {
|
||||
return collection_library_;
|
||||
}
|
||||
void set_collection_library(const Library& value) {
|
||||
collection_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* collection_library() const { return collection_library_; }
|
||||
RawLibrary* collection_dev_library() const {
|
||||
return collection_dev_library_;
|
||||
}
|
||||
void set_collection_dev_library(const Library& value) {
|
||||
collection_dev_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* crypto_library() const {
|
||||
return crypto_library_;
|
||||
}
|
||||
void set_crypto_library(const Library& value) {
|
||||
crypto_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* isolate_library() const {
|
||||
return isolate_library_;
|
||||
}
|
||||
void set_isolate_library(const Library& value) {
|
||||
isolate_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* json_library() const {
|
||||
return json_library_;
|
||||
}
|
||||
void set_json_library(const Library& value) {
|
||||
json_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* math_library() const {
|
||||
return math_library_;
|
||||
}
|
||||
void set_math_library(const Library& value) {
|
||||
math_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* crypto_library() const { return crypto_library_; }
|
||||
RawLibrary* isolate_library() const { return isolate_library_; }
|
||||
RawLibrary* json_library() const { return json_library_; }
|
||||
RawLibrary* math_library() const { return math_library_; }
|
||||
RawLibrary* mirrors_library() const { return mirrors_library_; }
|
||||
void set_mirrors_library(const Library& value) {
|
||||
mirrors_library_ = value.raw();
|
||||
RawLibrary* typed_data_library() const { return typed_data_library_; }
|
||||
RawLibrary* uri_library() const { return uri_library_; }
|
||||
RawLibrary* utf_library() const { return utf_library_; }
|
||||
void set_bootstrap_library(intptr_t index, const Library& value) {
|
||||
switch (index) {
|
||||
case kAsync:
|
||||
async_library_ = value.raw();
|
||||
break;
|
||||
case kCore:
|
||||
core_library_ = value.raw();
|
||||
break;
|
||||
case kCollection:
|
||||
collection_library_ = value.raw();
|
||||
break;
|
||||
case kCollectionDev:
|
||||
collection_dev_library_ = value.raw();
|
||||
break;
|
||||
case kCrypto:
|
||||
crypto_library_ = value.raw();
|
||||
break;
|
||||
case kIsolate:
|
||||
isolate_library_ = value.raw();
|
||||
break;
|
||||
case kJson:
|
||||
json_library_ = value.raw();
|
||||
break;
|
||||
case kMath:
|
||||
math_library_ = value.raw();
|
||||
break;
|
||||
case kMirrors:
|
||||
mirrors_library_ = value.raw();
|
||||
break;
|
||||
case kTypedData:
|
||||
typed_data_library_ = value.raw();
|
||||
break;
|
||||
case kUtf:
|
||||
utf_library_ = value.raw();
|
||||
break;
|
||||
case kUri:
|
||||
uri_library_ = value.raw();
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void set_builtin_library(const Library& value) {
|
||||
builtin_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* native_wrappers_library() const {
|
||||
@@ -319,27 +328,6 @@ class ObjectStore {
|
||||
root_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* typed_data_library() const {
|
||||
return typed_data_library_;
|
||||
}
|
||||
void set_typed_data_library(const Library& value) {
|
||||
typed_data_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* uri_library() const {
|
||||
return uri_library_;
|
||||
}
|
||||
void set_uri_library(const Library& value) {
|
||||
uri_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawLibrary* utf_library() const {
|
||||
return utf_library_;
|
||||
}
|
||||
void set_utf_library(const Library& value) {
|
||||
utf_library_ = value.raw();
|
||||
}
|
||||
|
||||
RawGrowableObjectArray* libraries() const { return libraries_; }
|
||||
void set_libraries(const GrowableObjectArray& value) {
|
||||
libraries_ = value.raw();
|
||||
@@ -473,7 +461,6 @@ class ObjectStore {
|
||||
RawLibrary* async_library_;
|
||||
RawLibrary* builtin_library_;
|
||||
RawLibrary* core_library_;
|
||||
RawLibrary* core_impl_library_;
|
||||
RawLibrary* collection_library_;
|
||||
RawLibrary* collection_dev_library_;
|
||||
RawLibrary* crypto_library_;
|
||||
|
||||
@@ -244,19 +244,19 @@ class ObjectPointerVisitor;
|
||||
V(_New, "_new") \
|
||||
V(DartScheme, "dart:") \
|
||||
V(DartSchemePrivate, "dart:_") \
|
||||
V(DartNativeWrappers, "dart:nativewrappers") \
|
||||
V(DartAsync, "dart:async") \
|
||||
V(DartCore, "dart:core") \
|
||||
V(DartCollection, "dart:collection") \
|
||||
V(DartCollectionDev, "dart:_collection-dev") \
|
||||
V(DartMath, "dart:math") \
|
||||
V(DartCrypto, "dart:crypto") \
|
||||
V(DartIsolate, "dart:isolate") \
|
||||
V(DartJson, "dart:json") \
|
||||
V(DartMath, "dart:math") \
|
||||
V(DartMirrors, "dart:mirrors") \
|
||||
V(DartTypedData, "dart:typed_data") \
|
||||
V(DartNativeWrappers, "dart:nativewrappers") \
|
||||
V(DartAsync, "dart:async") \
|
||||
V(DartUri, "dart:uri") \
|
||||
V(DartUtf, "dart:utf") \
|
||||
V(DartCrypto, "dart:crypto") \
|
||||
V(DartJson, "dart:json") \
|
||||
|
||||
|
||||
// Contains a list of frequently used strings in a canonicalized form. This
|
||||
|
||||
Reference in New Issue
Block a user