Bug 1575055 - Cleanup CompileOptions::setIntroductionInfo. r=jandem

The hasIntroductionInfo flag is equivalent to checking for the existance
introducerFilename so use that instead. Also remove unused setter for
the introducer script.

Differential Revision: https://phabricator.services.mozilla.com/D42558

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ted Campbell 2019-08-22 13:07:53 +00:00
Родитель 7ed950a31c
Коммит 6e9b305ee3
3 изменённых файлов: 14 добавлений и 18 удалений

Просмотреть файл

@ -131,7 +131,6 @@ class JS_PUBLIC_API TransitiveCompileOptions {
unsigned introductionLineno = 0;
uint32_t introductionOffset = 0;
bool hasIntroductionInfo = false;
// Mask of operation kinds which should be instrumented.
uint32_t instrumentationKinds = 0;
@ -144,6 +143,8 @@ class JS_PUBLIC_API TransitiveCompileOptions {
void copyPODTransitiveOptions(const TransitiveCompileOptions& rhs);
public:
bool hasIntroductionInfo() const { return introducerFilename_ != nullptr; }
// Read-only accessors for non-POD options. The proper way to set these
// depends on the derived type.
bool mutedErrors() const { return mutedErrors_; }
@ -368,11 +369,6 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
return *this;
}
CompileOptions& setIntroductionScript(JSScript* s) {
introductionScriptRoot = s;
return *this;
}
CompileOptions& setScriptOrModule(JSScript* s) {
scriptOrModuleRoot = s;
return *this;
@ -424,6 +420,7 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
}
CompileOptions& setIntroductionType(const char* t) {
MOZ_ASSERT(t);
introductionType = t;
return *this;
}
@ -431,12 +428,14 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
CompileOptions& setIntroductionInfo(const char* introducerFn,
const char* intro, unsigned line,
JSScript* script, uint32_t offset) {
setIntroductionType(intro);
MOZ_ASSERT(introducerFn);
introducerFilename_ = introducerFn;
introductionType = intro;
introductionLineno = line;
introductionScriptRoot = script;
introductionOffset = offset;
hasIntroductionInfo = true;
return *this;
}

Просмотреть файл

@ -3538,10 +3538,9 @@ void JS::TransitiveCompileOptions::copyPODTransitiveOptions(
introductionType = rhs.introductionType;
introductionLineno = rhs.introductionLineno;
introductionOffset = rhs.introductionOffset;
hasIntroductionInfo = rhs.hasIntroductionInfo;
hideScriptFromDebugger = rhs.hideScriptFromDebugger;
fieldsEnabledOption = rhs.fieldsEnabledOption;
};
}
void JS::ReadOnlyCompileOptions::copyPODOptions(
const ReadOnlyCompileOptions& rhs) {

Просмотреть файл

@ -3437,8 +3437,7 @@ bool ScriptSource::initFromOptions(JSContext* cx,
setIntroductionOffset(options.introductionOffset);
parameterListEnd_ = parameterListEnd.isSome() ? parameterListEnd.value() : 0;
if (options.hasIntroductionInfo) {
MOZ_ASSERT(options.introductionType != nullptr);
if (options.hasIntroductionInfo()) {
const char* filename =
options.filename() ? options.filename() : "<unknown>";
char* formatted = FormatIntroducedFilename(
@ -3447,17 +3446,16 @@ bool ScriptSource::initFromOptions(JSContext* cx,
return false;
}
filename_.reset(formatted);
} else if (options.filename()) {
if (!setFilename(cx, options.filename())) {
return false;
}
}
if (options.introducerFilename()) {
MOZ_ASSERT(options.introducerFilename());
introducerFilename_ = DuplicateString(cx, options.introducerFilename());
if (!introducerFilename_) {
return false;
}
} else if (options.filename()) {
if (!setFilename(cx, options.filename())) {
return false;
}
}
return true;