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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
7 #include "platform/json.h" | 7 #include "platform/json.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 5490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5501 "m1() => topLevel(2);\n" | 5501 "m1() => topLevel(2);\n" |
5502 "m2() {\n" | 5502 "m2() {\n" |
5503 " topLevelSetter = 20;\n" | 5503 " topLevelSetter = 20;\n" |
5504 " return topLevelGetter;\n" | 5504 " return topLevelGetter;\n" |
5505 "}\n" | 5505 "}\n" |
5506 "m3() => patch(7);\n"; | 5506 "m3() => patch(7);\n"; |
5507 | 5507 |
5508 Dart_Handle result = Dart_SetLibraryTagHandler(library_handler); | 5508 Dart_Handle result = Dart_SetLibraryTagHandler(library_handler); |
5509 EXPECT_VALID(result); | 5509 EXPECT_VALID(result); |
5510 | 5510 |
5511 Dart_Handle lib_url = Dart_NewString("theLibrary"); | 5511 Dart_Handle url = Dart_NewString("theLibrary"); |
5512 Dart_Handle source = Dart_NewString(kLibraryChars); | 5512 Dart_Handle source = Dart_NewString(kLibraryChars); |
5513 result = Dart_LoadLibrary(lib_url, source); | 5513 result = Dart_LoadLibrary(url, source); |
5514 EXPECT_VALID(result); | 5514 EXPECT_VALID(result); |
5515 | 5515 |
5516 const String& url = String::Handle(String::New("theLibrary")); | 5516 const String& patch_url = String::Handle(String::New("theLibrary patch")); |
5517 const String& patch_source = String::Handle(String::New(kPatchChars)); | 5517 const String& patch_source = String::Handle(String::New(kPatchChars)); |
5518 const Library& lib = Library::Handle(Library::LookupLibrary(url)); | 5518 const Script& patch_script = Script::Handle(Script::New( |
5519 const Error& err = Error::Handle(lib.Patch(url, patch_source)); | 5519 patch_url, patch_source, RawScript::kPatchTag)); |
| 5520 |
| 5521 const String& lib_url = String::Handle(String::New("theLibrary")); |
| 5522 const Library& lib = Library::Handle(Library::LookupLibrary(lib_url)); |
| 5523 const Error& err = Error::Handle(lib.Patch(patch_script)); |
5520 if (!err.IsNull()) { | 5524 if (!err.IsNull()) { |
5521 OS::Print("Patching error: %s\n", err.ToErrorCString()); | 5525 OS::Print("Patching error: %s\n", err.ToErrorCString()); |
5522 EXPECT(false); | 5526 EXPECT(false); |
5523 } | 5527 } |
5524 | 5528 |
5525 Dart_Handle script_url = Dart_NewString("theScript"); | 5529 Dart_Handle script_url = Dart_NewString("theScript"); |
5526 source = Dart_NewString(kScriptChars); | 5530 source = Dart_NewString(kScriptChars); |
5527 Dart_Handle test_script = Dart_LoadScript(script_url, source); | 5531 Dart_Handle test_script = Dart_LoadScript(script_url, source); |
5528 EXPECT_VALID(test_script); | 5532 EXPECT_VALID(test_script); |
5529 | 5533 |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6559 EXPECT(Dart_IsString(str)); | 6563 EXPECT(Dart_IsString(str)); |
6560 len = -1; | 6564 len = -1; |
6561 EXPECT_VALID(Dart_StringLength(str, &len)); | 6565 EXPECT_VALID(Dart_StringLength(str, &len)); |
6562 EXPECT_EQ(0, len); | 6566 EXPECT_EQ(0, len); |
6563 } | 6567 } |
6564 | 6568 |
6565 | 6569 |
6566 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 6570 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
6567 | 6571 |
6568 } // namespace dart | 6572 } // namespace dart |
OLD | NEW |