Implement new.target
This commit is contained in:
@@ -1003,6 +1003,10 @@ var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
|
||||
$documentation: "Base class for all symbols",
|
||||
});
|
||||
|
||||
var AST_NewTarget = DEFNODE("NewTarget", null, {
|
||||
$documentation: "A reference to new.target"
|
||||
});
|
||||
|
||||
var AST_SymbolAccessor = DEFNODE("SymbolAccessor", null, {
|
||||
$documentation: "The name of a property accessor (setter/getter function)"
|
||||
}, AST_Symbol);
|
||||
|
||||
@@ -1219,6 +1219,9 @@ function OutputStream(options) {
|
||||
});
|
||||
else output.print("{}");
|
||||
});
|
||||
DEFPRINT(AST_NewTarget, function(self, output) {
|
||||
output.print("new.target");
|
||||
});
|
||||
DEFPRINT(AST_ObjectKeyVal, function(self, output){
|
||||
var key = self.key;
|
||||
var quote = self.quote;
|
||||
|
||||
@@ -1292,6 +1292,14 @@ function parse($TEXT, options) {
|
||||
var new_ = function(allow_calls) {
|
||||
var start = S.token;
|
||||
expect_token("operator", "new");
|
||||
if (is("punc", ".")) {
|
||||
next();
|
||||
expect_token("name");
|
||||
return subscripts(new AST_NewTarget({
|
||||
start : start,
|
||||
end : prev()
|
||||
}), allow_calls);
|
||||
}
|
||||
var newexp = expr_atom(false), args;
|
||||
if (is("punc", "(")) {
|
||||
next();
|
||||
|
||||
@@ -251,6 +251,14 @@ class_name_can_be_preserved: {
|
||||
}
|
||||
}
|
||||
|
||||
new_target: {
|
||||
input: {
|
||||
new.target;
|
||||
new.target.name;
|
||||
}
|
||||
expect_exact: "new.target;new.target.name;"
|
||||
}
|
||||
|
||||
number_literals: {
|
||||
input: {
|
||||
0b1001;
|
||||
|
||||
Reference in New Issue
Block a user