terser 5.9.0 → 5.14.2

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