comp

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

collect.c (858B)


      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <string.h>
      4 #include "comp.h"
      5 
      6 typedef struct Collect_func {
      7 	Name *name;
      8 	Type *ret;
      9 } Collect_func;
     10 
     11 typedef struct Collect_scope {
     12 	struct Collect_scope *prev;
     13 	struct {
     14 		Name *name;
     15 		Type *type;
     16 	} *values;
     17 	int valuec;
     18 } Collect_scope;
     19 
     20 List *funcs;
     21 List *scopes;
     22 
     23 
     24 Collect_func *collect_func(Func *f) {
     25 	Collect_func *new = malloc(sizeof(Collect_func));
     26 	new->name = f->name;
     27 	new->ret = f->type;
     28 
     29 	return new;
     30 }
     31 
     32 Collect_scope *collect_exprs(Expr *body, int exprc) {
     33 	for (int i = 0; i < exprc; i++) {
     34 		if (body[i].expr == ASSIGN) {
     35 			body[i].assign.name
     36 		}
     37 	}
     38 }
     39 
     40 void collect_funcs(List *fns) {
     41 	for (int i = 0; i < fns->count; i++) {
     42 		Collect_func *f = collect_func(&((Func *)fns->data)[i]);
     43 		APPEND(funcs, f);
     44 		collect_exprs(&((Func *)fns->data)[i].body, &((Func *)fns->data)[i].exprc);
     45 	}
     46 }
     47