| 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 "vm/unit_test.h" | 5 #include "vm/unit_test.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "bin/builtin.h" | 9 #include "bin/builtin.h" |
| 10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // Store the new script in TLS. | 262 // Store the new script in TLS. |
| 263 OSThread::SetThreadLocal(script_reload_key, reinterpret_cast<uword>(script)); | 263 OSThread::SetThreadLocal(script_reload_key, reinterpret_cast<uword>(script)); |
| 264 } | 264 } |
| 265 | 265 |
| 266 | 266 |
| 267 Dart_Handle TestCase::TriggerReload() { | 267 Dart_Handle TestCase::TriggerReload() { |
| 268 Isolate* isolate = Isolate::Current(); | 268 Isolate* isolate = Isolate::Current(); |
| 269 | 269 |
| 270 { | 270 { |
| 271 TransitionNativeToVM transition(Thread::Current()); | 271 TransitionNativeToVM transition(Thread::Current()); |
| 272 isolate->ReloadSources(/* test_mode = */ true); | 272 isolate->ReloadSources(/* dont_delete_reload_context = */ true); |
| 273 } | 273 } |
| 274 | 274 |
| 275 return Dart_FinalizeLoading(false); | 275 return Dart_FinalizeLoading(false); |
| 276 } | 276 } |
| 277 | 277 |
| 278 | 278 |
| 279 Dart_Handle TestCase::GetReloadErrorOrRootLibrary() { | 279 Dart_Handle TestCase::GetReloadErrorOrRootLibrary() { |
| 280 Isolate* isolate = Isolate::Current(); | 280 Isolate* isolate = Isolate::Current(); |
| 281 | 281 |
| 282 if (isolate->reload_context() != NULL) { | 282 if (isolate->reload_context() != NULL && |
| 283 // We should only have a reload context hanging around if an error occurred. | 283 isolate->reload_context()->has_error()) { |
| 284 ASSERT(isolate->reload_context()->has_error()); | |
| 285 // Return a handle to the error. | 284 // Return a handle to the error. |
| 286 return Api::NewHandle(Thread::Current(), | 285 return Api::NewHandle(Thread::Current(), |
| 287 isolate->reload_context()->error()); | 286 isolate->reload_context()->error()); |
| 288 } | 287 } |
| 289 return Dart_RootLibrary(); | 288 return Dart_RootLibrary(); |
| 290 } | 289 } |
| 291 | 290 |
| 292 | 291 |
| 293 Dart_Handle TestCase::ReloadTestScript(const char* script) { | 292 Dart_Handle TestCase::ReloadTestScript(const char* script) { |
| 294 SetReloadTestScript(script); | 293 SetReloadTestScript(script); |
| 295 | 294 |
| 296 Dart_Handle result = TriggerReload(); | 295 Dart_Handle result = TriggerReload(); |
| 297 if (Dart_IsError(result)) { | 296 if (Dart_IsError(result)) { |
| 298 return result; | 297 return result; |
| 299 } | 298 } |
| 300 | 299 |
| 301 return GetReloadErrorOrRootLibrary(); | 300 result = GetReloadErrorOrRootLibrary(); |
| 301 |
| 302 Isolate* isolate = Isolate::Current(); |
| 303 if (isolate->reload_context() != NULL) { |
| 304 isolate->DeleteReloadContext(); |
| 305 } |
| 306 |
| 307 return result; |
| 302 } | 308 } |
| 303 | 309 |
| 304 | 310 |
| 305 #endif // !PRODUCT | 311 #endif // !PRODUCT |
| 306 | 312 |
| 307 | 313 |
| 308 Dart_Handle TestCase::LoadCoreTestScript(const char* script, | 314 Dart_Handle TestCase::LoadCoreTestScript(const char* script, |
| 309 Dart_NativeEntryResolver resolver) { | 315 Dart_NativeEntryResolver resolver) { |
| 310 return LoadTestScript(script, resolver, CORELIB_TEST_URI); | 316 return LoadTestScript(script, resolver, CORELIB_TEST_URI); |
| 311 } | 317 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 } | 459 } |
| 454 // Copy the remainder of in to out. | 460 // Copy the remainder of in to out. |
| 455 while (*in != '\0') { | 461 while (*in != '\0') { |
| 456 *out++ = *in++; | 462 *out++ = *in++; |
| 457 } | 463 } |
| 458 *out = '\0'; | 464 *out = '\0'; |
| 459 } | 465 } |
| 460 | 466 |
| 461 | 467 |
| 462 } // namespace dart | 468 } // namespace dart |
| OLD | NEW |