OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 var orig_animal = "'Cat'"; | 52 var orig_animal = "'Cat'"; |
53 var patch_pos = script.source.indexOf(orig_animal); | 53 var patch_pos = script.source.indexOf(orig_animal); |
54 var new_animal_patch = "'Capybara' + p"; | 54 var new_animal_patch = "'Capybara' + p"; |
55 | 55 |
56 // We patch innermost function "Chooser". | 56 // We patch innermost function "Chooser". |
57 // However, this does not actually patch existing "Chooser" instances, | 57 // However, this does not actually patch existing "Chooser" instances, |
58 // because old value of parameter "p" was not saved. | 58 // because old value of parameter "p" was not saved. |
59 // Instead it patches ChooseAnimal. | 59 // Instead it patches ChooseAnimal. |
60 var change_log = new Array(); | 60 var change_log = new Array(); |
61 Debug.LiveEditChangeScript(script, patch_pos, orig_animal.length, new_animal_pat
ch, change_log); | 61 Debug.LiveEdit.ApplyPatch(script, patch_pos, orig_animal.length, new_animal_patc
h, change_log); |
62 print("Change log: " + JSON.stringify(change_log) + "\n"); | 62 print("Change log: " + JSON.stringify(change_log) + "\n"); |
63 | 63 |
64 var new_closure = ChooseAnimal(19); | 64 var new_closure = ChooseAnimal(19); |
65 // New instance of closure is patched. | 65 // New instance of closure is patched. |
66 assertEquals("Capybara19", new_closure()); | 66 assertEquals("Capybara19", new_closure()); |
67 | 67 |
68 // Old instance of closure is not patched. | 68 // Old instance of closure is not patched. |
69 assertEquals("Cat", old_closure()); | 69 assertEquals("Cat", old_closure()); |
70 | 70 |
OLD | NEW |