Index: src/source-position.cc |
diff --git a/src/source-position.cc b/src/source-position.cc |
index ff204be73d327b2821646b77019badcff563d78d..02bb339357f3269e4cf65b57ee577e0a94c72838 100644 |
--- a/src/source-position.cc |
+++ b/src/source-position.cc |
@@ -11,10 +11,16 @@ namespace internal { |
std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos) { |
Handle<SharedFunctionInfo> function(pos.function); |
- Handle<Script> script(Script::cast(function->script())); |
+ String* name = nullptr; |
+ if (function->script()->IsScript()) { |
+ Script* script = Script::cast(function->script()); |
+ if (script->name()->IsString()) { |
+ name = String::cast(script->name()); |
+ } |
+ } |
out << "<"; |
- if (script->name()->IsString()) { |
- out << String::cast(script->name())->ToCString(DISALLOW_NULLS).get(); |
+ if (name != nullptr) { |
+ out << name->ToCString(DISALLOW_NULLS).get(); |
} else { |
out << "unknown"; |
} |
@@ -78,12 +84,15 @@ std::vector<SourcePositionInfo> SourcePosition::InliningStack( |
void SourcePosition::Print(std::ostream& out, |
SharedFunctionInfo* function) const { |
- Script* script = Script::cast(function->script()); |
- Object* source_name = script->name(); |
Script::PositionInfo pos; |
- script->GetPositionInfo(ScriptOffset(), &pos, Script::WITH_OFFSET); |
+ Object* source_name = nullptr; |
+ if (function->script()->IsScript()) { |
+ Script* script = Script::cast(function->script()); |
+ source_name = script->name(); |
+ script->GetPositionInfo(ScriptOffset(), &pos, Script::WITH_OFFSET); |
+ } |
out << "<"; |
- if (source_name->IsString()) { |
+ if (source_name != nullptr && source_name->IsString()) { |
out << String::cast(source_name) |
->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL) |
.get(); |
@@ -117,12 +126,14 @@ void SourcePosition::Print(std::ostream& out, Code* code) const { |
SourcePositionInfo::SourcePositionInfo(SourcePosition pos, |
Handle<SharedFunctionInfo> f) |
: position(pos), function(f) { |
- Handle<Script> script(Script::cast(function->script())); |
- Script::PositionInfo info; |
- if (Script::GetPositionInfo(script, pos.ScriptOffset(), &info, |
- Script::WITH_OFFSET)) { |
- line = info.line; |
- column = info.column; |
+ if (function->script()->IsScript()) { |
+ Handle<Script> script(Script::cast(function->script())); |
+ Script::PositionInfo info; |
+ if (Script::GetPositionInfo(script, pos.ScriptOffset(), &info, |
+ Script::WITH_OFFSET)) { |
+ line = info.line; |
+ column = info.column; |
+ } |
} |
} |