-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcompiler.v
More file actions
60 lines (54 loc) · 1.42 KB
/
compiler.v
File metadata and controls
60 lines (54 loc) · 1.42 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
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
59
60
module main
import time
import os
import json
import builder
import pref
import pex
import papyrus.util
//#flag -lucrtd
fn main() {
prefs := pref.parse_args()
mut sw := time.new_stopwatch()
sw.start()
match prefs.mode {
.version {
info := util.collect_info()
println("Version: ${info.version}")
println("Commit: ${info.git_commit}")
println("Build date: ${info.build_date}")
println("Build type: ${info.build_type}")
println("Repository: https://github.com/russo-2025/papyrus-compiler")
exit(0)
}
.compile {
builder.compile(prefs)
}
.read {
println("read file: `${prefs.paths[0]}`")
pex_file := pex.read_from_file(prefs.paths[0])
println(pex_file.str())
}
.disassembly {
println("disassembly file: `${prefs.paths[0]}` ")
pex_file := pex.read_from_file(prefs.paths[0])
output_file_name := prefs.paths[0] + ".txt"
os.write_file(output_file_name, pex_file.str()) or {
util.fatal_error("failed to write file ${output_file_name}; ${err}")
}
}
.create_dump {
dump_objects := pex.create_dump_from_pex_dir(prefs.paths[0])
json_data := json.encode_pretty(dump_objects)
output_file_name := os.real_path("dump.json")
os.write_file(output_file_name, json_data) or {
util.fatal_error("failed to write file ${output_file_name}; ${err}")
}
}
.help {
pref.print_help_info()
}
}
ms := f32(sw.elapsed().microseconds()) / 1000
println('finish $ms ms')
}