File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 3
3
4
4
#include < libasr/asr_scopes.h>
5
5
#include < libasr/asr_utils.h>
6
+ #include < libasr/pass/pass_utils.h>
6
7
7
8
std::string lcompilers_unique_ID;
8
9
@@ -39,14 +40,13 @@ void SymbolTable::mark_all_variables_external(Allocator &al) {
39
40
case (ASR::symbolType::Function) : {
40
41
ASR::Function_t *v = ASR::down_cast<ASR::Function_t>(a.second );
41
42
ASR::FunctionType_t* v_func_type = ASR::down_cast<ASR::FunctionType_t>(v->m_function_signature );
42
- if ((v_func_type->m_abi != ASR::abiType::Intrinsic) &&
43
- (v_func_type->m_abi != ASR::abiType::Interactive)) {
44
- v->m_dependencies = nullptr ;
45
- v->n_dependencies = 0 ;
43
+ if (v_func_type->m_abi != ASR::abiType::Interactive) {
44
+ v_func_type->m_abi = ASR::abiType::Interactive;
46
45
v->m_body = nullptr ;
47
46
v->n_body = 0 ;
47
+ PassUtils::UpdateDependenciesVisitor ud (al);
48
+ ud.visit_Function (*v);
48
49
}
49
- v_func_type->m_abi = ASR::abiType::Interactive;
50
50
break ;
51
51
}
52
52
case (ASR::symbolType::Module) : {
Original file line number Diff line number Diff line change @@ -420,6 +420,11 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
420
420
}
421
421
422
422
void visit_Function (const Function_t &x) {
423
+ ASR::FunctionType_t* x_func_type = ASR::down_cast<ASR::FunctionType_t>(x.m_function_signature );
424
+ if (x_func_type->m_abi == abiType::Interactive) {
425
+ require (x.n_body == 0 ,
426
+ " The Function::n_body should be 0 if abi set to Interactive" );
427
+ }
423
428
std::vector<std::string> function_dependencies_copy = function_dependencies;
424
429
function_dependencies.clear ();
425
430
function_dependencies.reserve (x.n_dependencies );
Original file line number Diff line number Diff line change @@ -621,3 +621,20 @@ TEST_CASE("PythonCompiler 1") {
621
621
CHECK (r.ok );
622
622
CHECK (r.result .type == PythonCompiler::EvalResult::none); // TODO: change to integer4 and check the value once printing top level expressions is implemented
623
623
}
624
+
625
+ TEST_CASE (" PythonCompiler 2" ) {
626
+ CompilerOptions cu;
627
+ cu.po .disable_main = true ;
628
+ cu.emit_debug_line_column = false ;
629
+ cu.generate_object_code = false ;
630
+ cu.interactive = true ;
631
+ cu.po .runtime_library_dir = LCompilers::LPython::get_runtime_library_dir ();
632
+ PythonCompiler e (cu);
633
+ LCompilers::Result<PythonCompiler::EvalResult>
634
+ r = e.evaluate2 (" i: i32 = 3 % 1" );
635
+ CHECK (r.ok );
636
+ CHECK (r.result .type == PythonCompiler::EvalResult::none);
637
+ r = e.evaluate2 (" i" );
638
+ CHECK (r.ok );
639
+ CHECK (r.result .type == PythonCompiler::EvalResult::none); // TODO: change to integer4 and check the value once printing top level expressions is implemented
640
+ }
You can’t perform that action at this time.
0 commit comments