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

Side by Side Diff: src/handles.cc

Issue 8508008: Add getters for column number and script id to v8::Function (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/handles.h ('k') | test/cctest/test-api.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 while (int half = (right - left) / 2) { 655 while (int half = (right - left) / 2) {
656 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) { 656 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) {
657 right -= half; 657 right -= half;
658 } else { 658 } else {
659 left += half; 659 left += half;
660 } 660 }
661 } 661 }
662 return right + script->line_offset()->value(); 662 return right + script->line_offset()->value();
663 } 663 }
664 664
665 // Convert code position into column number.
666 int GetScriptColumnNumber(Handle<Script> script, int code_pos) {
667 int line_number = GetScriptLineNumber(script, code_pos);
668 if (line_number == -1) return -1;
669
670 AssertNoAllocation no_allocation;
671 FixedArray* line_ends_array = FixedArray::cast(script->line_ends());
672 line_number = line_number - script->line_offset()->value();
673 if (line_number == 0) return code_pos + script->column_offset()->value();
674 int prev_line_end_pos =
675 Smi::cast(line_ends_array->get(line_number - 1))->value();
676 return code_pos - (prev_line_end_pos + 1);
677 }
665 678
666 int GetScriptLineNumberSafe(Handle<Script> script, int code_pos) { 679 int GetScriptLineNumberSafe(Handle<Script> script, int code_pos) {
667 AssertNoAllocation no_allocation; 680 AssertNoAllocation no_allocation;
668 if (!script->line_ends()->IsUndefined()) { 681 if (!script->line_ends()->IsUndefined()) {
669 return GetScriptLineNumber(script, code_pos); 682 return GetScriptLineNumber(script, code_pos);
670 } 683 }
671 // Slow mode: we do not have line_ends. We have to iterate through source. 684 // Slow mode: we do not have line_ends. We have to iterate through source.
672 if (!script->source()->IsString()) { 685 if (!script->source()->IsString()) {
673 return -1; 686 return -1;
674 } 687 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, 925 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table,
913 Handle<Object> key, 926 Handle<Object> key,
914 Handle<Object> value) { 927 Handle<Object> value) {
915 CALL_HEAP_FUNCTION(table->GetIsolate(), 928 CALL_HEAP_FUNCTION(table->GetIsolate(),
916 table->Put(*key, *value), 929 table->Put(*key, *value),
917 ObjectHashTable); 930 ObjectHashTable);
918 } 931 }
919 932
920 933
921 } } // namespace v8::internal 934 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698