~pixelherodev/zyg

d8d63395f858ca008e0ba084bf466d7c6f0a297e — Noam Preil 5 months ago 70345ad
[sema] improve usage debugging
2 files changed, 24 insertions(+), 12 deletions(-)

M driver.c
M sema.c
M driver.c => driver.c +1 -1
@@ 387,7 387,7 @@ main(int argc, char **argv)
		for(size_t i = 0; i < stb_sb_count(zyg_ctx.trees); i += 1){
	    		c3dump(*zyg_ctx.trees[i].tree);
				printf("\n");
				c3nodedump(*zyg_ctx.trees[i].tree, zyg_ctx.trees[i].tree->graphs.deps, 1);
				c3nodedump(*zyg_ctx.trees[i].tree, zyg_ctx.trees[i].tree->graphs.deps, 1, 1);
				printf("\nNote: the call graph is not dumped at present, as infinite recursion is not yet detected\n");
		}
	}

M sema.c => sema.c +23 -11
@@ 21,28 21,40 @@ uint32_t l_fn(uint32_t index);
int expr_finish(void);
int expr_gen_test(void);

static void
usagedump(struct c3tree tree)
{
	uint32_t i;
	uint32_t dep_node;
	uint16_t kids = c3nodekids(tree, tree.graphs.deps);
	for(i = 0; i < kids; i += 1){
		dep_node = c3nodechild(tree, tree.graphs.deps, i);
		printf("%d: %u: ", i, dep_node);
		c3nodedump(tree, dep_node, 0, 1);
		printf("\n");
	}
}

static int
anal_execute(struct c3tree *tree)
{
/*
	uint32_t i;
	uint32_t dep_node;
	uint16_t kids = c3nodekids(*tree, tree->graphs.deps);
	for(i = 0; i < kids; i += 1){
		dep_node = c3nodechild(*tree, tree->graphs.deps, i);
		// TODO: comptime engine
		if(!t_node(dep_node)){
			ERROR("Type analysis failed!", 0);
			return 0;
		}
//		if(!t_node(dep_node)){
//			ERROR("Type analysis failed!", 0);
//			return 0;
//		}
		if(c3nodetag(*tree, dep_node) == C3_VALUE_FN){
			if(l_fn(dep_node) == -1){
				ERROR("Failed to extract expression semantics", 0);
				return 0;
			}
//			if(l_fn(dep_node) == -1){
//				ERROR("Failed to extract expression semantics", 0);
//				return 0;
//			}
		}
	}
*/
	WARN("analysis is currently disabled, pending major changes being merged.", 0);
	return 0;
}


@@ 91,7 103,7 @@ analysis(struct c3tree *tree, int out)
	if(!serialize_deps(tree))
		return 0;
	if(zyg_ctx.usage_debug)
		c3dump(*tree);
		usagedump(*tree);
	good = anal_execute(tree);
	return anal_finish(tree, good, out);
}