• Adam Klein's avatar
    [ast] Save one pointer in most Function and Variable declaration node · 69b165db
    Adam Klein authored
    Currently, Declaration stores a Scope pointer to whichever Scope the
    declaration appeared in. This is used to disallow var declarations
    being hoisted over lexical declarations. For example:
    
      {
        let x;
        { var x; }
      }
    
    But in fact this is the only sort of case where storing the scope
    is required: for lexical declarations (including function declarations
    appearing in blocks), Declaration::scope() was always identical to
    Declaration::proxy()->var()->scope(). That is, only var declarations
    end up "nested" in this way.
    
    This patch adds a subclass of VariableDeclaration to store the Scope.
    Since the only thing that cares about that data is Scope analysis,
    this isn't treated as a distinct AstNode::NodeType from VariableDeclaration,
    leaving all AstVisitors untouched in the process.
    
    Also reworked the logic in Scope::CheckConflictingVarDeclarations() for
    clarity after making changes to accomodate the new code.
    
    Change-Id: I6ee4298700508ab9e28a76ddb8504bae68bc473f
    Reviewed-on: https://chromium-review.googlesource.com/619595
    Commit-Queue: Adam Klein <adamk@chromium.org>
    Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#47441}
    69b165db
Name
Last commit
Last update
benchmarks Loading commit data...
build_overrides Loading commit data...
docs Loading commit data...
gni Loading commit data...
gypfiles Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.editorconfig Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
Makefile Loading commit data...
Makefile.android Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...
snapshot_toolchain.gni Loading commit data...