comparison lwcc/symbol.c @ 299:856caf91ffaa ccdev

Added token list structure and switched some stuff to use it Swithced to using a token list structure instead of manually fiddling pointers throughout the macro expansion code. Also fixed up some problematic things related to stringification and concatenation.
author William Astle <lost@l-w.ca>
date Sun, 15 Sep 2013 13:06:00 -0600
parents 83fcc1ed6ad6
children 54f213c8fb81
comparison
equal deleted inserted replaced
298:6112c67728ba 299:856caf91ffaa
29 #include "token.h" 29 #include "token.h"
30 30
31 void symbol_free(struct symtab_e *s) 31 void symbol_free(struct symtab_e *s)
32 { 32 {
33 int i; 33 int i;
34 struct token *t; 34
35
36 lw_free(s -> name); 35 lw_free(s -> name);
37 36
38 for (i = 0; i < s -> nargs; i++) 37 for (i = 0; i < s -> nargs; i++)
39 lw_free(s -> params[i]); 38 lw_free(s -> params[i]);
40 lw_free(s -> params); 39 lw_free(s -> params);
41 while (s -> tl) 40 token_list_destroy(s -> tl);
42 {
43 t = s -> tl;
44 s -> tl = t -> next;
45 token_free(t);
46 }
47 } 41 }
48 42
49 struct symtab_e *symtab_find(struct preproc_info *pp, char *name) 43 struct symtab_e *symtab_find(struct preproc_info *pp, char *name)
50 { 44 {
51 struct symtab_e *s; 45 struct symtab_e *s;
75 } 69 }
76 p = &((*p) -> next); 70 p = &((*p) -> next);
77 } 71 }
78 } 72 }
79 73
80 void symtab_define(struct preproc_info *pp, char *name, struct token *def, int nargs, char **params, int vargs) 74 void symtab_define(struct preproc_info *pp, char *name, struct token_list *def, int nargs, char **params, int vargs)
81 { 75 {
82 struct symtab_e *s; 76 struct symtab_e *s;
83 77
84 s = lw_alloc(sizeof(struct symtab_e)); 78 s = lw_alloc(sizeof(struct symtab_e));
85 s -> name = lw_strdup(name); 79 s -> name = lw_strdup(name);