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

Unified Diff: src/messages.cc

Issue 1060583008: Port CallSite methods to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.h ('k') | src/messages.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.cc
diff --git a/src/messages.cc b/src/messages.cc
index 1c07854fb55bb9355414527f50855670c5a292a6..7dc5f64f00c9e3ee9966e8105dfc6a0a64970728 100644
--- a/src/messages.cc
+++ b/src/messages.cc
@@ -163,6 +163,85 @@ SmartArrayPointer<char> MessageHandler::GetLocalizedMessage(
}
+Handle<Object> CallSite::GetFileName(Isolate* isolate) {
+ Handle<Object> script(fun_->shared()->script(), isolate);
+ if (script->IsScript()) {
+ return Handle<Object>(Handle<Script>::cast(script)->name(), isolate);
+ }
+ return isolate->factory()->null_value();
+}
+
+
+Handle<Object> CallSite::GetFunctionName(Isolate* isolate) {
+ Handle<String> result = JSFunction::GetDebugName(fun_);
+ if (result->length() != 0) return result;
+ Handle<Object> script(fun_->shared()->script(), isolate);
+ if (script->IsScript() &&
+ Handle<Script>::cast(script)->compilation_type() ==
+ Script::COMPILATION_TYPE_EVAL) {
+ return isolate->factory()->eval_string();
+ }
+ return isolate->factory()->null_value();
+}
+
+
+Handle<Object> CallSite::GetScriptNameOrSourceUrl(Isolate* isolate) {
+ Handle<Object> script_obj(fun_->shared()->script(), isolate);
+ if (script_obj->IsScript()) {
+ Handle<Script> script = Handle<Script>::cast(script_obj);
+ Object* source_url = script->source_url();
+ if (source_url->IsString()) return Handle<Object>(source_url, isolate);
+ return Handle<Object>(script->name(), isolate);
+ }
+ return isolate->factory()->null_value();
+}
+
+
+int CallSite::GetLineNumber(Isolate* isolate) {
+ if (pos_ >= 0) {
+ Handle<Object> script_obj(fun_->shared()->script(), isolate);
+ if (script_obj->IsScript()) {
+ Handle<Script> script = Handle<Script>::cast(script_obj);
+ return Script::GetLineNumber(script, pos_) + 1;
+ }
+ }
+ return -1;
+}
+
+
+int CallSite::GetColumnNumber(Isolate* isolate) {
+ if (pos_ >= 0) {
+ Handle<Object> script_obj(fun_->shared()->script(), isolate);
+ if (script_obj->IsScript()) {
+ Handle<Script> script = Handle<Script>::cast(script_obj);
+ return Script::GetColumnNumber(script, pos_) + 1;
+ }
+ }
+ return -1;
+}
+
+
+bool CallSite::IsNative(Isolate* isolate) {
+ Handle<Object> script(fun_->shared()->script(), isolate);
+ return script->IsScript() &&
+ Handle<Script>::cast(script)->type()->value() == Script::TYPE_NATIVE;
+}
+
+
+bool CallSite::IsToplevel(Isolate* isolate) {
+ return receiver_->IsJSGlobalProxy() || receiver_->IsNull() ||
+ receiver_->IsUndefined();
+}
+
+
+bool CallSite::IsEval(Isolate* isolate) {
+ Handle<Object> script(fun_->shared()->script(), isolate);
+ return script->IsScript() &&
+ Handle<Script>::cast(script)->compilation_type() ==
+ Script::COMPILATION_TYPE_EVAL;
+}
+
+
MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
Handle<String> arg0,
Handle<String> arg1,
« no previous file with comments | « src/messages.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698