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

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

Issue 1405183002: Bring up the service isolate and use it for package resolution in gen_snapshot (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/bin/dartutils.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) 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 10
11 #include "bin/builtin.h" 11 #include "bin/builtin.h"
12 #include "bin/io_natives.h"
12 13
13 namespace dart { 14 namespace dart {
14 namespace bin { 15 namespace bin {
15 16
16 // Lists the native function implementing basic logging facility. 17 // Lists the native function implementing basic logging facility.
17 #define BUILTIN_NATIVE_LIST(V) \ 18 #define BUILTIN_NATIVE_LIST(V) \
18 V(Builtin_PrintString, 1) 19 V(Builtin_PrintString, 1)
19 20
20 BUILTIN_NATIVE_LIST(DECLARE_FUNCTION); 21 BUILTIN_NATIVE_LIST(DECLARE_FUNCTION);
21 22
(...skipping 16 matching lines...) Expand all
38 ASSERT(auto_setup_scope != NULL); 39 ASSERT(auto_setup_scope != NULL);
39 *auto_setup_scope = true; 40 *auto_setup_scope = true;
40 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); 41 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries);
41 for (int i = 0; i < num_entries; i++) { 42 for (int i = 0; i < num_entries; i++) {
42 struct NativeEntries* entry = &(BuiltinEntries[i]); 43 struct NativeEntries* entry = &(BuiltinEntries[i]);
43 if (!strcmp(function_name, entry->name_) && 44 if (!strcmp(function_name, entry->name_) &&
44 (entry->argument_count_ == argument_count)) { 45 (entry->argument_count_ == argument_count)) {
45 return reinterpret_cast<Dart_NativeFunction>(entry->function_); 46 return reinterpret_cast<Dart_NativeFunction>(entry->function_);
46 } 47 }
47 } 48 }
48 return NULL; 49 return IONativeLookup(name, argument_count, auto_setup_scope);
49 } 50 }
50 51
51 52
52 const uint8_t* Builtin::NativeSymbol(Dart_NativeFunction nf) { 53 const uint8_t* Builtin::NativeSymbol(Dart_NativeFunction nf) {
53 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); 54 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries);
54 for (int i = 0; i < num_entries; i++) { 55 for (int i = 0; i < num_entries; i++) {
55 struct NativeEntries* entry = &(BuiltinEntries[i]); 56 struct NativeEntries* entry = &(BuiltinEntries[i]);
56 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) { 57 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) {
57 return reinterpret_cast<const uint8_t*>(entry->name_); 58 return reinterpret_cast<const uint8_t*>(entry->name_);
58 } 59 }
59 } 60 }
60 return NULL; 61 return IONativeSymbol(nf);
61 } 62 }
62 63
63 64
64 // Implementation of native functions which are used for some 65 // Implementation of native functions which are used for some
65 // test/debug functionality in standalone dart mode. 66 // test/debug functionality in standalone dart mode.
66 void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) { 67 void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) {
67 Dart_EnterScope(); 68 Dart_EnterScope();
68 intptr_t length = 0; 69 intptr_t length = 0;
69 uint8_t* chars = NULL; 70 uint8_t* chars = NULL;
70 Dart_Handle str = Dart_GetNativeArgument(args, 0); 71 Dart_Handle str = Dart_GetNativeArgument(args, 0);
71 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); 72 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length);
72 if (Dart_IsError(result)) { 73 if (Dart_IsError(result)) {
73 // TODO(turnidge): Consider propagating some errors here. What if 74 // TODO(turnidge): Consider propagating some errors here. What if
74 // an isolate gets interrupted by the embedder in the middle of 75 // an isolate gets interrupted by the embedder in the middle of
75 // Dart_StringToUTF8? We need to make sure not to swallow the 76 // Dart_StringToUTF8? We need to make sure not to swallow the
76 // interrupt. 77 // interrupt.
77 fputs(Dart_GetError(result), stdout); 78 fputs(Dart_GetError(result), stdout);
78 } else { 79 } else {
79 fwrite(chars, sizeof(*chars), length, stdout); 80 fwrite(chars, sizeof(*chars), length, stdout);
80 } 81 }
81 fputc('\n', stdout); 82 fputc('\n', stdout);
82 fflush(stdout); 83 fflush(stdout);
83 Dart_ExitScope(); 84 Dart_ExitScope();
84 } 85 }
85 86
86 } // namespace bin 87 } // namespace bin
87 } // namespace dart 88 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/bin/dartutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698