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

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
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('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 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 18892 matching lines...) Expand 10 before | Expand all | Expand 10 after
18903 set_cache_stamp(date_cache->stamp()); 18903 set_cache_stamp(date_cache->stamp());
18904 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 18904 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
18905 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 18905 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
18906 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 18906 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
18907 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 18907 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
18908 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 18908 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
18909 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 18909 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
18910 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 18910 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
18911 } 18911 }
18912 18912
18913 namespace {
18914
18915 Script* ScriptFromJSValue(Object* in) {
18916 DCHECK(in->IsJSValue());
18917 JSValue* jsvalue = JSValue::cast(in);
18918 DCHECK(jsvalue->value()->IsScript());
18919 return Script::cast(jsvalue->value());
18920 }
18921
18922 } // namespace
18923
18924 int JSMessageObject::GetLineNumber() const {
18925 if (start_position() == -1) return Message::kNoLineNumberInfo;
18926
18927 Handle<Script> the_script = handle(ScriptFromJSValue(script()));
18928
18929 Script::PositionInfo info;
18930 const Script::OffsetFlag offset_flag = Script::WITH_OFFSET;
18931 if (!the_script->GetPositionInfo(start_position(), &info, offset_flag)) {
18932 return Message::kNoLineNumberInfo;
18933 }
18934
18935 return info.line + 1;
18936 }
18937
18938 int JSMessageObject::GetColumnNumber() const {
18939 if (start_position() == -1) return -1;
18940
18941 Handle<Script> the_script = handle(ScriptFromJSValue(script()));
18942
18943 Script::PositionInfo info;
18944 const Script::OffsetFlag offset_flag = Script::WITH_OFFSET;
18945 if (!the_script->GetPositionInfo(start_position(), &info, offset_flag)) {
18946 return -1;
18947 }
18948
18949 return info.column; // Note: No '+1' in contrast to GetLineNumber.
18950 }
18951
18952 Handle<String> JSMessageObject::GetSourceLine() const {
18953 Handle<Script> the_script = handle(ScriptFromJSValue(script()));
18954
18955 Isolate* isolate = the_script->GetIsolate();
18956 if (the_script->type() == Script::TYPE_WASM) {
18957 return isolate->factory()->empty_string();
18958 }
18959
18960 Script::PositionInfo info;
18961 const Script::OffsetFlag offset_flag = Script::WITH_OFFSET;
18962 if (!the_script->GetPositionInfo(start_position(), &info, offset_flag)) {
18963 return isolate->factory()->empty_string();
18964 }
18965
18966 Handle<String> src = handle(String::cast(the_script->source()), isolate);
18967 return isolate->factory()->NewSubString(src, info.line_start, info.line_end);
18968 }
18913 18969
18914 void JSArrayBuffer::Neuter() { 18970 void JSArrayBuffer::Neuter() {
18915 CHECK(is_neuterable()); 18971 CHECK(is_neuterable());
18916 CHECK(is_external()); 18972 CHECK(is_external());
18917 set_backing_store(NULL); 18973 set_backing_store(NULL);
18918 set_byte_length(Smi::FromInt(0)); 18974 set_byte_length(Smi::FromInt(0));
18919 set_was_neutered(true); 18975 set_was_neutered(true);
18920 } 18976 }
18921 18977
18922 18978
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
19206 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, 19262 for (PrototypeIterator iter(isolate, this, kStartAtReceiver,
19207 PrototypeIterator::END_AT_NULL); 19263 PrototypeIterator::END_AT_NULL);
19208 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { 19264 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) {
19209 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; 19265 if (iter.GetCurrent<Object>()->IsJSProxy()) return true;
19210 } 19266 }
19211 return false; 19267 return false;
19212 } 19268 }
19213 19269
19214 } // namespace internal 19270 } // namespace internal
19215 } // namespace v8 19271 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698