-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
32 lines (26 loc) · 1.11 KB
/
run.py
File metadata and controls
32 lines (26 loc) · 1.11 KB
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
from processing import preprocess, print_scope_table, print_func_table
from iterate_ast import alter_source, print_deref_table, print_funcCall_param_table
from globals import c_profiled_loc
import pickle
if __name__ == '__main__':
# Define source code
source = 'sample.c'
# Preprocess source code
func_table, scope_table, includes = preprocess(source)
# Get set of userfunc names
user_func_names = set([func_table[i] for i in func_table])
# Alter source code
deref_table, call_table = alter_source('sample_processed.c', includes, user_func_names)
print_func_table(func_table)
print_scope_table(scope_table)
print_deref_table(deref_table)
print_funcCall_param_table(call_table)
# Pickle the tables
with open(c_profiled_loc+'deref_table.pkl', 'wb') as f:
pickle.dump(deref_table, f)
with open(c_profiled_loc+'call_table.pkl', 'wb') as f:
pickle.dump(call_table, f)
with open(c_profiled_loc+'func_table.pkl', 'wb') as f:
pickle.dump(func_table, f)
with open(c_profiled_loc+'scope_table.pkl', 'wb') as f:
pickle.dump(scope_table, f)