• 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
..
OWNERS Loading commit data...
ast-expression-rewriter.cc Loading commit data...
ast-expression-rewriter.h Loading commit data...
ast-function-literal-id-reindexer.cc Loading commit data...
ast-function-literal-id-reindexer.h Loading commit data...
ast-numbering.cc Loading commit data...
ast-numbering.h Loading commit data...
ast-source-ranges.h Loading commit data...
ast-traversal-visitor.h Loading commit data...
ast-value-factory.cc Loading commit data...
ast-value-factory.h Loading commit data...
ast.cc Loading commit data...
ast.h Loading commit data...
compile-time-value.cc Loading commit data...
compile-time-value.h Loading commit data...
context-slot-cache.cc Loading commit data...
context-slot-cache.h Loading commit data...
modules.cc Loading commit data...
modules.h Loading commit data...
prettyprinter.cc Loading commit data...
prettyprinter.h Loading commit data...
scopes.cc Loading commit data...
scopes.h Loading commit data...
variables.cc Loading commit data...
variables.h Loading commit data...