add JavaScript support for new private fields syntax

This commit is contained in:
Erik Krogh Kristensen
2021-11-25 00:14:36 +01:00
parent d1a7feebc4
commit 19bbe6d276
9 changed files with 291 additions and 201 deletions

View File

@@ -1646,6 +1646,15 @@ public class Parser {
node = new ThisExpression(new SourceLocation(this.startLoc));
this.next();
return this.finishNode(node);
} else if (this.type == TokenType.pound) {
Position startLoc = this.startLoc;
// there is only one case where this is valid, and that is "Ergonomic brand checks for Private Fields", i.e. `#name in obj`.
Identifier id = parseIdent(true);
String op = String.valueOf(this.value);
if (!op.equals("in")) {
this.unexpected(startLoc);
}
return this.parseExprOp(id, this.start, startLoc, -1, false);
} else if (this.type == TokenType.name) {
Position startLoc = this.startLoc;
Identifier id = this.parseIdent(this.type != TokenType.name);
@@ -3314,9 +3323,6 @@ public class Parser {
if (pi.kind.equals("set") && node.getValue().hasRest())
this.raiseRecoverable(params.get(params.size() - 1), "Setter cannot use rest params");
}
if (pi.key instanceof Identifier && ((Identifier)pi.key).getName().startsWith("#")) {
raiseRecoverable(pi.key, "Only fields, not methods, can be declared private.");
}
return node;
}

View File

@@ -847,8 +847,15 @@ public class ASTExtractor {
@Override
public Label visit(BinaryExpression nd, Context c) {
Label key = super.visit(nd, c);
visit(nd.getLeft(), key, 0, true);
if (nd.getOperator().equals("in") && nd.getLeft() instanceof Identifier && ((Identifier)nd.getLeft()).getName().startsWith("#")) {
// this happens with Ergonomic brand checks for Private Fields (see https://github.com/tc39/proposal-private-fields-in-in).
// it's the only case where private field identifiers are used not as a field.
visit(nd.getLeft(), key, 0, IdContext.LABEL, true);
} else {
visit(nd.getLeft(), key, 0, true);
}
visit(nd.getRight(), key, 1, true);
extractRegxpFromBinop(nd, c);
return key;
}

View File

@@ -152,241 +152,259 @@ toplevels(#20044,4)
locations_default(#20045,#10000,6,16,6,16)
hasLocation(#20044,#20045)
#20046=*
js_parse_errors(#20046,#20044,"Error: Unexpected token","#foo")
hasLocation(#20046,#20045)
#20047=*
lines(#20047,#20044,"#foo","")
#20048=@"loc,{#10000},6,16,6,19"
locations_default(#20048,#10000,6,16,6,19)
hasLocation(#20047,#20048)
js_parse_errors(#20046,#20044,"Error: Cannot use private fields outside a class","#foo")
#20047=@"loc,{#10000},6,20,6,20"
locations_default(#20047,#10000,6,20,6,20)
hasLocation(#20046,#20047)
#20048=*
lines(#20048,#20044,"#foo","")
#20049=@"loc,{#10000},6,16,6,19"
locations_default(#20049,#10000,6,16,6,19)
hasLocation(#20048,#20049)
numlines(#20044,1,0,0)
#20050=*
js_parse_errors(#20050,#20044,"Error: Unexpected token","#foo")
hasLocation(#20050,#20045)
#20051=*
lines(#20051,#20044,"#foo","")
hasLocation(#20051,#20049)
numlines(#20044,1,0,0)
toplevel_parent_xml_node(#20044,#20041)
#20049=*
template_placeholder_tag_info(#20049,#20042,"{{/foo}}")
#20050=@"loc,{#10000},6,22,6,29"
locations_default(#20050,#10000,6,22,6,29)
hasLocation(#20049,#20050)
#20052=*
template_placeholder_tag_info(#20052,#20042,"{{/foo}}")
#20053=@"loc,{#10000},6,22,6,29"
locations_default(#20053,#10000,6,22,6,29)
hasLocation(#20052,#20053)
scopes(#20000,0)
#20051=@"script;{#10000},6,24"
toplevels(#20051,4)
#20052=@"loc,{#10000},6,24,6,24"
locations_default(#20052,#10000,6,24,6,24)
hasLocation(#20051,#20052)
#20053=*
js_parse_errors(#20053,#20051,"Error: Unterminated regular expression","/foo")
#20054=@"loc,{#10000},6,25,6,25"
locations_default(#20054,#10000,6,25,6,25)
hasLocation(#20053,#20054)
#20055=*
lines(#20055,#20051,"/foo","")
#20056=@"loc,{#10000},6,24,6,27"
locations_default(#20056,#10000,6,24,6,27)
hasLocation(#20055,#20056)
numlines(#20051,1,0,0)
toplevel_parent_xml_node(#20051,#20049)
#20057=*
#20054=@"script;{#10000},6,24"
toplevels(#20054,4)
#20055=@"loc,{#10000},6,24,6,24"
locations_default(#20055,#10000,6,24,6,24)
hasLocation(#20054,#20055)
#20056=*
js_parse_errors(#20056,#20054,"Error: Unterminated regular expression","/foo")
#20057=@"loc,{#10000},6,25,6,25"
locations_default(#20057,#10000,6,25,6,25)
hasLocation(#20056,#20057)
#20058=*
template_placeholder_tag_info(#20057,#20058,"{{#foo}}")
#20059=@"loc,{#10000},8,18,8,25"
locations_default(#20059,#10000,8,18,8,25)
hasLocation(#20057,#20059)
lines(#20058,#20054,"/foo","")
#20059=@"loc,{#10000},6,24,6,27"
locations_default(#20059,#10000,6,24,6,27)
hasLocation(#20058,#20059)
numlines(#20054,1,0,0)
toplevel_parent_xml_node(#20054,#20052)
#20060=*
#20061=*
template_placeholder_tag_info(#20060,#20061,"{{#foo}}")
#20062=@"loc,{#10000},8,18,8,25"
locations_default(#20062,#10000,8,18,8,25)
hasLocation(#20060,#20062)
scopes(#20000,0)
#20060=@"script;{#10000},8,20"
toplevels(#20060,4)
#20061=@"loc,{#10000},8,20,8,20"
locations_default(#20061,#10000,8,20,8,20)
hasLocation(#20060,#20061)
#20062=*
js_parse_errors(#20062,#20060,"Error: Unexpected token","#foo")
hasLocation(#20062,#20061)
#20063=*
lines(#20063,#20060,"#foo","")
#20064=@"loc,{#10000},8,20,8,23"
locations_default(#20064,#10000,8,20,8,23)
#20063=@"script;{#10000},8,20"
toplevels(#20063,4)
#20064=@"loc,{#10000},8,20,8,20"
locations_default(#20064,#10000,8,20,8,20)
hasLocation(#20063,#20064)
numlines(#20060,1,0,0)
toplevel_parent_xml_node(#20060,#20057)
#20065=*
template_placeholder_tag_info(#20065,#20058,"{{baz}}")
#20066=@"loc,{#10000},8,30,8,36"
locations_default(#20066,#10000,8,30,8,36)
js_parse_errors(#20065,#20063,"Error: Cannot use private fields outside a class","#foo")
#20066=@"loc,{#10000},8,24,8,24"
locations_default(#20066,#10000,8,24,8,24)
hasLocation(#20065,#20066)
scopes(#20000,0)
#20067=@"script;{#10000},8,32"
#20068=*
lines(#20068,#20067,"baz","")
#20069=@"loc,{#10000},8,32,8,34"
locations_default(#20069,#10000,8,32,8,34)
hasLocation(#20068,#20069)
numlines(#20067,1,1,0)
#20067=*
lines(#20067,#20063,"#foo","")
#20068=@"loc,{#10000},8,20,8,23"
locations_default(#20068,#10000,8,20,8,23)
hasLocation(#20067,#20068)
numlines(#20063,1,0,0)
#20069=*
js_parse_errors(#20069,#20063,"Error: Unexpected token","#foo")
hasLocation(#20069,#20064)
#20070=*
tokeninfo(#20070,6,#20067,0,"baz")
hasLocation(#20070,#20069)
lines(#20070,#20063,"#foo","")
hasLocation(#20070,#20068)
numlines(#20063,1,0,0)
toplevel_parent_xml_node(#20063,#20060)
#20071=*
tokeninfo(#20071,0,#20067,1,"")
#20072=@"loc,{#10000},8,35,8,34"
locations_default(#20072,#10000,8,35,8,34)
template_placeholder_tag_info(#20071,#20061,"{{baz}}")
#20072=@"loc,{#10000},8,30,8,36"
locations_default(#20072,#10000,8,30,8,36)
hasLocation(#20071,#20072)
toplevels(#20067,4)
hasLocation(#20067,#20069)
#20073=@"module;{#10000},8,32"
scopes(#20073,3)
scopenodes(#20067,#20073)
scopenesting(#20073,#20000)
is_module(#20067)
#20074=*
stmts(#20074,2,#20067,0,"baz")
hasLocation(#20074,#20069)
stmt_containers(#20074,#20067)
#20075=*
exprs(#20075,79,#20074,0,"baz")
hasLocation(#20075,#20069)
enclosing_stmt(#20075,#20074)
expr_containers(#20075,#20067)
literals("baz","baz",#20075)
#20076=@"var;{baz};{#20073}"
variables(#20076,"baz",#20073)
bind(#20075,#20076)
#20077=*
entry_cfg_node(#20077,#20067)
#20078=@"loc,{#10000},8,32,8,31"
locations_default(#20078,#10000,8,32,8,31)
hasLocation(#20077,#20078)
#20079=*
exit_cfg_node(#20079,#20067)
hasLocation(#20079,#20072)
successor(#20074,#20075)
successor(#20075,#20079)
successor(#20077,#20074)
toplevel_parent_xml_node(#20067,#20065)
#20080=*
template_placeholder_tag_info(#20080,#20058,"{{/foo}}")
#20081=@"loc,{#10000},8,37,8,44"
locations_default(#20081,#10000,8,37,8,44)
hasLocation(#20080,#20081)
scopes(#20000,0)
#20082=@"script;{#10000},8,39"
toplevels(#20082,4)
#20083=@"loc,{#10000},8,39,8,39"
locations_default(#20083,#10000,8,39,8,39)
hasLocation(#20082,#20083)
#20084=*
js_parse_errors(#20084,#20082,"Error: Unterminated regular expression","/foo")
#20085=@"loc,{#10000},8,40,8,40"
locations_default(#20085,#10000,8,40,8,40)
hasLocation(#20084,#20085)
#20073=@"script;{#10000},8,32"
#20074=*
lines(#20074,#20073,"baz","")
#20075=@"loc,{#10000},8,32,8,34"
locations_default(#20075,#10000,8,32,8,34)
hasLocation(#20074,#20075)
numlines(#20073,1,1,0)
#20076=*
tokeninfo(#20076,6,#20073,0,"baz")
hasLocation(#20076,#20075)
#20077=*
tokeninfo(#20077,0,#20073,1,"")
#20078=@"loc,{#10000},8,35,8,34"
locations_default(#20078,#10000,8,35,8,34)
hasLocation(#20077,#20078)
toplevels(#20073,4)
hasLocation(#20073,#20075)
#20079=@"module;{#10000},8,32"
scopes(#20079,3)
scopenodes(#20073,#20079)
scopenesting(#20079,#20000)
is_module(#20073)
#20080=*
stmts(#20080,2,#20073,0,"baz")
hasLocation(#20080,#20075)
stmt_containers(#20080,#20073)
#20081=*
exprs(#20081,79,#20080,0,"baz")
hasLocation(#20081,#20075)
enclosing_stmt(#20081,#20080)
expr_containers(#20081,#20073)
literals("baz","baz",#20081)
#20082=@"var;{baz};{#20079}"
variables(#20082,"baz",#20079)
bind(#20081,#20082)
#20083=*
entry_cfg_node(#20083,#20073)
#20084=@"loc,{#10000},8,32,8,31"
locations_default(#20084,#10000,8,32,8,31)
hasLocation(#20083,#20084)
#20085=*
exit_cfg_node(#20085,#20073)
hasLocation(#20085,#20078)
successor(#20080,#20081)
successor(#20081,#20085)
successor(#20083,#20080)
toplevel_parent_xml_node(#20073,#20071)
#20086=*
lines(#20086,#20082,"/foo","")
#20087=@"loc,{#10000},8,39,8,42"
locations_default(#20087,#10000,8,39,8,42)
template_placeholder_tag_info(#20086,#20061,"{{/foo}}")
#20087=@"loc,{#10000},8,37,8,44"
locations_default(#20087,#10000,8,37,8,44)
hasLocation(#20086,#20087)
numlines(#20082,1,0,0)
toplevel_parent_xml_node(#20082,#20080)
#20088=*
xmlChars(#20088,"
",#10000,0,0,#10000)
#20089=@"loc,{#10000},1,16,1,16"
locations_default(#20089,#10000,1,16,1,16)
xmllocations(#20088,#20089)
scopes(#20000,0)
#20088=@"script;{#10000},8,39"
toplevels(#20088,4)
#20089=@"loc,{#10000},8,39,8,39"
locations_default(#20089,#10000,8,39,8,39)
hasLocation(#20088,#20089)
#20090=*
xmlChars(#20090,"
",#10000,2,0,#10000)
#20091=@"loc,{#10000},10,8,10,8"
locations_default(#20091,#10000,10,8,10,8)
xmllocations(#20090,#20091)
js_parse_errors(#20090,#20088,"Error: Unterminated regular expression","/foo")
#20091=@"loc,{#10000},8,40,8,40"
locations_default(#20091,#10000,8,40,8,40)
hasLocation(#20090,#20091)
#20092=*
xmlElements(#20092,"html",#10000,1,#10000)
#20093=@"loc,{#10000},2,1,10,7"
locations_default(#20093,#10000,2,1,10,7)
xmllocations(#20092,#20093)
lines(#20092,#20088,"/foo","")
#20093=@"loc,{#10000},8,39,8,42"
locations_default(#20093,#10000,8,39,8,42)
hasLocation(#20092,#20093)
numlines(#20088,1,0,0)
toplevel_parent_xml_node(#20088,#20086)
#20094=*
xmlChars(#20094,"
",#20092,0,0,#10000)
#20095=@"loc,{#10000},2,7,3,2"
locations_default(#20095,#10000,2,7,3,2)
",#10000,0,0,#10000)
#20095=@"loc,{#10000},1,16,1,16"
locations_default(#20095,#10000,1,16,1,16)
xmllocations(#20094,#20095)
#20096=*
xmlChars(#20096,"
",#20092,2,0,#10000)
#20097=@"loc,{#10000},9,10,9,10"
locations_default(#20097,#10000,9,10,9,10)
",#10000,2,0,#10000)
#20097=@"loc,{#10000},10,8,10,8"
locations_default(#20097,#10000,10,8,10,8)
xmllocations(#20096,#20097)
#20098=*
xmlElements(#20098,"body",#20092,1,#10000)
#20099=@"loc,{#10000},3,3,9,9"
locations_default(#20099,#10000,3,3,9,9)
xmlElements(#20098,"html",#10000,1,#10000)
#20099=@"loc,{#10000},2,1,10,7"
locations_default(#20099,#10000,2,1,10,7)
xmllocations(#20098,#20099)
#20100=*
xmlChars(#20100,"
",#20098,0,0,#10000)
#20101=@"loc,{#10000},3,9,4,4"
locations_default(#20101,#10000,3,9,4,4)
",#20098,0,0,#10000)
#20101=@"loc,{#10000},2,7,3,2"
locations_default(#20101,#10000,2,7,3,2)
xmllocations(#20100,#20101)
#20102=*
xmlChars(#20102,"
",#20098,2,0,#10000)
#20103=@"loc,{#10000},4,28,5,4"
locations_default(#20103,#10000,4,28,5,4)
",#20098,2,0,#10000)
#20103=@"loc,{#10000},9,10,9,10"
locations_default(#20103,#10000,9,10,9,10)
xmllocations(#20102,#20103)
#20104=*
xmlChars(#20104,"
",#20098,4,0,#10000)
#20105=@"loc,{#10000},5,33,6,4"
locations_default(#20105,#10000,5,33,6,4)
xmlElements(#20104,"body",#20098,1,#10000)
#20105=@"loc,{#10000},3,3,9,9"
locations_default(#20105,#10000,3,3,9,9)
xmllocations(#20104,#20105)
#20106=*
xmlChars(#20106,"
",#20098,6,0,#10000)
#20107=@"loc,{#10000},6,32,7,4"
locations_default(#20107,#10000,6,32,7,4)
",#20104,0,0,#10000)
#20107=@"loc,{#10000},3,9,4,4"
locations_default(#20107,#10000,3,9,4,4)
xmllocations(#20106,#20107)
#20108=*
xmlChars(#20108,"
",#20098,8,0,#10000)
#20109=@"loc,{#10000},7,36,8,4"
locations_default(#20109,#10000,7,36,8,4)
",#20104,2,0,#10000)
#20109=@"loc,{#10000},4,28,5,4"
locations_default(#20109,#10000,4,28,5,4)
xmllocations(#20108,#20109)
#20110=*
xmlChars(#20110,"
",#20098,10,0,#10000)
#20111=@"loc,{#10000},8,47,9,2"
locations_default(#20111,#10000,8,47,9,2)
",#20104,4,0,#10000)
#20111=@"loc,{#10000},5,33,6,4"
locations_default(#20111,#10000,5,33,6,4)
xmllocations(#20110,#20111)
xmlElements(#20058,"div",#20098,9,#10000)
#20112=@"loc,{#10000},8,5,8,46"
locations_default(#20112,#10000,8,5,8,46)
xmllocations(#20058,#20112)
#20113=*
xmlElements(#20113,"div",#20098,7,#10000)
#20114=@"loc,{#10000},7,5,7,35"
locations_default(#20114,#10000,7,5,7,35)
xmllocations(#20113,#20114)
#20115=*
xmlElements(#20115,"div",#20098,5,#10000)
#20116=@"loc,{#10000},6,5,6,31"
locations_default(#20116,#10000,6,5,6,31)
xmllocations(#20115,#20116)
xmlAttrs(#20042,#20115,"foo","{{#foo}}{{/foo}}/",0,#10000)
#20117=@"loc,{#10000},6,10,6,30"
locations_default(#20117,#10000,6,10,6,30)
xmllocations(#20042,#20117)
#20118=*
xmlElements(#20118,"div",#20098,3,#10000)
#20119=@"loc,{#10000},5,5,5,32"
locations_default(#20119,#10000,5,5,5,32)
xmllocations(#20118,#20119)
xmlAttrs(#20018,#20118,"foo","{{{foo}}}{{/foo}}/",0,#10000)
#20120=@"loc,{#10000},5,10,5,31"
locations_default(#20120,#10000,5,10,5,31)
xmllocations(#20018,#20120)
#20112=*
xmlChars(#20112,"
",#20104,6,0,#10000)
#20113=@"loc,{#10000},6,32,7,4"
locations_default(#20113,#10000,6,32,7,4)
xmllocations(#20112,#20113)
#20114=*
xmlChars(#20114,"
",#20104,8,0,#10000)
#20115=@"loc,{#10000},7,36,8,4"
locations_default(#20115,#10000,7,36,8,4)
xmllocations(#20114,#20115)
#20116=*
xmlChars(#20116,"
",#20104,10,0,#10000)
#20117=@"loc,{#10000},8,47,9,2"
locations_default(#20117,#10000,8,47,9,2)
xmllocations(#20116,#20117)
xmlElements(#20061,"div",#20104,9,#10000)
#20118=@"loc,{#10000},8,5,8,46"
locations_default(#20118,#10000,8,5,8,46)
xmllocations(#20061,#20118)
#20119=*
xmlElements(#20119,"div",#20104,7,#10000)
#20120=@"loc,{#10000},7,5,7,35"
locations_default(#20120,#10000,7,5,7,35)
xmllocations(#20119,#20120)
#20121=*
xmlElements(#20121,"div",#20098,1,#10000)
#20122=@"loc,{#10000},4,5,4,27"
locations_default(#20122,#10000,4,5,4,27)
xmlElements(#20121,"div",#20104,5,#10000)
#20122=@"loc,{#10000},6,5,6,31"
locations_default(#20122,#10000,6,5,6,31)
xmllocations(#20121,#20122)
xmlAttrs(#20002,#20121,"foo","{{foo}}",0,#10000)
#20123=@"loc,{#10000},4,10,4,20"
locations_default(#20123,#10000,4,10,4,20)
xmllocations(#20002,#20123)
xmlAttrs(#20042,#20121,"foo","{{#foo}}{{/foo}}/",0,#10000)
#20123=@"loc,{#10000},6,10,6,30"
locations_default(#20123,#10000,6,10,6,30)
xmllocations(#20042,#20123)
#20124=*
xmlElements(#20124,"div",#20104,3,#10000)
#20125=@"loc,{#10000},5,5,5,32"
locations_default(#20125,#10000,5,5,5,32)
xmllocations(#20124,#20125)
xmlAttrs(#20018,#20124,"foo","{{{foo}}}{{/foo}}/",0,#10000)
#20126=@"loc,{#10000},5,10,5,31"
locations_default(#20126,#10000,5,10,5,31)
xmllocations(#20018,#20126)
#20127=*
xmlElements(#20127,"div",#20104,1,#10000)
#20128=@"loc,{#10000},4,5,4,27"
locations_default(#20128,#10000,4,5,4,27)
xmllocations(#20127,#20128)
xmlAttrs(#20002,#20127,"foo","{{foo}}",0,#10000)
#20129=@"loc,{#10000},4,10,4,20"
locations_default(#20129,#10000,4,10,4,20)
xmllocations(#20002,#20129)
numlines(#10000,10,3,0)
filetype(#10000,"html")

View File

@@ -17,8 +17,8 @@ hasLocation(#20002,#20003)
#20004=*
js_parse_errors(#20004,#20002,"Error: Unexpected token","#!/usr/bin/node
")
#20005=@"loc,{#10000},4,1,4,1"
locations_default(#20005,#10000,4,1,4,1)
#20005=@"loc,{#10000},4,2,4,2"
locations_default(#20005,#10000,4,2,4,2)
hasLocation(#20004,#20005)
#20006=*
lines(#20006,#20002,"","

View File

@@ -24,4 +24,16 @@ class Foo {
this.#privDecl();
new this.#privDecl();
}
}
class C {
#brand;
#method() {}
get #getter() {}
static isC(obj) {
return #brand in obj && #method in obj && #getter in obj;
}
}

View File

@@ -11,6 +11,7 @@ test_ComputedMethods
test_StaticMethods
| points.js:15:3:17:3 | static ... t";\\n } |
| points.js:30:3:32:3 | static ... t";\\n } |
| privateFields.js:36:3:38:3 | static ... bj;\\n } |
| staticConstructor.js:2:3:2:59 | static ... tor"; } |
| staticInitializer.js:12:3:14:3 | static ... 5;\\n } |
test_ClassDefinition_getSuperClass
@@ -19,6 +20,7 @@ test_ClassDefinition_getSuperClass
test_ClassNodeStaticMethod
| points.js:1:1:18:1 | class P ... ;\\n }\\n} | className | points.js:15:19:17:3 | () {\\n ... t";\\n } |
| points.js:20:1:33:1 | class C ... ;\\n }\\n} | className | points.js:30:19:32:3 | () {\\n ... t";\\n } |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | isC | privateFields.js:36:13:38:3 | (obj) { ... bj;\\n } |
| staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | constructor | staticConstructor.js:2:21:2:59 | () { re ... tor"; } |
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | bar | staticInitializer.js:12:13:14:3 | () {\\n ... 5;\\n } |
test_ClassDefinitions
@@ -27,6 +29,7 @@ test_ClassDefinitions
| points.js:1:1:18:1 | class P ... ;\\n }\\n} |
| points.js:20:1:33:1 | class C ... ;\\n }\\n} |
| privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} |
| staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} |
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} |
| tst.js:1:9:4:1 | class { ... */ }\\n} |
@@ -34,6 +37,7 @@ test_ClassDefinitions
| tst.js:11:1:14:1 | class C ... () {}\\n} |
test_AccessorMethods
| points.js:7:3:9:3 | get dis ... y);\\n } |
| privateFields.js:34:3:34:18 | get #getter() {} |
test_Fields
| dataflow.js:5:3:5:17 | #priv = source; | dataflow.js:5:3:5:7 | #priv |
| fields.js:2:3:2:4 | x; | fields.js:2:3:2:3 | x |
@@ -42,6 +46,7 @@ test_Fields
| privateFields.js:3:2:3:12 | #if = "if"; | privateFields.js:3:2:3:4 | #if |
| privateFields.js:19:2:19:13 | #privSecond; | privateFields.js:19:2:19:12 | #privSecond |
| privateFields.js:21:2:21:22 | ["#publ ... "] = 6; | privateFields.js:21:3:21:16 | "#publicField" |
| privateFields.js:30:3:30:9 | #brand; | privateFields.js:30:3:30:8 | #brand |
| staticInitializer.js:2:3:2:15 | static x = 1; | staticInitializer.js:2:10:2:10 | x |
test_ClassDefinition_getName
| dataflow.js:4:2:13:2 | class F ... \\n\\t\\t}\\n\\t} | Foo |
@@ -49,6 +54,7 @@ test_ClassDefinition_getName
| points.js:1:1:18:1 | class P ... ;\\n }\\n} | Point |
| points.js:20:1:33:1 | class C ... ;\\n }\\n} | ColouredPoint |
| privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | Foo |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | C |
| staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | MyClass |
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | MyClass |
| tst.js:1:9:4:1 | class { ... */ }\\n} | A |
@@ -71,6 +77,10 @@ test_MethodDefinitions
| privateFields.js:10:2:12:2 | equals( ... ecl;\\n\\t} | privateFields.js:10:2:10:7 | equals | privateFields.js:10:8:12:2 | (o) {\\n\\t ... ecl;\\n\\t} | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} |
| privateFields.js:14:2:17:2 | writes( ... = 5;\\n\\t} | privateFields.js:14:2:14:7 | writes | privateFields.js:14:8:17:2 | () {\\n\\t\\t ... = 5;\\n\\t} | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} |
| privateFields.js:23:2:26:2 | calls() ... l();\\n\\t} | privateFields.js:23:2:23:6 | calls | privateFields.js:23:7:26:2 | () {\\n\\t\\t ... l();\\n\\t} | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} |
| privateFields.js:29:9:29:8 | constructor() {} | privateFields.js:29:9:29:8 | constructor | privateFields.js:29:9:29:8 | () {} | privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} |
| privateFields.js:32:3:32:14 | #method() {} | privateFields.js:32:3:32:9 | #method | privateFields.js:32:10:32:14 | () {} | privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} |
| privateFields.js:34:3:34:18 | get #getter() {} | privateFields.js:34:7:34:13 | #getter | privateFields.js:34:14:34:18 | () {} | privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} |
| privateFields.js:36:3:38:3 | static ... bj;\\n } | privateFields.js:36:10:36:12 | isC | privateFields.js:36:13:38:3 | (obj) { ... bj;\\n } | privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} |
| staticConstructor.js:1:15:1:14 | constructor() {} | staticConstructor.js:1:15:1:14 | constructor | staticConstructor.js:1:15:1:14 | () {} | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} |
| staticConstructor.js:2:3:2:59 | static ... tor"; } | staticConstructor.js:2:10:2:20 | constructor | staticConstructor.js:2:21:2:59 | () { re ... tor"; } | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} |
| staticInitializer.js:3:3:5:3 | constru ... 2;\\n } | staticInitializer.js:3:3:3:13 | constructor | staticInitializer.js:3:14:5:3 | () {\\n ... 2;\\n } | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} |
@@ -106,6 +116,11 @@ test_getAMember
| privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | privateFields.js:19:2:19:13 | #privSecond; |
| privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | privateFields.js:21:2:21:22 | ["#publ ... "] = 6; |
| privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | privateFields.js:23:2:26:2 | calls() ... l();\\n\\t} |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:29:9:29:8 | constructor() {} |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:30:3:30:9 | #brand; |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:32:3:32:14 | #method() {} |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:34:3:34:18 | get #getter() {} |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:36:3:38:3 | static ... bj;\\n } |
| staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | staticConstructor.js:1:15:1:14 | constructor() {} |
| staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | staticConstructor.js:2:3:2:59 | static ... tor"; } |
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:2:3:2:15 | static x = 1; |
@@ -137,6 +152,10 @@ test_MethodNames
| privateFields.js:10:2:12:2 | equals( ... ecl;\\n\\t} | equals |
| privateFields.js:14:2:17:2 | writes( ... = 5;\\n\\t} | writes |
| privateFields.js:23:2:26:2 | calls() ... l();\\n\\t} | calls |
| privateFields.js:29:9:29:8 | constructor() {} | constructor |
| privateFields.js:32:3:32:14 | #method() {} | #method |
| privateFields.js:34:3:34:18 | get #getter() {} | #getter |
| privateFields.js:36:3:38:3 | static ... bj;\\n } | isC |
| staticConstructor.js:1:15:1:14 | constructor() {} | constructor |
| staticConstructor.js:2:3:2:59 | static ... tor"; } | constructor |
| staticInitializer.js:3:3:5:3 | constru ... 2;\\n } | constructor |
@@ -157,6 +176,7 @@ test_SyntheticConstructors
| dataflow.js:4:12:4:11 | constructor() {} |
| fields.js:1:9:1:8 | constructor() {} |
| privateFields.js:1:11:1:10 | constructor() {} |
| privateFields.js:29:9:29:8 | constructor() {} |
| staticConstructor.js:1:15:1:14 | constructor() {} |
| tst.js:11:9:11:8 | constructor() {} |
test_ConstructorDefinitions
@@ -165,6 +185,7 @@ test_ConstructorDefinitions
| points.js:2:3:5:3 | constru ... y;\\n } |
| points.js:21:3:24:3 | constru ... c;\\n } |
| privateFields.js:1:11:1:10 | constructor() {} |
| privateFields.js:29:9:29:8 | constructor() {} |
| staticConstructor.js:1:15:1:14 | constructor() {} |
| staticInitializer.js:3:3:5:3 | constru ... 2;\\n } |
| tst.js:2:3:2:50 | "constr ... r. */ } |
@@ -176,6 +197,7 @@ test_ClassNodeConstructor
| points.js:1:1:18:1 | class P ... ;\\n }\\n} | points.js:2:14:5:3 | (x, y) ... y;\\n } |
| points.js:20:1:33:1 | class C ... ;\\n }\\n} | points.js:21:14:24:3 | (x, y, ... c;\\n } |
| privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | privateFields.js:1:11:1:10 | () {} |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:29:9:29:8 | () {} |
| staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | staticConstructor.js:1:15:1:14 | () {} |
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:3:14:5:3 | () {\\n ... 2;\\n } |
| tst.js:1:9:4:1 | class { ... */ }\\n} | tst.js:2:16:2:50 | () { /* ... r. */ } |
@@ -190,6 +212,7 @@ test_ClassNodeInstanceMethod
| privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | equals | privateFields.js:10:8:12:2 | (o) {\\n\\t ... ecl;\\n\\t} |
| privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | reads | privateFields.js:4:7:8:2 | () {\\n\\t\\t ... #if;\\n\\t} |
| privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | writes | privateFields.js:14:8:17:2 | () {\\n\\t\\t ... = 5;\\n\\t} |
| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | #method | privateFields.js:32:10:32:14 | () {} |
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | foo | staticInitializer.js:9:6:11:3 | () {\\n ... 4;\\n } |
| tst.js:1:9:4:1 | class { ... */ }\\n} | constructor | tst.js:3:18:3:56 | () { /* ... r. */ } |
| tst.js:11:1:14:1 | class C ... () {}\\n} | m | tst.js:12:4:12:8 | () {} |
@@ -240,6 +263,10 @@ getAccessModifier
| privateFields.js:23:2:26:2 | calls() ... l();\\n\\t} | privateFields.js:23:2:23:6 | calls | Public |
| privateFields.js:24:3:24:16 | this.#privDecl | privateFields.js:24:8:24:16 | #privDecl | Private |
| privateFields.js:25:7:25:20 | this.#privDecl | privateFields.js:25:12:25:20 | #privDecl | Private |
| privateFields.js:29:9:29:8 | constructor() {} | privateFields.js:29:9:29:8 | constructor | Public |
| privateFields.js:32:3:32:14 | #method() {} | privateFields.js:32:3:32:9 | #method | Private |
| privateFields.js:34:3:34:18 | get #getter() {} | privateFields.js:34:7:34:13 | #getter | Private |
| privateFields.js:36:3:38:3 | static ... bj;\\n } | privateFields.js:36:10:36:12 | isC | Public |
| staticConstructor.js:1:15:1:14 | constructor() {} | staticConstructor.js:1:15:1:14 | constructor | Public |
| staticConstructor.js:2:3:2:59 | static ... tor"; } | staticConstructor.js:2:10:2:20 | constructor | Public |
| staticConstructor.js:4:1:4:11 | console.log | staticConstructor.js:4:9:4:11 | log | Public |
@@ -266,3 +293,22 @@ dataflow
staticInitializer
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:6:10:8:3 | {\\n M ... 3;\\n } |
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:15:10:17:3 | {\\n t ... 6;\\n } |
privateIdentifier
| dataflow.js:5:3:5:7 | #priv |
| dataflow.js:7:16:7:20 | #priv |
| privateFields.js:2:2:2:10 | #privDecl |
| privateFields.js:3:2:3:4 | #if |
| privateFields.js:5:18:5:25 | #privUse |
| privateFields.js:7:18:7:20 | #if |
| privateFields.js:11:15:11:23 | #privDecl |
| privateFields.js:11:31:11:39 | #privDecl |
| privateFields.js:15:8:15:16 | #privDecl |
| privateFields.js:19:2:19:12 | #privSecond |
| privateFields.js:24:8:24:16 | #privDecl |
| privateFields.js:25:12:25:20 | #privDecl |
| privateFields.js:30:3:30:8 | #brand |
| privateFields.js:32:3:32:9 | #method |
| privateFields.js:34:7:34:13 | #getter |
| privateFields.js:37:12:37:17 | #brand |
| privateFields.js:37:29:37:35 | #method |
| privateFields.js:37:47:37:53 | #getter |

View File

@@ -74,3 +74,5 @@ query predicate dataflow(DataFlow::Node pred, DataFlow::Node succ) {
}
query BlockStmt staticInitializer(ClassDefinition cd) { result = cd.getAStaticInitializerBlock() }
query Identifier privateIdentifier() { result.getName().matches("#%") }

View File

@@ -1,4 +1,3 @@
| arrows.js:1:5:1:5 | Error: Argument name clash | Error: Argument name clash |
| destructingPrivate.js:4:6:4:6 | Error: Unexpected token | Error: Unexpected token |
| privateMethod.js:2:3:2:3 | Error: Only fields, not methods, can be declared private. | Error: Only fields, not methods, can be declared private. |
| tst.js:2:12:2:12 | Error: Unterminated string constant | Error: Unterminated string constant |

View File

@@ -1,6 +1,6 @@
class C {
#privDecl;
bar() {
{#privDecl} = this;
{#privDecl} = this;
}
}