Changeset 54510 in webkit


Ignore:
Timestamp:
Feb 8, 2010, 2:26:59 PM (16 years ago)
Author:
[email protected]
Message:

Use an empty identifier instead of a null identifier for parse
tokens without an identifier.

Reviewed by Sam Weinig.

This helps encapsulate the null UStringImpl within UString.

  • parser/Grammar.y:
  • parser/NodeConstructors.h:

(JSC::ContinueNode::ContinueNode):
(JSC::BreakNode::BreakNode):
(JSC::ForInNode::ForInNode):

  • runtime/CommonIdentifiers.cpp:

(JSC::CommonIdentifiers::CommonIdentifiers):

  • runtime/CommonIdentifiers.h:
  • runtime/FunctionPrototype.cpp:

(JSC::FunctionPrototype::FunctionPrototype):

Location:
trunk/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r54481 r54510  
     12010-02-08  Gavin Barraclough  <[email protected]>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Use an empty identifier instead of a null identifier for parse
     6        tokens without an identifier.
     7
     8        This helps encapsulate the null UStringImpl within UString.
     9
     10        * parser/Grammar.y:
     11        * parser/NodeConstructors.h:
     12        (JSC::ContinueNode::ContinueNode):
     13        (JSC::BreakNode::BreakNode):
     14        (JSC::ForInNode::ForInNode):
     15        * runtime/CommonIdentifiers.cpp:
     16        (JSC::CommonIdentifiers::CommonIdentifiers):
     17        * runtime/CommonIdentifiers.h:
     18        * runtime/FunctionPrototype.cpp:
     19        (JSC::FunctionPrototype::FunctionPrototype):
     20
    1212010-02-08  Gustavo Noronha Silva  <[email protected]>
    222
  • trunk/JavaScriptCore/parser/Grammar.y

    r52791 r54510  
    11481148
    11491149TryStatement:
    1150     TRY Block FINALLY Block             { $$ = createNodeDeclarationInfo<StatementNode*>(new (GLOBAL_DATA) TryNode(GLOBAL_DATA, $2.m_node, GLOBAL_DATA->propertyNames->nullIdentifier, false, 0, $4.m_node),
     1150    TRY Block FINALLY Block             { $$ = createNodeDeclarationInfo<StatementNode*>(new (GLOBAL_DATA) TryNode(GLOBAL_DATA, $2.m_node, GLOBAL_DATA->propertyNames->emptyIdentifier, false, 0, $4.m_node),
    11511151                                                                                         mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations),
    11521152                                                                                         mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations),
     
    11891189
    11901190FunctionExpr:
    1191     FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new (GLOBAL_DATA) FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, $5, GLOBAL_DATA->lexer->sourceCode($4, $6, @4.first_line)), ClosureFeature, 0); setStatementLocation($5, @4, @6); }
     1191    FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new (GLOBAL_DATA) FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->emptyIdentifier, $5, GLOBAL_DATA->lexer->sourceCode($4, $6, @4.first_line)), ClosureFeature, 0); setStatementLocation($5, @4, @6); }
    11921192    | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
    11931193      {
    1194           $$ = createNodeInfo(new (GLOBAL_DATA) FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, $6, GLOBAL_DATA->lexer->sourceCode($5, $7, @5.first_line), $3.m_node.head), $3.m_features | ClosureFeature, 0);
     1194          $$ = createNodeInfo(new (GLOBAL_DATA) FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->emptyIdentifier, $6, GLOBAL_DATA->lexer->sourceCode($5, $7, @5.first_line), $3.m_node.head), $3.m_features | ClosureFeature, 0);
    11951195          if ($3.m_features & ArgumentsFeature)
    11961196              $6->setUsesArguments();
     
    19821982    else
    19831983        return 0;
    1984     return new (globalData) PropertyNode(globalData, name, new (globalData) FuncExprNode(globalData, globalData->propertyNames->nullIdentifier, body, source, params), type);
     1984    return new (globalData) PropertyNode(globalData, name, new (globalData) FuncExprNode(globalData, globalData->propertyNames->emptyIdentifier, body, source, params), type);
    19851985}
    19861986
  • trunk/JavaScriptCore/parser/NodeConstructors.h

    r47664 r54510  
    742742    inline ContinueNode::ContinueNode(JSGlobalData* globalData)
    743743        : StatementNode(globalData)
    744         , m_ident(globalData->propertyNames->nullIdentifier)
     744        , m_ident(globalData->propertyNames->emptyIdentifier)
    745745    {
    746746    }
     
    754754    inline BreakNode::BreakNode(JSGlobalData* globalData)
    755755        : StatementNode(globalData)
    756         , m_ident(globalData->propertyNames->nullIdentifier)
     756        , m_ident(globalData->propertyNames->emptyIdentifier)
    757757    {
    758758    }
     
    878878    inline ForInNode::ForInNode(JSGlobalData* globalData, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
    879879        : StatementNode(globalData)
    880         , m_ident(globalData->propertyNames->nullIdentifier)
     880        , m_ident(globalData->propertyNames->emptyIdentifier)
    881881        , m_init(0)
    882882        , m_lexpr(l)
  • trunk/JavaScriptCore/runtime/CommonIdentifiers.cpp

    r44813 r54510  
    2929
    3030CommonIdentifiers::CommonIdentifiers(JSGlobalData* globalData)
    31     : nullIdentifier(globalData, nullCString)
    32     , emptyIdentifier(globalData, "")
     31    : emptyIdentifier(globalData, "")
    3332    , underscoreProto(globalData, "__proto__")
    3433    , thisIdentifier(globalData, "this")
  • trunk/JavaScriptCore/runtime/CommonIdentifiers.h

    r53170 r54510  
    9191
    9292    public:
    93         const Identifier nullIdentifier;
    9493        const Identifier emptyIdentifier;
    9594        const Identifier underscoreProto;
  • trunk/JavaScriptCore/runtime/FunctionPrototype.cpp

    r52028 r54510  
    3939
    4040FunctionPrototype::FunctionPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure)
    41     : InternalFunction(&exec->globalData(), structure, exec->propertyNames().nullIdentifier)
     41    : InternalFunction(&exec->globalData(), structure, exec->propertyNames().emptyIdentifier)
    4242{
    4343    putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
  • trunk/JavaScriptCore/runtime/Identifier.cpp

    r54464 r54510  
    124124PassRefPtr<UString::Rep> Identifier::add(JSGlobalData* globalData, const char* c)
    125125{
    126     if (!c) {
    127         UString::Rep* rep = UString::null().rep();
    128         rep->hash();
    129         return rep;
    130     }
     126    ASSERT(c);
     127
    131128    if (!c[0]) {
    132129        UString::Rep::empty().hash();
  • trunk/JavaScriptCore/runtime/PropertyNameArray.cpp

    r54464 r54510  
    3131void PropertyNameArray::add(UString::Rep* identifier)
    3232{
    33     ASSERT(identifier == UString::null().rep() || identifier == &UString::Rep::empty() || identifier->isIdentifier());
     33    ASSERT(identifier == &UString::Rep::empty() || identifier->isIdentifier());
    3434
    3535    size_t size = m_data->propertyNameVector().size();
Note: See TracChangeset for help on using the changeset viewer.