| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 void TestCaseBase::RunAll() { | 42 void TestCaseBase::RunAll() { |
| 43 TestCaseBase* test = first_; | 43 TestCaseBase* test = first_; |
| 44 while (test != NULL) { | 44 while (test != NULL) { |
| 45 test->RunTest(); | 45 test->RunTest(); |
| 46 test = test->next_; | 46 test = test->next_; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 | 50 |
| 51 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, |
| 52 Dart_Handle library, |
| 53 Dart_Handle url) { |
| 54 if (!Dart_IsLibrary(library)) { |
| 55 return Dart_Error("not a library"); |
| 56 } |
| 57 if (!Dart_IsString8(url)) { |
| 58 return Dart_Error("url is not a string"); |
| 59 } |
| 60 const char* url_chars = NULL; |
| 61 Dart_Handle result = Dart_StringToCString(url, &url_chars); |
| 62 if (Dart_IsError(result)) { |
| 63 return Dart_Error("accessing url characters failed"); |
| 64 } |
| 65 static const char* kDartScheme = "dart:"; |
| 66 static const intptr_t kDartSchemeLen = strlen(kDartScheme); |
| 67 // If the URL starts with "dart:" then it is not modified as it will be |
| 68 // handled by the VM internally. |
| 69 if (strncmp(url_chars, kDartScheme, kDartSchemeLen) == 0) { |
| 70 if (tag == kCanonicalizeUrl) { |
| 71 return url; |
| 72 } |
| 73 return Dart_Error("unexpected tag encountered %d", tag); |
| 74 } |
| 75 return Dart_Error("unsupported url encountered %s", url_chars); |
| 76 } |
| 77 |
| 78 |
| 51 Dart_Handle TestCase::LoadTestScript(const char* script, | 79 Dart_Handle TestCase::LoadTestScript(const char* script, |
| 52 Dart_NativeEntryResolver resolver) { | 80 Dart_NativeEntryResolver resolver) { |
| 53 Dart_Handle url = Dart_NewString(TestCase::url()); | 81 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 54 Dart_Handle source = Dart_NewString(script); | 82 Dart_Handle source = Dart_NewString(script); |
| 55 Dart_Handle lib = Dart_LoadScript(url, source, NULL); | 83 Dart_Handle lib = Dart_LoadScript(url, source, LibraryTagHandler); |
| 56 ASSERT(!Dart_IsError(lib)); | 84 ASSERT(!Dart_IsError(lib)); |
| 57 Dart_Handle result = Dart_SetNativeResolver(lib, resolver); | 85 Dart_Handle result = Dart_SetNativeResolver(lib, resolver); |
| 58 ASSERT(!Dart_IsError(result)); | 86 ASSERT(!Dart_IsError(result)); |
| 59 return lib; | 87 return lib; |
| 60 } | 88 } |
| 61 | 89 |
| 62 | 90 |
| 63 Dart_Handle TestCase::lib() { | 91 Dart_Handle TestCase::lib() { |
| 64 Dart_Handle url = Dart_NewString(TestCase::url()); | 92 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 65 Dart_Handle lib = Dart_LookupLibrary(url); | 93 Dart_Handle lib = Dart_LookupLibrary(url); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 Compiler::CompileFunction(function); | 203 Compiler::CompileFunction(function); |
| 176 retval = true; | 204 retval = true; |
| 177 } else { | 205 } else { |
| 178 retval = false; | 206 retval = false; |
| 179 } | 207 } |
| 180 isolate->set_long_jump_base(base); | 208 isolate->set_long_jump_base(base); |
| 181 return retval; | 209 return retval; |
| 182 } | 210 } |
| 183 | 211 |
| 184 } // namespace dart | 212 } // namespace dart |
| OLD | NEW |