Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(719)

Side by Side Diff: src/liveedit.cc

Issue 1672006: Support multi-chunk differences (Closed)
Patch Set: merge Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/liveedit.h ('k') | src/liveedit-debugger.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 private: 340 private:
341 Handle<String> s1_; 341 Handle<String> s1_;
342 Handle<String> s2_; 342 Handle<String> s2_;
343 LineEndsWrapper line_ends1_; 343 LineEndsWrapper line_ends1_;
344 LineEndsWrapper line_ends2_; 344 LineEndsWrapper line_ends2_;
345 }; 345 };
346 346
347 347
348 // Stores compare result in JSArray. Each chunk is stored as 3 array elements: 348 // Stores compare result in JSArray. Each chunk is stored as 3 array elements:
349 // (pos1, len1, len2). 349 // (pos1_begin, pos1_end, pos2_end).
350 class LineArrayCompareOutput : public Compare::Output { 350 class LineArrayCompareOutput : public Compare::Output {
351 public: 351 public:
352 LineArrayCompareOutput(LineEndsWrapper line_ends1, LineEndsWrapper line_ends2) 352 LineArrayCompareOutput(LineEndsWrapper line_ends1, LineEndsWrapper line_ends2)
353 : array_(Factory::NewJSArray(10)), current_size_(0), 353 : array_(Factory::NewJSArray(10)), current_size_(0),
354 line_ends1_(line_ends1), line_ends2_(line_ends2) { 354 line_ends1_(line_ends1), line_ends2_(line_ends2) {
355 } 355 }
356 356
357 void AddChunk(int line_pos1, int line_pos2, int line_len1, int line_len2) { 357 void AddChunk(int line_pos1, int line_pos2, int line_len1, int line_len2) {
358 int char_pos1 = line_ends1_.GetLineStart(line_pos1); 358 int char_pos1 = line_ends1_.GetLineStart(line_pos1);
359 int char_pos2 = line_ends2_.GetLineStart(line_pos2); 359 int char_pos2 = line_ends2_.GetLineStart(line_pos2);
360 int char_len1 = line_ends1_.GetLineStart(line_pos1 + line_len1) - char_pos1; 360 int char_len1 = line_ends1_.GetLineStart(line_pos1 + line_len1) - char_pos1;
361 int char_len2 = line_ends2_.GetLineStart(line_pos2 + line_len2) - char_pos2; 361 int char_len2 = line_ends2_.GetLineStart(line_pos2 + line_len2) - char_pos2;
362 362
363 SetElement(array_, current_size_, Handle<Object>(Smi::FromInt(char_pos1))); 363 SetElement(array_, current_size_, Handle<Object>(Smi::FromInt(char_pos1)));
364 SetElement(array_, current_size_ + 1, 364 SetElement(array_, current_size_ + 1,
365 Handle<Object>(Smi::FromInt(char_len1))); 365 Handle<Object>(Smi::FromInt(char_pos1 + char_len1)));
366 SetElement(array_, current_size_ + 2, 366 SetElement(array_, current_size_ + 2,
367 Handle<Object>(Smi::FromInt(char_len2))); 367 Handle<Object>(Smi::FromInt(char_pos2 + char_len2)));
368 current_size_ += 3; 368 current_size_ += 3;
369 } 369 }
370 370
371 Handle<JSArray> GetResult() { 371 Handle<JSArray> GetResult() {
372 return array_; 372 return array_;
373 } 373 }
374 374
375 private: 375 private:
376 Handle<JSArray> array_; 376 Handle<JSArray> array_;
377 int current_size_; 377 int current_size_;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 710
711 virtual void VisitPointers(Object** start, Object** end) { 711 virtual void VisitPointers(Object** start, Object** end) {
712 for (Object** p = start; p < end; p++) { 712 for (Object** p = start; p < end; p++) {
713 if (*p == original_) { 713 if (*p == original_) {
714 rvalues_.Add(p); 714 rvalues_.Add(p);
715 } 715 }
716 } 716 }
717 } 717 }
718 718
719 void VisitCodeTarget(RelocInfo* rinfo) { 719 void VisitCodeTarget(RelocInfo* rinfo) {
720 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); 720 if (RelocInfo::IsCodeTarget(rinfo->rmode()) &&
721 if (Code::GetCodeFromTargetAddress(rinfo->target_address()) == original_) { 721 Code::GetCodeFromTargetAddress(rinfo->target_address()) == original_) {
722 reloc_infos_.Add(*rinfo); 722 reloc_infos_.Add(*rinfo);
723 } 723 }
724 } 724 }
725 725
726 virtual void VisitDebugTarget(RelocInfo* rinfo) { 726 virtual void VisitDebugTarget(RelocInfo* rinfo) {
727 VisitCodeTarget(rinfo); 727 VisitCodeTarget(rinfo);
728 } 728 }
729 729
730 // Post-visiting method that iterates over all collected references and 730 // Post-visiting method that iterates over all collected references and
731 // modifies them. 731 // modifies them.
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 1403
1404 bool LiveEditFunctionTracker::IsActive() { 1404 bool LiveEditFunctionTracker::IsActive() {
1405 return false; 1405 return false;
1406 } 1406 }
1407 1407
1408 #endif // ENABLE_DEBUGGER_SUPPORT 1408 #endif // ENABLE_DEBUGGER_SUPPORT
1409 1409
1410 1410
1411 1411
1412 } } // namespace v8::internal 1412 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/liveedit.h ('k') | src/liveedit-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698