FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lpython/src/lpython/pickle.cpp at main · rajpratyush/lpython · GitHub
rajpratyush
/
lpython
Public
forked from
lcompilers/lpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
lpython
/
src
/
lpython
/
pickle.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
117 lines (104 loc) · 3.24 KB
Breadcrumbs
lpython
/
src
/
lpython
/
pickle.cpp
Copy path
File metadata and controls
117 lines (104 loc) · 3.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#
include
<
string
>
#
include
<
lpython/pickle.h
>
#
include
<
lpython/pickle.h
>
#
include
<
lpython/bigint.h
>
#
include
<
libasr/asr_utils.h
>
#
include
<
libasr/string_utils.h
>
namespace
LFortran
{
/*
-----------------------------------------------------------------------
*/
//
ASR
class
ASRPickleVisitor
:
public LFortran::
ASR
::PickleBaseVisitor<ASRPickleVisitor>
{
public:
bool
show_intrinsic_modules;
std::string
get_str
() {
return
s;
}
void
visit_symbol
(
const
ASR
::
symbol_t
&x) {
s.
append
(
LFortran::ASRUtils::symbol_parent_symtab
(&x)->
get_counter
());
s.
append
(
"
"
);
if
(use_colors) {
s.
append
(
color
(fg::yellow));
}
s.
append
(
LFortran::ASRUtils::symbol_name
(&x));
if
(use_colors) {
s.
append
(
color
(fg::reset));
}
}
void
visit_ConstantInteger
(
const
ASR
::ConstantInteger_t &x) {
s.
append
(
"
(
"
);
if
(use_colors) {
s.
append
(
color
(style::bold));
s.
append
(
color
(fg::magenta));
}
s.
append
(
"
ConstantInteger
"
);
if
(use_colors) {
s.
append
(
color
(fg::reset));
s.
append
(
color
(style::reset));
}
s.
append
(
"
"
);
if
(use_colors) {
s.
append
(
color
(fg::cyan));
}
s.
append
(
std::to_string
(x.
m_n
));
if
(use_colors) {
s.
append
(
color
(fg::reset));
}
s.
append
(
"
"
);
this
->
visit_ttype
(*x.
m_type
);
s.
append
(
"
)
"
);
}
void
visit_Module
(
const
ASR
::Module_t &x) {
if
(!show_intrinsic_modules &&
(x.
m_intrinsic
||
startswith
(x.
m_name
,
"
lfortran_intrinsic_
"
))) {
s.
append
(
"
(
"
);
if
(use_colors) {
s.
append
(
color
(style::bold));
s.
append
(
color
(fg::magenta));
}
s.
append
(
"
IntrinsicModule
"
);
if
(use_colors) {
s.
append
(
color
(fg::reset));
s.
append
(
color
(style::reset));
}
s.
append
(
"
"
);
s.
append
(x.
m_name
);
s.
append
(
"
)
"
);
}
else
{
LFortran::
ASR
::PickleBaseVisitor<ASRPickleVisitor>::
visit_Module
(x);
};
}
};
std::string
pickle
(LFortran::
ASR
::
asr_t
&asr,
bool
colors,
bool
indent,
bool
show_intrinsic_modules) {
ASRPickleVisitor v;
v.
use_colors
= colors;
v.
indent
= indent;
v.
show_intrinsic_modules
= show_intrinsic_modules;
v.
visit_asr
(asr);
return
v.
get_str
();
}
std::string
pickle
(LFortran::
ASR
::TranslationUnit_t &asr,
bool
colors,
bool
indent,
bool
show_intrinsic_modules) {
return
pickle
((
ASR
::
asr_t
&)asr, colors, indent, show_intrinsic_modules);
}
class
ASRTreeVisitor
:
public LFortran::
ASR
::TreeBaseVisitor<ASRTreeVisitor>
{
public:
bool
show_intrinsic_modules;
std::string
get_str
() {
return
s;
}
};
std::string
pickle_tree
(LFortran::
ASR
::
asr_t
&asr,
bool
colors,
bool
show_intrinsic_modules) {
ASRTreeVisitor v;
v.
use_colors
= colors;
v.
show_intrinsic_modules
= show_intrinsic_modules;
v.
visit_asr
(asr);
return
v.
get_str
();
}
std::string
pickle_tree
(LFortran::
ASR
::TranslationUnit_t &asr,
bool
colors,
bool
show_intrinsic_modules) {
return
pickle_tree
((
ASR
::
asr_t
&)asr, colors, show_intrinsic_modules);
}
}
Back
|
FazBrowse Home
|
New Git URL