Source/JavaScriptCore: Support computed property names in object literals
https://bugs.webkit.org/show_bug.cgi?id=123112
Reviewed by Michael Saboff.
Add support for computed property names to the parser.
* bytecompiler/NodesCodegen.cpp:
(JSC::PropertyListNode::emitBytecode):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createProperty):
(JSC::ASTBuilder::getName):
* parser/NodeConstructors.h:
(JSC::PropertyNode::PropertyNode):
* parser/Nodes.h:
(JSC::PropertyNode::expressionName):
(JSC::PropertyNode::name):
* parser/Parser.cpp:
(JSC::::parseProperty):
(JSC::::parseStrictObjectLiteral):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::Property::Property):
(JSC::SyntaxChecker::createProperty):
(JSC::SyntaxChecker::operatorStackPop):
LayoutTests: Support expression property names in object literals
https://bugs.webkit.org/show_bug.cgi?id=123112
Reviewed by Michael Saboff.
Add tests
* js/basic-computed-property-name-expected.txt: Added.
* js/basic-computed-property-name.html: Added.
* js/parser-syntax-check-expected.txt:
* js/script-tests/basic-computed-property-name.js: Added.
(a.string_appeared_here.runTest):
* js/script-tests/parser-syntax-check.js:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157724 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/parser/SyntaxChecker.h b/Source/JavaScriptCore/parser/SyntaxChecker.h
index a8f5ab3..2dab1e2 100644
--- a/Source/JavaScriptCore/parser/SyntaxChecker.h
+++ b/Source/JavaScriptCore/parser/SyntaxChecker.h
@@ -88,8 +88,8 @@
{
}
ALWAYS_INLINE Property(const Identifier* ident, PropertyNode::Type ty)
- : name(ident)
- , type(ty)
+ : name(ident)
+ , type(ty)
{
}
ALWAYS_INLINE Property(PropertyNode::Type ty)
@@ -173,6 +173,10 @@
return Property(type);
return Property(&vm->parserArena->identifierArena().makeNumericIdentifier(vm, name), type);
}
+ template <bool complete> Property createProperty(VM*, ExpressionNode*, int, PropertyNode::Type type)
+ {
+ return Property(type);
+ }
int createPropertyList(const JSTokenLocation&, Property) { return 1; }
int createPropertyList(const JSTokenLocation&, Property, int) { return 1; }
int createElementList(int, int) { return 1; }
@@ -251,7 +255,7 @@
void assignmentStackAppend(int, int, int, int, int, Operator) { }
int createAssignment(const JSTokenLocation&, int, int, int, int, int) { RELEASE_ASSERT_NOT_REACHED(); return 1; }
- const Identifier& getName(const Property& property) const { ASSERT(property.name); return *property.name; }
+ const Identifier* getName(const Property& property) const { ASSERT(property.name); return property.name; }
PropertyNode::Type getType(const Property& property) const { return property.type; }
bool isResolve(ExpressionType expr) const { return expr == ResolveExpr || expr == ResolveEvalExpr; }
ExpressionType createDeconstructingAssignment(const JSTokenLocation&, int, ExpressionType)