Removed some copy-n-paste from StackFrame::Foo API entries.

BUG=v8:3436
LOG=y
R=dcarney@chromium.org

Review URL: https://codereview.chromium.org/388183002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22390 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 086290ba
...@@ -2168,109 +2168,77 @@ Local<StackTrace> StackTrace::CurrentStackTrace( ...@@ -2168,109 +2168,77 @@ Local<StackTrace> StackTrace::CurrentStackTrace(
// --- S t a c k F r a m e --- // --- S t a c k F r a m e ---
int StackFrame::GetLineNumber() const { static int getIntProperty(const StackFrame* f, const char* propertyName,
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); int defaultValue) {
i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate();
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this); i::Handle<i::JSObject> self = Utils::OpenHandle(f);
i::Handle<i::Object> line = i::Object::GetProperty( i::Handle<i::Object> obj =
isolate, self, "lineNumber").ToHandleChecked(); i::Object::GetProperty(isolate, self, propertyName).ToHandleChecked();
if (!line->IsSmi()) { return obj->IsSmi() ? i::Smi::cast(*obj)->value() : defaultValue;
return Message::kNoLineNumberInfo; }
}
return i::Smi::cast(*line)->value();
int StackFrame::GetLineNumber() const {
return getIntProperty(this, "lineNumber", Message::kNoLineNumberInfo);
} }
int StackFrame::GetColumn() const { int StackFrame::GetColumn() const {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); return getIntProperty(this, "column", Message::kNoColumnInfo);
ENTER_V8(isolate);
i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> column = i::Object::GetProperty(
isolate, self, "column").ToHandleChecked();
if (!column->IsSmi()) {
return Message::kNoColumnInfo;
}
return i::Smi::cast(*column)->value();
} }
int StackFrame::GetScriptId() const { int StackFrame::GetScriptId() const {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); return getIntProperty(this, "scriptId", Message::kNoScriptIdInfo);
ENTER_V8(isolate);
i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> scriptId = i::Object::GetProperty(
isolate, self, "scriptId").ToHandleChecked();
if (!scriptId->IsSmi()) {
return Message::kNoScriptIdInfo;
}
return i::Smi::cast(*scriptId)->value();
} }
Local<String> StackFrame::GetScriptName() const { static Local<String> getStringProperty(const StackFrame* f,
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); const char* propertyName) {
i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate();
ENTER_V8(isolate); ENTER_V8(isolate);
EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
i::Handle<i::JSObject> self = Utils::OpenHandle(this); i::Handle<i::JSObject> self = Utils::OpenHandle(f);
i::Handle<i::Object> name = i::Object::GetProperty( i::Handle<i::Object> obj =
isolate, self, "scriptName").ToHandleChecked(); i::Object::GetProperty(isolate, self, propertyName).ToHandleChecked();
if (!name->IsString()) { return obj->IsString()
return Local<String>(); ? scope.Escape(Local<String>::Cast(Utils::ToLocal(obj)))
} : Local<String>();
return scope.Escape(Local<String>::Cast(Utils::ToLocal(name))); }
Local<String> StackFrame::GetScriptName() const {
return getStringProperty(this, "scriptName");
} }
Local<String> StackFrame::GetScriptNameOrSourceURL() const { Local<String> StackFrame::GetScriptNameOrSourceURL() const {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); return getStringProperty(this, "scriptNameOrSourceURL");
ENTER_V8(isolate);
EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> name = i::Object::GetProperty(
isolate, self, "scriptNameOrSourceURL").ToHandleChecked();
if (!name->IsString()) {
return Local<String>();
}
return scope.Escape(Local<String>::Cast(Utils::ToLocal(name)));
} }
Local<String> StackFrame::GetFunctionName() const { Local<String> StackFrame::GetFunctionName() const {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); return getStringProperty(this, "functionName");
ENTER_V8(isolate);
EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> name = i::Object::GetProperty(
isolate, self, "functionName").ToHandleChecked();
if (!name->IsString()) {
return Local<String>();
}
return scope.Escape(Local<String>::Cast(Utils::ToLocal(name)));
} }
bool StackFrame::IsEval() const { static bool getBoolProperty(const StackFrame* f, const char* propertyName) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate();
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this); i::Handle<i::JSObject> self = Utils::OpenHandle(f);
i::Handle<i::Object> is_eval = i::Object::GetProperty( i::Handle<i::Object> obj =
isolate, self, "isEval").ToHandleChecked(); i::Object::GetProperty(isolate, self, propertyName).ToHandleChecked();
return is_eval->IsTrue(); return obj->IsTrue();
} }
bool StackFrame::IsEval() const { return getBoolProperty(this, "isEval"); }
bool StackFrame::IsConstructor() const { bool StackFrame::IsConstructor() const {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); return getBoolProperty(this, "isConstructor");
ENTER_V8(isolate);
i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> is_constructor = i::Object::GetProperty(
isolate, self, "isConstructor").ToHandleChecked();
return is_constructor->IsTrue();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment