vendor/v8/src/scopes.h in mustang-0.0.1 vs vendor/v8/src/scopes.h in mustang-0.1.0
- old
+ new
@@ -102,10 +102,13 @@
// Compute top scope and allocate variables. For lazy compilation the top
// scope only contains the single lazily compiled function, so this
// doesn't re-allocate variables repeatedly.
static bool Analyze(CompilationInfo* info);
+ static Scope* DeserializeScopeChain(CompilationInfo* info,
+ Scope* innermost_scope);
+
// The scope name is only used for printing/debugging.
void SetScopeName(Handle<String> scope_name) { scope_name_ = scope_name; }
virtual void Initialize(bool inside_with);
@@ -144,11 +147,13 @@
// the parameter list; they must be added in source order, from left to
// right.
void AddParameter(Variable* var);
// Create a new unresolved variable.
- virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with);
+ virtual VariableProxy* NewUnresolved(Handle<String> name,
+ bool inside_with,
+ int position = RelocInfo::kNoPosition);
// Remove a unresolved variable. During parsing, an unresolved variable
// may have been added optimistically, but then only the variable name
// was used (typically for labels). If the variable was not declared, the
// addition introduced a new unresolved variable which may end up being
@@ -191,18 +196,23 @@
void RecordWithStatement() { scope_contains_with_ = true; }
// Inform the scope that the corresponding code contains an eval call.
void RecordEvalCall() { scope_calls_eval_ = true; }
+ // Enable strict mode for the scope (unless disabled by a global flag).
+ void EnableStrictMode() {
+ strict_mode_ = FLAG_strict_mode;
+ }
// ---------------------------------------------------------------------------
// Predicates.
// Specific scope types.
bool is_eval_scope() const { return type_ == EVAL_SCOPE; }
bool is_function_scope() const { return type_ == FUNCTION_SCOPE; }
bool is_global_scope() const { return type_ == GLOBAL_SCOPE; }
+ bool is_strict_mode() const { return strict_mode_; }
// Information about which scopes calls eval.
bool calls_eval() const { return scope_calls_eval_; }
bool outer_scope_calls_eval() const { return outer_scope_calls_eval_; }
@@ -218,11 +228,11 @@
// Accessors.
// A new variable proxy corresponding to the (function) receiver.
VariableProxy* receiver() const {
VariableProxy* proxy =
- new VariableProxy(Factory::this_symbol(), true, false);
+ new VariableProxy(FACTORY->this_symbol(), true, false);
proxy->BindTo(receiver_);
return proxy;
}
// The variable holding the function literal for named function
@@ -311,18 +321,10 @@
protected:
friend class ParserFactory;
explicit Scope(Type type);
- void InsertAfterScope(Scope* scope) {
- inner_scopes_.Add(scope);
- outer_scope_ = scope->outer_scope_;
- outer_scope_->inner_scopes_.RemoveElement(scope);
- outer_scope_->inner_scopes_.Add(this);
- scope->outer_scope_ = this;
- }
-
// Scope tree.
Scope* outer_scope_; // the immediately enclosing outer scope, or NULL
ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes
// The scope type.
@@ -361,10 +363,11 @@
// Scope-specific information.
bool scope_inside_with_; // this scope is inside a 'with' of some outer scope
bool scope_contains_with_; // this scope contains a 'with' statement
bool scope_calls_eval_; // this scope contains an 'eval' call
+ bool strict_mode_; // this scope is a strict mode scope
// Computed via PropagateScopeInfo.
bool outer_scope_calls_eval_;
bool inner_scope_calls_eval_;
bool outer_scope_is_eval_scope_;
@@ -411,25 +414,34 @@
void AllocateVariablesRecursively();
private:
Scope(Scope* inner_scope, SerializedScopeInfo* scope_info);
+ void AddInnerScope(Scope* inner_scope) {
+ if (inner_scope != NULL) {
+ inner_scopes_.Add(inner_scope);
+ inner_scope->outer_scope_ = this;
+ }
+ }
+
void SetDefaults(Type type,
Scope* outer_scope,
SerializedScopeInfo* scope_info) {
outer_scope_ = outer_scope;
type_ = type;
- scope_name_ = Factory::empty_symbol();
+ scope_name_ = FACTORY->empty_symbol();
dynamics_ = NULL;
receiver_ = NULL;
function_ = NULL;
arguments_ = NULL;
arguments_shadow_ = NULL;
illegal_redecl_ = NULL;
scope_inside_with_ = false;
scope_contains_with_ = false;
scope_calls_eval_ = false;
+ // Inherit the strict mode from the parent scope.
+ strict_mode_ = (outer_scope != NULL) && outer_scope->strict_mode_;
outer_scope_calls_eval_ = false;
inner_scope_calls_eval_ = false;
outer_scope_is_eval_scope_ = false;
force_eager_compilation_ = false;
num_stack_slots_ = 0;
@@ -467,10 +479,12 @@
ASSERT(inside_with_level_ <= nesting_level_);
}
virtual Variable* Lookup(Handle<String> name) { return NULL; }
- virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with) {
+ virtual VariableProxy* NewUnresolved(Handle<String> name,
+ bool inside_with,
+ int position = RelocInfo::kNoPosition) {
return NULL;
}
virtual Variable* NewTemporary(Handle<String> name) { return NULL; }