Bug 1128106 - Clean up LazyScript's ScriptSource accessor. (r=till)

This commit is contained in:
Shu-yu Guo 2015-02-02 13:00:16 -08:00
parent c891137718
commit 6b55835b57
4 changed files with 13 additions and 6 deletions

View File

@ -468,7 +468,7 @@ frontend::CompileLazyFunction(JSContext *cx, Handle<LazyScript*> lazy, const cha
CompileOptions options(cx, lazy->version());
options.setMutedErrors(lazy->mutedErrors())
.setFileAndLine(lazy->source()->filename(), lazy->lineno())
.setFileAndLine(lazy->filename(), lazy->lineno())
.setColumn(lazy->column())
.setCompileAndGo(true)
.setNoScriptRval(false)

View File

@ -1481,11 +1481,11 @@ JSFunction::createScriptForLazilyInterpretedFunction(JSContext *cx, HandleFuncti
return true;
}
MOZ_ASSERT(lazy->source()->hasSourceData());
MOZ_ASSERT(lazy->scriptSource()->hasSourceData());
// Parse and compile the script from source.
UncompressedSourceCache::AutoHoldEntry holder;
const char16_t *chars = lazy->source()->chars(cx, holder);
const char16_t *chars = lazy->scriptSource()->chars(cx, holder);
if (!chars)
return false;

View File

@ -3737,6 +3737,12 @@ LazyScript::sourceObject() const
return sourceObject_ ? &sourceObject_->as<ScriptSourceObject>() : nullptr;
}
ScriptSource *
LazyScript::maybeForwardedScriptSource() const
{
return UncheckedUnwrap(MaybeForwarded(sourceObject()))->as<ScriptSourceObject>().source();
}
/* static */ LazyScript *
LazyScript::CreateRaw(ExclusiveContext *cx, HandleFunction fun,
uint64_t packedFields, uint32_t begin, uint32_t end,
@ -3961,7 +3967,7 @@ LazyScriptHashPolicy::match(JSScript *script, const Lookup &lookup)
if (!scriptChars)
return false;
const char16_t *lazyChars = lazy->source()->chars(cx, holder);
const char16_t *lazyChars = lazy->scriptSource()->chars(cx, holder);
if (!lazyChars)
return false;

View File

@ -1955,6 +1955,7 @@ class LazyScript : public gc::TenuredCell
ScriptSource *scriptSource() const {
return sourceObject()->source();
}
ScriptSource *maybeForwardedScriptSource() const;
bool mutedErrors() const {
return scriptSource()->mutedErrors();
}
@ -2052,8 +2053,8 @@ class LazyScript : public gc::TenuredCell
p_.treatAsRunOnce = true;
}
ScriptSource *source() const {
return sourceObject()->source();
const char *filename() const {
return scriptSource()->filename();
}
uint32_t begin() const {
return begin_;