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

Side by Side Diff: src/api.cc

Issue 265593002: Add v8::Message::GetScriptOrigin() with tests (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 7 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 "api.h" 5 #include "api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #include <cmath> // For isnan. 8 #include <cmath> // For isnan.
9 #include "../include/v8-debug.h" 9 #include "../include/v8-debug.h"
10 #include "../include/v8-profiler.h" 10 #include "../include/v8-profiler.h"
(...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 // Return this.script.name. 1930 // Return this.script.name.
1931 i::Handle<i::JSValue> script = 1931 i::Handle<i::JSValue> script =
1932 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), 1932 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(),
1933 isolate)); 1933 isolate));
1934 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(), 1934 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(),
1935 isolate); 1935 isolate);
1936 return scope.Escape(Utils::ToLocal(resource_name)); 1936 return scope.Escape(Utils::ToLocal(resource_name));
1937 } 1937 }
1938 1938
1939 1939
1940 v8::Handle<Value> Message::GetScriptResourceNameOrSourceURL() const {
1941 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1942 ENTER_V8(isolate);
1943 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
1944 i::Handle<i::JSMessageObject> message =
1945 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1946 // Return this.script.name.
vsevik 2014/04/30 10:18:40 This comment seems incorrect.
1947 i::Handle<i::JSValue> scriptValue =
1948 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(),
1949 isolate));
1950 i::Handle<i::Script> script(i::Script::cast(scriptValue->value()));
1951 i::Handle<i::Object> script_name = i::Script::GetNameOrSourceURL(script);
1952 return scope.Escape(Utils::ToLocal(script_name));
1953 }
1954
1955
1940 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { 1956 v8::Handle<v8::StackTrace> Message::GetStackTrace() const {
1941 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1957 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1942 ENTER_V8(isolate); 1958 ENTER_V8(isolate);
1943 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 1959 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
1944 i::Handle<i::JSMessageObject> message = 1960 i::Handle<i::JSMessageObject> message =
1945 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1961 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1946 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); 1962 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate);
1947 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); 1963 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
1948 i::Handle<i::JSArray> stackTrace = 1964 i::Handle<i::JSArray> stackTrace =
1949 i::Handle<i::JSArray>::cast(stackFramesObj); 1965 i::Handle<i::JSArray>::cast(stackFramesObj);
(...skipping 5632 matching lines...) Expand 10 before | Expand all | Expand 10 after
7582 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7598 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7583 Address callback_address = 7599 Address callback_address =
7584 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7600 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7585 VMState<EXTERNAL> state(isolate); 7601 VMState<EXTERNAL> state(isolate);
7586 ExternalCallbackScope call_scope(isolate, callback_address); 7602 ExternalCallbackScope call_scope(isolate, callback_address);
7587 callback(info); 7603 callback(info);
7588 } 7604 }
7589 7605
7590 7606
7591 } } // namespace v8::internal 7607 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698