-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcodegen.c
42 lines (39 loc) · 1.06 KB
/
codegen.c
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
#include "gcc.h"
_IO_FILE * code_outputfile;
void plugin_finish_type (tree t, void *_)
{
fprintf(code_outputfile, "finish_type(\"%s\",\n", tree_code_name[TREE_CODE(t)]);
// printf("check1 pointer %p\n",t);
// printf("check2 as long %ul\n",t);
#ifdef USE_GTK
gtk_add_node(t,tree_code_name[TREE_CODE(t)]);
#endif
// printf ( "after tcname:%s\n", tree_code_name[TREE_CODE(t)]);
// generic_callback(t, "user_data");
if (t)
{
record(t);
}
else
{
printf ( "no record\n");
}
fprintf(code_outputfile,"0),//finish_type\n");
//gcc_report_tree_visit(t);
}
void plugin_open_files()
{
// open the output file
code_outputfile=fopen ("example_output.c","w+");
fprintf(code_outputfile, "#include \"gccinterface.h\"\n");
fprintf(code_outputfile, "void main() {\n");
fprintf(code_outputfile, "start_plugin(\n");
if (code_outputfile == NULL) perror ("Error opening file");
}
void plugin_close_files()
{
// close the output file
fprintf(code_outputfile, "0);");
fprintf(code_outputfile, "}");
fclose(code_outputfile);
}