computed properties

This commit is contained in:
Fábio Santos
2015-09-07 22:46:07 +01:00
parent b14496c742
commit b31918bbf0
5 changed files with 42 additions and 0 deletions

View File

@@ -1465,6 +1465,15 @@ function parse($TEXT, options) {
continue;
}
}
if (type == "punc" && start.value == "[") {
expect(":");
a.push(new AST_ObjectComputedKeyVal({
key: name,
value: expression(false)
}));
continue;
}
if (!is("punc", ":")) {
// It's one of those object destructurings, the value is its own name
@@ -1495,6 +1504,12 @@ function parse($TEXT, options) {
var tmp = S.token;
next();
switch (tmp.type) {
case "punc":
if (tmp.value === "[") {
var ex = expression(false);
expect("]");
return ex;
} else unexpected();
case "num":
case "string":
case "name":