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

Side by Side Diff: runtime/bin/dartutils.cc

Issue 10386107: Implement spawnUri from dart:isolate. This function allows us to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/file.h" 7 #include "bin/file.h"
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/globals.h" 10 #include "platform/globals.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 Dart_Handle str = Dart_NewString(text_buffer); 192 Dart_Handle str = Dart_NewString(text_buffer);
193 free(text_buffer); 193 free(text_buffer);
194 return str; 194 return str;
195 } 195 }
196 196
197 197
198 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, 198 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping,
199 Dart_Handle library, 199 Dart_Handle library,
200 Dart_Handle url, 200 Dart_Handle url,
201 Dart_LibraryTag tag, 201 Dart_LibraryTag tag,
202 const char* url_string, 202 const char* url_string) {
203 Dart_Handle import_map) {
204 if (url_mapping != NULL && IsDartSchemeURL(url_string)) { 203 if (url_mapping != NULL && IsDartSchemeURL(url_string)) {
205 const char* mapped_url_string = MapLibraryUrl(url_mapping, url_string); 204 const char* mapped_url_string = MapLibraryUrl(url_mapping, url_string);
206 if (mapped_url_string == NULL) { 205 if (mapped_url_string == NULL) {
207 return Dart_Error("Do not know how to load %s", url_string); 206 return Dart_Error("Do not know how to load %s", url_string);
208 } 207 }
209 // We have a URL mapping specified, just read the file that the 208 // We have a URL mapping specified, just read the file that the
210 // URL mapping specifies and load it. 209 // URL mapping specifies and load it.
211 url_string = mapped_url_string; 210 url_string = mapped_url_string;
212 } 211 }
213 // The tag is either an import or a source tag. 212 // The tag is either an import or a source tag.
214 // Read the file and load it according to the specified tag. 213 // Read the file and load it according to the specified tag.
215 Dart_Handle source = DartUtils::ReadStringFromFile(url_string); 214 Dart_Handle source = DartUtils::ReadStringFromFile(url_string);
216 if (Dart_IsError(source)) { 215 if (Dart_IsError(source)) {
217 return source; // source contains the error string. 216 return source; // source contains the error string.
218 } 217 }
219 if (tag == kImportTag) { 218 if (tag == kImportTag) {
220 // Return library object or an error string. 219 // Return library object or an error string.
221 return Dart_LoadLibrary(url, source, import_map); 220 return Dart_LoadLibrary(url, source);
222 } else if (tag == kSourceTag) { 221 } else if (tag == kSourceTag) {
223 return Dart_LoadSource(library, url, source); 222 return Dart_LoadSource(library, url, source);
224 } 223 }
225 return Dart_Error("wrong tag"); 224 return Dart_Error("wrong tag");
226 } 225 }
227 226
228 227
229 const char* DartUtils::GetCanonicalPath(const char* reference_dir, 228 const char* DartUtils::GetCanonicalPath(const char* reference_dir,
230 const char* filename) { 229 const char* filename) {
231 if (File::IsAbsolutePath(filename)) { 230 if (File::IsAbsolutePath(filename)) {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 432
434 CObject* CObject::NewOSError(OSError* os_error) { 433 CObject* CObject::NewOSError(OSError* os_error) {
435 CObject* error_message = 434 CObject* error_message =
436 new CObjectString(CObject::NewString(os_error->message())); 435 new CObjectString(CObject::NewString(os_error->message()));
437 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 436 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
438 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 437 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
439 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 438 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
440 result->SetAt(2, error_message); 439 result->SetAt(2, error_message);
441 return result; 440 return result;
442 } 441 }
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/gen_snapshot.cc » ('j') | runtime/lib/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698