Commit 910050e6 authored by marja@chromium.org's avatar marja@chromium.org

Fix UnboundScript::GetScriptName and GetLineNumber.

Probably broken since r19925 (mine).

R=dcarney@chromium.org
BUG=

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21398 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 58a130da
......@@ -1586,13 +1586,13 @@ int UnboundScript::GetId() {
int UnboundScript::GetLineNumber(int code_pos) {
i::Handle<i::HeapObject> obj =
i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
i::Handle<i::SharedFunctionInfo> obj =
i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this));
i::Isolate* isolate = obj->GetIsolate();
ON_BAILOUT(isolate, "v8::UnboundScript::GetLineNumber()", return -1);
LOG_API(isolate, "UnboundScript::GetLineNumber");
if (obj->IsScript()) {
i::Handle<i::Script> script(i::Script::cast(*obj));
if (obj->script()->IsScript()) {
i::Handle<i::Script> script(i::Script::cast(obj->script()));
return i::Script::GetLineNumber(script, code_pos);
} else {
return -1;
......@@ -1601,14 +1601,14 @@ int UnboundScript::GetLineNumber(int code_pos) {
Handle<Value> UnboundScript::GetScriptName() {
i::Handle<i::HeapObject> obj =
i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
i::Handle<i::SharedFunctionInfo> obj =
i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this));
i::Isolate* isolate = obj->GetIsolate();
ON_BAILOUT(isolate, "v8::UnboundScript::GetName()",
return Handle<String>());
LOG_API(isolate, "UnboundScript::GetName");
if (obj->IsScript()) {
i::Object* name = i::Script::cast(*obj)->name();
if (obj->script()->IsScript()) {
i::Object* name = i::Script::cast(obj->script())->name();
return Utils::ToLocal(i::Handle<i::Object>(name, isolate));
} else {
return Handle<String>();
......
......@@ -22613,3 +22613,22 @@ TEST(CaptureStackTraceForStackOverflow) {
CompileRun("(function f(x) { f(x+1); })(0)");
CHECK(try_catch.HasCaught());
}
TEST(ScriptNameAndLineNumber) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
const char* url = "http://www.foo.com/foo.js";
v8::ScriptOrigin origin(v8_str(url), v8::Integer::New(isolate, 13));
v8::ScriptCompiler::Source script_source(v8_str("var foo;"), origin);
Local<Script> script = v8::ScriptCompiler::Compile(
isolate, &script_source);
Local<Value> script_name = script->GetUnboundScript()->GetScriptName();
CHECK(!script_name.IsEmpty());
CHECK(script_name->IsString());
String::Utf8Value utf8_name(script_name);
CHECK_EQ(url, *utf8_name);
int line_number = script->GetUnboundScript()->GetLineNumber(0);
CHECK_EQ(13, line_number);
}
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