-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathast.c
More file actions
709 lines (638 loc) · 20.4 KB
/
ast.c
File metadata and controls
709 lines (638 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
#include "common.h"
#include "ast.h"
static struct brd_node *
brd_node_program_copy(struct brd_node *n)
{
struct brd_node_program *p = (struct brd_node_program *)n;
struct brd_node **stmts = malloc(sizeof(struct brd_node *) * p->num_stmts);
for (size_t i = 0; i < p->num_stmts; i++) {
stmts[i] = brd_node_copy(p->stmts[i]);
}
return brd_node_program_new(stmts, p->num_stmts);
}
static void
brd_node_program_destroy(struct brd_node *n)
{
struct brd_node_program *p = (struct brd_node_program *)n;
for (size_t i = 0; i < p->num_stmts; i++) {
brd_node_destroy(p->stmts[i]);
}
free(p->stmts);
}
struct brd_node *
brd_node_program_new(struct brd_node **stmts, size_t num_stmts)
{
struct brd_node_program *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_PROGRAM;
n->_node.line_number = line_number;
n->stmts = stmts;
n->num_stmts = num_stmts;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_assign_copy(struct brd_node *n)
{
struct brd_node_assign *a = (struct brd_node_assign *)n;
return brd_node_assign_new(
brd_node_copy(a->l),
brd_node_copy(a->r)
);
}
static void
brd_node_assign_destroy(struct brd_node *n)
{
struct brd_node_assign *a = (struct brd_node_assign *)n;
brd_node_destroy(a->l);
brd_node_destroy(a->r);
}
struct brd_node *
brd_node_assign_new(struct brd_node *l, struct brd_node *r)
{
struct brd_node_assign *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_ASSIGN;
n->_node.line_number = line_number;
n->l = l;
n->r = r;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_binop_copy(struct brd_node *n)
{
struct brd_node_binop *b = (struct brd_node_binop *)n;
return brd_node_binop_new(
b->btype,
brd_node_copy(b->l),
brd_node_copy(b->r)
);
}
static void
brd_node_binop_destroy(struct brd_node *n)
{
struct brd_node_binop *b = (struct brd_node_binop *)n;
brd_node_destroy(b->l);
brd_node_destroy(b->r);
}
struct brd_node *
brd_node_binop_new(enum brd_binop btype, struct brd_node *l, struct brd_node *r)
{
struct brd_node_binop *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_BINOP;
n->_node.line_number = line_number;
n->btype = btype;
n->l = l;
n->r = r;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_unary_copy(struct brd_node *n)
{
struct brd_node_unary *u = (struct brd_node_unary *)n;
return brd_node_unary_new(u->utype, brd_node_copy(u->u));
}
static void
brd_node_unary_destroy(struct brd_node *n)
{
brd_node_destroy(((struct brd_node_unary *)n)->u);
}
struct brd_node *
brd_node_unary_new(enum brd_unary utype, struct brd_node *u)
{
struct brd_node_unary *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_UNARY;
n->_node.line_number = line_number;
n->utype = utype;
n->u = u;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_var_copy(struct brd_node *n)
{
return brd_node_var_new(((struct brd_node_var *) n)->id);
}
static void
brd_node_var_destroy(struct brd_node *n)
{
free(((struct brd_node_var *)n)->id);
}
struct brd_node *
brd_node_var_new(char *id)
{
struct brd_node_var *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_VAR;
n->_node.line_number = line_number;
n->id = strdup(id);
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_num_lit_copy(struct brd_node *n)
{
return brd_node_num_lit_new(((struct brd_node_num_lit *) n)->v);
}
static void
brd_node_num_lit_destroy(struct brd_node *n)
{
(void)n;
}
struct brd_node *
brd_node_num_lit_new(long double v)
{
struct brd_node_num_lit *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_NUM_LIT;
n->_node.line_number = line_number;
n->v = v;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_string_lit_copy(struct brd_node *n)
{
return brd_node_string_lit_new(((struct brd_node_string_lit *) n)->s);
}
static void
brd_node_string_lit_destroy(struct brd_node *n)
{
free(((struct brd_node_string_lit *)n)->s);
}
struct brd_node *
brd_node_string_lit_new(char *s)
{
struct brd_node_string_lit *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_STRING_LIT;
n->_node.line_number = line_number;
n->s = strdup(s);
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_bool_lit_copy(struct brd_node *n)
{
return brd_node_bool_lit_new(((struct brd_node_bool_lit *) n)->b);
}
static void
brd_node_bool_lit_destroy(struct brd_node *n)
{
(void)n;
}
struct brd_node *
brd_node_bool_lit_new(int b)
{
struct brd_node_bool_lit *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_BOOL_LIT;
n->_node.line_number = line_number;
n->b = b;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_unit_lit_copy(struct brd_node *n)
{
(void)n;
return brd_node_unit_lit_new();
}
static void
brd_node_unit_lit_destroy(struct brd_node *n)
{
(void)n;
}
struct brd_node *
brd_node_unit_lit_new(void)
{
struct brd_node_unit_lit *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_UNIT_LIT;
n->_node.line_number = line_number;
return (struct brd_node *)n;
}
static struct brd_node_arglist *
brd_node_arglist_copy(struct brd_node_arglist *a)
{
struct brd_node **args = malloc(sizeof(struct brd_node *) * a->num_args);
for (size_t i = 0; i < a->num_args; i++) {
args[i] = brd_node_copy(a->args[i]);
}
return brd_node_arglist_new(args, a->num_args);
}
void
brd_node_arglist_destroy(struct brd_node_arglist *args)
{
for (size_t i = 0; i < args->num_args; i++) {
brd_node_destroy(args->args[i]);
}
free(args->args);
free(args);
}
struct brd_node_arglist *
brd_node_arglist_new(struct brd_node **args, size_t num_args)
{
struct brd_node_arglist *n = malloc(sizeof(*n));
n->args = args;
n->num_args = num_args;
return n;
}
static struct brd_node *
brd_node_list_lit_copy(struct brd_node *n)
{
return brd_node_list_lit_new(
brd_node_arglist_copy(((struct brd_node_list_lit *) n)->items)
);
}
static void
brd_node_list_lit_destroy(struct brd_node *n)
{
brd_node_arglist_destroy(((struct brd_node_list_lit *)n)->items);
}
struct brd_node *
brd_node_list_lit_new(struct brd_node_arglist *items)
{
struct brd_node_list_lit *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_LIST_LIT;
n->_node.line_number = line_number;
n->items = items;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_funcall_copy(struct brd_node *n)
{
struct brd_node_funcall *f = (struct brd_node_funcall *)n;
return brd_node_funcall_new(
brd_node_copy(f->fn),
brd_node_arglist_copy(f->args)
);
}
static void
brd_node_funcall_destroy(struct brd_node *n)
{
struct brd_node_funcall *f = (struct brd_node_funcall *)n;
brd_node_destroy(f->fn);
brd_node_arglist_destroy(f->args);
}
struct brd_node *
brd_node_funcall_new(struct brd_node *fn, struct brd_node_arglist *args)
{
struct brd_node_funcall *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_FUNCALL;
n->_node.line_number = line_number;
n->fn = fn;
n->args = args;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_closure_copy(struct brd_node *n)
{
struct brd_node_closure *c = (struct brd_node_closure *)n;
char **args = malloc(sizeof(char *) * c->num_args);
for (size_t i = 0; i < c->num_args; i++) {
args[i] = strdup(c->args[i]);
}
return brd_node_closure_new(args, c->num_args, brd_node_copy(c->body));
}
static void
brd_node_closure_destroy(struct brd_node *n)
{
struct brd_node_closure *c = (struct brd_node_closure *)n;
for (size_t i = 0; i < c->num_args; i++) {
free(c->args[i]);
}
free(c->args);
brd_node_destroy(c->body);
}
struct brd_node *
brd_node_closure_new(char **args, size_t num_args, struct brd_node *body)
{
struct brd_node_closure *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_CLOSURE;
n->_node.line_number = line_number;
n->args = args;
n->num_args = num_args;
n->body = body;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_builtin_copy(struct brd_node *n)
{
return brd_node_builtin_new(((struct brd_node_builtin *) n)->builtin);
}
static void
brd_node_builtin_destroy(struct brd_node *n)
{
struct brd_node_builtin *b = (struct brd_node_builtin *)n;
free(b->builtin);
}
struct brd_node *
brd_node_builtin_new(char *builtin)
{
struct brd_node_builtin *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_BUILTIN;
n->_node.line_number = line_number;
n->builtin = strdup(builtin);
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_body_copy(struct brd_node *n)
{
struct brd_node_body *b = (struct brd_node_body *)n;
struct brd_node **stmts = malloc(sizeof(struct brd_node*) * b->num_stmts);
for (size_t i = 0; i < b->num_stmts; i++) {
stmts[i] = brd_node_copy(b->stmts[i]);
}
return brd_node_body_new(stmts, b->num_stmts);
}
static void
brd_node_body_destroy(struct brd_node *n)
{
struct brd_node_body *b = (struct brd_node_body *)n;
for (size_t i = 0; i < b->num_stmts; i++) {
brd_node_destroy(b->stmts[i]);
}
free(b->stmts);
}
struct brd_node *
brd_node_body_new(struct brd_node **stmts, size_t num_stmts)
{
struct brd_node_body *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_BODY;
n->_node.line_number = line_number;
n->stmts = stmts;
n->num_stmts = num_stmts;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_ifexpr_copy(struct brd_node *n)
{
struct brd_node_ifexpr *b = (struct brd_node_ifexpr *)n;
struct brd_node_elif *elifs =
malloc(sizeof(struct brd_node_elif) * b->num_elifs);
for (size_t i = 0; i < b->num_elifs; i++) {
elifs[i].cond = brd_node_copy(b->elifs[i].cond);
elifs[i].body = brd_node_copy(b->elifs[i].body);
}
return brd_node_ifexpr_new(
brd_node_copy(b->cond),
brd_node_copy(b->body),
elifs, b->num_elifs,
b->els ? brd_node_copy(b->els) : NULL
);
}
static void
brd_node_ifexpr_destroy(struct brd_node *n)
{
struct brd_node_ifexpr *b = (struct brd_node_ifexpr *)n;
brd_node_destroy(b->cond);
brd_node_destroy(b->body);
for (size_t i = 0; i < b->num_elifs; i++) {
brd_node_destroy(b->elifs[i].cond);
brd_node_destroy(b->elifs[i].body);
}
free(b->elifs);
if (b->els != NULL) {
brd_node_destroy(b->els);
}
}
struct brd_node *
brd_node_ifexpr_new(
struct brd_node *cond,
struct brd_node *body,
struct brd_node_elif *elifs,
size_t num_elifs,
struct brd_node *els)
{
struct brd_node_ifexpr *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_IFEXPR;
n->_node.line_number = line_number;
n->cond = cond;
n->body = body;
n->elifs = elifs;
n->num_elifs = num_elifs;
n->els = els;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_index_copy(struct brd_node *n)
{
struct brd_node_index *i = (struct brd_node_index *)n;
return brd_node_index_new(brd_node_copy(i->list), brd_node_copy(i->idx));
}
static void
brd_node_index_destroy(struct brd_node *n)
{
struct brd_node_index *i = (struct brd_node_index *)n;
brd_node_destroy(i->list);
brd_node_destroy(i->idx);
}
struct brd_node *
brd_node_index_new(struct brd_node *list, struct brd_node *idx)
{
struct brd_node_index *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_INDEX;
n->_node.line_number = line_number;
n->list = list;
n->idx = idx;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_while_copy(struct brd_node *n)
{
struct brd_node_while *w = (struct brd_node_while *)n;
return brd_node_while_new(
w->no_list,
brd_node_copy(w->cond),
brd_node_copy(w->body),
w->inc ? brd_node_copy(w->inc) : NULL
);
}
static void
brd_node_while_destroy(struct brd_node *n)
{
struct brd_node_while *w = (struct brd_node_while *)n;
brd_node_destroy(w->cond);
brd_node_destroy(w->body);
if (w->inc != NULL) {
brd_node_destroy(w->inc);
}
}
struct brd_node *
brd_node_while_new(int no_list, struct brd_node *cond, struct brd_node *body, struct brd_node *inc)
{
struct brd_node_while *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_WHILE;
n->_node.line_number = line_number;
n->no_list = no_list;
n->cond = cond;
n->body = body;
n->inc = inc;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_field_copy(struct brd_node *n)
{
struct brd_node_field *m = (struct brd_node_field *)n;
return brd_node_field_new(brd_node_copy(m->object), m->field);
}
static void
brd_node_field_destroy(struct brd_node *n)
{
struct brd_node_field *m = (struct brd_node_field *)n;
brd_node_destroy(m->object);
free(m->field);
}
struct brd_node *
brd_node_field_new(struct brd_node *object, char *field)
{
struct brd_node_field *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_FIELD;
n->_node.line_number = line_number;
n->object = object;
n->field = strdup(field);
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_acc_obj_copy(struct brd_node *n)
{
struct brd_node_acc_obj *m = (struct brd_node_acc_obj *)n;
return brd_node_acc_obj_new(brd_node_copy(m->object), m->id);
}
static void
brd_node_acc_obj_destroy(struct brd_node *n)
{
struct brd_node_acc_obj *m = (struct brd_node_acc_obj *)n;
brd_node_destroy(m->object);
free(m->id);
}
struct brd_node *
brd_node_acc_obj_new(struct brd_node *object, char *id)
{
struct brd_node_acc_obj *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_ACC_OBJ;
n->_node.line_number = line_number;
n->object = object;
n->id = strdup(id);
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_subclass_copy(struct brd_node *n)
{
struct brd_node_subclass *s = (struct brd_node_subclass *)n;
struct brd_node_subclass_set *decs =
malloc(sizeof(struct brd_node_subclass_set) * s->num_decs);
for (size_t i = 0; i < s->num_decs; i++) {
decs[i].id = strdup(s->decs[i].id);
decs[i].expression = brd_node_copy(s->decs[i].expression);
}
return brd_node_subclass_new(
brd_node_copy(s->super),
brd_node_copy(s->constructor),
decs, s->num_decs
);
}
static void
brd_node_subclass_destroy(struct brd_node *n)
{
struct brd_node_subclass *s = (struct brd_node_subclass *)n;
brd_node_destroy(s->super);
brd_node_destroy((struct brd_node *)s->constructor);
for (size_t i = 0; i < s->num_decs; i++) {
free(s->decs[i].id);
brd_node_destroy(s->decs[i].expression);
}
free(s->decs);
}
struct brd_node *
brd_node_subclass_new(
struct brd_node *super,
struct brd_node *constructor,
struct brd_node_subclass_set *decs,
size_t num_decs)
{
struct brd_node_subclass *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_SUBCLASS;
n->_node.line_number = line_number;
n->super = super;
n->constructor = constructor;
n->decs = decs;
n->num_decs = num_decs;
return (struct brd_node *)n;
}
static struct brd_node *
brd_node_dict_copy(struct brd_node *n)
{
struct brd_node_dict *d = (struct brd_node_dict *)n;
struct brd_node_dict_pair *pairs =
malloc(sizeof(struct brd_node_dict_pair) * d->num_pairs);
for (size_t i = 0; i < d->num_pairs; i++) {
pairs[i].key = strdup(d->pairs[i].key);
pairs[i].value = brd_node_copy(d->pairs[i].value);
}
return brd_node_dict_new(pairs, d->num_pairs);
}
static void
brd_node_dict_destroy(struct brd_node *n)
{
struct brd_node_dict *d = (struct brd_node_dict *)n;
for (size_t i = 0; i < d->num_pairs; i++) {
free(d->pairs[i].key);
brd_node_destroy(d->pairs[i].value);
}
free(d->pairs);
}
struct brd_node *
brd_node_dict_new(struct brd_node_dict_pair *pairs, size_t num_pairs) {
struct brd_node_dict *n = malloc(sizeof(*n));
n->_node.ntype = BRD_NODE_DICT;
n->_node.line_number = line_number;
n->pairs = pairs;
n->num_pairs = num_pairs;
return (struct brd_node *)n;
}
void
brd_node_destroy(struct brd_node *node)
{
switch(node->ntype) {
case BRD_NODE_ASSIGN: brd_node_assign_destroy(node); break;
case BRD_NODE_BINOP: brd_node_binop_destroy(node); break;
case BRD_NODE_UNARY: brd_node_unary_destroy(node); break;
case BRD_NODE_VAR: brd_node_var_destroy(node); break;
case BRD_NODE_NUM_LIT: brd_node_num_lit_destroy(node); break;
case BRD_NODE_STRING_LIT: brd_node_string_lit_destroy(node); break;
case BRD_NODE_BOOL_LIT: brd_node_bool_lit_destroy(node); break;
case BRD_NODE_UNIT_LIT: brd_node_unit_lit_destroy(node); break;
case BRD_NODE_LIST_LIT: brd_node_list_lit_destroy(node); break;
case BRD_NODE_FUNCALL: brd_node_funcall_destroy(node); break;
case BRD_NODE_CLOSURE: brd_node_closure_destroy(node); break;
case BRD_NODE_BUILTIN: brd_node_builtin_destroy(node); break;
case BRD_NODE_BODY: brd_node_body_destroy(node); break;
case BRD_NODE_IFEXPR: brd_node_ifexpr_destroy(node); break;
case BRD_NODE_INDEX: brd_node_index_destroy(node); break;
case BRD_NODE_WHILE: brd_node_while_destroy(node); break;
case BRD_NODE_FIELD: brd_node_field_destroy(node); break;
case BRD_NODE_ACC_OBJ: brd_node_acc_obj_destroy(node); break;
case BRD_NODE_SUBCLASS: brd_node_subclass_destroy(node); break;
case BRD_NODE_DICT: brd_node_dict_destroy(node); break;
case BRD_NODE_PROGRAM: brd_node_program_destroy(node); break;
}
free(node);
}
struct brd_node *
brd_node_copy(struct brd_node *node)
{
switch(node->ntype) {
case BRD_NODE_ASSIGN: return brd_node_assign_copy(node);
case BRD_NODE_BINOP: return brd_node_binop_copy(node);
case BRD_NODE_UNARY: return brd_node_unary_copy(node);
case BRD_NODE_VAR: return brd_node_var_copy(node);
case BRD_NODE_NUM_LIT: return brd_node_num_lit_copy(node);
case BRD_NODE_STRING_LIT: return brd_node_string_lit_copy(node);
case BRD_NODE_BOOL_LIT: return brd_node_bool_lit_copy(node);
case BRD_NODE_UNIT_LIT: return brd_node_unit_lit_copy(node);
case BRD_NODE_LIST_LIT: return brd_node_list_lit_copy(node);
case BRD_NODE_FUNCALL: return brd_node_funcall_copy(node);
case BRD_NODE_CLOSURE: return brd_node_closure_copy(node);
case BRD_NODE_BUILTIN: return brd_node_builtin_copy(node);
case BRD_NODE_BODY: return brd_node_body_copy(node);
case BRD_NODE_IFEXPR: return brd_node_ifexpr_copy(node);
case BRD_NODE_INDEX: return brd_node_index_copy(node);
case BRD_NODE_WHILE: return brd_node_while_copy(node);
case BRD_NODE_FIELD: return brd_node_field_copy(node);
case BRD_NODE_ACC_OBJ: return brd_node_acc_obj_copy(node);
case BRD_NODE_SUBCLASS: return brd_node_subclass_copy(node);
case BRD_NODE_DICT: brd_node_dict_copy(node); break;
case BRD_NODE_PROGRAM: return brd_node_program_copy(node);
}
BARF("what?");
return NULL;
}