Index: src/objects.cc |
=================================================================== |
--- src/objects.cc (revision 1480) |
+++ src/objects.cc (working copy) |
@@ -6959,76 +6959,6 @@ |
} |
-// Init line_ends array with code positions of line ends inside script source |
-void Script::InitLineEnds() { |
- if (!line_ends()->IsUndefined()) return; |
- |
- if (!source()->IsString()) { |
- ASSERT(source()->IsUndefined()); |
- set_line_ends(*(Factory::NewJSArray(0))); |
- ASSERT(line_ends()->IsJSArray()); |
- return; |
- } |
- |
- Handle<String> src(String::cast(source())); |
- const int src_len = src->length(); |
- Handle<String> new_line = Factory::NewStringFromAscii(CStrVector("\n")); |
- |
- // Pass 1: Identify line count |
- int line_count = 0; |
- int position = 0; |
- while (position != -1 && position < src_len) { |
- position = Runtime::StringMatch(src, new_line, position); |
- if (position != -1) { |
- position++; |
- } |
- // Even if the last line misses a line end, it is counted |
- line_count++; |
- } |
- |
- // Pass 2: Fill in line ends positions |
- Handle<FixedArray> array = Factory::NewFixedArray(line_count); |
- int array_index = 0; |
- position = 0; |
- while (position != -1 && position < src_len) { |
- position = Runtime::StringMatch(src, new_line, position); |
- // If the script does not end with a line ending add the final end position |
- // as just past the last line ending. |
- array->set(array_index++, |
- Smi::FromInt(position != -1 ? position++ : src_len)); |
- } |
- ASSERT(array_index == line_count); |
- |
- Handle<JSArray> object = Factory::NewJSArrayWithElements(array); |
- set_line_ends(*object); |
- ASSERT(line_ends()->IsJSArray()); |
-} |
- |
- |
-// Convert code position into line number |
-int Script::GetLineNumber(int code_pos) { |
- InitLineEnds(); |
- JSArray* line_ends_array = JSArray::cast(line_ends()); |
- const int line_ends_len = (Smi::cast(line_ends_array->length()))->value(); |
- |
- int line = -1; |
- if (line_ends_len > 0 && |
- code_pos <= (Smi::cast(line_ends_array->GetElement(0)))->value()) { |
- line = 0; |
- } else { |
- for (int i = 1; i < line_ends_len; ++i) { |
- if ((Smi::cast(line_ends_array->GetElement(i - 1)))->value() < code_pos && |
- code_pos <= (Smi::cast(line_ends_array->GetElement(i)))->value()) { |
- line = i; |
- break; |
- } |
- } |
- } |
- |
- return line != -1 ? line + line_offset()->value() : line; |
-} |
- |
- |
// Check if there is a break point at this code position. |
bool DebugInfo::HasBreakPoint(int code_position) { |
// Get the break point info object for this code position. |