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

Unified Diff: bin/process_script.cc

Issue 8537023: Implement automatic loading of dart:core_native_fields library (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: bin/process_script.cc
===================================================================
--- bin/process_script.cc (revision 1465)
+++ bin/process_script.cc (working copy)
@@ -11,6 +11,7 @@
#include "include/dart_api.h"
#include "bin/builtin.h"
+#include "bin/dartutils.h"
#include "bin/file.h"
#include "bin/globals.h"
#include "bin/process_script.h"
@@ -86,10 +87,10 @@
}
-static Dart_Handle LibraryTagHandlerHelper(Dart_LibraryTag tag,
- Dart_Handle library,
- Dart_Handle url,
- bool import_builtin_lib) {
+Dart_Handle LibraryTagHandlerHelper(Dart_LibraryTag tag,
+ Dart_Handle library,
+ Dart_Handle url,
+ bool import_builtin_lib) {
if (!Dart_IsLibrary(library)) {
return Dart_Error("not a library");
}
@@ -101,8 +102,12 @@
if (!Dart_IsValid(result)) {
return Dart_Error("accessing url characters failed");
}
-
+ bool is_native_flds_library = !strcmp(url_chars,
Anton Muhin 2011/11/13 16:19:32 I am somewhat concerned that logic for dart:core_n
siva 2011/11/15 02:16:52 Moved this check to just before invoking the libra
+ DartUtils::kCoreNativeFieldsLibURL);
if (tag == kCanonicalizeUrl) {
+ if (is_native_flds_library) {
+ return url;
+ }
// Create the full path based on the including library and the current url.
// Get the url of the calling library.
@@ -127,6 +132,10 @@
return canon_url;
}
+ if (is_native_flds_library) {
+ return Dart_LookupLibrary(url);
+ }
+
// The tag is either an import or a source tag. Read the file based on the
// url chars.
Dart_Handle source = ReadStringFromFile(url_chars);
@@ -145,6 +154,7 @@
return Dart_Error("wrong tag");
}
+
static Dart_Handle MainLibraryTagHandler(Dart_LibraryTag tag,
Dart_Handle library,
Dart_Handle url) {
@@ -153,31 +163,22 @@
}
-static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
- Dart_Handle library,
- Dart_Handle url) {
- const bool kDontImportBuiltinLib = false; // Do not import builtin lib.
- return LibraryTagHandlerHelper(tag, library, url, kDontImportBuiltinLib);
-}
-
-
Dart_Handle LoadScript(const char* script_name) {
Dart_Handle source = ReadStringFromFile(script_name);
if (!Dart_IsValid(source)) {
return source;
}
Dart_Handle url = Dart_NewString(script_name);
-
return Dart_LoadScript(url, source, MainLibraryTagHandler);
}
-Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
+Dart_Handle LoadSnapshotCreationScript(const char* script_name,
+ Dart_LibraryTagHandler handler) {
Dart_Handle source = ReadStringFromFile(script_name);
if (!Dart_IsValid(source)) {
return source;
}
Dart_Handle url = Dart_NewString(script_name);
-
- return Dart_LoadScript(url, source, CreateSnapshotLibraryTagHandler);
+ return Dart_LoadScript(url, source, handler);
}

Powered by Google App Engine
This is Rietveld 408576698