Ignore:
Timestamp:
Jul 21, 2015, 12:18:47 PM (10 years ago)
Author:
[email protected]
Message:

DestructuringPatternNode and DestructuringAssignmentNode should be ParserArenaFreeable
https://bugs.webkit.org/show_bug.cgi?id=147140

Reviewed by Geoffrey Garen.

The descendants of DestructuringPatternNode that need destruction also
inherit from ParserArenaDeletable.

  • parser/Nodes.h:

(JSC::DestructuringPatternNode::~DestructuringPatternNode):
(JSC::ObjectPatternNode::appendEntry):
(JSC::DestructuringAssignmentNode::bindings):

File:
1 edited

Legend:

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

    r187108 r187111  
    764764                break;
    765765
    766             Identifier propertyName;
     766            const Identifier* propertyName = nullptr;
    767767            TreeDestructuringPattern innerPattern = 0;
    768768            JSTokenLocation location = m_token.m_location;
    769769            if (match(IDENT) || isLETMaskedAsIDENT()) {
    770770                failIfTrue(match(LET) && (kind == DestructureToLet || kind == DestructureToConst), "Can't use 'let' as an identifier name for a LexicalDeclaration");
    771                 propertyName = *m_token.m_data.ident;
     771                propertyName = m_token.m_data.ident;
    772772                JSToken identifierToken = m_token;
    773773                next();
     
    775775                    innerPattern = parseDestructuringPattern(context, kind, bindingContext, depth + 1);
    776776                else
    777                     innerPattern = createBindingPattern(context, kind, propertyName, depth, identifierToken, bindingContext);
     777                    innerPattern = createBindingPattern(context, kind, *propertyName, depth, identifierToken, bindingContext);
    778778            } else {
    779779                JSTokenType tokenType = m_token.m_type;
     
    781781                case DOUBLE:
    782782                case INTEGER:
    783                     propertyName = Identifier::from(m_vm, m_token.m_data.doubleValue);
     783                    propertyName = &m_parserArena.identifierArena().makeNumericIdentifier(const_cast<VM*>(m_vm), m_token.m_data.doubleValue);
    784784                    break;
    785785                case STRING:
    786                     propertyName = *m_token.m_data.ident;
     786                    propertyName = m_token.m_data.ident;
    787787                    wasString = true;
    788788                    break;
     
    793793                        failWithMessage("Expected a property name");
    794794                    }
    795                     propertyName = *m_token.m_data.ident;
     795                    propertyName = m_token.m_data.ident;
    796796                    break;
    797797                }
     
    800800                    if (kind == DestructureToExpressions)
    801801                        return 0;
    802                     semanticFailIfTrue(tokenType == RESERVED, "Cannot use abbreviated destructuring syntax for reserved name '", propertyName.impl(), "'");
    803                     semanticFailIfTrue(tokenType == RESERVED_IF_STRICT, "Cannot use abbreviated destructuring syntax for reserved name '", propertyName.impl(), "' in strict mode");
    804                     semanticFailIfTrue(tokenType & KeywordTokenFlag, "Cannot use abbreviated destructuring syntax for keyword '", propertyName.impl(), "'");
     802                    semanticFailIfTrue(tokenType == RESERVED, "Cannot use abbreviated destructuring syntax for reserved name '", propertyName->impl(), "'");
     803                    semanticFailIfTrue(tokenType == RESERVED_IF_STRICT, "Cannot use abbreviated destructuring syntax for reserved name '", propertyName->impl(), "' in strict mode");
     804                    semanticFailIfTrue(tokenType & KeywordTokenFlag, "Cannot use abbreviated destructuring syntax for keyword '", propertyName->impl(), "'");
    805805                   
    806806                    failWithMessage("Expected a ':' prior to a named destructuring property");
     
    813813            TreeExpression defaultValue = parseDefaultValueForDestructuringPattern(context);
    814814            failIfTrue(kind == DestructureToParameters && defaultValue, "Default values in destructuring parameters are currently not supported");
    815             context.appendObjectPatternEntry(objectPattern, location, wasString, propertyName, innerPattern, defaultValue);
     815            ASSERT(propertyName);
     816            context.appendObjectPatternEntry(objectPattern, location, wasString, *propertyName, innerPattern, defaultValue);
    816817        } while (consume(COMMA));
    817818
Note: See TracChangeset for help on using the changeset viewer.