variables.cc 1.01 KB
Newer Older
1
// Copyright 2011 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5
#include "src/ast/variables.h"
6

7
#include "src/ast/scopes.h"
yangguo's avatar
yangguo committed
8
#include "src/globals.h"
9
#include "src/objects-inl.h"
10

11 12
namespace v8 {
namespace internal {
13 14 15 16

// ----------------------------------------------------------------------------
// Implementation Variable.

17 18 19 20 21 22 23 24
Variable::Variable(Variable* other)
    : scope_(other->scope_),
      name_(other->name_),
      local_if_not_shadowed_(nullptr),
      next_(nullptr),
      index_(other->index_),
      initializer_position_(other->initializer_position_),
      bit_field_(other->bit_field_) {}
25

26
bool Variable::IsGlobalObjectProperty() const {
27 28
  // Temporaries are never global, they must always be allocated in the
  // activation frame.
29
  return (IsDynamicVariableMode(mode()) || mode() == VariableMode::kVar) &&
neis's avatar
neis committed
30
         scope_ != nullptr && scope_->is_script_scope();
31 32
}

33 34
}  // namespace internal
}  // namespace v8