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

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
« no previous file with comments | « bin/builtin.h ('k') | bin/builtin_in.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 <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/23 19:03:33 Remove result.
siva 2011/11/23 22:37:27 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 result = Dart_LibraryImportLibrary(coreimpl_lib, builtin_lib);
19 cstring = Dart_GetError(result); 24 DART_CHECK_VALID(result);
turnidge 2011/11/23 19:03:33 Remove result.
siva 2011/11/23 22:37:27 Done.
20 }
21 fprintf(out, "%s\n", cstring);
22 fflush(out);
23 } 25 }
24 26
25 27
26 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { 28 Dart_Handle Builtin::Source() {
27 Dart_EnterScope(); 29 Dart_Handle source = Dart_NewString(Builtin::Builtin_source_);
28 PrintString(stdout, Dart_GetNativeArgument(args, 0)); 30 return source;
29 Dart_ExitScope();
30 } 31 }
31 32
32 void FUNCTION_NAME(Exit)(Dart_NativeArguments args) { 33
33 Dart_EnterScope(); 34 void Builtin::SetupLibrary(Dart_Handle builtin_lib) {
34 int64_t status = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); 35 // Setup core lib, builtin import structure.
35 Dart_ExitScope(); 36 SetupCorelibImports(builtin_lib);
36 exit(status); 37 // Setup the native resolver for built in library functions.
38 Dart_Handle result = Dart_SetNativeResolver(builtin_lib, NativeLookup);
39 DART_CHECK_VALID(result);
37 } 40 }
41
42
43 void Builtin::ImportLibrary(Dart_Handle library) {
44 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL);
45 Dart_Handle builtin_lib = Dart_LookupLibrary(url);
46 if (Dart_IsError(builtin_lib)) {
47 builtin_lib = Dart_LoadLibrary(url, Source());
48 if (!Dart_IsError(builtin_lib)) {
49 SetupLibrary(builtin_lib);
50 }
51 }
52 // Import the builtin library into current library.
53 DART_CHECK_VALID(builtin_lib);
54 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, builtin_lib));
55 }
OLDNEW
« no previous file with comments | « bin/builtin.h ('k') | bin/builtin_in.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698