Ignore:
Timestamp:
Aug 18, 2014, 12:11:41 PM (11 years ago)
Author:
[email protected]
Message:

The parser should generate AST nodes the var declarations with no initializers
https://bugs.webkit.org/show_bug.cgi?id=135545

Patch by Saam Barati <[email protected]> on 2014-08-18
Reviewed by Geoffrey Garen.

Currently, JSC's parser ignores variable declarations
that have no assignment initializer value because all
variables are implicitly assigned to undefined. But,
type profiling needs an AST node to be generated for these
empty variable declarations because it needs to be able to
profile their text locations and to see that their type
is undefined.

  • bytecompiler/NodesCodegen.cpp:

(JSC::EmptyVarExpression::emitBytecode):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createVarStatement):
(JSC::ASTBuilder::createEmptyVarExpression):

  • parser/NodeConstructors.h:

(JSC::EmptyVarExpression::EmptyVarExpression):

  • parser/Nodes.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseVarDeclarationList):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createEmptyVarExpression):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r172381 r172717  
    459459        if (match(IDENT)) {
    460460            JSTextPosition varStart = tokenStartPosition();
     461            JSTokenLocation varStartLocation(tokenLocation());
    461462            identStart = varStart;
    462463            const Identifier* name = m_token.m_data.ident;
     
    476477               
    477478                node = context.createAssignResolve(location, *name, initializer, varStart, varDivot, lastTokenEndPosition());
    478             }
     479            } else
     480                node = context.createEmptyVarExpression(varStartLocation, *name);
    479481        } else {
    480482            lastIdent = 0;
     
    491493        }
    492494       
    493         if (hasInitializer) {
    494             if (!varDecls)
    495                 varDecls = node;
    496             else
    497                 varDecls = context.combineCommaNodes(location, varDecls, node);
    498         }
     495        if (!varDecls)
     496            varDecls = node;
     497        else
     498            varDecls = context.combineCommaNodes(location, varDecls, node);
    499499    } while (match(COMMA));
    500500    if (lastIdent)
Note: See TracChangeset for help on using the changeset viewer.