Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 9e389492eca14cf87aec73a292b6a4794bd21e3e..069d3a87f592b68ce375a21b1fbf059e72ee8baa 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -12792,6 +12792,44 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { |
} |
+// Restarts a call frame and completely drops all frames above. |
+// Returns 'true' if success or undefined or error message elseway. |
Yang
2012/06/14 09:09:28
Ambiguous sentence. How about "Returns true if suc
Peter Rybin
2012/06/14 22:08:03
Perfect fit for 80 columns!
Done
|
+RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditRestartFrame) { |
+ HandleScope scope(isolate); |
+ ASSERT(args.length() == 2); |
+ |
+ // Check arguments. |
+ Object* check; |
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
+ RUNTIME_ARGUMENTS(isolate, args)); |
+ if (!maybe_check->ToObject(&check)) return maybe_check; |
+ } |
+ CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
+ Heap* heap = isolate->heap(); |
+ |
+ // Find the relevant frame with the requested index. |
+ StackFrame::Id id = isolate->debug()->break_frame_id(); |
+ if (id == StackFrame::NO_ID) { |
+ // If there are no JavaScript stack frames return undefined. |
+ return heap->undefined_value(); |
+ } |
+ |
+ int count = 0; |
+ JavaScriptFrameIterator it(isolate, id); |
+ for (; !it.done(); it.Advance()) { |
+ if (index < count + it.frame()->GetInlineCount()) break; |
+ count += it.frame()->GetInlineCount(); |
+ } |
+ if (it.done()) return heap->undefined_value(); |
+ |
+ const char* error_message = LiveEdit::RestartFrame(it.frame(), isolate->zone()); |
Yang
2012/06/14 09:09:28
80 character limit.
Peter Rybin
2012/06/14 22:08:03
Done.
|
+ if (error_message) { |
+ return *(isolate->factory()->LookupAsciiSymbol(error_message)); |
+ } |
+ return heap->true_value(); |
+} |
+ |
+ |
// A testing entry. Returns statement position which is the closest to |
// source_position. |
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { |