Ignore:
Timestamp:
Mar 6, 2015, 1:31:27 PM (10 years ago)
Author:
Joseph Pecoraro
Message:

proto shorthand property should not modify prototype in Object Literal construction
https://bugs.webkit.org/show_bug.cgi?id=142382

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

When parsing shorthand property syntax we know we will do a
put direct, even if the property name is proto. Pass that
information through to bytecode generation.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitDirectPutById):

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::PropertyListNode::emitPutConstantProperty):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createGetterOrSetterProperty):
(JSC::ASTBuilder::createProperty):

  • parser/NodeConstructors.h:

(JSC::PropertyNode::PropertyNode):

  • parser/Nodes.h:

(JSC::PropertyNode::putType):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseProperty):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createProperty):

LayoutTests:

  • js/object-literal-shorthand-construction-expected.txt:
  • js/script-tests/object-literal-shorthand-construction.js:

Update test to cover the proto shorthand case which is
different from longhand case.

File:
1 edited

Legend:

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

    r181121 r181179  
    15231523            semanticFailIfTrue(isStaticMethod && *methodInfo.name == propertyNames.prototype,
    15241524                "Cannot declare a static method named 'prototype'");
    1525             property = context.createProperty(methodInfo.name, method, PropertyNode::Constant, alwaysStrictInsideClass);
     1525            property = context.createProperty(methodInfo.name, method, PropertyNode::Constant, PropertyNode::Unknown, alwaysStrictInsideClass);
    15261526        }
    15271527
     
    19341934            failIfFalse(node, "Cannot parse expression for property declaration");
    19351935            context.setEndOffset(node, m_lexer->currentOffset());
    1936             return context.createProperty(ident, node, PropertyNode::Constant, complete);
     1936            return context.createProperty(ident, node, PropertyNode::Constant, PropertyNode::Unknown, complete);
    19371937        }
    19381938
     
    19441944            currentScope()->useVariable(ident, m_vm->propertyNames->eval == *ident);
    19451945            TreeExpression node = context.createResolve(location, ident, start);
    1946             return context.createProperty(ident, node, PropertyNode::Constant, complete);
     1946            return context.createProperty(ident, node, PropertyNode::Constant, PropertyNode::KnownDirect, complete);
    19471947        }
    19481948
     
    19641964        failIfFalse(node, "Cannot parse expression for property declaration");
    19651965        context.setEndOffset(node, m_lexer->currentOffset());
    1966         return context.createProperty(const_cast<VM*>(m_vm), m_parserArena, propertyName, node, PropertyNode::Constant, complete);
     1966        return context.createProperty(const_cast<VM*>(m_vm), m_parserArena, propertyName, node, PropertyNode::Constant, PropertyNode::Unknown, complete);
    19671967    }
    19681968    case OPENBRACKET: {
     
    19761976        failIfFalse(node, "Cannot parse expression for property declaration");
    19771977        context.setEndOffset(node, m_lexer->currentOffset());
    1978         return context.createProperty(propertyName, node, PropertyNode::Constant, complete);
     1978        return context.createProperty(propertyName, node, PropertyNode::Constant, PropertyNode::Unknown, complete);
    19791979    }
    19801980    default:
Note: See TracChangeset for help on using the changeset viewer.