~pixelherodev/c3lib

ref: 1bc526eb7b27f722afb4aec981a581706bc4371c c3lib/sema/usage.c -rw-r--r-- 16.6 KiB
1bc526ebNoam Preil fix padding 4 months ago
                                                                                
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
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

#include "../util.h"
#include "../tags.h"
#include "../c3.h"
#include "../stb.h"
#include "../stb_ds.h"
#include "scope.h"

static struct ctx {
	c3ctx *c3;
	struct{
		// list of nodes used by the node being analyzed
		// This value exists per-node, so it must be saved before descending into a node, and restored afterwards
		// these children are themselves call graph nodes, not main ctx nodes!
		uint32_t *children;
	} call_graph;
	struct{
		// list of nodes used by the node being analyzed
		// This value exists per-node, so it must be saved before descending into a node, and restored afterwards
		// these children are themselves dep ctx nodes, not main ctx nodes!
		uint32_t *children;
	} deps;
	uint32_t *tests;
	uint32_t *queue;
	uint32_t current_scope;
	uint32_t current_fn;
	uint32_t deepest_container;
} ctx;

static uint32_t
u_find(uint32_t **list, uint32_t index)
{
	uint32_t i;
	for(i = 0; i < stb_sb_count(*list); i += 1)
		if(c3nodechild(*ctx.c3, (*list)[i], 0) == index)
			return (*list)[i];
	return -1;
}

static uint32_t u_func(uint32_t index);
static int u_block(uint32_t index);
static int u_node(uint32_t source, int is_dep);
static uint32_t u_scope_declarative_scope(uint32_t parent_scope, uint32_t index);
uint32_t t_dedup_tag(uint32_t tag);

static int
u_type(uint32_t source)
{
	uint32_t index = ctx.c3->ast.nodes[source].node_index;
	if(c3nodetag(*ctx.c3, index) == C3_COMPTIME)
		return u_type(index + 1);
	if(c3nodetag(*ctx.c3, index) != C3_TYPE_UNRES)
		return u_node(source, 1);
	return 1;
}

static inline int
u_kids(uint32_t index, const char *msg, int zero)
{
	uint32_t i;
	uint16_t kid_count = c3nodekids(*ctx.c3, index);
	c3nodedump(*ctx.c3, index, 1, 1);
	for(i = zero ? 0 : 1; i < kid_count; i += 1)
		if(!u_node(index + 1 + i, 1)){
			ERROR("%s", msg);
			return 0;
		}
	return 1;
}

static int
u_asm(uint32_t index)
{
	return u_kids(index, "failed to analyze asm expr", 0);
}

static int
u_fnargs(uint32_t index)
{
	return u_kids(index, "Failed to analyze function arguments", 1);
}

// containing_scope: the scope in which node is found
// parent_scope: REQUIRED, MUST NOT be NULL; the scope in which the resolved
// expr is found
static uint32_t
resolve_expr(uint32_t index, uint32_t containing_scope, uint32_t *parent_scope)
{
	uint32_t val, tmp, ident, lhs;
	c3tag tag;
	if(index == -1){
		ERROR("resolve_expr given bad node", 0);
		return -1;
	}
	tag = c3nodetag(*ctx.c3, index);
	if(tag == C3_IDENT){
		val = scope_find_decl(containing_scope, index, parent_scope, 0);
	}
	else if(tag == C3_EXPR_MEMBER){
		// lhs must be either ident or member, so just resolve_expr it
		lhs = resolve_expr(c3nodechild(*ctx.c3, index, 0), containing_scope, parent_scope);
		if(lhs == -1 || *parent_scope == -1){
			ERROR("Failed to resolve member subexpr", 0);
			return -1;
		}
		tmp = scope_subscope(*parent_scope, lhs);
		if(tmp == -1){
			// Not yet processed
			tmp = u_scope_declarative_scope(*parent_scope, lhs);
			if(tmp == -1){
				ERROR("Failed to generate scope info for dependent scope", 0);
				return -1;
			}
		}
		*parent_scope = tmp;
		ident = c3nodechild(*ctx.c3, index, 1);
		val = scope_find_decl(*parent_scope, ident, parent_scope, 0);
	}
	else{
		val = index;
		*parent_scope = containing_scope;
	}
	if(val == -1){
		ERROR("Unable to resolve decl", 0);
		c3nodedump(*ctx.c3, index, 0, 1);
		puts("");
		return -1;
	}
	tag = c3nodetag(*ctx.c3, val);
	if(tag == C3_PUB){
		val = c3nodechild(*ctx.c3, val, 0);
		tag = c3nodetag(*ctx.c3, val);
	}
	if(tag == C3_CONST){
		val = c3nodechild(*ctx.c3, val, 2);
		tag = c3nodetag(*ctx.c3, val);
	}
	if(tag == C3_IDENT || tag == C3_EXPR_MEMBER)
		val = resolve_expr(val, *parent_scope, parent_scope);
	if(val == -1){
		ERROR("Resolved %s to bad",c3tagstr(tag));
		}
	return val;
}

static int
u_call(uint32_t source)
{
	// The call target may reside in a different scope. next_scope is set to the
	// parent scope of the target, so that during analysis of the function, the
	// scope is tracked correctly.
	// u_func will then create a new scope for the target function, using the next_scope
	// as its parent scope.
	// we don't need to set current_fn in here, since that doesn't depend on its parent.
	uint32_t next_scope, prev_scope;
	uint16_t conv;
	uint32_t fn_src;
	uint32_t index = ctx.c3->ast.nodes[source].node_index;
	uint32_t kiddex;
	c3tag tag;
	next_scope = ctx.current_scope;
	if(c3nodetag(*ctx.c3, index) == C3_BUILTIN_PANIC)
		return u_fnargs(c3nodechild(*ctx.c3, index, 0));
	ctx.c3->ast.nodes[index + 1].node_index = resolve_expr(c3nodechild(*ctx.c3, index, 0), ctx.current_scope, &next_scope);
	if(ctx.c3->ast.nodes[index + 1].node_index == -1){
		ERROR("Failed to resolve expr", 0);
		return 0;
	}
	if(next_scope == -1){
		ERROR("ICE: bad scope", 0);
		return 0;
	}
	kiddex = c3nodechild(*ctx.c3, index, 0);
	tag = c3nodetag(*ctx.c3, kiddex);
	if(tag != C3_VALUE_FN){
		ERROR("ICE: call target didn't resolve into function: %s", c3tagstr(tag));
		return 0;
	}
	fn_src = index + 1;
	conv = c3nodetag(*ctx.c3, c3nodechild(*ctx.c3, c3nodechild(*ctx.c3, kiddex, 0), 2));
	prev_scope = ctx.current_scope;
	ctx.current_scope = next_scope;
	if(!u_node(fn_src, conv != C3_CALL_CONV_INLINE)){
		ctx.current_scope = prev_scope;
		ERROR("Function analysis failed", 0);
		return 0;
	}
	ctx.current_scope = prev_scope;
	return u_fnargs(c3nodechild(*ctx.c3, index, 1));
}

static int
u_initialized(uint32_t index)
{
	uint32_t value;
	uint32_t i;
	uint16_t kidcount;
	value = c3nodechild(*ctx.c3, index, 1);
	kidcount = c3nodekids(*ctx.c3, value);
	if(!u_node(index + 1, 1)){
		ERROR("Failed to analyze type of initialized expression", 0);
		return 0;
	}
	//RHS shares INITIALIZED tag, but contains list
	for(i = 0; i < kidcount; i += 1){
		if(!u_node(value + 1 + i, 1)){
			ERROR("Failed to analyze value of initialized expression", 0);
			return 0;
		}
	}
	return 1;
}


static int
u_this(uint32_t source)
{
	if(ctx.deepest_container == -1){
		ERROR("ICE: unable to find deepest container", 0);
		return 0;
	}
	ctx.c3->ast.nodes[source].node_index = ctx.deepest_container;
	return 1;
}

static int
u_field(uint32_t index)
{
	return u_node(index+ 2, 1);
}

static uint32_t
u_scope_declarative_scope(uint32_t parent_scope, uint32_t index)
{
	uint32_t i;
	uint32_t scope;
	uint32_t child;
	c3tag tag;
	uint16_t kids = c3nodekids(*ctx.c3, index);
	scope = scope_new(parent_scope, index);
	if(scope == -1){
		ERROR("Failed to create declarative scope", 0);
		return -1;
	}
	for(i = 0; i < kids; i += 1){
		child = c3nodechild(*ctx.c3, index, i);
		tag = c3nodetag(*ctx.c3, child);
		if(tag == C3_EXPORT)
			child = c3nodechild(*ctx.c3, child, 0);
		if(tag == C3_PUB)
			child = c3nodechild(*ctx.c3, child, 0);
		if(tag == C3_CONST || tag == C3_VAR)
			if(!scope_insert(scope, child))
				return -1;
	}
	return scope;
}

static int
u_declarative_scope(uint32_t index)
{
	uint32_t i;
	uint32_t prev_scope = ctx.current_scope;
	uint32_t prev_cont = ctx.deepest_container;
	uint16_t kids = c3nodekids(*ctx.c3, index);
	uint32_t child;
	c3tag tag;
	int ret = 1;
	if(ctx.current_scope != -1)
		ctx.current_scope = scope_subscope(prev_scope, index);
	if(ctx.current_scope == -1){
		ctx.current_scope = u_scope_declarative_scope(prev_scope, index);
		if(ctx.current_scope == -1){
			ctx.current_scope = prev_scope;
			return 0;
		}
	}
	ctx.deepest_container = index;
	for(i = 0; ret == 1 && i < kids; i += 1){
		child = c3nodechild(*ctx.c3, index, i);
		tag = c3nodetag(*ctx.c3, child);
		switch(tag){
		case C3_EXPORT:
			if(!u_node(index + 1 + i, 1)){
				ret = 0;
				break;
			}
			break;
		// Ignored unless referenced from something else
		case C3_CONST:
		// Tests don't get added as dependencys of the structure. Instead, they get
		// added to the test list by u_node itself, and handled in the driver later.
		// This removes them from the normal analysis pipeline, avoiding costly work
		// compiling tests when they're not being run.
		case C3_TEST:
			break;
		case C3_COMPTIME:
			if(!u_node(index + 1 + i, 1)){
				ret = 0;
				break;
			}
			ERROR("TODO: comptime engine", 0);
			ret = 0;
			break;
		default:
			ERROR("TODO: declarative scope: %s", c3tagstr(tag));
			ret = 0;
			break;
		}
	}
	ctx.current_scope = prev_scope;
	ctx.deepest_container = prev_cont;
	return ret;
}

static int
u_test(uint32_t index)
{
	uint32_t fn, fntype, rettype, param_list, callconv;
	rettype = t_dedup_tag(C3_VOID);
	callconv = t_dedup_tag(C3_CALL_CONV_INLINE);
	param_list = c3append(ctx.c3, C3_FN_PARAM_LIST, 0);
	if(rettype == -1 || callconv == -1 || param_list == -1)
		OOM();
	fntype = c3append(ctx.c3, C3_TYPE_FN, 3, rettype, param_list, callconv);
	if(fntype == -1)
		OOM();
	fn = c3append(ctx.c3, C3_VALUE_FN, 4, index, fntype, c3nodechild(*ctx.c3, index, 0), -1);
	if(fn == -1)
		OOM();
	ctx.c3->ast.nodes[index + 1].node_index = fn;
	if(!stb_sb_push_u32(&ctx.tests, index))
		return 0;
	return u_node(index + 1, 1);
}

static int
u_return(uint32_t source)
{
	uint32_t index = ctx.c3->ast.nodes[source].node_index;
	uint32_t retval = c3nodechild(*ctx.c3, index, 0);
	index = c3append(ctx.c3, C3_EXPR_RETURN, 2, ctx.current_fn, retval);
	if(index == -1){
		ERROR("OOM", 0);
		return 0;
	}
	ctx.c3->ast.nodes[source].node_index = index;
	// Note: this logic should be identical to the BREAK logic in analyze_node, most likely
	return u_node(index + 2, 1);
}

static int
u_analyze_node(uint32_t source)
{
	uint32_t index;
	c3tag tag;
	index = ctx.c3->ast.nodes[source].node_index;
	tag = c3nodetag(*ctx.c3, index);
	if(tag == C3_EXPR_DEFER)
		return u_node(index + 1, 1);
	switch(tag){
	case C3_VALUE_TRUE:
	case C3_VALUE_FALSE:
		return 1;
	case C3_BUILTIN_PANIC:
	case C3_EXPR_CALL:
		return u_call(source);
	case C3_EXPR_IF:
		// condition and block/stmt
		return u_node(index + 1, 1) && u_node(index + 2, 1);
	case C3_LOOP:
		return u_node(index + 1, 1) && u_node(index + 2, 1);
	case C3_BREAK:
		// ONLY check the value, NOT the block. The break is DEFINITIONALLY
		// within the block it is breaking, so it's a bug; semantically, it doesn't
		// actually *depend* on the block, just its type.
		// The type needs to be added explicitly (TODO!), because it should be
		// analzed *before* the break, so that it can be properly compared.
		// The type of the value and the type of the block both need to be analyzed
		// before the break, so that equality can be validated.
		return u_node(index + 2, 1);
	case C3_CONST:
	case C3_VAR:
		// Analyze the type and the initializer
		return u_type(index + 2) && u_node(index + 3, 1);
	case C3_FN_PARAM:
		return u_type(index + 2);
	case C3_INITIALIZED:
		// Initialized expression
		return u_initialized(index);
	case C3_EXPR_RETURN:
		return u_return(source);
	case C3_EXPR_ASSIGN:
	case C3_EXPR_ASSIGN_PLUS:
	case C3_EXPR_ASSIGN_MINUS:
	case C3_EXPR_BITWISE_OR:
	case C3_EXPR_BITSHIFT_LEFT:
	case C3_EXPR_ADD:
	case C3_EXPR_SUB:
		return u_node(index + 1, 1) && u_node(index + 2, 1);
	case C3_TYPE_SLICE:
	case C3_CONSTANT:
		return u_type(index + 1);
	case C3_NORETURN:
	case C3_VOID:
	case C3_TYPE_BOOL:
	case C3_TYPE_U8:
	case C3_TYPE_U32:
	case C3_LITERAL_STRING:
	case C3_LINT:
	case C3_DISCARD:
		return 1;
	case C3_ASM:
		return u_asm(index);
	case C3_BUILTIN_THIS:
		return u_this(source);
	case C3_FIELD_INIT:
		return u_field(index);
	case C3_STRUCT:
		return u_declarative_scope(index);
	case C3_PUB:
	case C3_EXPORT:
		return u_node(index + 1, 1);
	case C3_VALUE_FN:
		return u_func(index) != -1;
	case C3_BLOCK:
		return u_block(index);
	case C3_TEST:
		return u_test(index);
	default:
		ERROR("TODO: usage analysis of %s", c3tagstr(tag));
		return 0;
	}
}

static int
u_node(uint32_t source, int is_dep)
{
	uint32_t index;
	uint32_t *parents_kids;
	uint32_t dep_node;
	uint32_t prev_scope, scope;
	c3tag tag;
	prev_scope = ctx.current_scope;
	index = ctx.c3->ast.nodes[source].node_index;
	tag = c3nodetag(*ctx.c3, index);
	if(tag != C3_CONST && tag != C3_VAR){
		index = resolve_expr(index, prev_scope, &scope);
		if(index == -1){
			ERROR("Failed to resolve expr", 0);
			return 0;
		}
		ctx.c3->ast.nodes[source].node_index = index;
	}
	else
		scope = ctx.current_scope;
	dep_node = stbds_hmget(ctx.c3->analysis.deps, index);
	if(dep_node != 0){
		if(dep_node == -1){
			ERROR("Recursive dep found on index %d (tag %s)", index, c3tagstr(c3nodetag(*ctx.c3, index)));
			return 0;
		}
		if(is_dep && !stb_sb_push_u32(&ctx.deps.children, dep_node)){
			ERROR("ICE: OOM", 0);
			return 0;
		}
		return 1;
	}
	tag = c3nodetag(*ctx.c3, index);
	parents_kids = ctx.deps.children;
	ctx.deps.children = NULL;
	if(!stb_sb_push_u32(&ctx.deps.children, -1))
		OOM();
	stbds_hmput(ctx.c3->analysis.deps, index, -1);
	ctx.current_scope = scope;
	if(!u_analyze_node(source)){
		ctx.deps.children = parents_kids;
		ctx.current_scope = prev_scope;
		return 0;
	}
	ctx.current_scope = prev_scope;
	// Add the patched index to the dep graph - might have been changed by scope resolution!
	index = ctx.c3->ast.nodes[source].node_index;
	ctx.deps.children[0] = index;
	dep_node = c3appendarr(ctx.c3, C3_DEP, stb_sb_count(ctx.deps.children), ctx.deps.children);
	if(dep_node == -1)
		return 0;
	stb_sb_free(ctx.deps.children);
	ctx.deps.children = parents_kids;
	if(is_dep && !stb_sb_push_u32(&ctx.deps.children, dep_node))
		OOM();
	stbds_hmput(ctx.c3->analysis.deps, index, dep_node);
	return 1;
}

static int
u_block(uint32_t index)
{
	uint32_t i;
	uint16_t kids = c3nodekids(*ctx.c3, index);
	uint32_t child;
	c3tag tag;
	if(!u_type(index + 1))
		return 0;
	for(i = 1; i < kids; i += 1){
		if(!u_node(index + 1 + i, 1)){
			ERROR("analyzing expression failed", 0);
			return 0;
		}
		child = c3nodechild(*ctx.c3, index, i);
		tag = c3nodetag(*ctx.c3, child);
		if(tag == C3_CONST || tag == C3_VAR){
			WARN("block decl found", 0);
			scope_insert(ctx.current_scope, child);
		}
	}
	return 1;
}

static int
u_fnparams(uint32_t index)
{
	uint32_t i;
	uint32_t kid_index;
	c3tag tag = c3nodetag(*ctx.c3, index);
	uint16_t kids = c3nodekids(*ctx.c3, index);
	if(tag != C3_FN_PARAM_LIST){
		ERROR("ICE: expected param list", 0);
		return 0;
	}
	for(i = 0; i < kids; i += 1){
		kid_index = c3nodechild(*ctx.c3, index, i);
		tag = c3nodetag(*ctx.c3, kid_index);
		if(tag == C3_BAD){
			ERROR("ICE: getting parameter failed", 0);
			return 0;
		}
		if(tag == C3_COMPTIME){
			kid_index = c3nodechild(*ctx.c3, kid_index, 0);
			tag = c3nodetag(*ctx.c3, kid_index);
			if(tag == C3_BAD){
				ERROR("ICE: getting comptime parameter failed", 0);
				return 0;
			}
		}
		if(tag != C3_FN_PARAM){
			ERROR("ICE: expected fn param, found %s", c3tagstr(tag));
			return 0;
		}
		if(!u_type(kid_index + 2) || !scope_insert(ctx.current_scope, kid_index))
			return 0;
	}
	return 1;
}

static uint32_t
u_func(uint32_t index)
{
	uint32_t call_graph_node;
	uint32_t i;
	uint32_t *parent_list;
	uint32_t prev_scope, prev_fn;
	uint16_t conv;
	uint32_t fnrettype;
	uint32_t block;
	call_graph_node = u_find(&ctx.c3->analysis.exports, index);
	if(call_graph_node != -1){
		i = u_find(&ctx.call_graph.children, index);
		if(i == -1)
			stb_sb_push_u32(&ctx.call_graph.children, call_graph_node);
		return call_graph_node;
	}
	parent_list = ctx.call_graph.children;
	ctx.call_graph.children = NULL;
	if(!stb_sb_push_u32(&ctx.call_graph.children, index))
		OOM();
	prev_scope = ctx.current_scope;
	prev_fn = ctx.current_fn;
	ctx.current_scope = scope_new(prev_scope, index);
	if(ctx.current_scope == -1){
		ERROR("ICE: failed to generate scope info for function", 0);
		return -1;
	}
	ctx.current_fn = index;
	i = c3nodechild(*ctx.c3, index, 0);
	conv = c3nodetag(*ctx.c3, c3nodechild(*ctx.c3, i, 2));;
	if(!u_node(i + 1, 1)){
		ERROR("Failed to analyze function type", 0);
		return -1;
	}
	fnrettype = c3nodechild(*ctx.c3, i, 0);
	i = c3nodechild(*ctx.c3, i, 1);
	if(!u_fnparams(i)){
		ERROR("Unable to insert parameters into scope", 0);
		return -1;
	}
	block = c3nodechild(*ctx.c3, index, 1);
	ctx.c3->ast.nodes[block + 1].node_index = fnrettype;
	if(!u_node(index + 2, 1)){
		ERROR("Failed to analyze block call graph", 0);
		call_graph_node = -1;
	}
	else{
		call_graph_node = c3appendarr(ctx.c3, C3_DEP, stb_sb_count(ctx.call_graph.children), ctx.call_graph.children);
	}
	ctx.current_scope = prev_scope;
	ctx.current_fn = prev_fn;
	stb_sb_free(ctx.call_graph.children);
	ctx.call_graph.children = parent_list;
	if(conv != C3_CALL_CONV_INLINE)
		if(!stb_sb_push_u32(&ctx.c3->analysis.fns, call_graph_node))
			OOM();
	return call_graph_node;
}

static void
ctx_init(c3ctx *c3ctx)
{
	ctx.call_graph.children = NULL;
	ctx.deps.children = NULL;
	ctx.current_fn = -1;
	ctx.current_scope = -1;
	ctx.deepest_container = -1;
	ctx.tests = NULL;
	ctx.c3 = c3ctx;
}

int
resolve_tree(c3ctx *c3ctx)
{
	ctx_init(c3ctx);
	scope_init(c3ctx);
	if(!u_node(1, 1)){
		ERROR("ctx resolution failed", 0);
		return 0;
	}
	stb_sb_free(ctx.tests);
	stb_sb_free(ctx.deps.children);
	return 1;
}