-
Notifications
You must be signed in to change notification settings - Fork 3
/
codegen_single_func_final.py
59 lines (45 loc) · 1.53 KB
/
codegen_single_func_final.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import argparse
import subprocess
from multiprocessing import cpu_count
from multiprocessing.pool import ThreadPool
from concurrent.futures import ThreadPoolExecutor
import sys
import os
from typing import *
import queue
import threading
import multiprocessing
import subprocess
import json
import pprint
import re
from datetime import datetime
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--path-prefix")
parser.add_argument("--prelude")
parser.add_argument("--code-data")
parser.add_argument("--global-data")
parser.add_argument("--deduplicate-text")
args = parser.parse_args()
def get_path(name):
return args.path_prefix + "." + name + ".json"
def open_get_path(name):
if isinstance(name, str):
with open(get_path(name)) as f:
return json.load(f)
else:
raise ValueError("Unrecognized name: ", (name))
result_file_text = []
result_file_text.extend((open_get_path(args.prelude)))
deduplicated = set()
for file in (open_get_path(args.deduplicate_text)):
for line in (open_get_path(file)):
deduplicated.add(line)
result_file_text.extend(list(deduplicated))
for file in (open_get_path(args.global_data)):
result_file_text.extend((open_get_path(file)))
for file in (open_get_path(args.code_data)):
with open(get_path(file)) as f:
result_file_text.append(f.read())
open(args.path_prefix + ".ll", "w").writelines(result_file_text)