OLD | NEW |
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 <math.h> | 5 #include <math.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 VMGlue::LoadSourceFromFile(extension_script_); | 82 VMGlue::LoadSourceFromFile(extension_script_); |
83 Dart_Handle library = CheckError(Dart_LoadLibrary(urlHandle, source)); | 83 Dart_Handle library = CheckError(Dart_LoadLibrary(urlHandle, source)); |
84 CheckError(Dart_SetNativeResolver(library, ResolveName)); | 84 CheckError(Dart_SetNativeResolver(library, ResolveName)); |
85 return library; | 85 return library; |
86 } | 86 } |
87 LOGE("UNIMPLEMENTED: load library %s\n", url); | 87 LOGE("UNIMPLEMENTED: load library %s\n", url); |
88 return NULL; | 88 return NULL; |
89 } | 89 } |
90 | 90 |
91 // Returns true on success, false on failure. | 91 // Returns true on success, false on failure. |
92 bool VMGlue::CreateIsolateAndSetupHelper(const char* script_uri, | 92 Dart_Isolate VMGlue::CreateIsolateAndSetupHelper(const char* script_uri, |
93 const char* main, | 93 const char* main, |
94 void* data, | 94 void* data, |
95 char** error) { | 95 char** error) { |
96 LOGI("Creating isolate %s, %s", script_uri, main); | 96 LOGI("Creating isolate %s, %s", script_uri, main); |
97 Dart_Isolate isolate = | 97 Dart_Isolate isolate = |
98 Dart_CreateIsolate(script_uri, main, NULL, data, error); | 98 Dart_CreateIsolate(script_uri, main, NULL, data, error); |
99 if (isolate == NULL) { | 99 if (isolate == NULL) { |
100 LOGE("Couldn't create isolate: %s", *error); | 100 LOGE("Couldn't create isolate: %s", *error); |
101 return false; | 101 return NULL; |
102 } | 102 } |
103 | 103 |
104 LOGI("Entering scope"); | 104 LOGI("Entering scope"); |
105 Dart_EnterScope(); | 105 Dart_EnterScope(); |
106 | 106 |
107 // Set up the library tag handler for this isolate. | 107 // Set up the library tag handler for this isolate. |
108 LOGI("Setting up library tag handler"); | 108 LOGI("Setting up library tag handler"); |
109 Dart_Handle result = CheckError(Dart_SetLibraryTagHandler(LibraryTagHandler)); | 109 Dart_Handle result = CheckError(Dart_SetLibraryTagHandler(LibraryTagHandler)); |
110 CHECK_RESULT(result); | 110 CHECK_RESULT(result); |
111 | 111 |
112 Dart_ExitScope(); | 112 Dart_ExitScope(); |
113 return true; | 113 return isolate; |
114 } | 114 } |
115 | 115 |
116 bool VMGlue::CreateIsolateAndSetup(const char* script_uri, | 116 Dart_Isolate VMGlue::CreateIsolateAndSetup(const char* script_uri, |
117 const char* main, | 117 const char* main, |
118 void* data, char** error) { | 118 void* data, char** error) { |
119 return CreateIsolateAndSetupHelper(script_uri, | 119 return CreateIsolateAndSetupHelper(script_uri, |
120 main, | 120 main, |
121 data, | 121 data, |
122 error); | 122 error); |
123 } | 123 } |
124 | 124 |
125 const char* VM_FLAGS[] = { | 125 const char* VM_FLAGS[] = { |
126 "--enable_type_checks", // TODO(gram): This should be an option! | 126 "--enable_type_checks", // TODO(gram): This should be an option! |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 357 |
358 void VMGlue::FinishMainIsolate() { | 358 void VMGlue::FinishMainIsolate() { |
359 LOGI("Finish main isolate"); | 359 LOGI("Finish main isolate"); |
360 Dart_EnterIsolate(isolate_); | 360 Dart_EnterIsolate(isolate_); |
361 // Shutdown the isolate. | 361 // Shutdown the isolate. |
362 Dart_ShutdownIsolate(); | 362 Dart_ShutdownIsolate(); |
363 isolate_ = NULL; | 363 isolate_ = NULL; |
364 initialized_script_ = false; | 364 initialized_script_ = false; |
365 } | 365 } |
366 | 366 |
OLD | NEW |