FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lpython/src/lpython/python_evaluator.cpp at main · caguerra/lpython · GitHub
caguerra
/
lpython
Public
forked from
lcompilers/lpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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
/
python_evaluator.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
76 lines (63 loc) · 1.77 KB
Breadcrumbs
lpython
/
src
/
lpython
/
python_evaluator.cpp
Copy path
File metadata and controls
76 lines (63 loc) · 1.77 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
#
include
<
iostream
>
#
include
<
fstream
>
#
include
<
lpython/python_evaluator.h
>
#
include
<
libasr/codegen/asr_to_cpp.h
>
#
include
<
libasr/exception.h
>
#
include
<
libasr/asr.h
>
#
ifdef
HAVE_LFORTRAN_LLVM
#
include
<
libasr/codegen/evaluator.h
>
#
include
<
libasr/codegen/asr_to_llvm.h
>
#
else
namespace
LFortran
{
class
LLVMEvaluator
{};
}
#
endif
namespace
LFortran
{
/*
-------------------------------------------------------------------------
*/
//
PythonEvaluator
PythonCompiler::PythonCompiler
(CompilerOptions compiler_options)
:
al{
1024
*
1024
},
#
ifdef
HAVE_LFORTRAN_LLVM
e{std::make_unique<LLVMEvaluator>()},
eval_count{
0
},
#
endif
compiler_options{compiler_options}
//
symbol_table{nullptr}
{
}
PythonCompiler::~PythonCompiler
() =
default
;
Result<std::unique_ptr<LLVMModule>>
PythonCompiler::get_llvm3
(
#
ifdef
HAVE_LFORTRAN_LLVM
ASR
::TranslationUnit_t &asr, LCompilers::PassManager& lpm,
diag::Diagnostics &diagnostics,
const
std::string &infile
#
else
ASR
::TranslationUnit_t &
/*
asr
*/
, LCompilers::PassManager&
/*
lpm
*/
,
diag::Diagnostics &
/*
diagnostics
*/
,
const
std::string &
/*
infile
*/
#
endif
)
{
#
ifdef
HAVE_LFORTRAN_LLVM
eval_count++;
run_fn =
"
__lfortran_evaluate_
"
+
std::to_string
(eval_count);
//
ASR -> LLVM
std::unique_ptr<LFortran::LLVMModule> m;
Result<std::unique_ptr<LFortran::LLVMModule>> res
=
asr_to_llvm
(asr, diagnostics,
e->
get_context
(), al, lpm, compiler_options,
run_fn, infile);
if
(res.
ok
) {
m =
std::move
(res.
result
);
}
else
{
LFORTRAN_ASSERT
(diagnostics.
has_error
())
return
res.
error
;
}
if
(compiler_options.
fast
) {
e->
opt
(*m->
m_m
);
}
return
m;
#
else
throw
LCompilersException
(
"
LLVM is not enabled
"
);
#
endif
}
}
//
namespace LFortran
Back
|
FazBrowse Home
|
New Git URL