| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 var pattern = /\/\*\$\*\//g; | 55 var pattern = /\/\*\$\*\//g; |
| 56 while ((match = pattern.exec(text)) != null) { | 56 while ((match = pattern.exec(text)) != null) { |
| 57 positions.push(match.index); | 57 positions.push(match.index); |
| 58 } | 58 } |
| 59 return positions; | 59 return positions; |
| 60 } | 60 } |
| 61 | 61 |
| 62 function ReadPCMap(func, positions) { | 62 function ReadPCMap(func, positions) { |
| 63 var res = new Array(); | 63 var res = new Array(); |
| 64 for (var i = 0; i < positions.length; i++) { | 64 for (var i = 0; i < positions.length; i++) { |
| 65 res.push(Debug.LiveEditChangeScript.GetPcFromSourcePos(func, positions[i])); | 65 res.push(Debug.LiveEdit.GetPcFromSourcePos(func, positions[i])); |
| 66 } | 66 } |
| 67 return res; | 67 return res; |
| 68 } | 68 } |
| 69 | 69 |
| 70 var res = ChooseAnimal(); | 70 var res = ChooseAnimal(); |
| 71 assertEquals("Cat15", res); | 71 assertEquals("Cat15", res); |
| 72 | 72 |
| 73 var markerPositionsBefore = ReadMarkerPositions(ChooseAnimal); | 73 var markerPositionsBefore = ReadMarkerPositions(ChooseAnimal); |
| 74 var pcArrayBefore = ReadPCMap(ChooseAnimal, markerPositionsBefore); | 74 var pcArrayBefore = ReadPCMap(ChooseAnimal, markerPositionsBefore); |
| 75 | 75 |
| 76 var script = Debug.findScript(ChooseAnimal); | 76 var script = Debug.findScript(ChooseAnimal); |
| 77 | 77 |
| 78 var orig_animal = "'Cat'"; | 78 var orig_animal = "'Cat'"; |
| 79 var patch_pos = script.source.indexOf(orig_animal); | 79 var patch_pos = script.source.indexOf(orig_animal); |
| 80 var new_animal_patch = "'Capybara'"; | 80 var new_animal_patch = "'Capybara'"; |
| 81 | 81 |
| 82 var change_log = new Array(); | 82 var change_log = new Array(); |
| 83 Debug.LiveEditChangeScript(script, patch_pos, orig_animal.length, new_animal_pat
ch, change_log); | 83 Debug.LiveEdit.ApplyPatch(script, patch_pos, orig_animal.length, new_animal_patc
h, change_log); |
| 84 print("Change log: " + JSON.stringify(change_log) + "\n"); | 84 print("Change log: " + JSON.stringify(change_log) + "\n"); |
| 85 | 85 |
| 86 var res = ChooseAnimal(); | 86 var res = ChooseAnimal(); |
| 87 assertEquals("Capybara15", res); | 87 assertEquals("Capybara15", res); |
| 88 | 88 |
| 89 var markerPositionsAfter = ReadMarkerPositions(ChooseAnimal); | 89 var markerPositionsAfter = ReadMarkerPositions(ChooseAnimal); |
| 90 var pcArrayAfter = ReadPCMap(ChooseAnimal, markerPositionsAfter); | 90 var pcArrayAfter = ReadPCMap(ChooseAnimal, markerPositionsAfter); |
| 91 | 91 |
| 92 assertArrayEquals(pcArrayBefore, pcArrayAfter); | 92 assertArrayEquals(pcArrayBefore, pcArrayAfter); |
| 93 | 93 |
| OLD | NEW |