Skip to content

Commit f2e6a48

Browse files
Add missing reserved words in JSBuilder (hkust-taco#269)
1 parent 898af77 commit f2e6a48

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,21 @@ object JSBuilder:
464464
"final",
465465
"float",
466466
"goto",
467+
"implements",
467468
"int",
468469
"long",
469470
"native",
471+
"package",
472+
"protected",
470473
"short",
474+
"static",
471475
"synchronized",
472476
"throws",
473477
"transient",
474478
"volatile",
479+
// not a keyword, but cannot be declared as identifier in strict mode
480+
"arguments",
481+
"eval",
475482
)
476483

477484
def makeStringLiteral(s: Str): Str =
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
:js
2+
3+
:import PredefJS.mls
4+
//│ Imported 2 member(s)
5+
6+
:global
7+
:sjs
8+
9+
10+
class Foo(arguments)
11+
//│ JS (unsanitized):
12+
//│ let Foo1;
13+
//│ Foo1 = function Foo(arguments2) { return new Foo.class(arguments2); };
14+
//│ Foo1.class = class Foo {
15+
//│ constructor(arguments1) {
16+
//│ this.arguments = arguments1;
17+
//│ }
18+
//│ toString() { return "Foo(" + globalThis.Predef.render(this.arguments) + ")"; }
19+
//│ };
20+
//│ null
21+
22+
23+
class Foo(eval)
24+
//│ JS (unsanitized):
25+
//│ let Foo3;
26+
//│ Foo3 = function Foo(eval2) { return new Foo.class(eval2); };
27+
//│ Foo3.class = class Foo2 {
28+
//│ constructor(eval1) {
29+
//│ this.eval = eval1;
30+
//│ }
31+
//│ toString() { return "Foo(" + globalThis.Predef.render(this.eval) + ")"; }
32+
//│ };
33+
//│ null
34+
35+
36+
class Foo(implements)
37+
//│ JS (unsanitized):
38+
//│ let Foo5;
39+
//│ Foo5 = function Foo(implements2) { return new Foo.class(implements2); };
40+
//│ Foo5.class = class Foo4 {
41+
//│ constructor(implements1) {
42+
//│ this.implements = implements1;
43+
//│ }
44+
//│ toString() { return "Foo(" + globalThis.Predef.render(this.implements) + ")"; }
45+
//│ };
46+
//│ null
47+
48+
49+
class Foo(package)
50+
//│ JS (unsanitized):
51+
//│ let Foo7;
52+
//│ Foo7 = function Foo(package2) { return new Foo.class(package2); };
53+
//│ Foo7.class = class Foo6 {
54+
//│ constructor(package1) {
55+
//│ this.package = package1;
56+
//│ }
57+
//│ toString() { return "Foo(" + globalThis.Predef.render(this.package) + ")"; }
58+
//│ };
59+
//│ null
60+
61+
62+
class Foo(protected)
63+
//│ JS (unsanitized):
64+
//│ let Foo9;
65+
//│ Foo9 = function Foo(protected2) { return new Foo.class(protected2); };
66+
//│ Foo9.class = class Foo8 {
67+
//│ constructor(protected1) {
68+
//│ this.protected = protected1;
69+
//│ }
70+
//│ toString() { return "Foo(" + globalThis.Predef.render(this.protected) + ")"; }
71+
//│ };
72+
//│ null
73+
74+
75+
class Foo(static)
76+
//│ JS (unsanitized):
77+
//│ let Foo11;
78+
//│ Foo11 = function Foo(static2) { return new Foo.class(static2); };
79+
//│ Foo11.class = class Foo10 {
80+
//│ constructor(static1) {
81+
//│ this.static = static1;
82+
//│ }
83+
//│ toString() { return "Foo(" + globalThis.Predef.render(this.static) + ")"; }
84+
//│ };
85+
//│ null

0 commit comments

Comments
 (0)