From 43ad2924bdf92463bfc2badf9015af6328b7f4f5 Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Mon, 15 Jun 2015 21:32:30 -0700 Subject: [PATCH] Bug 1165486 - Cleanup: rename staticEvalScope to topStaticScope to prepare for the static top-level lexical scope. (r=luke) --- js/src/builtin/Eval.cpp | 4 ++-- js/src/frontend/BytecodeCompiler.cpp | 12 ++++++------ js/src/frontend/BytecodeCompiler.h | 11 +++++------ js/src/frontend/BytecodeEmitter.cpp | 2 +- js/src/frontend/BytecodeEmitter.h | 2 +- js/src/frontend/SharedContext.h | 10 +++++----- js/src/vm/Debugger.cpp | 4 ++-- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/js/src/builtin/Eval.cpp b/js/src/builtin/Eval.cpp index 5fb5b63c038..02f233692b6 100644 --- a/js/src/builtin/Eval.cpp +++ b/js/src/builtin/Eval.cpp @@ -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; diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index 12337039cf5..b811080b704 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -210,8 +210,8 @@ frontend::CreateScriptSourceObject(ExclusiveContext* cx, const ReadOnlyCompileOp JSScript* frontend::CompileScript(ExclusiveContext* cx, LifoAlloc* alloc, HandleObject scopeChain, + Handle enclosingStaticScope, HandleScript evalCaller, - Handle 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 script(cx, JSScript::Create(cx, evalStaticScope, savedCallerFun, + Rooted 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() && + enclosingStaticScope->as().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; diff --git a/js/src/frontend/BytecodeCompiler.h b/js/src/frontend/BytecodeCompiler.h index b034e299ee7..4474f9836ef 100644 --- a/js/src/frontend/BytecodeCompiler.h +++ b/js/src/frontend/BytecodeCompiler.h @@ -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 evalStaticScope, - const ReadOnlyCompileOptions& options, SourceBufferHolder& srcBuf, - JSString* source_ = nullptr, unsigned staticLevel = 0, - SourceCompressionTask* extraSct = nullptr); + HandleObject scopeChain, Handle enclosingStaticScope, + HandleScript evalCaller, const ReadOnlyCompileOptions& options, + SourceBufferHolder& srcBuf, JSString* source_ = nullptr, + unsigned staticLevel = 0, SourceCompressionTask* extraSct = nullptr); bool CompileLazyFunction(JSContext* cx, Handle lazy, const char16_t* chars, size_t length); diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index db3836eafaf..99ca0ba928e 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -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(); diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h index 47962e1a8bd..70aea4a7be7 100644 --- a/js/src/frontend/BytecodeEmitter.h +++ b/js/src/frontend/BytecodeEmitter.h @@ -22,7 +22,7 @@ namespace js { -class StaticEvalObject; +class ScopeObject; namespace frontend { diff --git a/js/src/frontend/SharedContext.h b/js/src/frontend/SharedContext.h index ed22a701854..8599f68d7ee 100644 --- a/js/src/frontend/SharedContext.h +++ b/js/src/frontend/SharedContext.h @@ -256,21 +256,21 @@ class SharedContext class GlobalSharedContext : public SharedContext { private: - Handle staticEvalScope_; + Handle topStaticScope_; public: GlobalSharedContext(ExclusiveContext* cx, - Directives directives, Handle staticEvalScope, + Directives directives, Handle 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 it(context, staticEvalScope_); + StaticScopeIter it(context, topStaticScope_); for (; !it.done(); it++) { if (it.type() == StaticScopeIter::Function && !it.fun().isArrow()) diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 2d5eb9eb7ec..c818b04256c 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -6275,8 +6275,8 @@ EvaluateInEnv(JSContext* cx, Handle 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)