blob: 3d8c8e6ffa1219f315112a17a54312b085c4bf6a (
plain) (
blame)
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
|
#
#
# The Nim Compiler
# (c) Copyright 2023 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## Nir Compiler. Currently only supports a "view" command.
import ".." / ic / [bitabs, rodfiles]
import nirinsts, nirtypes, nirlineinfos
proc view(filename: string) =
var lit = Literals()
var r = rodfiles.open(filename)
var code = default Tree
var man = default LineInfoManager
var types = initTypeGraph(lit)
try:
r.loadHeader(nirCookie)
r.loadSection stringsSection
r.load lit.strings
r.loadSection numbersSection
r.load lit.numbers
r.loadSection bodiesSection
r.load code
r.loadSection typesSection
r.load types
r.loadSection sideChannelSection
r.load man
finally:
r.close()
var res = ""
allTreesToString code, lit.strings, lit.numbers, res
res.add "\n# TYPES\n"
nirtypes.toString res, types
echo res
import std / os
view paramStr(1)
|