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

Unified Diff: src/source-position.cc

Issue 2684033007: Allow a ParseInfo without a script for %SetCode users (Closed)
Patch Set: nit Created 3 years, 10 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/parsing/parse-info.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
}
}
« no previous file with comments | « src/parsing/parse-info.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698