Starting destructuring expressions
This commit is contained in:
@@ -1179,6 +1179,17 @@ function OutputStream(options) {
|
|||||||
var def = self.definition();
|
var def = self.definition();
|
||||||
output.print_name(def ? def.mangled_name || def.name : self.name);
|
output.print_name(def ? def.mangled_name || def.name : self.name);
|
||||||
});
|
});
|
||||||
|
DEFPRINT(AST_ObjectSymbol, function(self, output){
|
||||||
|
var def = self.symbol.definition();
|
||||||
|
if (def && def.mangled_name) {
|
||||||
|
output.print(self.symbol.name);
|
||||||
|
output.print(':');
|
||||||
|
output.space();
|
||||||
|
output.print(def.mangled_name);
|
||||||
|
} else {
|
||||||
|
output.print(self.symbol.name);
|
||||||
|
}
|
||||||
|
});
|
||||||
DEFPRINT(AST_Undefined, function(self, output){
|
DEFPRINT(AST_Undefined, function(self, output){
|
||||||
output.print("void 0");
|
output.print("void 0");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1410,9 +1410,6 @@ function parse($TEXT, options) {
|
|||||||
|
|
||||||
if (!is("punc", ":")) {
|
if (!is("punc", ":")) {
|
||||||
// It's one of those object destructurings, the value is its own name
|
// It's one of those object destructurings, the value is its own name
|
||||||
if (!S.in_parameters) {
|
|
||||||
croak("Invalid syntax", S.token.line, S.token.col);
|
|
||||||
}
|
|
||||||
a.push(new AST_ObjectSymbol({
|
a.push(new AST_ObjectSymbol({
|
||||||
start: start,
|
start: start,
|
||||||
end: start,
|
end: start,
|
||||||
|
|||||||
@@ -32,3 +32,12 @@ destructuring_vardef_in_loops: {
|
|||||||
}
|
}
|
||||||
expect_exact: "for(var[x,y]in pairs);for(var[a]=0;;);for(var{c}of cees);"
|
expect_exact: "for(var[x,y]in pairs);for(var[a]=0;;);for(var{c}of cees);"
|
||||||
}
|
}
|
||||||
|
destructuring_expressions: {
|
||||||
|
input: {
|
||||||
|
({a, b});
|
||||||
|
[{a}];
|
||||||
|
f({x});
|
||||||
|
}
|
||||||
|
expect_exact: "({a,b});[{a}];f({x});"
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user