OLD | NEW |
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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 | 10 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 Dart_EnterScope(); | 163 Dart_EnterScope(); |
164 | 164 |
165 // Load the specified script. | 165 // Load the specified script. |
166 library = LoadScript(script_name); | 166 library = LoadScript(script_name); |
167 if (Dart_IsError(library)) { | 167 if (Dart_IsError(library)) { |
168 const char* err_msg = Dart_GetError(library); | 168 const char* err_msg = Dart_GetError(library); |
169 fprintf(stderr, "Errors encountered while loading script: %s\n", err_msg); | 169 fprintf(stderr, "Errors encountered while loading script: %s\n", err_msg); |
170 Dart_ExitScope(); | 170 Dart_ExitScope(); |
171 exit(255); | 171 exit(255); |
172 } | 172 } |
173 | |
174 if (!Dart_IsLibrary(library)) { | 173 if (!Dart_IsLibrary(library)) { |
175 fprintf(stderr, | 174 fprintf(stderr, |
176 "Expected a library when loading script: %s", | 175 "Expected a library when loading script: %s", |
177 script_name); | 176 script_name); |
178 Dart_ExitScope(); | 177 Dart_ExitScope(); |
179 exit(255); | 178 exit(255); |
180 } | 179 } |
181 Builtin_ImportLibrary(library); | 180 Builtin_ImportLibrary(library); // Import builtin library. |
182 // Setup the native resolver for built in library functions. | |
183 Builtin_SetNativeResolver(); | |
184 | 181 |
185 Dart_ExitScope(); | 182 Dart_ExitScope(); |
186 return data; | 183 return data; |
187 } | 184 } |
188 | 185 |
189 | 186 |
190 static void PrintUsage() { | 187 static void PrintUsage() { |
191 fprintf(stderr, | 188 fprintf(stderr, |
192 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n"); | 189 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n"); |
193 } | 190 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 return 255; // Indicates we encountered an error. | 229 return 255; // Indicates we encountered an error. |
233 } | 230 } |
234 Dart_Isolate isolate = Dart_CreateIsolate(snapshot_buffer, | 231 Dart_Isolate isolate = Dart_CreateIsolate(snapshot_buffer, |
235 canonical_script_name); | 232 canonical_script_name); |
236 if (isolate == NULL) { | 233 if (isolate == NULL) { |
237 free(canonical_script_name); | 234 free(canonical_script_name); |
238 return 255; | 235 return 255; |
239 } | 236 } |
240 | 237 |
241 Dart_EnterScope(); | 238 Dart_EnterScope(); |
| 239 |
| 240 if (snapshot_buffer != NULL) { |
| 241 // Setup the native resolver as the snapshot does not carry it. |
| 242 Builtin_SetNativeResolver(); |
| 243 } |
| 244 |
242 if (HasCompileAll(vm_options)) { | 245 if (HasCompileAll(vm_options)) { |
243 Dart_Handle result = Dart_CompileAll(); | 246 Dart_Handle result = Dart_CompileAll(); |
244 if (Dart_IsError(result)) { | 247 if (Dart_IsError(result)) { |
245 fprintf(stderr, "%s\n", Dart_GetError(result)); | 248 fprintf(stderr, "%s\n", Dart_GetError(result)); |
246 Dart_ExitScope(); | 249 Dart_ExitScope(); |
247 Dart_ShutdownIsolate(); | 250 Dart_ShutdownIsolate(); |
248 free(canonical_script_name); | 251 free(canonical_script_name); |
249 return 255; // Indicates we encountered an error. | 252 return 255; // Indicates we encountered an error. |
250 } | 253 } |
251 } | 254 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 return 255; // Indicates we encountered an error. | 295 return 255; // Indicates we encountered an error. |
293 } | 296 } |
294 free(canonical_script_name); | 297 free(canonical_script_name); |
295 Dart_ExitScope(); | 298 Dart_ExitScope(); |
296 // Dump symbol information for the profiler. | 299 // Dump symbol information for the profiler. |
297 DumpPprofSymbolInfo(); | 300 DumpPprofSymbolInfo(); |
298 // Shutdown the isolate. | 301 // Shutdown the isolate. |
299 Dart_ShutdownIsolate(); | 302 Dart_ShutdownIsolate(); |
300 return 0; | 303 return 0; |
301 } | 304 } |
OLD | NEW |