terser 5.12.1 → 5.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/ast.js CHANGED
@@ -48,23 +48,13 @@ import {
48
48
  } from "./utils/index.js";
49
49
  import { parse } from "./parse.js";
50
50
 
51
- function DEFNODE(type, props, methods, base = AST_Node) {
51
+ function DEFNODE(type, props, ctor, methods, base = AST_Node) {
52
52
  if (!props) props = [];
53
53
  else props = props.split(/\s+/);
54
54
  var self_props = props;
55
55
  if (base && base.PROPS)
56
56
  props = props.concat(base.PROPS);
57
- var code = "return function AST_" + type + "(props){ if (props) { ";
58
- for (var i = props.length; --i >= 0;) {
59
- code += "this." + props[i] + " = props." + props[i] + ";";
60
- }
61
57
  const proto = base && Object.create(base.prototype);
62
- if (proto && proto.initialize || (methods && methods.initialize))
63
- code += "this.initialize();";
64
- code += "}";
65
- code += "this.flags = 0;";
66
- code += "}";
67
- var ctor = new Function(code)();
68
58
  if (proto) {
69
59
  ctor.prototype = proto;
70
60
  ctor.BASE = base;
@@ -78,7 +68,7 @@ function DEFNODE(type, props, methods, base = AST_Node) {
78
68
  if (type) {
79
69
  ctor.prototype.TYPE = ctor.TYPE = type;
80
70
  }
81
- if (methods) for (i in methods) if (HOP(methods, i)) {
71
+ if (methods) for (let i in methods) if (HOP(methods, i)) {
82
72
  if (i[0] === "$") {
83
73
  ctor[i.substr(1)] = methods[i];
84
74
  } else {
@@ -140,7 +130,14 @@ class AST_Token {
140
130
  }
141
131
  }
142
132
 
143
- var AST_Node = DEFNODE("Node", "start end", {
133
+ var AST_Node = DEFNODE("Node", "start end", function AST_Node(props) {
134
+ if (props) {
135
+ this.start = props.start;
136
+ this.end = props.end;
137
+ }
138
+
139
+ this.flags = 0;
140
+ }, {
144
141
  _clone: function(deep) {
145
142
  if (deep) {
146
143
  var self = this.clone();
@@ -171,15 +168,38 @@ var AST_Node = DEFNODE("Node", "start end", {
171
168
 
172
169
  /* -----[ statements ]----- */
173
170
 
174
- var AST_Statement = DEFNODE("Statement", null, {
171
+ var AST_Statement = DEFNODE("Statement", null, function AST_Statement(props) {
172
+ if (props) {
173
+ this.start = props.start;
174
+ this.end = props.end;
175
+ }
176
+
177
+ this.flags = 0;
178
+ }, {
175
179
  $documentation: "Base class of all statements",
176
180
  });
177
181
 
178
- var AST_Debugger = DEFNODE("Debugger", null, {
182
+ var AST_Debugger = DEFNODE("Debugger", null, function AST_Debugger(props) {
183
+ if (props) {
184
+ this.start = props.start;
185
+ this.end = props.end;
186
+ }
187
+
188
+ this.flags = 0;
189
+ }, {
179
190
  $documentation: "Represents a debugger statement",
180
191
  }, AST_Statement);
181
192
 
182
- var AST_Directive = DEFNODE("Directive", "value quote", {
193
+ var AST_Directive = DEFNODE("Directive", "value quote", function AST_Directive(props) {
194
+ if (props) {
195
+ this.value = props.value;
196
+ this.quote = props.quote;
197
+ this.start = props.start;
198
+ this.end = props.end;
199
+ }
200
+
201
+ this.flags = 0;
202
+ }, {
183
203
  $documentation: "Represents a directive, like \"use strict\";",
184
204
  $propdoc: {
185
205
  value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
@@ -187,7 +207,15 @@ var AST_Directive = DEFNODE("Directive", "value quote", {
187
207
  },
188
208
  }, AST_Statement);
189
209
 
190
- var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
210
+ var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", function AST_SimpleStatement(props) {
211
+ if (props) {
212
+ this.body = props.body;
213
+ this.start = props.start;
214
+ this.end = props.end;
215
+ }
216
+
217
+ this.flags = 0;
218
+ }, {
191
219
  $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
192
220
  $propdoc: {
193
221
  body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
@@ -217,7 +245,16 @@ function clone_block_scope(deep) {
217
245
  return clone;
218
246
  }
219
247
 
220
- var AST_Block = DEFNODE("Block", "body block_scope", {
248
+ var AST_Block = DEFNODE("Block", "body block_scope", function AST_Block(props) {
249
+ if (props) {
250
+ this.body = props.body;
251
+ this.block_scope = props.block_scope;
252
+ this.start = props.start;
253
+ this.end = props.end;
254
+ }
255
+
256
+ this.flags = 0;
257
+ }, {
221
258
  $documentation: "A body of statements (usually braced)",
222
259
  $propdoc: {
223
260
  body: "[AST_Statement*] an array of statements",
@@ -235,22 +272,55 @@ var AST_Block = DEFNODE("Block", "body block_scope", {
235
272
  clone: clone_block_scope
236
273
  }, AST_Statement);
237
274
 
238
- var AST_BlockStatement = DEFNODE("BlockStatement", null, {
275
+ var AST_BlockStatement = DEFNODE("BlockStatement", null, function AST_BlockStatement(props) {
276
+ if (props) {
277
+ this.body = props.body;
278
+ this.block_scope = props.block_scope;
279
+ this.start = props.start;
280
+ this.end = props.end;
281
+ }
282
+
283
+ this.flags = 0;
284
+ }, {
239
285
  $documentation: "A block statement",
240
286
  }, AST_Block);
241
287
 
242
- var AST_EmptyStatement = DEFNODE("EmptyStatement", null, {
288
+ var AST_EmptyStatement = DEFNODE("EmptyStatement", null, function AST_EmptyStatement(props) {
289
+ if (props) {
290
+ this.start = props.start;
291
+ this.end = props.end;
292
+ }
293
+
294
+ this.flags = 0;
295
+ }, {
243
296
  $documentation: "The empty statement (empty block or simply a semicolon)"
244
297
  }, AST_Statement);
245
298
 
246
- var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", {
299
+ var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", function AST_StatementWithBody(props) {
300
+ if (props) {
301
+ this.body = props.body;
302
+ this.start = props.start;
303
+ this.end = props.end;
304
+ }
305
+
306
+ this.flags = 0;
307
+ }, {
247
308
  $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
248
309
  $propdoc: {
249
310
  body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
250
311
  }
251
312
  }, AST_Statement);
252
313
 
253
- var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", {
314
+ var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", function AST_LabeledStatement(props) {
315
+ if (props) {
316
+ this.label = props.label;
317
+ this.body = props.body;
318
+ this.start = props.start;
319
+ this.end = props.end;
320
+ }
321
+
322
+ this.flags = 0;
323
+ }, {
254
324
  $documentation: "Statement with a label",
255
325
  $propdoc: {
256
326
  label: "[AST_Label] a label definition"
@@ -282,22 +352,57 @@ var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", {
282
352
  }
283
353
  }, AST_StatementWithBody);
284
354
 
285
- var AST_IterationStatement = DEFNODE("IterationStatement", "block_scope", {
286
- $documentation: "Internal class. All loops inherit from it.",
287
- $propdoc: {
288
- block_scope: "[AST_Scope] the block scope for this iteration statement."
355
+ var AST_IterationStatement = DEFNODE(
356
+ "IterationStatement",
357
+ "block_scope",
358
+ function AST_IterationStatement(props) {
359
+ if (props) {
360
+ this.block_scope = props.block_scope;
361
+ this.body = props.body;
362
+ this.start = props.start;
363
+ this.end = props.end;
364
+ }
365
+
366
+ this.flags = 0;
289
367
  },
290
- clone: clone_block_scope
291
- }, AST_StatementWithBody);
368
+ {
369
+ $documentation: "Internal class. All loops inherit from it.",
370
+ $propdoc: {
371
+ block_scope: "[AST_Scope] the block scope for this iteration statement."
372
+ },
373
+ clone: clone_block_scope
374
+ },
375
+ AST_StatementWithBody
376
+ );
377
+
378
+ var AST_DWLoop = DEFNODE("DWLoop", "condition", function AST_DWLoop(props) {
379
+ if (props) {
380
+ this.condition = props.condition;
381
+ this.block_scope = props.block_scope;
382
+ this.body = props.body;
383
+ this.start = props.start;
384
+ this.end = props.end;
385
+ }
292
386
 
293
- var AST_DWLoop = DEFNODE("DWLoop", "condition", {
387
+ this.flags = 0;
388
+ }, {
294
389
  $documentation: "Base class for do/while statements",
295
390
  $propdoc: {
296
391
  condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
297
392
  }
298
393
  }, AST_IterationStatement);
299
394
 
300
- var AST_Do = DEFNODE("Do", null, {
395
+ var AST_Do = DEFNODE("Do", null, function AST_Do(props) {
396
+ if (props) {
397
+ this.condition = props.condition;
398
+ this.block_scope = props.block_scope;
399
+ this.body = props.body;
400
+ this.start = props.start;
401
+ this.end = props.end;
402
+ }
403
+
404
+ this.flags = 0;
405
+ }, {
301
406
  $documentation: "A `do` statement",
302
407
  _walk: function(visitor) {
303
408
  return visitor._visit(this, function() {
@@ -311,7 +416,17 @@ var AST_Do = DEFNODE("Do", null, {
311
416
  }
312
417
  }, AST_DWLoop);
313
418
 
314
- var AST_While = DEFNODE("While", null, {
419
+ var AST_While = DEFNODE("While", null, function AST_While(props) {
420
+ if (props) {
421
+ this.condition = props.condition;
422
+ this.block_scope = props.block_scope;
423
+ this.body = props.body;
424
+ this.start = props.start;
425
+ this.end = props.end;
426
+ }
427
+
428
+ this.flags = 0;
429
+ }, {
315
430
  $documentation: "A `while` statement",
316
431
  _walk: function(visitor) {
317
432
  return visitor._visit(this, function() {
@@ -325,7 +440,19 @@ var AST_While = DEFNODE("While", null, {
325
440
  },
326
441
  }, AST_DWLoop);
327
442
 
328
- var AST_For = DEFNODE("For", "init condition step", {
443
+ var AST_For = DEFNODE("For", "init condition step", function AST_For(props) {
444
+ if (props) {
445
+ this.init = props.init;
446
+ this.condition = props.condition;
447
+ this.step = props.step;
448
+ this.block_scope = props.block_scope;
449
+ this.body = props.body;
450
+ this.start = props.start;
451
+ this.end = props.end;
452
+ }
453
+
454
+ this.flags = 0;
455
+ }, {
329
456
  $documentation: "A `for` statement",
330
457
  $propdoc: {
331
458
  init: "[AST_Node?] the `for` initialization code, or null if empty",
@@ -348,7 +475,18 @@ var AST_For = DEFNODE("For", "init condition step", {
348
475
  },
349
476
  }, AST_IterationStatement);
350
477
 
351
- var AST_ForIn = DEFNODE("ForIn", "init object", {
478
+ var AST_ForIn = DEFNODE("ForIn", "init object", function AST_ForIn(props) {
479
+ if (props) {
480
+ this.init = props.init;
481
+ this.object = props.object;
482
+ this.block_scope = props.block_scope;
483
+ this.body = props.body;
484
+ this.start = props.start;
485
+ this.end = props.end;
486
+ }
487
+
488
+ this.flags = 0;
489
+ }, {
352
490
  $documentation: "A `for ... in` statement",
353
491
  $propdoc: {
354
492
  init: "[AST_Node] the `for/in` initialization code",
@@ -368,11 +506,32 @@ var AST_ForIn = DEFNODE("ForIn", "init object", {
368
506
  },
369
507
  }, AST_IterationStatement);
370
508
 
371
- var AST_ForOf = DEFNODE("ForOf", "await", {
509
+ var AST_ForOf = DEFNODE("ForOf", "await", function AST_ForOf(props) {
510
+ if (props) {
511
+ this.await = props.await;
512
+ this.init = props.init;
513
+ this.object = props.object;
514
+ this.block_scope = props.block_scope;
515
+ this.body = props.body;
516
+ this.start = props.start;
517
+ this.end = props.end;
518
+ }
519
+
520
+ this.flags = 0;
521
+ }, {
372
522
  $documentation: "A `for ... of` statement",
373
523
  }, AST_ForIn);
374
524
 
375
- var AST_With = DEFNODE("With", "expression", {
525
+ var AST_With = DEFNODE("With", "expression", function AST_With(props) {
526
+ if (props) {
527
+ this.expression = props.expression;
528
+ this.body = props.body;
529
+ this.start = props.start;
530
+ this.end = props.end;
531
+ }
532
+
533
+ this.flags = 0;
534
+ }, {
376
535
  $documentation: "A `with` statement",
377
536
  $propdoc: {
378
537
  expression: "[AST_Node] the `with` expression"
@@ -391,43 +550,80 @@ var AST_With = DEFNODE("With", "expression", {
391
550
 
392
551
  /* -----[ scope and functions ]----- */
393
552
 
394
- var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent_scope enclosed cname", {
395
- $documentation: "Base class for all statements introducing a lexical scope",
396
- $propdoc: {
397
- variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
398
- uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
399
- uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
400
- parent_scope: "[AST_Scope?/S] link to the parent scope",
401
- enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
402
- cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
403
- },
404
- get_defun_scope: function() {
405
- var self = this;
406
- while (self.is_block_scope()) {
407
- self = self.parent_scope;
553
+ var AST_Scope = DEFNODE(
554
+ "Scope",
555
+ "variables uses_with uses_eval parent_scope enclosed cname",
556
+ function AST_Scope(props) {
557
+ if (props) {
558
+ this.variables = props.variables;
559
+ this.uses_with = props.uses_with;
560
+ this.uses_eval = props.uses_eval;
561
+ this.parent_scope = props.parent_scope;
562
+ this.enclosed = props.enclosed;
563
+ this.cname = props.cname;
564
+ this.body = props.body;
565
+ this.block_scope = props.block_scope;
566
+ this.start = props.start;
567
+ this.end = props.end;
408
568
  }
409
- return self;
410
- },
411
- clone: function(deep, toplevel) {
412
- var node = this._clone(deep);
413
- if (deep && this.variables && toplevel && !this._block_scope) {
414
- node.figure_out_scope({}, {
415
- toplevel: toplevel,
416
- parent_scope: this.parent_scope
417
- });
418
- } else {
419
- if (this.variables) node.variables = new Map(this.variables);
420
- if (this.enclosed) node.enclosed = this.enclosed.slice();
421
- if (this._block_scope) node._block_scope = this._block_scope;
569
+
570
+ this.flags = 0;
571
+ },
572
+ {
573
+ $documentation: "Base class for all statements introducing a lexical scope",
574
+ $propdoc: {
575
+ variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
576
+ uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
577
+ uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
578
+ parent_scope: "[AST_Scope?/S] link to the parent scope",
579
+ enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
580
+ cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
581
+ },
582
+ get_defun_scope: function() {
583
+ var self = this;
584
+ while (self.is_block_scope()) {
585
+ self = self.parent_scope;
586
+ }
587
+ return self;
588
+ },
589
+ clone: function(deep, toplevel) {
590
+ var node = this._clone(deep);
591
+ if (deep && this.variables && toplevel && !this._block_scope) {
592
+ node.figure_out_scope({}, {
593
+ toplevel: toplevel,
594
+ parent_scope: this.parent_scope
595
+ });
596
+ } else {
597
+ if (this.variables) node.variables = new Map(this.variables);
598
+ if (this.enclosed) node.enclosed = this.enclosed.slice();
599
+ if (this._block_scope) node._block_scope = this._block_scope;
600
+ }
601
+ return node;
602
+ },
603
+ pinned: function() {
604
+ return this.uses_eval || this.uses_with;
422
605
  }
423
- return node;
424
606
  },
425
- pinned: function() {
426
- return this.uses_eval || this.uses_with;
607
+ AST_Block
608
+ );
609
+
610
+ var AST_Toplevel = DEFNODE("Toplevel", "globals", function AST_Toplevel(props) {
611
+ if (props) {
612
+ this.globals = props.globals;
613
+ this.variables = props.variables;
614
+ this.uses_with = props.uses_with;
615
+ this.uses_eval = props.uses_eval;
616
+ this.parent_scope = props.parent_scope;
617
+ this.enclosed = props.enclosed;
618
+ this.cname = props.cname;
619
+ this.body = props.body;
620
+ this.block_scope = props.block_scope;
621
+ this.start = props.start;
622
+ this.end = props.end;
427
623
  }
428
- }, AST_Block);
429
624
 
430
- var AST_Toplevel = DEFNODE("Toplevel", "globals", {
625
+ this.flags = 0;
626
+ }, {
431
627
  $documentation: "The toplevel scope",
432
628
  $propdoc: {
433
629
  globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
@@ -462,7 +658,15 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", {
462
658
  }
463
659
  }, AST_Scope);
464
660
 
465
- var AST_Expansion = DEFNODE("Expansion", "expression", {
661
+ var AST_Expansion = DEFNODE("Expansion", "expression", function AST_Expansion(props) {
662
+ if (props) {
663
+ this.expression = props.expression;
664
+ this.start = props.start;
665
+ this.end = props.end;
666
+ }
667
+
668
+ this.flags = 0;
669
+ }, {
466
670
  $documentation: "An expandible argument, such as ...rest, a splat, such as [1,2,...all], or an expansion in a variable declaration, such as var [first, ...rest] = list",
467
671
  $propdoc: {
468
672
  expression: "[AST_Node] the thing to be expanded"
@@ -477,80 +681,195 @@ var AST_Expansion = DEFNODE("Expansion", "expression", {
477
681
  },
478
682
  });
479
683
 
480
- var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments is_generator async", {
481
- $documentation: "Base class for functions",
482
- $propdoc: {
483
- name: "[AST_SymbolDeclaration?] the name of this function",
484
- argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
485
- uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
486
- is_generator: "[boolean] is this a generator method",
487
- async: "[boolean] is this method async",
488
- },
489
- args_as_names: function () {
490
- var out = [];
491
- for (var i = 0; i < this.argnames.length; i++) {
492
- if (this.argnames[i] instanceof AST_Destructuring) {
493
- out.push(...this.argnames[i].all_symbols());
494
- } else {
495
- out.push(this.argnames[i]);
496
- }
684
+ var AST_Lambda = DEFNODE(
685
+ "Lambda",
686
+ "name argnames uses_arguments is_generator async",
687
+ function AST_Lambda(props) {
688
+ if (props) {
689
+ this.name = props.name;
690
+ this.argnames = props.argnames;
691
+ this.uses_arguments = props.uses_arguments;
692
+ this.is_generator = props.is_generator;
693
+ this.async = props.async;
694
+ this.variables = props.variables;
695
+ this.uses_with = props.uses_with;
696
+ this.uses_eval = props.uses_eval;
697
+ this.parent_scope = props.parent_scope;
698
+ this.enclosed = props.enclosed;
699
+ this.cname = props.cname;
700
+ this.body = props.body;
701
+ this.block_scope = props.block_scope;
702
+ this.start = props.start;
703
+ this.end = props.end;
497
704
  }
498
- return out;
705
+
706
+ this.flags = 0;
499
707
  },
500
- _walk: function(visitor) {
501
- return visitor._visit(this, function() {
502
- if (this.name) this.name._walk(visitor);
503
- var argnames = this.argnames;
504
- for (var i = 0, len = argnames.length; i < len; i++) {
505
- argnames[i]._walk(visitor);
708
+ {
709
+ $documentation: "Base class for functions",
710
+ $propdoc: {
711
+ name: "[AST_SymbolDeclaration?] the name of this function",
712
+ argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
713
+ uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
714
+ is_generator: "[boolean] is this a generator method",
715
+ async: "[boolean] is this method async",
716
+ },
717
+ args_as_names: function () {
718
+ var out = [];
719
+ for (var i = 0; i < this.argnames.length; i++) {
720
+ if (this.argnames[i] instanceof AST_Destructuring) {
721
+ out.push(...this.argnames[i].all_symbols());
722
+ } else {
723
+ out.push(this.argnames[i]);
724
+ }
506
725
  }
507
- walk_body(this, visitor);
508
- });
509
- },
510
- _children_backwards(push) {
511
- let i = this.body.length;
512
- while (i--) push(this.body[i]);
726
+ return out;
727
+ },
728
+ _walk: function(visitor) {
729
+ return visitor._visit(this, function() {
730
+ if (this.name) this.name._walk(visitor);
731
+ var argnames = this.argnames;
732
+ for (var i = 0, len = argnames.length; i < len; i++) {
733
+ argnames[i]._walk(visitor);
734
+ }
735
+ walk_body(this, visitor);
736
+ });
737
+ },
738
+ _children_backwards(push) {
739
+ let i = this.body.length;
740
+ while (i--) push(this.body[i]);
513
741
 
514
- i = this.argnames.length;
515
- while (i--) push(this.argnames[i]);
742
+ i = this.argnames.length;
743
+ while (i--) push(this.argnames[i]);
516
744
 
517
- if (this.name) push(this.name);
518
- },
519
- is_braceless() {
520
- return this.body[0] instanceof AST_Return && this.body[0].value;
521
- },
522
- // Default args and expansion don't count, so .argnames.length doesn't cut it
523
- length_property() {
524
- let length = 0;
745
+ if (this.name) push(this.name);
746
+ },
747
+ is_braceless() {
748
+ return this.body[0] instanceof AST_Return && this.body[0].value;
749
+ },
750
+ // Default args and expansion don't count, so .argnames.length doesn't cut it
751
+ length_property() {
752
+ let length = 0;
525
753
 
526
- for (const arg of this.argnames) {
527
- if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
528
- length++;
754
+ for (const arg of this.argnames) {
755
+ if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
756
+ length++;
757
+ }
529
758
  }
530
- }
531
759
 
532
- return length;
760
+ return length;
761
+ }
762
+ },
763
+ AST_Scope
764
+ );
765
+
766
+ var AST_Accessor = DEFNODE("Accessor", null, function AST_Accessor(props) {
767
+ if (props) {
768
+ this.name = props.name;
769
+ this.argnames = props.argnames;
770
+ this.uses_arguments = props.uses_arguments;
771
+ this.is_generator = props.is_generator;
772
+ this.async = props.async;
773
+ this.variables = props.variables;
774
+ this.uses_with = props.uses_with;
775
+ this.uses_eval = props.uses_eval;
776
+ this.parent_scope = props.parent_scope;
777
+ this.enclosed = props.enclosed;
778
+ this.cname = props.cname;
779
+ this.body = props.body;
780
+ this.block_scope = props.block_scope;
781
+ this.start = props.start;
782
+ this.end = props.end;
533
783
  }
534
- }, AST_Scope);
535
784
 
536
- var AST_Accessor = DEFNODE("Accessor", null, {
785
+ this.flags = 0;
786
+ }, {
537
787
  $documentation: "A setter/getter function. The `name` property is always null."
538
788
  }, AST_Lambda);
539
789
 
540
- var AST_Function = DEFNODE("Function", null, {
790
+ var AST_Function = DEFNODE("Function", null, function AST_Function(props) {
791
+ if (props) {
792
+ this.name = props.name;
793
+ this.argnames = props.argnames;
794
+ this.uses_arguments = props.uses_arguments;
795
+ this.is_generator = props.is_generator;
796
+ this.async = props.async;
797
+ this.variables = props.variables;
798
+ this.uses_with = props.uses_with;
799
+ this.uses_eval = props.uses_eval;
800
+ this.parent_scope = props.parent_scope;
801
+ this.enclosed = props.enclosed;
802
+ this.cname = props.cname;
803
+ this.body = props.body;
804
+ this.block_scope = props.block_scope;
805
+ this.start = props.start;
806
+ this.end = props.end;
807
+ }
808
+
809
+ this.flags = 0;
810
+ }, {
541
811
  $documentation: "A function expression"
542
812
  }, AST_Lambda);
543
813
 
544
- var AST_Arrow = DEFNODE("Arrow", null, {
814
+ var AST_Arrow = DEFNODE("Arrow", null, function AST_Arrow(props) {
815
+ if (props) {
816
+ this.name = props.name;
817
+ this.argnames = props.argnames;
818
+ this.uses_arguments = props.uses_arguments;
819
+ this.is_generator = props.is_generator;
820
+ this.async = props.async;
821
+ this.variables = props.variables;
822
+ this.uses_with = props.uses_with;
823
+ this.uses_eval = props.uses_eval;
824
+ this.parent_scope = props.parent_scope;
825
+ this.enclosed = props.enclosed;
826
+ this.cname = props.cname;
827
+ this.body = props.body;
828
+ this.block_scope = props.block_scope;
829
+ this.start = props.start;
830
+ this.end = props.end;
831
+ }
832
+
833
+ this.flags = 0;
834
+ }, {
545
835
  $documentation: "An ES6 Arrow function ((a) => b)"
546
836
  }, AST_Lambda);
547
837
 
548
- var AST_Defun = DEFNODE("Defun", null, {
838
+ var AST_Defun = DEFNODE("Defun", null, function AST_Defun(props) {
839
+ if (props) {
840
+ this.name = props.name;
841
+ this.argnames = props.argnames;
842
+ this.uses_arguments = props.uses_arguments;
843
+ this.is_generator = props.is_generator;
844
+ this.async = props.async;
845
+ this.variables = props.variables;
846
+ this.uses_with = props.uses_with;
847
+ this.uses_eval = props.uses_eval;
848
+ this.parent_scope = props.parent_scope;
849
+ this.enclosed = props.enclosed;
850
+ this.cname = props.cname;
851
+ this.body = props.body;
852
+ this.block_scope = props.block_scope;
853
+ this.start = props.start;
854
+ this.end = props.end;
855
+ }
856
+
857
+ this.flags = 0;
858
+ }, {
549
859
  $documentation: "A function definition"
550
860
  }, AST_Lambda);
551
861
 
552
862
  /* -----[ DESTRUCTURING ]----- */
553
- var AST_Destructuring = DEFNODE("Destructuring", "names is_array", {
863
+ var AST_Destructuring = DEFNODE("Destructuring", "names is_array", function AST_Destructuring(props) {
864
+ if (props) {
865
+ this.names = props.names;
866
+ this.is_array = props.is_array;
867
+ this.start = props.start;
868
+ this.end = props.end;
869
+ }
870
+
871
+ this.flags = 0;
872
+ }, {
554
873
  $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
555
874
  $propdoc: {
556
875
  "names": "[AST_Node*] Array of properties or elements",
@@ -578,25 +897,47 @@ var AST_Destructuring = DEFNODE("Destructuring", "names is_array", {
578
897
  }
579
898
  });
580
899
 
581
- var AST_PrefixedTemplateString = DEFNODE("PrefixedTemplateString", "template_string prefix", {
582
- $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
583
- $propdoc: {
584
- template_string: "[AST_TemplateString] The template string",
585
- prefix: "[AST_Node] The prefix, which will get called."
586
- },
587
- _walk: function(visitor) {
588
- return visitor._visit(this, function () {
589
- this.prefix._walk(visitor);
590
- this.template_string._walk(visitor);
591
- });
592
- },
593
- _children_backwards(push) {
594
- push(this.template_string);
595
- push(this.prefix);
900
+ var AST_PrefixedTemplateString = DEFNODE(
901
+ "PrefixedTemplateString",
902
+ "template_string prefix",
903
+ function AST_PrefixedTemplateString(props) {
904
+ if (props) {
905
+ this.template_string = props.template_string;
906
+ this.prefix = props.prefix;
907
+ this.start = props.start;
908
+ this.end = props.end;
909
+ }
910
+
911
+ this.flags = 0;
596
912
  },
597
- });
913
+ {
914
+ $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
915
+ $propdoc: {
916
+ template_string: "[AST_TemplateString] The template string",
917
+ prefix: "[AST_Node] The prefix, which will get called."
918
+ },
919
+ _walk: function(visitor) {
920
+ return visitor._visit(this, function () {
921
+ this.prefix._walk(visitor);
922
+ this.template_string._walk(visitor);
923
+ });
924
+ },
925
+ _children_backwards(push) {
926
+ push(this.template_string);
927
+ push(this.prefix);
928
+ },
929
+ }
930
+ );
598
931
 
599
- var AST_TemplateString = DEFNODE("TemplateString", "segments", {
932
+ var AST_TemplateString = DEFNODE("TemplateString", "segments", function AST_TemplateString(props) {
933
+ if (props) {
934
+ this.segments = props.segments;
935
+ this.start = props.start;
936
+ this.end = props.end;
937
+ }
938
+
939
+ this.flags = 0;
940
+ }, {
600
941
  $documentation: "A template string literal",
601
942
  $propdoc: {
602
943
  segments: "[AST_Node*] One or more segments, starting with AST_TemplateSegment. AST_Node may follow AST_TemplateSegment, but each AST_Node must be followed by AST_TemplateSegment."
@@ -614,7 +955,16 @@ var AST_TemplateString = DEFNODE("TemplateString", "segments", {
614
955
  }
615
956
  });
616
957
 
617
- var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", {
958
+ var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", function AST_TemplateSegment(props) {
959
+ if (props) {
960
+ this.value = props.value;
961
+ this.raw = props.raw;
962
+ this.start = props.start;
963
+ this.end = props.end;
964
+ }
965
+
966
+ this.flags = 0;
967
+ }, {
618
968
  $documentation: "A segment of a template string literal",
619
969
  $propdoc: {
620
970
  value: "Content of the segment",
@@ -624,11 +974,26 @@ var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", {
624
974
 
625
975
  /* -----[ JUMPS ]----- */
626
976
 
627
- var AST_Jump = DEFNODE("Jump", null, {
977
+ var AST_Jump = DEFNODE("Jump", null, function AST_Jump(props) {
978
+ if (props) {
979
+ this.start = props.start;
980
+ this.end = props.end;
981
+ }
982
+
983
+ this.flags = 0;
984
+ }, {
628
985
  $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
629
986
  }, AST_Statement);
630
987
 
631
- var AST_Exit = DEFNODE("Exit", "value", {
988
+ var AST_Exit = DEFNODE("Exit", "value", function AST_Exit(props) {
989
+ if (props) {
990
+ this.value = props.value;
991
+ this.start = props.start;
992
+ this.end = props.end;
993
+ }
994
+
995
+ this.flags = 0;
996
+ }, {
632
997
  $documentation: "Base class for “exits” (`return` and `throw`)",
633
998
  $propdoc: {
634
999
  value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
@@ -643,15 +1008,39 @@ var AST_Exit = DEFNODE("Exit", "value", {
643
1008
  },
644
1009
  }, AST_Jump);
645
1010
 
646
- var AST_Return = DEFNODE("Return", null, {
1011
+ var AST_Return = DEFNODE("Return", null, function AST_Return(props) {
1012
+ if (props) {
1013
+ this.value = props.value;
1014
+ this.start = props.start;
1015
+ this.end = props.end;
1016
+ }
1017
+
1018
+ this.flags = 0;
1019
+ }, {
647
1020
  $documentation: "A `return` statement"
648
1021
  }, AST_Exit);
649
1022
 
650
- var AST_Throw = DEFNODE("Throw", null, {
1023
+ var AST_Throw = DEFNODE("Throw", null, function AST_Throw(props) {
1024
+ if (props) {
1025
+ this.value = props.value;
1026
+ this.start = props.start;
1027
+ this.end = props.end;
1028
+ }
1029
+
1030
+ this.flags = 0;
1031
+ }, {
651
1032
  $documentation: "A `throw` statement"
652
1033
  }, AST_Exit);
653
1034
 
654
- var AST_LoopControl = DEFNODE("LoopControl", "label", {
1035
+ var AST_LoopControl = DEFNODE("LoopControl", "label", function AST_LoopControl(props) {
1036
+ if (props) {
1037
+ this.label = props.label;
1038
+ this.start = props.start;
1039
+ this.end = props.end;
1040
+ }
1041
+
1042
+ this.flags = 0;
1043
+ }, {
655
1044
  $documentation: "Base class for loop control statements (`break` and `continue`)",
656
1045
  $propdoc: {
657
1046
  label: "[AST_LabelRef?] the label, or null if none",
@@ -666,15 +1055,39 @@ var AST_LoopControl = DEFNODE("LoopControl", "label", {
666
1055
  },
667
1056
  }, AST_Jump);
668
1057
 
669
- var AST_Break = DEFNODE("Break", null, {
1058
+ var AST_Break = DEFNODE("Break", null, function AST_Break(props) {
1059
+ if (props) {
1060
+ this.label = props.label;
1061
+ this.start = props.start;
1062
+ this.end = props.end;
1063
+ }
1064
+
1065
+ this.flags = 0;
1066
+ }, {
670
1067
  $documentation: "A `break` statement"
671
1068
  }, AST_LoopControl);
672
1069
 
673
- var AST_Continue = DEFNODE("Continue", null, {
1070
+ var AST_Continue = DEFNODE("Continue", null, function AST_Continue(props) {
1071
+ if (props) {
1072
+ this.label = props.label;
1073
+ this.start = props.start;
1074
+ this.end = props.end;
1075
+ }
1076
+
1077
+ this.flags = 0;
1078
+ }, {
674
1079
  $documentation: "A `continue` statement"
675
1080
  }, AST_LoopControl);
676
1081
 
677
- var AST_Await = DEFNODE("Await", "expression", {
1082
+ var AST_Await = DEFNODE("Await", "expression", function AST_Await(props) {
1083
+ if (props) {
1084
+ this.expression = props.expression;
1085
+ this.start = props.start;
1086
+ this.end = props.end;
1087
+ }
1088
+
1089
+ this.flags = 0;
1090
+ }, {
678
1091
  $documentation: "An `await` statement",
679
1092
  $propdoc: {
680
1093
  expression: "[AST_Node] the mandatory expression being awaited",
@@ -689,7 +1102,16 @@ var AST_Await = DEFNODE("Await", "expression", {
689
1102
  },
690
1103
  });
691
1104
 
692
- var AST_Yield = DEFNODE("Yield", "expression is_star", {
1105
+ var AST_Yield = DEFNODE("Yield", "expression is_star", function AST_Yield(props) {
1106
+ if (props) {
1107
+ this.expression = props.expression;
1108
+ this.is_star = props.is_star;
1109
+ this.start = props.start;
1110
+ this.end = props.end;
1111
+ }
1112
+
1113
+ this.flags = 0;
1114
+ }, {
693
1115
  $documentation: "A `yield` statement",
694
1116
  $propdoc: {
695
1117
  expression: "[AST_Node?] the value returned or thrown by this statement; could be null (representing undefined) but only when is_star is set to false",
@@ -707,7 +1129,17 @@ var AST_Yield = DEFNODE("Yield", "expression is_star", {
707
1129
 
708
1130
  /* -----[ IF ]----- */
709
1131
 
710
- var AST_If = DEFNODE("If", "condition alternative", {
1132
+ var AST_If = DEFNODE("If", "condition alternative", function AST_If(props) {
1133
+ if (props) {
1134
+ this.condition = props.condition;
1135
+ this.alternative = props.alternative;
1136
+ this.body = props.body;
1137
+ this.start = props.start;
1138
+ this.end = props.end;
1139
+ }
1140
+
1141
+ this.flags = 0;
1142
+ }, {
711
1143
  $documentation: "A `if` statement",
712
1144
  $propdoc: {
713
1145
  condition: "[AST_Node] the `if` condition",
@@ -731,7 +1163,17 @@ var AST_If = DEFNODE("If", "condition alternative", {
731
1163
 
732
1164
  /* -----[ SWITCH ]----- */
733
1165
 
734
- var AST_Switch = DEFNODE("Switch", "expression", {
1166
+ var AST_Switch = DEFNODE("Switch", "expression", function AST_Switch(props) {
1167
+ if (props) {
1168
+ this.expression = props.expression;
1169
+ this.body = props.body;
1170
+ this.block_scope = props.block_scope;
1171
+ this.start = props.start;
1172
+ this.end = props.end;
1173
+ }
1174
+
1175
+ this.flags = 0;
1176
+ }, {
735
1177
  $documentation: "A `switch` statement",
736
1178
  $propdoc: {
737
1179
  expression: "[AST_Node] the `switch` “discriminant”"
@@ -749,15 +1191,43 @@ var AST_Switch = DEFNODE("Switch", "expression", {
749
1191
  }
750
1192
  }, AST_Block);
751
1193
 
752
- var AST_SwitchBranch = DEFNODE("SwitchBranch", null, {
1194
+ var AST_SwitchBranch = DEFNODE("SwitchBranch", null, function AST_SwitchBranch(props) {
1195
+ if (props) {
1196
+ this.body = props.body;
1197
+ this.block_scope = props.block_scope;
1198
+ this.start = props.start;
1199
+ this.end = props.end;
1200
+ }
1201
+
1202
+ this.flags = 0;
1203
+ }, {
753
1204
  $documentation: "Base class for `switch` branches",
754
1205
  }, AST_Block);
755
1206
 
756
- var AST_Default = DEFNODE("Default", null, {
1207
+ var AST_Default = DEFNODE("Default", null, function AST_Default(props) {
1208
+ if (props) {
1209
+ this.body = props.body;
1210
+ this.block_scope = props.block_scope;
1211
+ this.start = props.start;
1212
+ this.end = props.end;
1213
+ }
1214
+
1215
+ this.flags = 0;
1216
+ }, {
757
1217
  $documentation: "A `default` switch branch",
758
1218
  }, AST_SwitchBranch);
759
1219
 
760
- var AST_Case = DEFNODE("Case", "expression", {
1220
+ var AST_Case = DEFNODE("Case", "expression", function AST_Case(props) {
1221
+ if (props) {
1222
+ this.expression = props.expression;
1223
+ this.body = props.body;
1224
+ this.block_scope = props.block_scope;
1225
+ this.start = props.start;
1226
+ this.end = props.end;
1227
+ }
1228
+
1229
+ this.flags = 0;
1230
+ }, {
761
1231
  $documentation: "A `case` switch branch",
762
1232
  $propdoc: {
763
1233
  expression: "[AST_Node] the `case` expression"
@@ -777,7 +1247,18 @@ var AST_Case = DEFNODE("Case", "expression", {
777
1247
 
778
1248
  /* -----[ EXCEPTIONS ]----- */
779
1249
 
780
- var AST_Try = DEFNODE("Try", "bcatch bfinally", {
1250
+ var AST_Try = DEFNODE("Try", "bcatch bfinally", function AST_Try(props) {
1251
+ if (props) {
1252
+ this.bcatch = props.bcatch;
1253
+ this.bfinally = props.bfinally;
1254
+ this.body = props.body;
1255
+ this.block_scope = props.block_scope;
1256
+ this.start = props.start;
1257
+ this.end = props.end;
1258
+ }
1259
+
1260
+ this.flags = 0;
1261
+ }, {
781
1262
  $documentation: "A `try` statement",
782
1263
  $propdoc: {
783
1264
  bcatch: "[AST_Catch?] the catch block, or null if not present",
@@ -798,7 +1279,17 @@ var AST_Try = DEFNODE("Try", "bcatch bfinally", {
798
1279
  },
799
1280
  }, AST_Block);
800
1281
 
801
- var AST_Catch = DEFNODE("Catch", "argname", {
1282
+ var AST_Catch = DEFNODE("Catch", "argname", function AST_Catch(props) {
1283
+ if (props) {
1284
+ this.argname = props.argname;
1285
+ this.body = props.body;
1286
+ this.block_scope = props.block_scope;
1287
+ this.start = props.start;
1288
+ this.end = props.end;
1289
+ }
1290
+
1291
+ this.flags = 0;
1292
+ }, {
802
1293
  $documentation: "A `catch` node; only makes sense as part of a `try` statement",
803
1294
  $propdoc: {
804
1295
  argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
@@ -816,13 +1307,30 @@ var AST_Catch = DEFNODE("Catch", "argname", {
816
1307
  },
817
1308
  }, AST_Block);
818
1309
 
819
- var AST_Finally = DEFNODE("Finally", null, {
1310
+ var AST_Finally = DEFNODE("Finally", null, function AST_Finally(props) {
1311
+ if (props) {
1312
+ this.body = props.body;
1313
+ this.block_scope = props.block_scope;
1314
+ this.start = props.start;
1315
+ this.end = props.end;
1316
+ }
1317
+
1318
+ this.flags = 0;
1319
+ }, {
820
1320
  $documentation: "A `finally` node; only makes sense as part of a `try` statement"
821
1321
  }, AST_Block);
822
1322
 
823
1323
  /* -----[ VAR/CONST ]----- */
824
1324
 
825
- var AST_Definitions = DEFNODE("Definitions", "definitions", {
1325
+ var AST_Definitions = DEFNODE("Definitions", "definitions", function AST_Definitions(props) {
1326
+ if (props) {
1327
+ this.definitions = props.definitions;
1328
+ this.start = props.start;
1329
+ this.end = props.end;
1330
+ }
1331
+
1332
+ this.flags = 0;
1333
+ }, {
826
1334
  $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
827
1335
  $propdoc: {
828
1336
  definitions: "[AST_VarDef*] array of variable definitions"
@@ -841,19 +1349,52 @@ var AST_Definitions = DEFNODE("Definitions", "definitions", {
841
1349
  },
842
1350
  }, AST_Statement);
843
1351
 
844
- var AST_Var = DEFNODE("Var", null, {
1352
+ var AST_Var = DEFNODE("Var", null, function AST_Var(props) {
1353
+ if (props) {
1354
+ this.definitions = props.definitions;
1355
+ this.start = props.start;
1356
+ this.end = props.end;
1357
+ }
1358
+
1359
+ this.flags = 0;
1360
+ }, {
845
1361
  $documentation: "A `var` statement"
846
1362
  }, AST_Definitions);
847
1363
 
848
- var AST_Let = DEFNODE("Let", null, {
1364
+ var AST_Let = DEFNODE("Let", null, function AST_Let(props) {
1365
+ if (props) {
1366
+ this.definitions = props.definitions;
1367
+ this.start = props.start;
1368
+ this.end = props.end;
1369
+ }
1370
+
1371
+ this.flags = 0;
1372
+ }, {
849
1373
  $documentation: "A `let` statement"
850
1374
  }, AST_Definitions);
851
1375
 
852
- var AST_Const = DEFNODE("Const", null, {
1376
+ var AST_Const = DEFNODE("Const", null, function AST_Const(props) {
1377
+ if (props) {
1378
+ this.definitions = props.definitions;
1379
+ this.start = props.start;
1380
+ this.end = props.end;
1381
+ }
1382
+
1383
+ this.flags = 0;
1384
+ }, {
853
1385
  $documentation: "A `const` statement"
854
1386
  }, AST_Definitions);
855
1387
 
856
- var AST_VarDef = DEFNODE("VarDef", "name value", {
1388
+ var AST_VarDef = DEFNODE("VarDef", "name value", function AST_VarDef(props) {
1389
+ if (props) {
1390
+ this.name = props.name;
1391
+ this.value = props.value;
1392
+ this.start = props.start;
1393
+ this.end = props.end;
1394
+ }
1395
+
1396
+ this.flags = 0;
1397
+ }, {
857
1398
  $documentation: "A variable declaration; only appears in a AST_Definitions node",
858
1399
  $propdoc: {
859
1400
  name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
@@ -871,7 +1412,16 @@ var AST_VarDef = DEFNODE("VarDef", "name value", {
871
1412
  },
872
1413
  });
873
1414
 
874
- var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", {
1415
+ var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_NameMapping(props) {
1416
+ if (props) {
1417
+ this.foreign_name = props.foreign_name;
1418
+ this.name = props.name;
1419
+ this.start = props.start;
1420
+ this.end = props.end;
1421
+ }
1422
+
1423
+ this.flags = 0;
1424
+ }, {
875
1425
  $documentation: "The part of the export/import statement that declare names from a module.",
876
1426
  $propdoc: {
877
1427
  foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
@@ -889,114 +1439,193 @@ var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", {
889
1439
  },
890
1440
  });
891
1441
 
892
- var AST_Import = DEFNODE("Import", "imported_name imported_names module_name assert_clause", {
893
- $documentation: "An `import` statement",
894
- $propdoc: {
895
- imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
896
- imported_names: "[AST_NameMapping*] The names of non-default imported variables",
897
- module_name: "[AST_String] String literal describing where this module came from",
898
- assert_clause: "[AST_Object?] The import assertion"
1442
+ var AST_Import = DEFNODE(
1443
+ "Import",
1444
+ "imported_name imported_names module_name assert_clause",
1445
+ function AST_Import(props) {
1446
+ if (props) {
1447
+ this.imported_name = props.imported_name;
1448
+ this.imported_names = props.imported_names;
1449
+ this.module_name = props.module_name;
1450
+ this.assert_clause = props.assert_clause;
1451
+ this.start = props.start;
1452
+ this.end = props.end;
1453
+ }
1454
+
1455
+ this.flags = 0;
899
1456
  },
900
- _walk: function(visitor) {
901
- return visitor._visit(this, function() {
902
- if (this.imported_name) {
903
- this.imported_name._walk(visitor);
904
- }
1457
+ {
1458
+ $documentation: "An `import` statement",
1459
+ $propdoc: {
1460
+ imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
1461
+ imported_names: "[AST_NameMapping*] The names of non-default imported variables",
1462
+ module_name: "[AST_String] String literal describing where this module came from",
1463
+ assert_clause: "[AST_Object?] The import assertion"
1464
+ },
1465
+ _walk: function(visitor) {
1466
+ return visitor._visit(this, function() {
1467
+ if (this.imported_name) {
1468
+ this.imported_name._walk(visitor);
1469
+ }
1470
+ if (this.imported_names) {
1471
+ this.imported_names.forEach(function(name_import) {
1472
+ name_import._walk(visitor);
1473
+ });
1474
+ }
1475
+ this.module_name._walk(visitor);
1476
+ });
1477
+ },
1478
+ _children_backwards(push) {
1479
+ push(this.module_name);
905
1480
  if (this.imported_names) {
906
- this.imported_names.forEach(function(name_import) {
907
- name_import._walk(visitor);
908
- });
1481
+ let i = this.imported_names.length;
1482
+ while (i--) push(this.imported_names[i]);
909
1483
  }
910
- this.module_name._walk(visitor);
911
- });
912
- },
913
- _children_backwards(push) {
914
- push(this.module_name);
915
- if (this.imported_names) {
916
- let i = this.imported_names.length;
917
- while (i--) push(this.imported_names[i]);
918
- }
919
- if (this.imported_name) push(this.imported_name);
920
- },
921
- });
1484
+ if (this.imported_name) push(this.imported_name);
1485
+ },
1486
+ }
1487
+ );
1488
+
1489
+ var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props) {
1490
+ if (props) {
1491
+ this.start = props.start;
1492
+ this.end = props.end;
1493
+ }
922
1494
 
923
- var AST_ImportMeta = DEFNODE("ImportMeta", null, {
1495
+ this.flags = 0;
1496
+ }, {
924
1497
  $documentation: "A reference to import.meta",
925
1498
  });
926
1499
 
927
- var AST_Export = DEFNODE("Export", "exported_definition exported_value is_default exported_names module_name assert_clause", {
928
- $documentation: "An `export` statement",
929
- $propdoc: {
930
- exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
931
- exported_value: "[AST_Node?] An exported value",
932
- exported_names: "[AST_NameMapping*?] List of exported names",
933
- module_name: "[AST_String?] Name of the file to load exports from",
934
- is_default: "[Boolean] Whether this is the default exported value of this module",
935
- assert_clause: "[AST_Object?] The import assertion"
936
- },
937
- _walk: function (visitor) {
938
- return visitor._visit(this, function () {
939
- if (this.exported_definition) {
940
- this.exported_definition._walk(visitor);
941
- }
942
- if (this.exported_value) {
943
- this.exported_value._walk(visitor);
944
- }
1500
+ var AST_Export = DEFNODE(
1501
+ "Export",
1502
+ "exported_definition exported_value is_default exported_names module_name assert_clause",
1503
+ function AST_Export(props) {
1504
+ if (props) {
1505
+ this.exported_definition = props.exported_definition;
1506
+ this.exported_value = props.exported_value;
1507
+ this.is_default = props.is_default;
1508
+ this.exported_names = props.exported_names;
1509
+ this.module_name = props.module_name;
1510
+ this.assert_clause = props.assert_clause;
1511
+ this.start = props.start;
1512
+ this.end = props.end;
1513
+ }
1514
+
1515
+ this.flags = 0;
1516
+ },
1517
+ {
1518
+ $documentation: "An `export` statement",
1519
+ $propdoc: {
1520
+ exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
1521
+ exported_value: "[AST_Node?] An exported value",
1522
+ exported_names: "[AST_NameMapping*?] List of exported names",
1523
+ module_name: "[AST_String?] Name of the file to load exports from",
1524
+ is_default: "[Boolean] Whether this is the default exported value of this module",
1525
+ assert_clause: "[AST_Object?] The import assertion"
1526
+ },
1527
+ _walk: function (visitor) {
1528
+ return visitor._visit(this, function () {
1529
+ if (this.exported_definition) {
1530
+ this.exported_definition._walk(visitor);
1531
+ }
1532
+ if (this.exported_value) {
1533
+ this.exported_value._walk(visitor);
1534
+ }
1535
+ if (this.exported_names) {
1536
+ this.exported_names.forEach(function(name_export) {
1537
+ name_export._walk(visitor);
1538
+ });
1539
+ }
1540
+ if (this.module_name) {
1541
+ this.module_name._walk(visitor);
1542
+ }
1543
+ });
1544
+ },
1545
+ _children_backwards(push) {
1546
+ if (this.module_name) push(this.module_name);
945
1547
  if (this.exported_names) {
946
- this.exported_names.forEach(function(name_export) {
947
- name_export._walk(visitor);
948
- });
1548
+ let i = this.exported_names.length;
1549
+ while (i--) push(this.exported_names[i]);
949
1550
  }
950
- if (this.module_name) {
951
- this.module_name._walk(visitor);
952
- }
953
- });
954
- },
955
- _children_backwards(push) {
956
- if (this.module_name) push(this.module_name);
957
- if (this.exported_names) {
958
- let i = this.exported_names.length;
959
- while (i--) push(this.exported_names[i]);
1551
+ if (this.exported_value) push(this.exported_value);
1552
+ if (this.exported_definition) push(this.exported_definition);
960
1553
  }
961
- if (this.exported_value) push(this.exported_value);
962
- if (this.exported_definition) push(this.exported_definition);
963
- }
964
- }, AST_Statement);
1554
+ },
1555
+ AST_Statement
1556
+ );
965
1557
 
966
1558
  /* -----[ OTHER ]----- */
967
1559
 
968
- var AST_Call = DEFNODE("Call", "expression args optional _annotations", {
969
- $documentation: "A function call expression",
970
- $propdoc: {
971
- expression: "[AST_Node] expression to invoke as function",
972
- args: "[AST_Node*] array of arguments",
973
- optional: "[boolean] whether this is an optional call (IE ?.() )",
974
- _annotations: "[number] bitfield containing information about the call"
975
- },
976
- initialize() {
977
- if (this._annotations == null) this._annotations = 0;
978
- },
979
- _walk(visitor) {
980
- return visitor._visit(this, function() {
981
- var args = this.args;
982
- for (var i = 0, len = args.length; i < len; i++) {
983
- args[i]._walk(visitor);
984
- }
985
- this.expression._walk(visitor); // TODO why do we need to crawl this last?
986
- });
987
- },
988
- _children_backwards(push) {
989
- let i = this.args.length;
990
- while (i--) push(this.args[i]);
991
- push(this.expression);
1560
+ var AST_Call = DEFNODE(
1561
+ "Call",
1562
+ "expression args optional _annotations",
1563
+ function AST_Call(props) {
1564
+ if (props) {
1565
+ this.expression = props.expression;
1566
+ this.args = props.args;
1567
+ this.optional = props.optional;
1568
+ this._annotations = props._annotations;
1569
+ this.start = props.start;
1570
+ this.end = props.end;
1571
+ this.initialize();
1572
+ }
1573
+
1574
+ this.flags = 0;
992
1575
  },
993
- });
1576
+ {
1577
+ $documentation: "A function call expression",
1578
+ $propdoc: {
1579
+ expression: "[AST_Node] expression to invoke as function",
1580
+ args: "[AST_Node*] array of arguments",
1581
+ optional: "[boolean] whether this is an optional call (IE ?.() )",
1582
+ _annotations: "[number] bitfield containing information about the call"
1583
+ },
1584
+ initialize() {
1585
+ if (this._annotations == null) this._annotations = 0;
1586
+ },
1587
+ _walk(visitor) {
1588
+ return visitor._visit(this, function() {
1589
+ var args = this.args;
1590
+ for (var i = 0, len = args.length; i < len; i++) {
1591
+ args[i]._walk(visitor);
1592
+ }
1593
+ this.expression._walk(visitor); // TODO why do we need to crawl this last?
1594
+ });
1595
+ },
1596
+ _children_backwards(push) {
1597
+ let i = this.args.length;
1598
+ while (i--) push(this.args[i]);
1599
+ push(this.expression);
1600
+ },
1601
+ }
1602
+ );
1603
+
1604
+ var AST_New = DEFNODE("New", null, function AST_New(props) {
1605
+ if (props) {
1606
+ this.expression = props.expression;
1607
+ this.args = props.args;
1608
+ this.optional = props.optional;
1609
+ this._annotations = props._annotations;
1610
+ this.start = props.start;
1611
+ this.end = props.end;
1612
+ this.initialize();
1613
+ }
994
1614
 
995
- var AST_New = DEFNODE("New", null, {
1615
+ this.flags = 0;
1616
+ }, {
996
1617
  $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
997
1618
  }, AST_Call);
998
1619
 
999
- var AST_Sequence = DEFNODE("Sequence", "expressions", {
1620
+ var AST_Sequence = DEFNODE("Sequence", "expressions", function AST_Sequence(props) {
1621
+ if (props) {
1622
+ this.expressions = props.expressions;
1623
+ this.start = props.start;
1624
+ this.end = props.end;
1625
+ }
1626
+
1627
+ this.flags = 0;
1628
+ }, {
1000
1629
  $documentation: "A sequence expression (comma-separated expressions)",
1001
1630
  $propdoc: {
1002
1631
  expressions: "[AST_Node*] array of expressions (at least two)"
@@ -1014,17 +1643,43 @@ var AST_Sequence = DEFNODE("Sequence", "expressions", {
1014
1643
  },
1015
1644
  });
1016
1645
 
1017
- var AST_PropAccess = DEFNODE("PropAccess", "expression property optional", {
1018
- $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
1019
- $propdoc: {
1020
- expression: "[AST_Node] the “container” expression",
1021
- property: "[AST_Node|string] the property to access. For AST_Dot & AST_DotHash this is always a plain string, while for AST_Sub it's an arbitrary AST_Node",
1646
+ var AST_PropAccess = DEFNODE(
1647
+ "PropAccess",
1648
+ "expression property optional",
1649
+ function AST_PropAccess(props) {
1650
+ if (props) {
1651
+ this.expression = props.expression;
1652
+ this.property = props.property;
1653
+ this.optional = props.optional;
1654
+ this.start = props.start;
1655
+ this.end = props.end;
1656
+ }
1657
+
1658
+ this.flags = 0;
1659
+ },
1660
+ {
1661
+ $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
1662
+ $propdoc: {
1663
+ expression: "[AST_Node] the “container” expression",
1664
+ property: "[AST_Node|string] the property to access. For AST_Dot & AST_DotHash this is always a plain string, while for AST_Sub it's an arbitrary AST_Node",
1022
1665
 
1023
- optional: "[boolean] whether this is an optional property access (IE ?.)"
1666
+ optional: "[boolean] whether this is an optional property access (IE ?.)"
1667
+ }
1668
+ }
1669
+ );
1670
+
1671
+ var AST_Dot = DEFNODE("Dot", "quote", function AST_Dot(props) {
1672
+ if (props) {
1673
+ this.quote = props.quote;
1674
+ this.expression = props.expression;
1675
+ this.property = props.property;
1676
+ this.optional = props.optional;
1677
+ this.start = props.start;
1678
+ this.end = props.end;
1024
1679
  }
1025
- });
1026
1680
 
1027
- var AST_Dot = DEFNODE("Dot", "quote", {
1681
+ this.flags = 0;
1682
+ }, {
1028
1683
  $documentation: "A dotted property access expression",
1029
1684
  $propdoc: {
1030
1685
  quote: "[string] the original quote character when transformed from AST_Sub",
@@ -1039,7 +1694,17 @@ var AST_Dot = DEFNODE("Dot", "quote", {
1039
1694
  },
1040
1695
  }, AST_PropAccess);
1041
1696
 
1042
- var AST_DotHash = DEFNODE("DotHash", "", {
1697
+ var AST_DotHash = DEFNODE("DotHash", "", function AST_DotHash(props) {
1698
+ if (props) {
1699
+ this.expression = props.expression;
1700
+ this.property = props.property;
1701
+ this.optional = props.optional;
1702
+ this.start = props.start;
1703
+ this.end = props.end;
1704
+ }
1705
+
1706
+ this.flags = 0;
1707
+ }, {
1043
1708
  $documentation: "A dotted property access to a private property",
1044
1709
  _walk: function(visitor) {
1045
1710
  return visitor._visit(this, function() {
@@ -1051,7 +1716,17 @@ var AST_DotHash = DEFNODE("DotHash", "", {
1051
1716
  },
1052
1717
  }, AST_PropAccess);
1053
1718
 
1054
- var AST_Sub = DEFNODE("Sub", null, {
1719
+ var AST_Sub = DEFNODE("Sub", null, function AST_Sub(props) {
1720
+ if (props) {
1721
+ this.expression = props.expression;
1722
+ this.property = props.property;
1723
+ this.optional = props.optional;
1724
+ this.start = props.start;
1725
+ this.end = props.end;
1726
+ }
1727
+
1728
+ this.flags = 0;
1729
+ }, {
1055
1730
  $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
1056
1731
  _walk: function(visitor) {
1057
1732
  return visitor._visit(this, function() {
@@ -1065,7 +1740,15 @@ var AST_Sub = DEFNODE("Sub", null, {
1065
1740
  },
1066
1741
  }, AST_PropAccess);
1067
1742
 
1068
- var AST_Chain = DEFNODE("Chain", "expression", {
1743
+ var AST_Chain = DEFNODE("Chain", "expression", function AST_Chain(props) {
1744
+ if (props) {
1745
+ this.expression = props.expression;
1746
+ this.start = props.start;
1747
+ this.end = props.end;
1748
+ }
1749
+
1750
+ this.flags = 0;
1751
+ }, {
1069
1752
  $documentation: "A chain expression like a?.b?.(c)?.[d]",
1070
1753
  $propdoc: {
1071
1754
  expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
@@ -1080,7 +1763,16 @@ var AST_Chain = DEFNODE("Chain", "expression", {
1080
1763
  },
1081
1764
  });
1082
1765
 
1083
- var AST_Unary = DEFNODE("Unary", "operator expression", {
1766
+ var AST_Unary = DEFNODE("Unary", "operator expression", function AST_Unary(props) {
1767
+ if (props) {
1768
+ this.operator = props.operator;
1769
+ this.expression = props.expression;
1770
+ this.start = props.start;
1771
+ this.end = props.end;
1772
+ }
1773
+
1774
+ this.flags = 0;
1775
+ }, {
1084
1776
  $documentation: "Base class for unary expressions",
1085
1777
  $propdoc: {
1086
1778
  operator: "[string] the operator",
@@ -1096,15 +1788,43 @@ var AST_Unary = DEFNODE("Unary", "operator expression", {
1096
1788
  },
1097
1789
  });
1098
1790
 
1099
- var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, {
1791
+ var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, function AST_UnaryPrefix(props) {
1792
+ if (props) {
1793
+ this.operator = props.operator;
1794
+ this.expression = props.expression;
1795
+ this.start = props.start;
1796
+ this.end = props.end;
1797
+ }
1798
+
1799
+ this.flags = 0;
1800
+ }, {
1100
1801
  $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
1101
1802
  }, AST_Unary);
1102
1803
 
1103
- var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, {
1804
+ var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, function AST_UnaryPostfix(props) {
1805
+ if (props) {
1806
+ this.operator = props.operator;
1807
+ this.expression = props.expression;
1808
+ this.start = props.start;
1809
+ this.end = props.end;
1810
+ }
1811
+
1812
+ this.flags = 0;
1813
+ }, {
1104
1814
  $documentation: "Unary postfix expression, i.e. `i++`"
1105
1815
  }, AST_Unary);
1106
1816
 
1107
- var AST_Binary = DEFNODE("Binary", "operator left right", {
1817
+ var AST_Binary = DEFNODE("Binary", "operator left right", function AST_Binary(props) {
1818
+ if (props) {
1819
+ this.operator = props.operator;
1820
+ this.left = props.left;
1821
+ this.right = props.right;
1822
+ this.start = props.start;
1823
+ this.end = props.end;
1824
+ }
1825
+
1826
+ this.flags = 0;
1827
+ }, {
1108
1828
  $documentation: "Binary expression, i.e. `a + b`",
1109
1829
  $propdoc: {
1110
1830
  left: "[AST_Node] left-hand side expression",
@@ -1123,41 +1843,85 @@ var AST_Binary = DEFNODE("Binary", "operator left right", {
1123
1843
  },
1124
1844
  });
1125
1845
 
1126
- var AST_Conditional = DEFNODE("Conditional", "condition consequent alternative", {
1127
- $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
1128
- $propdoc: {
1129
- condition: "[AST_Node]",
1130
- consequent: "[AST_Node]",
1131
- alternative: "[AST_Node]"
1132
- },
1133
- _walk: function(visitor) {
1134
- return visitor._visit(this, function() {
1135
- this.condition._walk(visitor);
1136
- this.consequent._walk(visitor);
1137
- this.alternative._walk(visitor);
1138
- });
1139
- },
1140
- _children_backwards(push) {
1141
- push(this.alternative);
1142
- push(this.consequent);
1143
- push(this.condition);
1846
+ var AST_Conditional = DEFNODE(
1847
+ "Conditional",
1848
+ "condition consequent alternative",
1849
+ function AST_Conditional(props) {
1850
+ if (props) {
1851
+ this.condition = props.condition;
1852
+ this.consequent = props.consequent;
1853
+ this.alternative = props.alternative;
1854
+ this.start = props.start;
1855
+ this.end = props.end;
1856
+ }
1857
+
1858
+ this.flags = 0;
1144
1859
  },
1145
- });
1860
+ {
1861
+ $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
1862
+ $propdoc: {
1863
+ condition: "[AST_Node]",
1864
+ consequent: "[AST_Node]",
1865
+ alternative: "[AST_Node]"
1866
+ },
1867
+ _walk: function(visitor) {
1868
+ return visitor._visit(this, function() {
1869
+ this.condition._walk(visitor);
1870
+ this.consequent._walk(visitor);
1871
+ this.alternative._walk(visitor);
1872
+ });
1873
+ },
1874
+ _children_backwards(push) {
1875
+ push(this.alternative);
1876
+ push(this.consequent);
1877
+ push(this.condition);
1878
+ },
1879
+ }
1880
+ );
1881
+
1882
+ var AST_Assign = DEFNODE("Assign", "logical", function AST_Assign(props) {
1883
+ if (props) {
1884
+ this.logical = props.logical;
1885
+ this.operator = props.operator;
1886
+ this.left = props.left;
1887
+ this.right = props.right;
1888
+ this.start = props.start;
1889
+ this.end = props.end;
1890
+ }
1146
1891
 
1147
- var AST_Assign = DEFNODE("Assign", "logical", {
1892
+ this.flags = 0;
1893
+ }, {
1148
1894
  $documentation: "An assignment expression — `a = b + 5`",
1149
1895
  $propdoc: {
1150
1896
  logical: "Whether it's a logical assignment"
1151
1897
  }
1152
1898
  }, AST_Binary);
1153
1899
 
1154
- var AST_DefaultAssign = DEFNODE("DefaultAssign", null, {
1900
+ var AST_DefaultAssign = DEFNODE("DefaultAssign", null, function AST_DefaultAssign(props) {
1901
+ if (props) {
1902
+ this.operator = props.operator;
1903
+ this.left = props.left;
1904
+ this.right = props.right;
1905
+ this.start = props.start;
1906
+ this.end = props.end;
1907
+ }
1908
+
1909
+ this.flags = 0;
1910
+ }, {
1155
1911
  $documentation: "A default assignment expression like in `(a = 3) => a`"
1156
1912
  }, AST_Binary);
1157
1913
 
1158
1914
  /* -----[ LITERALS ]----- */
1159
1915
 
1160
- var AST_Array = DEFNODE("Array", "elements", {
1916
+ var AST_Array = DEFNODE("Array", "elements", function AST_Array(props) {
1917
+ if (props) {
1918
+ this.elements = props.elements;
1919
+ this.start = props.start;
1920
+ this.end = props.end;
1921
+ }
1922
+
1923
+ this.flags = 0;
1924
+ }, {
1161
1925
  $documentation: "An array literal",
1162
1926
  $propdoc: {
1163
1927
  elements: "[AST_Node*] array of elements"
@@ -1176,7 +1940,15 @@ var AST_Array = DEFNODE("Array", "elements", {
1176
1940
  },
1177
1941
  });
1178
1942
 
1179
- var AST_Object = DEFNODE("Object", "properties", {
1943
+ var AST_Object = DEFNODE("Object", "properties", function AST_Object(props) {
1944
+ if (props) {
1945
+ this.properties = props.properties;
1946
+ this.start = props.start;
1947
+ this.end = props.end;
1948
+ }
1949
+
1950
+ this.flags = 0;
1951
+ }, {
1180
1952
  $documentation: "An object literal",
1181
1953
  $propdoc: {
1182
1954
  properties: "[AST_ObjectProperty*] array of properties"
@@ -1195,7 +1967,16 @@ var AST_Object = DEFNODE("Object", "properties", {
1195
1967
  },
1196
1968
  });
1197
1969
 
1198
- var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
1970
+ var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", function AST_ObjectProperty(props) {
1971
+ if (props) {
1972
+ this.key = props.key;
1973
+ this.value = props.value;
1974
+ this.start = props.start;
1975
+ this.end = props.end;
1976
+ }
1977
+
1978
+ this.flags = 0;
1979
+ }, {
1199
1980
  $documentation: "Base class for literal object properties",
1200
1981
  $propdoc: {
1201
1982
  key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
@@ -1214,7 +1995,17 @@ var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
1214
1995
  }
1215
1996
  });
1216
1997
 
1217
- var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", {
1998
+ var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", function AST_ObjectKeyVal(props) {
1999
+ if (props) {
2000
+ this.quote = props.quote;
2001
+ this.key = props.key;
2002
+ this.value = props.value;
2003
+ this.start = props.start;
2004
+ this.end = props.end;
2005
+ }
2006
+
2007
+ this.flags = 0;
2008
+ }, {
1218
2009
  $documentation: "A key: value object property",
1219
2010
  $propdoc: {
1220
2011
  quote: "[string] the original quote character"
@@ -1224,7 +2015,17 @@ var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", {
1224
2015
  }
1225
2016
  }, AST_ObjectProperty);
1226
2017
 
1227
- var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", {
2018
+ var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", function AST_PrivateSetter(props) {
2019
+ if (props) {
2020
+ this.static = props.static;
2021
+ this.key = props.key;
2022
+ this.value = props.value;
2023
+ this.start = props.start;
2024
+ this.end = props.end;
2025
+ }
2026
+
2027
+ this.flags = 0;
2028
+ }, {
1228
2029
  $propdoc: {
1229
2030
  static: "[boolean] whether this is a static private setter"
1230
2031
  },
@@ -1234,7 +2035,17 @@ var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", {
1234
2035
  }
1235
2036
  }, AST_ObjectProperty);
1236
2037
 
1237
- var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", {
2038
+ var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", function AST_PrivateGetter(props) {
2039
+ if (props) {
2040
+ this.static = props.static;
2041
+ this.key = props.key;
2042
+ this.value = props.value;
2043
+ this.start = props.start;
2044
+ this.end = props.end;
2045
+ }
2046
+
2047
+ this.flags = 0;
2048
+ }, {
1238
2049
  $propdoc: {
1239
2050
  static: "[boolean] whether this is a static private getter"
1240
2051
  },
@@ -1244,7 +2055,18 @@ var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", {
1244
2055
  }
1245
2056
  }, AST_ObjectProperty);
1246
2057
 
1247
- var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", {
2058
+ var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", function AST_ObjectSetter(props) {
2059
+ if (props) {
2060
+ this.quote = props.quote;
2061
+ this.static = props.static;
2062
+ this.key = props.key;
2063
+ this.value = props.value;
2064
+ this.start = props.start;
2065
+ this.end = props.end;
2066
+ }
2067
+
2068
+ this.flags = 0;
2069
+ }, {
1248
2070
  $propdoc: {
1249
2071
  quote: "[string|undefined] the original quote character, if any",
1250
2072
  static: "[boolean] whether this is a static setter (classes only)"
@@ -1255,7 +2077,18 @@ var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", {
1255
2077
  }
1256
2078
  }, AST_ObjectProperty);
1257
2079
 
1258
- var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", {
2080
+ var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_ObjectGetter(props) {
2081
+ if (props) {
2082
+ this.quote = props.quote;
2083
+ this.static = props.static;
2084
+ this.key = props.key;
2085
+ this.value = props.value;
2086
+ this.start = props.start;
2087
+ this.end = props.end;
2088
+ }
2089
+
2090
+ this.flags = 0;
2091
+ }, {
1259
2092
  $propdoc: {
1260
2093
  quote: "[string|undefined] the original quote character, if any",
1261
2094
  static: "[boolean] whether this is a static getter (classes only)"
@@ -1266,24 +2099,74 @@ var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", {
1266
2099
  }
1267
2100
  }, AST_ObjectProperty);
1268
2101
 
1269
- var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator async", {
1270
- $propdoc: {
1271
- quote: "[string|undefined] the original quote character, if any",
1272
- static: "[boolean] is this method static (classes only)",
1273
- is_generator: "[boolean] is this a generator method",
1274
- async: "[boolean] is this method async",
2102
+ var AST_ConciseMethod = DEFNODE(
2103
+ "ConciseMethod",
2104
+ "quote static is_generator async",
2105
+ function AST_ConciseMethod(props) {
2106
+ if (props) {
2107
+ this.quote = props.quote;
2108
+ this.static = props.static;
2109
+ this.is_generator = props.is_generator;
2110
+ this.async = props.async;
2111
+ this.key = props.key;
2112
+ this.value = props.value;
2113
+ this.start = props.start;
2114
+ this.end = props.end;
2115
+ }
2116
+
2117
+ this.flags = 0;
1275
2118
  },
1276
- $documentation: "An ES6 concise method inside an object or class",
1277
- computed_key() {
1278
- return !(this.key instanceof AST_SymbolMethod);
2119
+ {
2120
+ $propdoc: {
2121
+ quote: "[string|undefined] the original quote character, if any",
2122
+ static: "[boolean] is this method static (classes only)",
2123
+ is_generator: "[boolean] is this a generator method",
2124
+ async: "[boolean] is this method async",
2125
+ },
2126
+ $documentation: "An ES6 concise method inside an object or class",
2127
+ computed_key() {
2128
+ return !(this.key instanceof AST_SymbolMethod);
2129
+ }
2130
+ },
2131
+ AST_ObjectProperty
2132
+ );
2133
+
2134
+ var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(props) {
2135
+ if (props) {
2136
+ this.quote = props.quote;
2137
+ this.static = props.static;
2138
+ this.is_generator = props.is_generator;
2139
+ this.async = props.async;
2140
+ this.key = props.key;
2141
+ this.value = props.value;
2142
+ this.start = props.start;
2143
+ this.end = props.end;
1279
2144
  }
1280
- }, AST_ObjectProperty);
1281
2145
 
1282
- var AST_PrivateMethod = DEFNODE("PrivateMethod", "", {
2146
+ this.flags = 0;
2147
+ }, {
1283
2148
  $documentation: "A private class method inside a class",
1284
2149
  }, AST_ConciseMethod);
1285
2150
 
1286
- var AST_Class = DEFNODE("Class", "name extends properties", {
2151
+ var AST_Class = DEFNODE("Class", "name extends properties", function AST_Class(props) {
2152
+ if (props) {
2153
+ this.name = props.name;
2154
+ this.extends = props.extends;
2155
+ this.properties = props.properties;
2156
+ this.variables = props.variables;
2157
+ this.uses_with = props.uses_with;
2158
+ this.uses_eval = props.uses_eval;
2159
+ this.parent_scope = props.parent_scope;
2160
+ this.enclosed = props.enclosed;
2161
+ this.cname = props.cname;
2162
+ this.body = props.body;
2163
+ this.block_scope = props.block_scope;
2164
+ this.start = props.start;
2165
+ this.end = props.end;
2166
+ }
2167
+
2168
+ this.flags = 0;
2169
+ }, {
1287
2170
  $propdoc: {
1288
2171
  name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
1289
2172
  extends: "[AST_Node]? optional parent class",
@@ -1309,7 +2192,18 @@ var AST_Class = DEFNODE("Class", "name extends properties", {
1309
2192
  },
1310
2193
  }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
1311
2194
 
1312
- var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", {
2195
+ var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_ClassProperty(props) {
2196
+ if (props) {
2197
+ this.static = props.static;
2198
+ this.quote = props.quote;
2199
+ this.key = props.key;
2200
+ this.value = props.value;
2201
+ this.start = props.start;
2202
+ this.end = props.end;
2203
+ }
2204
+
2205
+ this.flags = 0;
2206
+ }, {
1313
2207
  $documentation: "A class property",
1314
2208
  $propdoc: {
1315
2209
  static: "[boolean] whether this is a static key",
@@ -1332,19 +2226,76 @@ var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", {
1332
2226
  }
1333
2227
  }, AST_ObjectProperty);
1334
2228
 
1335
- var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", {
2229
+ var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
2230
+ if (props) {
2231
+ this.static = props.static;
2232
+ this.quote = props.quote;
2233
+ this.key = props.key;
2234
+ this.value = props.value;
2235
+ this.start = props.start;
2236
+ this.end = props.end;
2237
+ }
2238
+
2239
+ this.flags = 0;
2240
+ }, {
1336
2241
  $documentation: "A class property for a private property",
1337
2242
  }, AST_ClassProperty);
1338
2243
 
1339
- var AST_DefClass = DEFNODE("DefClass", null, {
2244
+ var AST_DefClass = DEFNODE("DefClass", null, function AST_DefClass(props) {
2245
+ if (props) {
2246
+ this.name = props.name;
2247
+ this.extends = props.extends;
2248
+ this.properties = props.properties;
2249
+ this.variables = props.variables;
2250
+ this.uses_with = props.uses_with;
2251
+ this.uses_eval = props.uses_eval;
2252
+ this.parent_scope = props.parent_scope;
2253
+ this.enclosed = props.enclosed;
2254
+ this.cname = props.cname;
2255
+ this.body = props.body;
2256
+ this.block_scope = props.block_scope;
2257
+ this.start = props.start;
2258
+ this.end = props.end;
2259
+ }
2260
+
2261
+ this.flags = 0;
2262
+ }, {
1340
2263
  $documentation: "A class definition",
1341
2264
  }, AST_Class);
1342
2265
 
1343
- var AST_ClassExpression = DEFNODE("ClassExpression", null, {
2266
+ var AST_ClassExpression = DEFNODE("ClassExpression", null, function AST_ClassExpression(props) {
2267
+ if (props) {
2268
+ this.name = props.name;
2269
+ this.extends = props.extends;
2270
+ this.properties = props.properties;
2271
+ this.variables = props.variables;
2272
+ this.uses_with = props.uses_with;
2273
+ this.uses_eval = props.uses_eval;
2274
+ this.parent_scope = props.parent_scope;
2275
+ this.enclosed = props.enclosed;
2276
+ this.cname = props.cname;
2277
+ this.body = props.body;
2278
+ this.block_scope = props.block_scope;
2279
+ this.start = props.start;
2280
+ this.end = props.end;
2281
+ }
2282
+
2283
+ this.flags = 0;
2284
+ }, {
1344
2285
  $documentation: "A class expression."
1345
2286
  }, AST_Class);
1346
2287
 
1347
- var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
2288
+ var AST_Symbol = DEFNODE("Symbol", "scope name thedef", function AST_Symbol(props) {
2289
+ if (props) {
2290
+ this.scope = props.scope;
2291
+ this.name = props.name;
2292
+ this.thedef = props.thedef;
2293
+ this.start = props.start;
2294
+ this.end = props.end;
2295
+ }
2296
+
2297
+ this.flags = 0;
2298
+ }, {
1348
2299
  $propdoc: {
1349
2300
  name: "[string] name of this symbol",
1350
2301
  scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
@@ -1353,71 +2304,258 @@ var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
1353
2304
  $documentation: "Base class for all symbols"
1354
2305
  });
1355
2306
 
1356
- var AST_NewTarget = DEFNODE("NewTarget", null, {
2307
+ var AST_NewTarget = DEFNODE("NewTarget", null, function AST_NewTarget(props) {
2308
+ if (props) {
2309
+ this.start = props.start;
2310
+ this.end = props.end;
2311
+ }
2312
+
2313
+ this.flags = 0;
2314
+ }, {
1357
2315
  $documentation: "A reference to new.target"
1358
2316
  });
1359
2317
 
1360
- var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", {
2318
+ var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", function AST_SymbolDeclaration(props) {
2319
+ if (props) {
2320
+ this.init = props.init;
2321
+ this.scope = props.scope;
2322
+ this.name = props.name;
2323
+ this.thedef = props.thedef;
2324
+ this.start = props.start;
2325
+ this.end = props.end;
2326
+ }
2327
+
2328
+ this.flags = 0;
2329
+ }, {
1361
2330
  $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
1362
2331
  }, AST_Symbol);
1363
2332
 
1364
- var AST_SymbolVar = DEFNODE("SymbolVar", null, {
2333
+ var AST_SymbolVar = DEFNODE("SymbolVar", null, function AST_SymbolVar(props) {
2334
+ if (props) {
2335
+ this.init = props.init;
2336
+ this.scope = props.scope;
2337
+ this.name = props.name;
2338
+ this.thedef = props.thedef;
2339
+ this.start = props.start;
2340
+ this.end = props.end;
2341
+ }
2342
+
2343
+ this.flags = 0;
2344
+ }, {
1365
2345
  $documentation: "Symbol defining a variable",
1366
2346
  }, AST_SymbolDeclaration);
1367
2347
 
1368
- var AST_SymbolBlockDeclaration = DEFNODE("SymbolBlockDeclaration", null, {
1369
- $documentation: "Base class for block-scoped declaration symbols"
1370
- }, AST_SymbolDeclaration);
2348
+ var AST_SymbolBlockDeclaration = DEFNODE(
2349
+ "SymbolBlockDeclaration",
2350
+ null,
2351
+ function AST_SymbolBlockDeclaration(props) {
2352
+ if (props) {
2353
+ this.init = props.init;
2354
+ this.scope = props.scope;
2355
+ this.name = props.name;
2356
+ this.thedef = props.thedef;
2357
+ this.start = props.start;
2358
+ this.end = props.end;
2359
+ }
1371
2360
 
1372
- var AST_SymbolConst = DEFNODE("SymbolConst", null, {
2361
+ this.flags = 0;
2362
+ },
2363
+ {
2364
+ $documentation: "Base class for block-scoped declaration symbols"
2365
+ },
2366
+ AST_SymbolDeclaration
2367
+ );
2368
+
2369
+ var AST_SymbolConst = DEFNODE("SymbolConst", null, function AST_SymbolConst(props) {
2370
+ if (props) {
2371
+ this.init = props.init;
2372
+ this.scope = props.scope;
2373
+ this.name = props.name;
2374
+ this.thedef = props.thedef;
2375
+ this.start = props.start;
2376
+ this.end = props.end;
2377
+ }
2378
+
2379
+ this.flags = 0;
2380
+ }, {
1373
2381
  $documentation: "A constant declaration"
1374
2382
  }, AST_SymbolBlockDeclaration);
1375
2383
 
1376
- var AST_SymbolLet = DEFNODE("SymbolLet", null, {
2384
+ var AST_SymbolLet = DEFNODE("SymbolLet", null, function AST_SymbolLet(props) {
2385
+ if (props) {
2386
+ this.init = props.init;
2387
+ this.scope = props.scope;
2388
+ this.name = props.name;
2389
+ this.thedef = props.thedef;
2390
+ this.start = props.start;
2391
+ this.end = props.end;
2392
+ }
2393
+
2394
+ this.flags = 0;
2395
+ }, {
1377
2396
  $documentation: "A block-scoped `let` declaration"
1378
2397
  }, AST_SymbolBlockDeclaration);
1379
2398
 
1380
- var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, {
2399
+ var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, function AST_SymbolFunarg(props) {
2400
+ if (props) {
2401
+ this.init = props.init;
2402
+ this.scope = props.scope;
2403
+ this.name = props.name;
2404
+ this.thedef = props.thedef;
2405
+ this.start = props.start;
2406
+ this.end = props.end;
2407
+ }
2408
+
2409
+ this.flags = 0;
2410
+ }, {
1381
2411
  $documentation: "Symbol naming a function argument",
1382
2412
  }, AST_SymbolVar);
1383
2413
 
1384
- var AST_SymbolDefun = DEFNODE("SymbolDefun", null, {
2414
+ var AST_SymbolDefun = DEFNODE("SymbolDefun", null, function AST_SymbolDefun(props) {
2415
+ if (props) {
2416
+ this.init = props.init;
2417
+ this.scope = props.scope;
2418
+ this.name = props.name;
2419
+ this.thedef = props.thedef;
2420
+ this.start = props.start;
2421
+ this.end = props.end;
2422
+ }
2423
+
2424
+ this.flags = 0;
2425
+ }, {
1385
2426
  $documentation: "Symbol defining a function",
1386
2427
  }, AST_SymbolDeclaration);
1387
2428
 
1388
- var AST_SymbolMethod = DEFNODE("SymbolMethod", null, {
2429
+ var AST_SymbolMethod = DEFNODE("SymbolMethod", null, function AST_SymbolMethod(props) {
2430
+ if (props) {
2431
+ this.scope = props.scope;
2432
+ this.name = props.name;
2433
+ this.thedef = props.thedef;
2434
+ this.start = props.start;
2435
+ this.end = props.end;
2436
+ }
2437
+
2438
+ this.flags = 0;
2439
+ }, {
1389
2440
  $documentation: "Symbol in an object defining a method",
1390
2441
  }, AST_Symbol);
1391
2442
 
1392
- var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, {
2443
+ var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, function AST_SymbolClassProperty(props) {
2444
+ if (props) {
2445
+ this.scope = props.scope;
2446
+ this.name = props.name;
2447
+ this.thedef = props.thedef;
2448
+ this.start = props.start;
2449
+ this.end = props.end;
2450
+ }
2451
+
2452
+ this.flags = 0;
2453
+ }, {
1393
2454
  $documentation: "Symbol for a class property",
1394
2455
  }, AST_Symbol);
1395
2456
 
1396
- var AST_SymbolLambda = DEFNODE("SymbolLambda", null, {
2457
+ var AST_SymbolLambda = DEFNODE("SymbolLambda", null, function AST_SymbolLambda(props) {
2458
+ if (props) {
2459
+ this.init = props.init;
2460
+ this.scope = props.scope;
2461
+ this.name = props.name;
2462
+ this.thedef = props.thedef;
2463
+ this.start = props.start;
2464
+ this.end = props.end;
2465
+ }
2466
+
2467
+ this.flags = 0;
2468
+ }, {
1397
2469
  $documentation: "Symbol naming a function expression",
1398
2470
  }, AST_SymbolDeclaration);
1399
2471
 
1400
- var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, {
2472
+ var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, function AST_SymbolDefClass(props) {
2473
+ if (props) {
2474
+ this.init = props.init;
2475
+ this.scope = props.scope;
2476
+ this.name = props.name;
2477
+ this.thedef = props.thedef;
2478
+ this.start = props.start;
2479
+ this.end = props.end;
2480
+ }
2481
+
2482
+ this.flags = 0;
2483
+ }, {
1401
2484
  $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
1402
2485
  }, AST_SymbolBlockDeclaration);
1403
2486
 
1404
- var AST_SymbolClass = DEFNODE("SymbolClass", null, {
2487
+ var AST_SymbolClass = DEFNODE("SymbolClass", null, function AST_SymbolClass(props) {
2488
+ if (props) {
2489
+ this.init = props.init;
2490
+ this.scope = props.scope;
2491
+ this.name = props.name;
2492
+ this.thedef = props.thedef;
2493
+ this.start = props.start;
2494
+ this.end = props.end;
2495
+ }
2496
+
2497
+ this.flags = 0;
2498
+ }, {
1405
2499
  $documentation: "Symbol naming a class's name. Lexically scoped to the class."
1406
2500
  }, AST_SymbolDeclaration);
1407
2501
 
1408
- var AST_SymbolCatch = DEFNODE("SymbolCatch", null, {
2502
+ var AST_SymbolCatch = DEFNODE("SymbolCatch", null, function AST_SymbolCatch(props) {
2503
+ if (props) {
2504
+ this.init = props.init;
2505
+ this.scope = props.scope;
2506
+ this.name = props.name;
2507
+ this.thedef = props.thedef;
2508
+ this.start = props.start;
2509
+ this.end = props.end;
2510
+ }
2511
+
2512
+ this.flags = 0;
2513
+ }, {
1409
2514
  $documentation: "Symbol naming the exception in catch",
1410
2515
  }, AST_SymbolBlockDeclaration);
1411
2516
 
1412
- var AST_SymbolImport = DEFNODE("SymbolImport", null, {
2517
+ var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(props) {
2518
+ if (props) {
2519
+ this.init = props.init;
2520
+ this.scope = props.scope;
2521
+ this.name = props.name;
2522
+ this.thedef = props.thedef;
2523
+ this.start = props.start;
2524
+ this.end = props.end;
2525
+ }
2526
+
2527
+ this.flags = 0;
2528
+ }, {
1413
2529
  $documentation: "Symbol referring to an imported name",
1414
2530
  }, AST_SymbolBlockDeclaration);
1415
2531
 
1416
- var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, {
2532
+ var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, function AST_SymbolImportForeign(props) {
2533
+ if (props) {
2534
+ this.scope = props.scope;
2535
+ this.name = props.name;
2536
+ this.thedef = props.thedef;
2537
+ this.start = props.start;
2538
+ this.end = props.end;
2539
+ }
2540
+
2541
+ this.flags = 0;
2542
+ }, {
1417
2543
  $documentation: "A symbol imported from a module, but it is defined in the other module, and its real name is irrelevant for this module's purposes",
1418
2544
  }, AST_Symbol);
1419
2545
 
1420
- var AST_Label = DEFNODE("Label", "references", {
2546
+ var AST_Label = DEFNODE("Label", "references", function AST_Label(props) {
2547
+ if (props) {
2548
+ this.references = props.references;
2549
+ this.scope = props.scope;
2550
+ this.name = props.name;
2551
+ this.thedef = props.thedef;
2552
+ this.start = props.start;
2553
+ this.end = props.end;
2554
+ this.initialize();
2555
+ }
2556
+
2557
+ this.flags = 0;
2558
+ }, {
1421
2559
  $documentation: "Symbol naming a label (declaration)",
1422
2560
  $propdoc: {
1423
2561
  references: "[AST_LoopControl*] a list of nodes referring to this label"
@@ -1428,38 +2566,114 @@ var AST_Label = DEFNODE("Label", "references", {
1428
2566
  }
1429
2567
  }, AST_Symbol);
1430
2568
 
1431
- var AST_SymbolRef = DEFNODE("SymbolRef", null, {
2569
+ var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
2570
+ if (props) {
2571
+ this.scope = props.scope;
2572
+ this.name = props.name;
2573
+ this.thedef = props.thedef;
2574
+ this.start = props.start;
2575
+ this.end = props.end;
2576
+ }
2577
+
2578
+ this.flags = 0;
2579
+ }, {
1432
2580
  $documentation: "Reference to some symbol (not definition/declaration)",
1433
2581
  }, AST_Symbol);
1434
2582
 
1435
- var AST_SymbolExport = DEFNODE("SymbolExport", null, {
2583
+ var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(props) {
2584
+ if (props) {
2585
+ this.scope = props.scope;
2586
+ this.name = props.name;
2587
+ this.thedef = props.thedef;
2588
+ this.start = props.start;
2589
+ this.end = props.end;
2590
+ }
2591
+
2592
+ this.flags = 0;
2593
+ }, {
1436
2594
  $documentation: "Symbol referring to a name to export",
1437
2595
  }, AST_SymbolRef);
1438
2596
 
1439
- var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, {
2597
+ var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, function AST_SymbolExportForeign(props) {
2598
+ if (props) {
2599
+ this.scope = props.scope;
2600
+ this.name = props.name;
2601
+ this.thedef = props.thedef;
2602
+ this.start = props.start;
2603
+ this.end = props.end;
2604
+ }
2605
+
2606
+ this.flags = 0;
2607
+ }, {
1440
2608
  $documentation: "A symbol exported from this module, but it is used in the other module, and its real name is irrelevant for this module's purposes",
1441
2609
  }, AST_Symbol);
1442
2610
 
1443
- var AST_LabelRef = DEFNODE("LabelRef", null, {
2611
+ var AST_LabelRef = DEFNODE("LabelRef", null, function AST_LabelRef(props) {
2612
+ if (props) {
2613
+ this.scope = props.scope;
2614
+ this.name = props.name;
2615
+ this.thedef = props.thedef;
2616
+ this.start = props.start;
2617
+ this.end = props.end;
2618
+ }
2619
+
2620
+ this.flags = 0;
2621
+ }, {
1444
2622
  $documentation: "Reference to a label symbol",
1445
2623
  }, AST_Symbol);
1446
2624
 
1447
- var AST_This = DEFNODE("This", null, {
2625
+ var AST_This = DEFNODE("This", null, function AST_This(props) {
2626
+ if (props) {
2627
+ this.scope = props.scope;
2628
+ this.name = props.name;
2629
+ this.thedef = props.thedef;
2630
+ this.start = props.start;
2631
+ this.end = props.end;
2632
+ }
2633
+
2634
+ this.flags = 0;
2635
+ }, {
1448
2636
  $documentation: "The `this` symbol",
1449
2637
  }, AST_Symbol);
1450
2638
 
1451
- var AST_Super = DEFNODE("Super", null, {
2639
+ var AST_Super = DEFNODE("Super", null, function AST_Super(props) {
2640
+ if (props) {
2641
+ this.scope = props.scope;
2642
+ this.name = props.name;
2643
+ this.thedef = props.thedef;
2644
+ this.start = props.start;
2645
+ this.end = props.end;
2646
+ }
2647
+
2648
+ this.flags = 0;
2649
+ }, {
1452
2650
  $documentation: "The `super` symbol",
1453
2651
  }, AST_This);
1454
2652
 
1455
- var AST_Constant = DEFNODE("Constant", null, {
2653
+ var AST_Constant = DEFNODE("Constant", null, function AST_Constant(props) {
2654
+ if (props) {
2655
+ this.start = props.start;
2656
+ this.end = props.end;
2657
+ }
2658
+
2659
+ this.flags = 0;
2660
+ }, {
1456
2661
  $documentation: "Base class for all constants",
1457
2662
  getValue: function() {
1458
2663
  return this.value;
1459
2664
  }
1460
2665
  });
1461
2666
 
1462
- var AST_String = DEFNODE("String", "value quote", {
2667
+ var AST_String = DEFNODE("String", "value quote", function AST_String(props) {
2668
+ if (props) {
2669
+ this.value = props.value;
2670
+ this.quote = props.quote;
2671
+ this.start = props.start;
2672
+ this.end = props.end;
2673
+ }
2674
+
2675
+ this.flags = 0;
2676
+ }, {
1463
2677
  $documentation: "A string literal",
1464
2678
  $propdoc: {
1465
2679
  value: "[string] the contents of this string",
@@ -1467,7 +2681,16 @@ var AST_String = DEFNODE("String", "value quote", {
1467
2681
  }
1468
2682
  }, AST_Constant);
1469
2683
 
1470
- var AST_Number = DEFNODE("Number", "value raw", {
2684
+ var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
2685
+ if (props) {
2686
+ this.value = props.value;
2687
+ this.raw = props.raw;
2688
+ this.start = props.start;
2689
+ this.end = props.end;
2690
+ }
2691
+
2692
+ this.flags = 0;
2693
+ }, {
1471
2694
  $documentation: "A number literal",
1472
2695
  $propdoc: {
1473
2696
  value: "[number] the numeric value",
@@ -1475,59 +2698,138 @@ var AST_Number = DEFNODE("Number", "value raw", {
1475
2698
  }
1476
2699
  }, AST_Constant);
1477
2700
 
1478
- var AST_BigInt = DEFNODE("BigInt", "value", {
2701
+ var AST_BigInt = DEFNODE("BigInt", "value", function AST_BigInt(props) {
2702
+ if (props) {
2703
+ this.value = props.value;
2704
+ this.start = props.start;
2705
+ this.end = props.end;
2706
+ }
2707
+
2708
+ this.flags = 0;
2709
+ }, {
1479
2710
  $documentation: "A big int literal",
1480
2711
  $propdoc: {
1481
2712
  value: "[string] big int value"
1482
2713
  }
1483
2714
  }, AST_Constant);
1484
2715
 
1485
- var AST_RegExp = DEFNODE("RegExp", "value", {
2716
+ var AST_RegExp = DEFNODE("RegExp", "value", function AST_RegExp(props) {
2717
+ if (props) {
2718
+ this.value = props.value;
2719
+ this.start = props.start;
2720
+ this.end = props.end;
2721
+ }
2722
+
2723
+ this.flags = 0;
2724
+ }, {
1486
2725
  $documentation: "A regexp literal",
1487
2726
  $propdoc: {
1488
2727
  value: "[RegExp] the actual regexp",
1489
2728
  }
1490
2729
  }, AST_Constant);
1491
2730
 
1492
- var AST_Atom = DEFNODE("Atom", null, {
2731
+ var AST_Atom = DEFNODE("Atom", null, function AST_Atom(props) {
2732
+ if (props) {
2733
+ this.start = props.start;
2734
+ this.end = props.end;
2735
+ }
2736
+
2737
+ this.flags = 0;
2738
+ }, {
1493
2739
  $documentation: "Base class for atoms",
1494
2740
  }, AST_Constant);
1495
2741
 
1496
- var AST_Null = DEFNODE("Null", null, {
2742
+ var AST_Null = DEFNODE("Null", null, function AST_Null(props) {
2743
+ if (props) {
2744
+ this.start = props.start;
2745
+ this.end = props.end;
2746
+ }
2747
+
2748
+ this.flags = 0;
2749
+ }, {
1497
2750
  $documentation: "The `null` atom",
1498
2751
  value: null
1499
2752
  }, AST_Atom);
1500
2753
 
1501
- var AST_NaN = DEFNODE("NaN", null, {
2754
+ var AST_NaN = DEFNODE("NaN", null, function AST_NaN(props) {
2755
+ if (props) {
2756
+ this.start = props.start;
2757
+ this.end = props.end;
2758
+ }
2759
+
2760
+ this.flags = 0;
2761
+ }, {
1502
2762
  $documentation: "The impossible value",
1503
2763
  value: 0/0
1504
2764
  }, AST_Atom);
1505
2765
 
1506
- var AST_Undefined = DEFNODE("Undefined", null, {
2766
+ var AST_Undefined = DEFNODE("Undefined", null, function AST_Undefined(props) {
2767
+ if (props) {
2768
+ this.start = props.start;
2769
+ this.end = props.end;
2770
+ }
2771
+
2772
+ this.flags = 0;
2773
+ }, {
1507
2774
  $documentation: "The `undefined` value",
1508
2775
  value: (function() {}())
1509
2776
  }, AST_Atom);
1510
2777
 
1511
- var AST_Hole = DEFNODE("Hole", null, {
2778
+ var AST_Hole = DEFNODE("Hole", null, function AST_Hole(props) {
2779
+ if (props) {
2780
+ this.start = props.start;
2781
+ this.end = props.end;
2782
+ }
2783
+
2784
+ this.flags = 0;
2785
+ }, {
1512
2786
  $documentation: "A hole in an array",
1513
2787
  value: (function() {}())
1514
2788
  }, AST_Atom);
1515
2789
 
1516
- var AST_Infinity = DEFNODE("Infinity", null, {
2790
+ var AST_Infinity = DEFNODE("Infinity", null, function AST_Infinity(props) {
2791
+ if (props) {
2792
+ this.start = props.start;
2793
+ this.end = props.end;
2794
+ }
2795
+
2796
+ this.flags = 0;
2797
+ }, {
1517
2798
  $documentation: "The `Infinity` value",
1518
2799
  value: 1/0
1519
2800
  }, AST_Atom);
1520
2801
 
1521
- var AST_Boolean = DEFNODE("Boolean", null, {
2802
+ var AST_Boolean = DEFNODE("Boolean", null, function AST_Boolean(props) {
2803
+ if (props) {
2804
+ this.start = props.start;
2805
+ this.end = props.end;
2806
+ }
2807
+
2808
+ this.flags = 0;
2809
+ }, {
1522
2810
  $documentation: "Base class for booleans",
1523
2811
  }, AST_Atom);
1524
2812
 
1525
- var AST_False = DEFNODE("False", null, {
2813
+ var AST_False = DEFNODE("False", null, function AST_False(props) {
2814
+ if (props) {
2815
+ this.start = props.start;
2816
+ this.end = props.end;
2817
+ }
2818
+
2819
+ this.flags = 0;
2820
+ }, {
1526
2821
  $documentation: "The `false` atom",
1527
2822
  value: false
1528
2823
  }, AST_Boolean);
1529
2824
 
1530
- var AST_True = DEFNODE("True", null, {
2825
+ var AST_True = DEFNODE("True", null, function AST_True(props) {
2826
+ if (props) {
2827
+ this.start = props.start;
2828
+ this.end = props.end;
2829
+ }
2830
+
2831
+ this.flags = 0;
2832
+ }, {
1531
2833
  $documentation: "The `true` atom",
1532
2834
  value: true
1533
2835
  }, AST_Boolean);
@@ -1557,6 +2859,21 @@ function walk(node, cb, to_visit = [node]) {
1557
2859
  return false;
1558
2860
  }
1559
2861
 
2862
+ /**
2863
+ * Walks an AST node and its children.
2864
+ *
2865
+ * {cb} can return `walk_abort` to interrupt the walk.
2866
+ *
2867
+ * @param node
2868
+ * @param cb {(node, info: { parent: (nth) => any }) => (boolean | undefined)}
2869
+ *
2870
+ * @returns {boolean} whether the walk was aborted
2871
+ *
2872
+ * @example
2873
+ * const found_some_cond = walk_parent(my_ast_node, (node, { parent }) => {
2874
+ * if (some_cond(node, parent())) return walk_abort
2875
+ * });
2876
+ */
1560
2877
  function walk_parent(node, cb, initial_stack) {
1561
2878
  const to_visit = [node];
1562
2879
  const push = to_visit.push.bind(to_visit);
@@ -1675,6 +2992,15 @@ class TreeWalker {
1675
2992
  }
1676
2993
  }
1677
2994
 
2995
+ find_scope() {
2996
+ for (let i = 0;;i++) {
2997
+ const p = this.parent(i);
2998
+ if (p instanceof AST_Toplevel) return p;
2999
+ if (p instanceof AST_Lambda) return p;
3000
+ if (p.block_scope) return p.block_scope;
3001
+ }
3002
+ }
3003
+
1678
3004
  has_directive(type) {
1679
3005
  var dir = this.directives[type];
1680
3006
  if (dir) return dir;