Bug 1165486 - Cleanup: rename staticEvalScope to topStaticScope to prepare for the static top-level lexical scope. (r=luke)

This commit is contained in:
Shu-yu Guo 2015-06-15 21:32:30 -07:00
parent 92cb3daad4
commit 43ad2924bd
7 changed files with 22 additions and 23 deletions

View File

@ -350,7 +350,7 @@ EvalKernel(JSContext* cx, const CallArgs& args, EvalType evalType, AbstractFrame
: SourceBufferHolder::NoOwnership;
SourceBufferHolder srcBuf(chars, linearStr->length(), ownership);
JSScript* compiled = frontend::CompileScript(cx, &cx->tempLifoAlloc(),
scopeobj, callerScript, staticScope,
scopeobj, staticScope, callerScript,
options, srcBuf, linearStr, staticLevel);
if (!compiled)
return false;
@ -436,7 +436,7 @@ js::DirectEvalStringFromIon(JSContext* cx,
: SourceBufferHolder::NoOwnership;
SourceBufferHolder srcBuf(chars, linearStr->length(), ownership);
JSScript* compiled = frontend::CompileScript(cx, &cx->tempLifoAlloc(),
scopeobj, callerScript, staticScope,
scopeobj, staticScope, callerScript,
options, srcBuf, linearStr, staticLevel);
if (!compiled)
return false;

View File

@ -210,8 +210,8 @@ frontend::CreateScriptSourceObject(ExclusiveContext* cx, const ReadOnlyCompileOp
JSScript*
frontend::CompileScript(ExclusiveContext* cx, LifoAlloc* alloc, HandleObject scopeChain,
Handle<ScopeObject*> enclosingStaticScope,
HandleScript evalCaller,
Handle<StaticEvalObject*> evalStaticScope,
const ReadOnlyCompileOptions& options,
SourceBufferHolder& srcBuf,
JSString* source_ /* = nullptr */,
@ -284,22 +284,22 @@ frontend::CompileScript(ExclusiveContext* cx, LifoAlloc* alloc, HandleObject sco
bool savedCallerFun = evalCaller && evalCaller->functionOrCallerFunction();
Directives directives(options.strictOption);
GlobalSharedContext globalsc(cx, directives, evalStaticScope, options.extraWarningsOption);
GlobalSharedContext globalsc(cx, directives, enclosingStaticScope, options.extraWarningsOption);
Rooted<JSScript*> script(cx, JSScript::Create(cx, evalStaticScope, savedCallerFun,
Rooted<JSScript*> script(cx, JSScript::Create(cx, enclosingStaticScope, savedCallerFun,
options, staticLevel, sourceObject, 0,
srcBuf.length()));
if (!script)
return nullptr;
bool insideNonGlobalEval =
evalStaticScope && evalStaticScope->enclosingScopeForStaticScopeIter();
enclosingStaticScope && enclosingStaticScope->is<StaticEvalObject>() &&
enclosingStaticScope->as<StaticEvalObject>().enclosingScopeForStaticScopeIter();
BytecodeEmitter::EmitterMode emitterMode =
options.selfHostingMode ? BytecodeEmitter::SelfHosting : BytecodeEmitter::Normal;
BytecodeEmitter bce(/* parent = */ nullptr, &parser, &globalsc, script,
/* lazyScript = */ nullptr, options.forEval,
evalCaller, insideNonGlobalEval,
options.lineno, emitterMode);
evalCaller, insideNonGlobalEval, options.lineno, emitterMode);
if (!bce.init())
return nullptr;

View File

@ -17,18 +17,17 @@ class AutoNameVector;
class LazyScript;
class LifoAlloc;
class ScriptSourceObject;
class StaticEvalObject;
class ScopeObject;
struct SourceCompressionTask;
namespace frontend {
JSScript*
CompileScript(ExclusiveContext* cx, LifoAlloc* alloc,
HandleObject scopeChain, HandleScript evalCaller,
Handle<StaticEvalObject*> evalStaticScope,
const ReadOnlyCompileOptions& options, SourceBufferHolder& srcBuf,
JSString* source_ = nullptr, unsigned staticLevel = 0,
SourceCompressionTask* extraSct = nullptr);
HandleObject scopeChain, Handle<ScopeObject*> enclosingStaticScope,
HandleScript evalCaller, const ReadOnlyCompileOptions& options,
SourceBufferHolder& srcBuf, JSString* source_ = nullptr,
unsigned staticLevel = 0, SourceCompressionTask* extraSct = nullptr);
bool
CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const char16_t* chars, size_t length);

View File

@ -769,7 +769,7 @@ BytecodeEmitter::enclosingStaticScope()
// Top-level eval scripts have a placeholder static scope so that
// StaticScopeIter may iterate through evals.
return sc->asGlobalSharedContext()->evalStaticScope();
return sc->asGlobalSharedContext()->topStaticScope();
}
return sc->asFunctionBox()->function();

View File

@ -22,7 +22,7 @@
namespace js {
class StaticEvalObject;
class ScopeObject;
namespace frontend {

View File

@ -256,21 +256,21 @@ class SharedContext
class GlobalSharedContext : public SharedContext
{
private:
Handle<StaticEvalObject*> staticEvalScope_;
Handle<ScopeObject*> topStaticScope_;
public:
GlobalSharedContext(ExclusiveContext* cx,
Directives directives, Handle<StaticEvalObject*> staticEvalScope,
Directives directives, Handle<ScopeObject*> topStaticScope,
bool extraWarnings)
: SharedContext(cx, directives, extraWarnings),
staticEvalScope_(staticEvalScope)
topStaticScope_(topStaticScope)
{}
ObjectBox* toObjectBox() { return nullptr; }
HandleObject evalStaticScope() const { return staticEvalScope_; }
HandleObject topStaticScope() const { return topStaticScope_; }
bool allowSyntax(AllowedSyntax allowed) const {
StaticScopeIter<CanGC> it(context, staticEvalScope_);
StaticScopeIter<CanGC> it(context, topStaticScope_);
for (; !it.done(); it++) {
if (it.type() == StaticScopeIter<CanGC>::Function &&
!it.fun().isArrow())

View File

@ -6275,8 +6275,8 @@ EvaluateInEnv(JSContext* cx, Handle<Env*> env, HandleValue thisv, AbstractFrameP
.maybeMakeStrictMode(frame ? frame.script()->strict() : false);
RootedScript callerScript(cx, frame ? frame.script() : nullptr);
SourceBufferHolder srcBuf(chars.start().get(), chars.length(), SourceBufferHolder::NoOwnership);
RootedScript script(cx, frontend::CompileScript(cx, &cx->tempLifoAlloc(), env, callerScript,
staticScope, options, srcBuf,
RootedScript script(cx, frontend::CompileScript(cx, &cx->tempLifoAlloc(), env, staticScope,
callerScript, options, srcBuf,
/* source = */ nullptr,
/* staticLevel = */ frame ? 1 : 0));
if (!script)