2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
12 EArray
* d_calltags_file
;
14 inline bool tree_immune (char * m_fname
)
16 return ENV
->immune_list
->sfind (m_fname
) == -1 ? false : true;
19 /* "SilentBob -u" functionality. */
20 void rctree_iter (char * f_name
, int n_trip
)
30 if (n_trip
> ENV
->d_depth
)
34 * 1. Find record in d_calltags_file.
35 * 2. Find _first_ record in d_calltags_file.
37 * 4. Check d_donelist list.
38 * 5. If f_name not in ENV->full_list :
39 * 5.1 Add f_name to ENV->full_list.
44 snprintf (m_buf
, 255, "%s\t", f_name
);
47 i
= d_calltags_file
->snfind_fast (m_buf
, strlen (m_buf
));
48 d_donelist
= new EArray (32);
54 S
= d_calltags_file
->get (i
);
57 } while (! strncmp (S
, m_buf
, len
));
61 S
= d_calltags_file
->get (i
);
62 if (! S
|| strncmp (S
, m_buf
, len
))
65 S
= strstr (S
, "\tby\t");
67 fprintf (ENV
->d_stream_dbg
, "\tBUG (no \"by\") : %s\n",
68 d_calltags_file
->get (i
));
75 if (d_donelist
->sfind (S
) != -1)
78 d_donelist
->add (strdup (S
));
79 for (a
= 0; a
< n_trip
; a
++)
82 tree_echo (n_trip
, S
);
84 if (ENV
->full_list
->sfind (S
) == -1) {
85 ENV
->full_list
->add (strdup (S
));
86 rctree_iter (S
, n_trip
);
90 d_donelist
->foreach (free
);
94 void reverse_calltree (char * f_name
)
96 assert (f_name
== NULL
, "Lena 2");
100 tree_echo (0, f_name
);
101 d_calltags_file
= new EArray
;
102 d_calltags_file
->from_file ("./call_tags");
103 if (d_calltags_file
->get_size () == 0) {
107 rctree_iter (f_name
, 0);
109 d_calltags_file
->foreach (free
);
110 delete d_calltags_file
;
114 void tree_echo (int n_trip
, char *S
)
116 struct d_tag_t
* tag
;
119 if (! SB_FLGET (SB_FLFNAMES
))
123 if (! tags
|| (tags
->get_size () == 0))
126 tag
= (struct d_tag_t
*) tags
->get (0);
130 printf ("// %i // %s\t%s", n_trip
, S
, tag
->d_file
);
131 if (tags
->get_size () > 1)
133 fputc ('\n', stdout
);
139 printf ("// %i // %s\n", n_trip
, S
);
142 inline void tree_mkpos (int N
)
145 fputc ('\t', stdout
);
148 /* SilentBob call-tree functionality. */
149 void call_tree (char * f_name
, int n_trip
)
151 struct tt_state_t
* d_tt_state
;
152 char * d_ptr
, *d_out
;
155 DArray
* d_vars
; // hash_t **
160 if (n_trip
> ENV
->d_depth
)
164 tree_echo (0, f_name
);
165 if (SB_FLGET (SB_FLLINEAR
) || SB_FLGET (SB_FLVERBOSE
))
166 nogui_tagsdump (f_name
, 0);
169 d_tt_state
= get_onett_tag (f_name
, &d_ptr
);
171 if (ENV
->full_list
->get_size () == 0)
172 bug_nosuch_tag (f_name
);
177 d_donelist
= new EArray (256);
178 d_vars
= new DArray (32);
180 ch
= t_op (&d_ptr
, &d_out
);
187 ch
= t_op (&d_ptr
, &d_out
);
192 d_words
= split_to_words (d_out
);
193 assert (d_words
== NULL
, "Lena 28");
195 for (i
= 0; i
< d_words
->get_size (); i
++) {
196 S
= cts ((struct c_word
*) d_words
->get (i
));
201 if (d_donelist
->sfind (S
) != -1)
204 if (! SB_FLGET (SB_FLLINEAR
))
207 d_donelist
->add (strdup (S
));
208 tree_echo (n_trip
, S
);
210 if ((SB_FLGET (SB_FLVERBOSE
) || SB_FLGET (SB_FLLINEAR
))
211 && !tree_immune (S
)) {
212 nogui_tagsdump (S
, n_trip
);
215 if (ENV
->full_list
->sfind (S
) == -1) {
216 ENV
->full_list
->add (strdup (S
));
217 if (!tree_immune (S
))
218 call_tree (S
, n_trip
+1);
222 d_words
->foreach ((Dfunc_t
) free_cword
);
228 d_vars
->foreach (free
);