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

Side by Side Diff: src/objects.cc

Issue 2224973002: Move remaining Message functions to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 4 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 18869 matching lines...) Expand 10 before | Expand all | Expand 10 after
18880 set_cache_stamp(date_cache->stamp()); 18880 set_cache_stamp(date_cache->stamp());
18881 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 18881 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
18882 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 18882 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
18883 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 18883 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
18884 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 18884 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
18885 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 18885 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
18886 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 18886 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
18887 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 18887 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
18888 } 18888 }
18889 18889
18890 namespace {
18891
18892 Script* ScriptFromJSValue(Object* in) {
18893 DCHECK(in->IsJSValue());
18894 JSValue* jsvalue = JSValue::cast(in);
18895 DCHECK(jsvalue->value()->IsScript());
18896 return Script::cast(jsvalue->value());
18897 }
18898
18899 } // namespace
18900
18901 int JSMessageObject::GetLineNumber() const {
18902 if (start_position() == -1) return Message::kNoLineNumberInfo;
18903
18904 Handle<Script> the_script = handle(ScriptFromJSValue(script()));
18905
18906 Script::PositionInfo info;
18907 const Script::OffsetFlag offset_flag = Script::WITH_OFFSET;
18908 if (!the_script->GetPositionInfo(start_position(), &info, offset_flag)) {
18909 return Message::kNoLineNumberInfo;
18910 }
18911
18912 return info.line + 1;
18913 }
18914
18915 int JSMessageObject::GetColumnNumber() const {
18916 if (start_position() == -1) return -1;
18917
18918 Handle<Script> the_script = handle(ScriptFromJSValue(script()));
18919
18920 Script::PositionInfo info;
18921 const Script::OffsetFlag offset_flag = Script::WITH_OFFSET;
18922 if (!the_script->GetPositionInfo(start_position(), &info, offset_flag)) {
18923 return -1;
18924 }
18925
18926 return info.column; // Note: No + 1.
Yang 2016/08/10 09:03:18 please rephrase the comment as "No '+1'". Otherwis
jgruber 2016/08/10 09:25:10 Done.
18927 }
18928
18929 Handle<String> JSMessageObject::GetSourceLine() const {
18930 Handle<Script> the_script = handle(ScriptFromJSValue(script()));
18931
18932 Isolate* isolate = the_script->GetIsolate();
18933 if (the_script->type() == Script::TYPE_WASM) {
18934 return isolate->factory()->empty_string();
18935 }
18936
18937 Script::PositionInfo info;
18938 const Script::OffsetFlag offset_flag = Script::WITH_OFFSET;
18939 if (!the_script->GetPositionInfo(start_position(), &info, offset_flag)) {
18940 return isolate->factory()->empty_string();
18941 }
18942
18943 Handle<String> src = handle(String::cast(the_script->source()), isolate);
18944 return isolate->factory()->NewSubString(src, info.line_start, info.line_end);
18945 }
18890 18946
18891 void JSArrayBuffer::Neuter() { 18947 void JSArrayBuffer::Neuter() {
18892 CHECK(is_neuterable()); 18948 CHECK(is_neuterable());
18893 CHECK(is_external()); 18949 CHECK(is_external());
18894 set_backing_store(NULL); 18950 set_backing_store(NULL);
18895 set_byte_length(Smi::FromInt(0)); 18951 set_byte_length(Smi::FromInt(0));
18896 set_was_neutered(true); 18952 set_was_neutered(true);
18897 } 18953 }
18898 18954
18899 18955
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
19184 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, 19240 for (PrototypeIterator iter(isolate, this, kStartAtReceiver,
19185 PrototypeIterator::END_AT_NULL); 19241 PrototypeIterator::END_AT_NULL);
19186 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { 19242 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) {
19187 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; 19243 if (iter.GetCurrent<Object>()->IsJSProxy()) return true;
19188 } 19244 }
19189 return false; 19245 return false;
19190 } 19246 }
19191 19247
19192 } // namespace internal 19248 } // namespace internal
19193 } // namespace v8 19249 } // namespace v8
OLDNEW
« src/api.cc ('K') | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698