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

Side by Side Diff: bin/builtin.cc

Issue 8673002: - Refactor the isolate callback mechanism to also include creation of the (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 unified diff | Download patch | Annotate | Revision Log
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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "bin/builtin.h" 9 #include "bin/builtin.h"
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
11 11
12 // Implementation of native functions which are used for some 12 static void SetupCorelibImports(Dart_Handle builtin_lib) {
13 // test/debug functionality in standalone dart mode. 13 // Lookup the core libraries and import the builtin library into them.
14 Dart_Handle url = Dart_NewString(DartUtils::kCoreLibURL);
15 Dart_Handle core_lib = Dart_LookupLibrary(url);
16 DART_CHECK_VALID(core_lib);
17 Dart_Handle result = Dart_LibraryImportLibrary(core_lib, builtin_lib);
18 DART_CHECK_VALID(result);
turnidge 2011/11/28 18:39:58 Can get rid of "result" here if you want.
siva 2011/11/29 00:54:25 Done.
14 19
15 void PrintString(FILE* out, Dart_Handle str) { 20 url = Dart_NewString(DartUtils::kCoreImplLibURL);
16 const char* cstring = NULL; 21 Dart_Handle coreimpl_lib = Dart_LookupLibrary(url);
17 Dart_Handle result = Dart_StringToCString(str, &cstring); 22 DART_CHECK_VALID(coreimpl_lib);
18 if (Dart_IsError(result)) { 23 DART_CHECK_VALID(Dart_LibraryImportLibrary(coreimpl_lib, builtin_lib));
19 cstring = Dart_GetError(result);
20 }
21 fprintf(out, "%s\n", cstring);
22 fflush(out);
23 } 24 }
24 25
25 26
26 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { 27 Dart_Handle Builtin::Source() {
27 Dart_EnterScope(); 28 Dart_Handle source = Dart_NewString(Builtin::Builtin_source_);
28 PrintString(stdout, Dart_GetNativeArgument(args, 0)); 29 return source;
29 Dart_ExitScope();
30 } 30 }
31 31
32 void FUNCTION_NAME(Exit)(Dart_NativeArguments args) { 32
33 Dart_EnterScope(); 33 void Builtin::SetupLibrary(Dart_Handle builtin_lib) {
34 int64_t status = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); 34 // Setup core lib, builtin import structure.
35 Dart_ExitScope(); 35 SetupCorelibImports(builtin_lib);
36 exit(status); 36 // Setup the native resolver for built in library functions.
37 DART_CHECK_VALID(Dart_SetNativeResolver(builtin_lib, NativeLookup));
37 } 38 }
39
40
41 void Builtin::ImportLibrary(Dart_Handle library) {
42 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL);
43 Dart_Handle builtin_lib = Dart_LookupLibrary(url);
44 if (Dart_IsError(builtin_lib)) {
45 builtin_lib = Dart_LoadLibrary(url, Source());
46 if (!Dart_IsError(builtin_lib)) {
47 SetupLibrary(builtin_lib);
48 }
49 }
50 // Import the builtin library into current library.
51 DART_CHECK_VALID(builtin_lib);
52 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, builtin_lib));
53 }
OLDNEW
« no previous file with comments | « bin/builtin.h ('k') | bin/builtin_in.cc » ('j') | bin/builtin_natives.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698