From c7507fecbcf605ea33a7b0b92d6b1355195ed59a Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 21 Jun 2022 15:34:09 +0530 Subject: [PATCH 1/9] Added test to verify behaviour of LPython with local and global variables --- integration_tests/expr_07.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 integration_tests/expr_07.py diff --git a/integration_tests/expr_07.py b/integration_tests/expr_07.py new file mode 100644 index 0000000000..e02b041fc3 --- /dev/null +++ b/integration_tests/expr_07.py @@ -0,0 +1,17 @@ +from ltypes import i32 + +def g(x: i32): + print(x) + +x: i32 = 7 + +def f(): + a: i32 = 5 + x: i32 = 3 + x = 5 + b: i32 = x + 1 + assert b == 6 + print(a, b) + g(a*b + 3) + +f() From 17ec0ef67e00315341573587647feb175e44c010 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 21 Jun 2022 15:34:46 +0530 Subject: [PATCH 2/9] Added test to verify that LPython does operations with runtime values and not compile time values --- integration_tests/expr_09.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 integration_tests/expr_09.py diff --git a/integration_tests/expr_09.py b/integration_tests/expr_09.py new file mode 100644 index 0000000000..76c75f6102 --- /dev/null +++ b/integration_tests/expr_09.py @@ -0,0 +1,10 @@ +from ltypes import i32 + +def main0(): + i1: i32 = 10 + i2: i32 = 4 + i1 = 3 + i2 = 5 + assert -i1 ^ -i2 == 6 + +main0() From 64b842b7f5ad7a304fcd0229d4a3f7416fdd4082 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 21 Jun 2022 15:35:41 +0530 Subject: [PATCH 3/9] 1. Convert initialisation at declaration to assignment (only for non-global variables) 2. Don't set value attribute for Variables (Python doesn't have constant variables by default) --- src/lpython/semantics/python_ast_to_asr.cpp | 35 +++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 529df81568..81d6e70c37 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -280,12 +280,14 @@ class CommonVisitor : public AST::BaseVisitor { AttributeHandler attr_handler; std::map &ast_overload; std::string parent_dir; + Vec *current_body; CommonVisitor(Allocator &al, SymbolTable *symbol_table, diag::Diagnostics &diagnostics, bool main_module, std::map &ast_overload, std::string parent_dir) : diag{diagnostics}, al{al}, current_scope{symbol_table}, main_module{main_module}, - ast_overload{ast_overload}, parent_dir{parent_dir} { + ast_overload{ast_overload}, parent_dir{parent_dir}, + current_body{nullptr} { current_module_dependencies.reserve(al, 4); } @@ -1351,7 +1353,12 @@ class CommonVisitor : public AST::BaseVisitor { throw SemanticAbort(); } init_expr = value; - value = ASRUtils::expr_value(value); + // Set compile time to value to nullptr + // Once constant variables are supported + // in LPython set value according to the + // nature of the variable (nullptr if non-constant, + // otherwise ASRUtils::expr_value(init_expr). + value = nullptr; } ASR::intentType s_intent = ASRUtils::intent_local; ASR::storage_typeType storage_type = @@ -1364,7 +1371,23 @@ class CommonVisitor : public AST::BaseVisitor { s2c(al, var_name), s_intent, init_expr, value, storage_type, type, current_procedure_abi_type, s_access, s_presence, value_attr); - current_scope->add_symbol(var_name, ASR::down_cast(v)); + ASR::symbol_t* v_sym = ASR::down_cast(v); + // Convert initialisation at declaration to assignment + // only for non-global variables. For global variables + // keep relying on `m_symbolic_value`. + if( init_expr && current_scope->parent != nullptr) { + ASR::expr_t* v_expr = ASRUtils::EXPR(ASR::make_Var_t(al, x.base.base.loc, v_sym)); + init_expr = cast_helper(ASRUtils::expr_type(v_expr), init_expr, true); + ASR::asr_t* assign = ASR::make_Assignment_t(al, x.base.base.loc, v_expr, + init_expr, nullptr); + if( current_body ) { + current_body->push_back(al, ASRUtils::STMT(assign)); + } + ASR::Variable_t* v_variable = ASR::down_cast(v_sym); + v_variable->m_symbolic_value = nullptr; + v_variable->m_value = nullptr; + } + current_scope->add_symbol(var_name, v_sym); tmp = nullptr; } @@ -2284,7 +2307,6 @@ class BodyVisitor : public CommonVisitor { public: ASR::asr_t *asr; - Vec *current_body; BodyVisitor(Allocator &al, ASR::asr_t *unit, diag::Diagnostics &diagnostics, bool main_module, std::map &ast_overload) @@ -2297,11 +2319,11 @@ class BodyVisitor : public CommonVisitor { // The `body` Vec must already be reserved void transform_stmts(Vec &body, size_t n_body, AST::stmt_t **m_body) { tmp = nullptr; + Vec* current_body_copy = current_body; + current_body = &body; for (size_t i=0; ivisit_stmt(*m_body[i]); - current_body = nullptr; if (tmp != nullptr) { ASR::stmt_t* tmp_stmt = ASRUtils::STMT(tmp); body.push_back(al, tmp_stmt); @@ -2309,6 +2331,7 @@ class BodyVisitor : public CommonVisitor { // To avoid last statement to be entered twice once we exit this node tmp = nullptr; } + current_body = current_body_copy; } void visit_Module(const AST::Module_t &x) { From 9cfa935248520dcfa3db9ac59fa6c17f62e2ee71 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 21 Jun 2022 15:37:14 +0530 Subject: [PATCH 4/9] Ignore Lists for now in Assignment.value --- src/libasr/codegen/asr_to_llvm.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libasr/codegen/asr_to_llvm.cpp b/src/libasr/codegen/asr_to_llvm.cpp index 8569b8bbb9..784f5d6117 100644 --- a/src/libasr/codegen/asr_to_llvm.cpp +++ b/src/libasr/codegen/asr_to_llvm.cpp @@ -2742,6 +2742,11 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor return ; } + // TODO: Remove this check after supporting ListConstant + if( ASR::is_a(*ASRUtils::expr_type(x.m_value)) ) { + return ; + } + if( ASR::is_a(*ASRUtils::expr_type(x.m_target)) && ASR::is_a(*x.m_value) ) { ASR::Variable_t *asr_target = EXPR2VAR(x.m_target); From b780432b4a1f3de4820fb82015f3d67c18adfb46 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 21 Jun 2022 15:37:27 +0530 Subject: [PATCH 5/9] Updated reference tests --- integration_tests/CMakeLists.txt | 4 +++- tests/reference/asr-assign2-8d1a2ee.json | 2 +- tests/reference/asr-assign2-8d1a2ee.stdout | 2 +- tests/reference/asr-expr_07-7742668.json | 13 +++++++++++++ tests/reference/asr-expr_07-7742668.stdout | 1 + tests/reference/asr-structs_03-0cef911.json | 2 +- tests/reference/asr-structs_03-0cef911.stdout | 2 +- tests/reference/asr-test_bool_binop-f856ef0.json | 2 +- tests/reference/asr-test_bool_binop-f856ef0.stdout | 2 +- tests/reference/asr-test_builtin_pow-f02fcda.json | 2 +- tests/reference/asr-test_builtin_pow-f02fcda.stdout | 2 +- tests/reference/asr-test_c_interop_01-e374f43.json | 2 +- .../reference/asr-test_c_interop_01-e374f43.stdout | 2 +- tests/reference/asr-test_max_min-3c2fc51.json | 2 +- tests/reference/asr-test_max_min-3c2fc51.stdout | 2 +- tests/reference/cpp-test_builtin_pow-56b3f92.json | 2 +- tests/reference/cpp-test_builtin_pow-56b3f92.stdout | 6 ++++++ tests/tests.toml | 8 ++++++++ 18 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 tests/reference/asr-expr_07-7742668.json create mode 100644 tests/reference/asr-expr_07-7742668.stdout diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 7076599c85..a5df50532d 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -132,7 +132,9 @@ RUN(NAME expr_03 LABELS cpython llvm c) RUN(NAME expr_04 LABELS cpython llvm c) RUN(NAME expr_05 LABELS cpython llvm) RUN(NAME expr_06 LABELS cpython llvm) -RUN(NAME expr_08 LABELS llvm c) +RUN(NAME expr_07 LABELS cpython llvm) +RUN(NAME expr_08 LABELS cpython llvm c) +RUN(NAME expr_09 LABELS cpython llvm c) RUN(NAME test_types_01 LABELS cpython llvm) RUN(NAME test_str_01 LABELS cpython llvm) RUN(NAME test_str_02 LABELS cpython llvm) diff --git a/tests/reference/asr-assign2-8d1a2ee.json b/tests/reference/asr-assign2-8d1a2ee.json index c5a24fa4c6..d173f18d06 100644 --- a/tests/reference/asr-assign2-8d1a2ee.json +++ b/tests/reference/asr-assign2-8d1a2ee.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-assign2-8d1a2ee.stdout", - "stdout_hash": "b358f13ad062675500fda44dc9108ac54f4d4a6dde14422717b86567", + "stdout_hash": "1faef0f925e9b0aef9c1c606170bf8a3795c2a076ea3de13e2f83143", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-assign2-8d1a2ee.stdout b/tests/reference/asr-assign2-8d1a2ee.stdout index 3548e998a6..6016f9b490 100644 --- a/tests/reference/asr-assign2-8d1a2ee.stdout +++ b/tests/reference/asr-assign2-8d1a2ee.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {f: (Variable 1 f Local (Cast (RealConstant 1.23456788999999989e+00 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 1.23456788999999989e+00 (Real 4 []))) (RealConstant 1.23456788999999989e+00 (Real 4 [])) Default (Real 4 []) Source Public Required .false.), f2: (Variable 1 f2 Local (RealConstant 1.23456789012340007e+00 (Real 8 [])) (RealConstant 1.23456789012340007e+00 (Real 8 [])) Default (Real 8 []) Source Public Required .false.), i: (Variable 1 i Local (IntegerConstant 5 (Integer 4 [])) (IntegerConstant 5 (Integer 4 [])) Default (Integer 4 []) Source Public Required .false.), i2: (Variable 1 i2 Local (Cast (IntegerConstant 53430903434 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) () Default (Integer 8 []) Source Public Required .false.), main_program: (Program (SymbolTable 2 {}) main_program [] [])}) []) +(TranslationUnit (SymbolTable 1 {f: (Variable 1 f Local (Cast (RealConstant 1.23456788999999989e+00 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 1.23456788999999989e+00 (Real 4 []))) () Default (Real 4 []) Source Public Required .false.), f2: (Variable 1 f2 Local (RealConstant 1.23456789012340007e+00 (Real 8 [])) () Default (Real 8 []) Source Public Required .false.), i: (Variable 1 i Local (IntegerConstant 5 (Integer 4 [])) () Default (Integer 4 []) Source Public Required .false.), i2: (Variable 1 i2 Local (Cast (IntegerConstant 53430903434 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) () Default (Integer 8 []) Source Public Required .false.), main_program: (Program (SymbolTable 2 {}) main_program [] [])}) []) diff --git a/tests/reference/asr-expr_07-7742668.json b/tests/reference/asr-expr_07-7742668.json new file mode 100644 index 0000000000..25eecba999 --- /dev/null +++ b/tests/reference/asr-expr_07-7742668.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-expr_07-7742668", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/../integration_tests/expr_07.py", + "infile_hash": "93d7dc8e33e95441ae207ead74fd68fbd1f7070211a51d857a449230", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-expr_07-7742668.stdout", + "stdout_hash": "afdf1ef922a6f5fe0737c75962082c8d9b7b16ad392a7d9fb8dd5cc9", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-expr_07-7742668.stdout b/tests/reference/asr-expr_07-7742668.stdout new file mode 100644 index 0000000000..735a79fa69 --- /dev/null +++ b/tests/reference/asr-expr_07-7742668.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Subroutine (SymbolTable 5 {}) _lpython_main_program [] [(SubroutineCall 1 f () [] ())] Source Public Implementation () .false. .false.), f: (Subroutine (SymbolTable 3 {a: (Variable 3 a Local () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 3 b Local () () Default (Integer 4 []) Source Public Required .false.), x: (Variable 3 x Local () () Default (Integer 4 []) Source Public Required .false.)}) f [] [(= (Var 3 a) (IntegerConstant 5 (Integer 4 [])) ()) (= (Var 3 x) (IntegerConstant 3 (Integer 4 [])) ()) (= (Var 3 x) (IntegerConstant 5 (Integer 4 [])) ()) (= (Var 3 b) (IntegerBinOp (Var 3 x) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) ()) ()) (Assert (Compare (Var 3 b) Eq (IntegerConstant 6 (Integer 4 [])) (Logical 4 []) () ()) ()) (Print () [(Var 3 a) (Var 3 b)]) (SubroutineCall 1 g () [((IntegerBinOp (IntegerBinOp (Var 3 a) Mul (Var 3 b) (Integer 4 []) ()) Add (IntegerConstant 3 (Integer 4 [])) (Integer 4 []) ()))] ())] Source Public Implementation () .false. .false.), g: (Subroutine (SymbolTable 2 {x: (Variable 2 x In () () Default (Integer 4 []) Source Public Required .false.)}) g [(Var 2 x)] [(Print () [(Var 2 x)])] Source Public Implementation () .false. .false.), main_program: (Program (SymbolTable 4 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())]), x: (Variable 1 x Local (IntegerConstant 7 (Integer 4 [])) () Default (Integer 4 []) Source Public Required .false.)}) []) diff --git a/tests/reference/asr-structs_03-0cef911.json b/tests/reference/asr-structs_03-0cef911.json index c39e2a2616..67b35b3584 100644 --- a/tests/reference/asr-structs_03-0cef911.json +++ b/tests/reference/asr-structs_03-0cef911.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-structs_03-0cef911.stdout", - "stdout_hash": "1028ceedc469db4b7760b842a14fddab5bf06056b0e80709748e9b3c", + "stdout_hash": "2cecfb5a8f3375186e436a64af29e3bfaf72859bcd1eadfa7260cc77", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-structs_03-0cef911.stdout b/tests/reference/asr-structs_03-0cef911.stdout index 6ae8e8aee5..2bb27227c0 100644 --- a/tests/reference/asr-structs_03-0cef911.stdout +++ b/tests/reference/asr-structs_03-0cef911.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {A: (DerivedType (SymbolTable 2 {x: (Variable 2 x Local () () Default (Integer 4 []) Source Public Required .false.), y: (Variable 2 y Local () () Default (Real 4 []) Source Public Required .false.)}) A [x y] Source Public ()), _lpython_main_program: (Subroutine (SymbolTable 6 {}) _lpython_main_program [] [(SubroutineCall 1 g () [] ())] Source Public Implementation () .false. .false.), f: (Subroutine (SymbolTable 3 {pa: (Variable 3 pa In () () Default (Pointer (Derived 1 A [])) Source Public Required .false.)}) f [(Var 3 pa)] [(Print () [(DerivedRef (Var 3 pa) 2 x (Integer 4 []) ())]) (Print () [(DerivedRef (Var 3 pa) 2 y (Real 4 []) ())])] Source Public Implementation () .false. .false.), g: (Subroutine (SymbolTable 4 {x: (Variable 4 x Local (DerivedTypeConstructor 1 A [(IntegerConstant 3 (Integer 4 [])) (Cast (RealConstant 3.25000000000000000e+00 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 3.25000000000000000e+00 (Real 4 [])))] (Derived 1 A []) ()) () Default (Derived 1 A []) Source Public Required .false.), xp: (Variable 4 xp Local (GetPointer (Var 4 x) (Pointer (Derived 1 A [])) ()) () Default (Pointer (Derived 1 A [])) Source Public Required .false.)}) g [] [(Assert (Compare (DerivedRef (Var 4 xp) 2 x (Integer 4 []) ()) Eq (IntegerConstant 3 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (Cast (DerivedRef (Var 4 xp) 2 y (Real 4 []) ()) RealToReal (Real 8 []) ()) Eq (RealConstant 3.25000000000000000e+00 (Real 8 [])) (Logical 4 []) () ()) ()) (= (DerivedRef (Var 4 xp) 2 x (Integer 4 []) ()) (IntegerConstant 5 (Integer 4 [])) ()) (= (DerivedRef (Var 4 xp) 2 y (Real 4 []) ()) (Cast (RealConstant 5.50000000000000000e+00 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 5.50000000000000000e+00 (Real 4 []))) ()) (SubroutineCall 1 f () [((Var 4 xp))] ())] Source Public Implementation () .false. .false.), main_program: (Program (SymbolTable 5 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())])}) []) +(TranslationUnit (SymbolTable 1 {A: (DerivedType (SymbolTable 2 {x: (Variable 2 x Local () () Default (Integer 4 []) Source Public Required .false.), y: (Variable 2 y Local () () Default (Real 4 []) Source Public Required .false.)}) A [x y] Source Public ()), _lpython_main_program: (Subroutine (SymbolTable 6 {}) _lpython_main_program [] [(SubroutineCall 1 g () [] ())] Source Public Implementation () .false. .false.), f: (Subroutine (SymbolTable 3 {pa: (Variable 3 pa In () () Default (Pointer (Derived 1 A [])) Source Public Required .false.)}) f [(Var 3 pa)] [(Print () [(DerivedRef (Var 3 pa) 2 x (Integer 4 []) ())]) (Print () [(DerivedRef (Var 3 pa) 2 y (Real 4 []) ())])] Source Public Implementation () .false. .false.), g: (Subroutine (SymbolTable 4 {x: (Variable 4 x Local () () Default (Derived 1 A []) Source Public Required .false.), xp: (Variable 4 xp Local () () Default (Pointer (Derived 1 A [])) Source Public Required .false.)}) g [] [(= (Var 4 x) (DerivedTypeConstructor 1 A [(IntegerConstant 3 (Integer 4 [])) (Cast (RealConstant 3.25000000000000000e+00 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 3.25000000000000000e+00 (Real 4 [])))] (Derived 1 A []) ()) ()) (= (Var 4 xp) (GetPointer (Var 4 x) (Pointer (Derived 1 A [])) ()) ()) (Assert (Compare (DerivedRef (Var 4 xp) 2 x (Integer 4 []) ()) Eq (IntegerConstant 3 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (Cast (DerivedRef (Var 4 xp) 2 y (Real 4 []) ()) RealToReal (Real 8 []) ()) Eq (RealConstant 3.25000000000000000e+00 (Real 8 [])) (Logical 4 []) () ()) ()) (= (DerivedRef (Var 4 xp) 2 x (Integer 4 []) ()) (IntegerConstant 5 (Integer 4 [])) ()) (= (DerivedRef (Var 4 xp) 2 y (Real 4 []) ()) (Cast (RealConstant 5.50000000000000000e+00 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 5.50000000000000000e+00 (Real 4 []))) ()) (SubroutineCall 1 f () [((Var 4 xp))] ())] Source Public Implementation () .false. .false.), main_program: (Program (SymbolTable 5 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())])}) []) diff --git a/tests/reference/asr-test_bool_binop-f856ef0.json b/tests/reference/asr-test_bool_binop-f856ef0.json index f6f36cb64f..b93d66d3ee 100644 --- a/tests/reference/asr-test_bool_binop-f856ef0.json +++ b/tests/reference/asr-test_bool_binop-f856ef0.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_bool_binop-f856ef0.stdout", - "stdout_hash": "da20c06dbc29523b9010516d6c1fc79748f7a5bab368b3d74c648f3a", + "stdout_hash": "0958aaa6a8402946f0a224b4a3b436b60f5642ad90fe41028ef45e75", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_bool_binop-f856ef0.stdout b/tests/reference/asr-test_bool_binop-f856ef0.stdout index b98f31c0fa..9fedecda16 100644 --- a/tests/reference/asr-test_bool_binop-f856ef0.stdout +++ b/tests/reference/asr-test_bool_binop-f856ef0.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lpython_floordiv@__lpython_overloaded_2___lpython_floordiv: (ExternalSymbol 1 _lpython_floordiv@__lpython_overloaded_2___lpython_floordiv 4 __lpython_overloaded_2___lpython_floordiv lpython_builtin [] __lpython_overloaded_2___lpython_floordiv Public), _lpython_main_program: (Subroutine (SymbolTable 100 {}) _lpython_main_program [] [(SubroutineCall 1 f () [] ())] Source Public Implementation () .false. .false.), f: (Subroutine (SymbolTable 2 {_lpython_floordiv: (ExternalSymbol 2 _lpython_floordiv 4 _lpython_floordiv lpython_builtin [] _lpython_floordiv Private), b1: (Variable 2 b1 Local (LogicalConstant .false. (Logical 4 [])) (LogicalConstant .false. (Logical 4 [])) Default (Logical 4 []) Source Public Required .false.), b2: (Variable 2 b2 Local (LogicalConstant .true. (Logical 4 [])) (LogicalConstant .true. (Logical 4 [])) Default (Logical 4 []) Source Public Required .false.), f: (Variable 2 f Local () () Default (Real 8 []) Source Public Required .false.), i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.)}) f [] [(= (Var 2 i) (IntegerBinOp (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) Add (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) (Integer 4 []) ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 2 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (IntegerBinOp (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) Sub (Cast (LogicalConstant .false. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) (Integer 4 []) ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (IntegerBinOp (Cast (LogicalConstant .false. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) Mul (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) (Integer 4 []) ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (FunctionCall 1 _lpython_floordiv@__lpython_overloaded_2___lpython_floordiv 2 _lpython_floordiv [((Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ())) ((Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()))] (Integer 4 []) () ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (FunctionCall 1 _lpython_floordiv@__lpython_overloaded_2___lpython_floordiv 2 _lpython_floordiv [((Cast (LogicalConstant .false. (Logical 4 [])) LogicalToInteger (Integer 4 []) ())) ((Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()))] (Integer 4 []) () ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (IntegerBinOp (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) Pow (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) (Integer 4 []) ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 f) (RealBinOp (Cast (Cast (Var 2 b1) LogicalToInteger (Integer 4 []) ()) IntegerToReal (Real 8 []) ()) Div (Cast (Cast (Var 2 b2) LogicalToInteger (Integer 4 []) ()) IntegerToReal (Real 8 []) ()) (Real 8 []) ()) ()) (Assert (Compare (Var 2 f) Eq (RealConstant 0.00000000000000000e+00 (Real 8 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 99 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())])}) []) +(TranslationUnit (SymbolTable 1 {_lpython_floordiv@__lpython_overloaded_2___lpython_floordiv: (ExternalSymbol 1 _lpython_floordiv@__lpython_overloaded_2___lpython_floordiv 4 __lpython_overloaded_2___lpython_floordiv lpython_builtin [] __lpython_overloaded_2___lpython_floordiv Public), _lpython_main_program: (Subroutine (SymbolTable 100 {}) _lpython_main_program [] [(SubroutineCall 1 f () [] ())] Source Public Implementation () .false. .false.), f: (Subroutine (SymbolTable 2 {_lpython_floordiv: (ExternalSymbol 2 _lpython_floordiv 4 _lpython_floordiv lpython_builtin [] _lpython_floordiv Private), b1: (Variable 2 b1 Local () () Default (Logical 4 []) Source Public Required .false.), b2: (Variable 2 b2 Local () () Default (Logical 4 []) Source Public Required .false.), f: (Variable 2 f Local () () Default (Real 8 []) Source Public Required .false.), i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.)}) f [] [(= (Var 2 i) (IntegerBinOp (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) Add (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) (Integer 4 []) ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 2 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (IntegerBinOp (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) Sub (Cast (LogicalConstant .false. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) (Integer 4 []) ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (IntegerBinOp (Cast (LogicalConstant .false. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) Mul (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) (Integer 4 []) ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (FunctionCall 1 _lpython_floordiv@__lpython_overloaded_2___lpython_floordiv 2 _lpython_floordiv [((Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ())) ((Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()))] (Integer 4 []) () ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (FunctionCall 1 _lpython_floordiv@__lpython_overloaded_2___lpython_floordiv 2 _lpython_floordiv [((Cast (LogicalConstant .false. (Logical 4 [])) LogicalToInteger (Integer 4 []) ())) ((Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()))] (Integer 4 []) () ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (IntegerBinOp (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) Pow (Cast (LogicalConstant .true. (Logical 4 [])) LogicalToInteger (Integer 4 []) ()) (Integer 4 []) ()) ()) (Assert (Compare (Var 2 i) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 b1) (LogicalConstant .false. (Logical 4 [])) ()) (= (Var 2 b2) (LogicalConstant .true. (Logical 4 [])) ()) (= (Var 2 f) (RealBinOp (Cast (Cast (Var 2 b1) LogicalToInteger (Integer 4 []) ()) IntegerToReal (Real 8 []) ()) Div (Cast (Cast (Var 2 b2) LogicalToInteger (Integer 4 []) ()) IntegerToReal (Real 8 []) ()) (Real 8 []) ()) ()) (Assert (Compare (Var 2 f) Eq (RealConstant 0.00000000000000000e+00 (Real 8 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 99 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())])}) []) diff --git a/tests/reference/asr-test_builtin_pow-f02fcda.json b/tests/reference/asr-test_builtin_pow-f02fcda.json index ec7755a97f..2e1d62c9ba 100644 --- a/tests/reference/asr-test_builtin_pow-f02fcda.json +++ b/tests/reference/asr-test_builtin_pow-f02fcda.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_pow-f02fcda.stdout", - "stdout_hash": "7793fa6daaf23da6f58420064d69ec07752a81f33e0790879c80e5a5", + "stdout_hash": "a0eb2b82f41397baa52fb1dcb933d6864008994cda4a0a5abc390ba7", "stderr": "asr-test_builtin_pow-f02fcda.stderr", "stderr_hash": "180e1adfbb0d9c63a2fffa31951bbd629b3f1950cf0d97ca1389efe5", "returncode": 0 diff --git a/tests/reference/asr-test_builtin_pow-f02fcda.stdout b/tests/reference/asr-test_builtin_pow-f02fcda.stdout index 638f125f81..55226332b9 100644 --- a/tests/reference/asr-test_builtin_pow-f02fcda.stdout +++ b/tests/reference/asr-test_builtin_pow-f02fcda.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Subroutine (SymbolTable 100 {}) _lpython_main_program [] [(SubroutineCall 1 test_pow () [] ())] Source Public Implementation () .false. .false.), abs@__lpython_overloaded_0__abs: (ExternalSymbol 1 abs@__lpython_overloaded_0__abs 4 __lpython_overloaded_0__abs lpython_builtin [] __lpython_overloaded_0__abs Public), complex@__lpython_overloaded_9__complex: (ExternalSymbol 1 complex@__lpython_overloaded_9__complex 4 __lpython_overloaded_9__complex lpython_builtin [] __lpython_overloaded_9__complex Public), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 99 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())]), pow@__lpython_overloaded_0__pow: (ExternalSymbol 1 pow@__lpython_overloaded_0__pow 4 __lpython_overloaded_0__pow lpython_builtin [] __lpython_overloaded_0__pow Public), pow@__lpython_overloaded_1__pow: (ExternalSymbol 1 pow@__lpython_overloaded_1__pow 4 __lpython_overloaded_1__pow lpython_builtin [] __lpython_overloaded_1__pow Public), pow@__lpython_overloaded_2__pow: (ExternalSymbol 1 pow@__lpython_overloaded_2__pow 4 __lpython_overloaded_2__pow lpython_builtin [] __lpython_overloaded_2__pow Public), pow@__lpython_overloaded_3__pow: (ExternalSymbol 1 pow@__lpython_overloaded_3__pow 4 __lpython_overloaded_3__pow lpython_builtin [] __lpython_overloaded_3__pow Public), pow@__lpython_overloaded_4__pow: (ExternalSymbol 1 pow@__lpython_overloaded_4__pow 4 __lpython_overloaded_4__pow lpython_builtin [] __lpython_overloaded_4__pow Public), pow@__lpython_overloaded_5__pow: (ExternalSymbol 1 pow@__lpython_overloaded_5__pow 4 __lpython_overloaded_5__pow lpython_builtin [] __lpython_overloaded_5__pow Public), pow@__lpython_overloaded_6__pow: (ExternalSymbol 1 pow@__lpython_overloaded_6__pow 4 __lpython_overloaded_6__pow lpython_builtin [] __lpython_overloaded_6__pow Public), pow@__lpython_overloaded_7__pow: (ExternalSymbol 1 pow@__lpython_overloaded_7__pow 4 __lpython_overloaded_7__pow lpython_builtin [] __lpython_overloaded_7__pow Public), pow@__lpython_overloaded_8__pow: (ExternalSymbol 1 pow@__lpython_overloaded_8__pow 4 __lpython_overloaded_8__pow lpython_builtin [] __lpython_overloaded_8__pow Public), pow@__lpython_overloaded_9__pow: (ExternalSymbol 1 pow@__lpython_overloaded_9__pow 4 __lpython_overloaded_9__pow lpython_builtin [] __lpython_overloaded_9__pow Public), test_pow: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), a1: (Variable 2 a1 Local (RealConstant 4.50000000000000000e+00 (Real 8 [])) (RealConstant 4.50000000000000000e+00 (Real 8 [])) Default (Real 8 []) Source Public Required .false.), a2: (Variable 2 a2 Local (RealConstant 2.29999999999999982e+00 (Real 8 [])) (RealConstant 2.29999999999999982e+00 (Real 8 [])) Default (Real 8 []) Source Public Required .false.), abs: (ExternalSymbol 2 abs 4 abs lpython_builtin [] abs Private), b: (Variable 2 b Local () () Default (Integer 4 []) Source Public Required .false.), b1: (Variable 2 b1 Local (LogicalConstant .true. (Logical 4 [])) (LogicalConstant .true. (Logical 4 [])) Default (Logical 4 []) Source Public Required .false.), b2: (Variable 2 b2 Local (LogicalConstant .false. (Logical 4 [])) (LogicalConstant .false. (Logical 4 [])) Default (Logical 4 []) Source Public Required .false.), c1: (Variable 2 c1 Local () () Default (Complex 4 []) Source Public Required .false.), complex: (ExternalSymbol 2 complex 4 complex lpython_builtin [] complex Private), eps: (Variable 2 eps Local () () Default (Real 8 []) Source Public Required .false.), f1: (Variable 2 f1 Local () () Default (Real 4 []) Source Public Required .false.), f2: (Variable 2 f2 Local () () Default (Real 4 []) Source Public Required .false.), i1: (Variable 2 i1 Local () () Default (Integer 8 []) Source Public Required .false.), i2: (Variable 2 i2 Local () () Default (Integer 8 []) Source Public Required .false.), p: (Variable 2 p Local () () Default (Real 4 []) Source Public Required .false.), pow: (ExternalSymbol 2 pow 4 pow lpython_builtin [] pow Private), x: (Variable 2 x Local (IntegerConstant 3 (Integer 4 [])) (IntegerConstant 3 (Integer 4 [])) Default (Integer 4 []) Source Public Required .false.), y: (Variable 2 y Local (RealConstant 2.29999999999999982e+00 (Real 8 [])) (RealConstant 2.29999999999999982e+00 (Real 8 [])) Default (Real 8 []) Source Public Required .false.)}) test_pow [] [(= (Var 2 eps) (RealConstant 9.99999999999999980e-13 (Real 8 [])) ()) (= (Var 2 a) (IntegerConstant 2 (Integer 4 [])) ()) (= (Var 2 b) (IntegerConstant 5 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((Var 2 a)) ((Var 2 b))] (Integer 4 []) () ()) Eq (IntegerConstant 32 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (IntegerConstant 6 (Integer 4 [])) ()) (= (Var 2 b) (IntegerConstant 3 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((Var 2 a)) ((Var 2 b))] (Integer 4 []) () ()) Eq (IntegerConstant 216 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (IntegerConstant 2 (Integer 4 [])) ()) (= (Var 2 b) (IntegerConstant 0 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((Var 2 a)) ((Var 2 b))] (Integer 4 []) () ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (IntegerConstant 2 (Integer 4 [])) ()) (= (Var 2 b) (IntegerUnaryMinus (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant -1 (Integer 4 []))) ()) (= (Var 2 a) (IntegerConstant 6 (Integer 4 [])) ()) (= (Var 2 b) (IntegerUnaryMinus (IntegerConstant 4 (Integer 4 [])) (Integer 4 []) (IntegerConstant -4 (Integer 4 []))) ()) (= (Var 2 i1) (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 2 i2) (Cast (IntegerConstant 5 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_1__pow 2 pow [((Var 2 i1)) ((Var 2 i2))] (Integer 8 []) () ()) Eq (Cast (IntegerConstant 32 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) (Logical 4 []) () ()) ()) (= (Var 2 i1) (Cast (IntegerConstant 6 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 2 i2) (Cast (IntegerUnaryMinus (IntegerConstant 3 (Integer 4 [])) (Integer 4 []) (IntegerConstant -3 (Integer 4 []))) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 2 f1) (Cast (RealBinOp (Cast (IntegerConstant 525346 (Integer 4 [])) IntegerToReal (Real 8 []) ()) Div (Cast (IntegerConstant 66456 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()) RealToReal (Real 4 []) ()) ()) (= (Var 2 f2) (Cast (RealConstant 3.00000000000000000e+00 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 3.00000000000000000e+00 (Real 4 []))) ()) (= (Var 2 p) (FunctionCall 1 pow@__lpython_overloaded_2__pow 2 pow [((Var 2 f1)) ((Var 2 f2))] (Real 4 []) () ()) ()) (= (Var 2 f1) (FunctionCall 1 pow@__lpython_overloaded_4__pow 2 pow [((Var 2 a)) ((Var 2 f2))] (Real 4 []) () ()) ()) (= (Var 2 f1) (FunctionCall 1 pow@__lpython_overloaded_5__pow 2 pow [((Var 2 f2)) ((Var 2 a))] (Real 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_8__pow 2 pow [((Var 2 b1)) ((Var 2 b2))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_8__pow 2 pow [((Var 2 b2)) ((Var 2 b1))] (Integer 4 []) (IntegerConstant 0 (Integer 4 [])) ()) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_8__pow 2 pow [((Var 2 b1)) ((Var 2 b2))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_8__pow 2 pow [((LogicalConstant .false. (Logical 4 []))) ((LogicalConstant .false. (Logical 4 [])))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((Var 2 a1)) ((Var 2 a2))] (Real 8 []) (RealConstant 3.17971929089206000e+01 (Real 8 [])) ()) Sub (RealConstant 3.17971929089206000e+01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((Var 2 a2)) ((Var 2 a1))] (Real 8 []) (RealConstant 4.24399889427765871e+01 (Real 8 [])) ()) Sub (RealConstant 4.24399889427765871e+01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_6__pow 2 pow [((Var 2 x)) ((Var 2 y))] (Real 8 []) (RealConstant 1.25135025328431819e+01 (Real 8 [])) ()) Sub (RealConstant 1.25135025328431819e+01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_7__pow 2 pow [((Var 2 y)) ((Var 2 x))] (Real 8 []) (RealConstant 1.21669999999999980e+01 (Real 8 [])) ()) Sub (RealConstant 1.21669999999999980e+01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_6__pow 2 pow [((Var 2 x)) ((RealConstant 5.50000000000000000e+00 (Real 8 [])))] (Real 8 []) (RealConstant 4.20888346239237194e+02 (Real 8 [])) ()) Sub (RealConstant 4.20888346239237194e+02 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (Cast (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 2 (Integer 4 []))) ((IntegerUnaryMinus (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant -1 (Integer 4 []))))] (Integer 4 []) (RealConstant 5.00000000000000000e-01 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Sub (RealConstant 5.00000000000000000e-01 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (Cast (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 6 (Integer 4 []))) ((IntegerUnaryMinus (IntegerConstant 4 (Integer 4 [])) (Integer 4 []) (IntegerConstant -4 (Integer 4 []))))] (Integer 4 []) (RealConstant 7.71604938271604895e-04 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Sub (RealConstant 7.71604938271604895e-04 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (Cast (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerUnaryMinus (IntegerConstant 3 (Integer 4 [])) (Integer 4 []) (IntegerConstant -3 (Integer 4 [])))) ((IntegerUnaryMinus (IntegerConstant 5 (Integer 4 [])) (Integer 4 []) (IntegerConstant -5 (Integer 4 []))))] (Integer 4 []) (RealConstant -4.11522633744856002e-03 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Add (RealConstant 4.11522633744856002e-03 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (Cast (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 6 (Integer 4 []))) ((IntegerUnaryMinus (IntegerConstant 4 (Integer 4 [])) (Integer 4 []) (IntegerConstant -4 (Integer 4 []))))] (Integer 4 []) (RealConstant 7.71604938271604895e-04 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Sub (RealConstant 7.71604938271604895e-04 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((RealConstant 4.50000000000000000e+00 (Real 8 []))) ((RealConstant 2.29999999999999982e+00 (Real 8 [])))] (Real 8 []) (RealConstant 3.17971929089206000e+01 (Real 8 [])) ()) Sub (RealConstant 3.17971929089206000e+01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((RealConstant 2.29999999999999982e+00 (Real 8 []))) ((RealConstant 0.00000000000000000e+00 (Real 8 [])))] (Real 8 []) (RealConstant 1.00000000000000000e+00 (Real 8 [])) ()) Sub (RealConstant 1.00000000000000000e+00 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((RealConstant 2.29999999999999982e+00 (Real 8 []))) ((RealUnaryMinus (RealConstant 1.50000000000000000e+00 (Real 8 [])) (Real 8 []) (RealConstant -1.50000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 2.86687162345994395e-01 (Real 8 [])) ()) Sub (RealConstant 2.86687162345994395e-01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_6__pow 2 pow [((IntegerConstant 2 (Integer 4 []))) ((RealConstant 3.39999999999999991e+00 (Real 8 [])))] (Real 8 []) (RealConstant 1.05560632861831536e+01 (Real 8 [])) ()) Sub (RealConstant 1.05560632861831536e+01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_6__pow 2 pow [((IntegerConstant 2 (Integer 4 []))) ((RealUnaryMinus (RealConstant 3.39999999999999991e+00 (Real 8 [])) (Real 8 []) (RealConstant -3.39999999999999991e+00 (Real 8 []))))] (Real 8 []) (RealConstant 9.47322854068998882e-02 (Real 8 [])) ()) Sub (RealConstant 9.47322854068998882e-02 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_7__pow 2 pow [((RealConstant 3.39999999999999991e+00 (Real 8 []))) ((IntegerConstant 9 (Integer 4 [])))] (Real 8 []) (RealConstant 6.07169927664639836e+04 (Real 8 [])) ()) Sub (RealConstant 6.07169927664639836e+04 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_7__pow 2 pow [((RealConstant 0.00000000000000000e+00 (Real 8 []))) ((IntegerConstant 53 (Integer 4 [])))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Sub (RealConstant 0.00000000000000000e+00 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 4 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 16 (Integer 4 [])) ()) Eq (IntegerConstant 16 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_7__pow 2 pow [((RealUnaryMinus (RealConstant 4.23500000000000000e+03 (Real 8 [])) (Real 8 []) (RealConstant -4.23500000000000000e+03 (Real 8 [])))) ((IntegerConstant 52 (Integer 4 [])))] (Real 8 []) (RealConstant 3.94800380598526379e+188 (Real 8 [])) ()) Sub (RealConstant 3.94800380598526379e+188 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (= (Var 2 c1) (Cast (FunctionCall 1 complex@__lpython_overloaded_9__complex 2 complex [((IntegerConstant 4 (Integer 4 []))) ((IntegerConstant 5 (Integer 4 [])))] (Complex 8 []) (ComplexConstant 4.00000000000000000e+00 5.00000000000000000e+00 (Complex 8 [])) ()) ComplexToComplex (Complex 4 []) (ComplexConstant 4.00000000000000000e+00 5.00000000000000000e+00 (Complex 4 []))) ()) (= (Var 2 c1) (FunctionCall 1 pow@__lpython_overloaded_9__pow 2 pow [((Var 2 c1)) ((IntegerConstant 4 (Integer 4 [])))] (Complex 4 []) () ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Subroutine (SymbolTable 100 {}) _lpython_main_program [] [(SubroutineCall 1 test_pow () [] ())] Source Public Implementation () .false. .false.), abs@__lpython_overloaded_0__abs: (ExternalSymbol 1 abs@__lpython_overloaded_0__abs 4 __lpython_overloaded_0__abs lpython_builtin [] __lpython_overloaded_0__abs Public), complex@__lpython_overloaded_9__complex: (ExternalSymbol 1 complex@__lpython_overloaded_9__complex 4 __lpython_overloaded_9__complex lpython_builtin [] __lpython_overloaded_9__complex Public), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 99 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())]), pow@__lpython_overloaded_0__pow: (ExternalSymbol 1 pow@__lpython_overloaded_0__pow 4 __lpython_overloaded_0__pow lpython_builtin [] __lpython_overloaded_0__pow Public), pow@__lpython_overloaded_1__pow: (ExternalSymbol 1 pow@__lpython_overloaded_1__pow 4 __lpython_overloaded_1__pow lpython_builtin [] __lpython_overloaded_1__pow Public), pow@__lpython_overloaded_2__pow: (ExternalSymbol 1 pow@__lpython_overloaded_2__pow 4 __lpython_overloaded_2__pow lpython_builtin [] __lpython_overloaded_2__pow Public), pow@__lpython_overloaded_3__pow: (ExternalSymbol 1 pow@__lpython_overloaded_3__pow 4 __lpython_overloaded_3__pow lpython_builtin [] __lpython_overloaded_3__pow Public), pow@__lpython_overloaded_4__pow: (ExternalSymbol 1 pow@__lpython_overloaded_4__pow 4 __lpython_overloaded_4__pow lpython_builtin [] __lpython_overloaded_4__pow Public), pow@__lpython_overloaded_5__pow: (ExternalSymbol 1 pow@__lpython_overloaded_5__pow 4 __lpython_overloaded_5__pow lpython_builtin [] __lpython_overloaded_5__pow Public), pow@__lpython_overloaded_6__pow: (ExternalSymbol 1 pow@__lpython_overloaded_6__pow 4 __lpython_overloaded_6__pow lpython_builtin [] __lpython_overloaded_6__pow Public), pow@__lpython_overloaded_7__pow: (ExternalSymbol 1 pow@__lpython_overloaded_7__pow 4 __lpython_overloaded_7__pow lpython_builtin [] __lpython_overloaded_7__pow Public), pow@__lpython_overloaded_8__pow: (ExternalSymbol 1 pow@__lpython_overloaded_8__pow 4 __lpython_overloaded_8__pow lpython_builtin [] __lpython_overloaded_8__pow Public), pow@__lpython_overloaded_9__pow: (ExternalSymbol 1 pow@__lpython_overloaded_9__pow 4 __lpython_overloaded_9__pow lpython_builtin [] __lpython_overloaded_9__pow Public), test_pow: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), a1: (Variable 2 a1 Local () () Default (Real 8 []) Source Public Required .false.), a2: (Variable 2 a2 Local () () Default (Real 8 []) Source Public Required .false.), abs: (ExternalSymbol 2 abs 4 abs lpython_builtin [] abs Private), b: (Variable 2 b Local () () Default (Integer 4 []) Source Public Required .false.), b1: (Variable 2 b1 Local () () Default (Logical 4 []) Source Public Required .false.), b2: (Variable 2 b2 Local () () Default (Logical 4 []) Source Public Required .false.), c1: (Variable 2 c1 Local () () Default (Complex 4 []) Source Public Required .false.), complex: (ExternalSymbol 2 complex 4 complex lpython_builtin [] complex Private), eps: (Variable 2 eps Local () () Default (Real 8 []) Source Public Required .false.), f1: (Variable 2 f1 Local () () Default (Real 4 []) Source Public Required .false.), f2: (Variable 2 f2 Local () () Default (Real 4 []) Source Public Required .false.), i1: (Variable 2 i1 Local () () Default (Integer 8 []) Source Public Required .false.), i2: (Variable 2 i2 Local () () Default (Integer 8 []) Source Public Required .false.), p: (Variable 2 p Local () () Default (Real 4 []) Source Public Required .false.), pow: (ExternalSymbol 2 pow 4 pow lpython_builtin [] pow Private), x: (Variable 2 x Local () () Default (Integer 4 []) Source Public Required .false.), y: (Variable 2 y Local () () Default (Real 8 []) Source Public Required .false.)}) test_pow [] [(= (Var 2 eps) (RealConstant 9.99999999999999980e-13 (Real 8 [])) ()) (= (Var 2 a) (IntegerConstant 2 (Integer 4 [])) ()) (= (Var 2 b) (IntegerConstant 5 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((Var 2 a)) ((Var 2 b))] (Integer 4 []) () ()) Eq (IntegerConstant 32 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (IntegerConstant 6 (Integer 4 [])) ()) (= (Var 2 b) (IntegerConstant 3 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((Var 2 a)) ((Var 2 b))] (Integer 4 []) () ()) Eq (IntegerConstant 216 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (IntegerConstant 2 (Integer 4 [])) ()) (= (Var 2 b) (IntegerConstant 0 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((Var 2 a)) ((Var 2 b))] (Integer 4 []) () ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (IntegerConstant 2 (Integer 4 [])) ()) (= (Var 2 b) (IntegerUnaryMinus (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant -1 (Integer 4 []))) ()) (= (Var 2 a) (IntegerConstant 6 (Integer 4 [])) ()) (= (Var 2 b) (IntegerUnaryMinus (IntegerConstant 4 (Integer 4 [])) (Integer 4 []) (IntegerConstant -4 (Integer 4 []))) ()) (= (Var 2 i1) (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 2 i2) (Cast (IntegerConstant 5 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_1__pow 2 pow [((Var 2 i1)) ((Var 2 i2))] (Integer 8 []) () ()) Eq (Cast (IntegerConstant 32 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) (Logical 4 []) () ()) ()) (= (Var 2 i1) (Cast (IntegerConstant 6 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 2 i2) (Cast (IntegerUnaryMinus (IntegerConstant 3 (Integer 4 [])) (Integer 4 []) (IntegerConstant -3 (Integer 4 []))) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 2 f1) (Cast (RealBinOp (Cast (IntegerConstant 525346 (Integer 4 [])) IntegerToReal (Real 8 []) ()) Div (Cast (IntegerConstant 66456 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()) RealToReal (Real 4 []) ()) ()) (= (Var 2 f2) (Cast (RealConstant 3.00000000000000000e+00 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 3.00000000000000000e+00 (Real 4 []))) ()) (= (Var 2 p) (FunctionCall 1 pow@__lpython_overloaded_2__pow 2 pow [((Var 2 f1)) ((Var 2 f2))] (Real 4 []) () ()) ()) (= (Var 2 f1) (FunctionCall 1 pow@__lpython_overloaded_4__pow 2 pow [((Var 2 a)) ((Var 2 f2))] (Real 4 []) () ()) ()) (= (Var 2 f1) (FunctionCall 1 pow@__lpython_overloaded_5__pow 2 pow [((Var 2 f2)) ((Var 2 a))] (Real 4 []) () ()) ()) (= (Var 2 b1) (LogicalConstant .true. (Logical 4 [])) ()) (= (Var 2 b2) (LogicalConstant .false. (Logical 4 [])) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_8__pow 2 pow [((Var 2 b1)) ((Var 2 b2))] (Integer 4 []) () ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_8__pow 2 pow [((Var 2 b2)) ((Var 2 b1))] (Integer 4 []) () ()) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_8__pow 2 pow [((Var 2 b1)) ((Var 2 b2))] (Integer 4 []) () ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_8__pow 2 pow [((LogicalConstant .false. (Logical 4 []))) ((LogicalConstant .false. (Logical 4 [])))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (= (Var 2 a1) (RealConstant 4.50000000000000000e+00 (Real 8 [])) ()) (= (Var 2 a2) (RealConstant 2.29999999999999982e+00 (Real 8 [])) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((Var 2 a1)) ((Var 2 a2))] (Real 8 []) () ()) Sub (RealConstant 3.17971929089206000e+01 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((Var 2 a2)) ((Var 2 a1))] (Real 8 []) () ()) Sub (RealConstant 4.24399889427765871e+01 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (= (Var 2 x) (IntegerConstant 3 (Integer 4 [])) ()) (= (Var 2 y) (RealConstant 2.29999999999999982e+00 (Real 8 [])) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_6__pow 2 pow [((Var 2 x)) ((Var 2 y))] (Real 8 []) () ()) Sub (RealConstant 1.25135025328431819e+01 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_7__pow 2 pow [((Var 2 y)) ((Var 2 x))] (Real 8 []) () ()) Sub (RealConstant 1.21669999999999980e+01 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_6__pow 2 pow [((Var 2 x)) ((RealConstant 5.50000000000000000e+00 (Real 8 [])))] (Real 8 []) () ()) Sub (RealConstant 4.20888346239237194e+02 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (Cast (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 2 (Integer 4 []))) ((IntegerUnaryMinus (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant -1 (Integer 4 []))))] (Integer 4 []) (RealConstant 5.00000000000000000e-01 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Sub (RealConstant 5.00000000000000000e-01 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (Cast (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 6 (Integer 4 []))) ((IntegerUnaryMinus (IntegerConstant 4 (Integer 4 [])) (Integer 4 []) (IntegerConstant -4 (Integer 4 []))))] (Integer 4 []) (RealConstant 7.71604938271604895e-04 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Sub (RealConstant 7.71604938271604895e-04 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (Cast (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerUnaryMinus (IntegerConstant 3 (Integer 4 [])) (Integer 4 []) (IntegerConstant -3 (Integer 4 [])))) ((IntegerUnaryMinus (IntegerConstant 5 (Integer 4 [])) (Integer 4 []) (IntegerConstant -5 (Integer 4 []))))] (Integer 4 []) (RealConstant -4.11522633744856002e-03 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Add (RealConstant 4.11522633744856002e-03 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (Cast (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 6 (Integer 4 []))) ((IntegerUnaryMinus (IntegerConstant 4 (Integer 4 [])) (Integer 4 []) (IntegerConstant -4 (Integer 4 []))))] (Integer 4 []) (RealConstant 7.71604938271604895e-04 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Sub (RealConstant 7.71604938271604895e-04 (Real 8 [])) (Real 8 []) ()))] (Real 8 []) () ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((RealConstant 4.50000000000000000e+00 (Real 8 []))) ((RealConstant 2.29999999999999982e+00 (Real 8 [])))] (Real 8 []) (RealConstant 3.17971929089206000e+01 (Real 8 [])) ()) Sub (RealConstant 3.17971929089206000e+01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((RealConstant 2.29999999999999982e+00 (Real 8 []))) ((RealConstant 0.00000000000000000e+00 (Real 8 [])))] (Real 8 []) (RealConstant 1.00000000000000000e+00 (Real 8 [])) ()) Sub (RealConstant 1.00000000000000000e+00 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_3__pow 2 pow [((RealConstant 2.29999999999999982e+00 (Real 8 []))) ((RealUnaryMinus (RealConstant 1.50000000000000000e+00 (Real 8 [])) (Real 8 []) (RealConstant -1.50000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 2.86687162345994395e-01 (Real 8 [])) ()) Sub (RealConstant 2.86687162345994395e-01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_6__pow 2 pow [((IntegerConstant 2 (Integer 4 []))) ((RealConstant 3.39999999999999991e+00 (Real 8 [])))] (Real 8 []) (RealConstant 1.05560632861831536e+01 (Real 8 [])) ()) Sub (RealConstant 1.05560632861831536e+01 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_6__pow 2 pow [((IntegerConstant 2 (Integer 4 []))) ((RealUnaryMinus (RealConstant 3.39999999999999991e+00 (Real 8 [])) (Real 8 []) (RealConstant -3.39999999999999991e+00 (Real 8 []))))] (Real 8 []) (RealConstant 9.47322854068998882e-02 (Real 8 [])) ()) Sub (RealConstant 9.47322854068998882e-02 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_7__pow 2 pow [((RealConstant 3.39999999999999991e+00 (Real 8 []))) ((IntegerConstant 9 (Integer 4 [])))] (Real 8 []) (RealConstant 6.07169927664639836e+04 (Real 8 [])) ()) Sub (RealConstant 6.07169927664639836e+04 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_7__pow 2 pow [((RealConstant 0.00000000000000000e+00 (Real 8 []))) ((IntegerConstant 53 (Integer 4 [])))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Sub (RealConstant 0.00000000000000000e+00 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 4 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 16 (Integer 4 [])) ()) Eq (IntegerConstant 16 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 2 abs [((RealBinOp (FunctionCall 1 pow@__lpython_overloaded_7__pow 2 pow [((RealUnaryMinus (RealConstant 4.23500000000000000e+03 (Real 8 [])) (Real 8 []) (RealConstant -4.23500000000000000e+03 (Real 8 [])))) ((IntegerConstant 52 (Integer 4 [])))] (Real 8 []) (RealConstant 3.94800380598526379e+188 (Real 8 [])) ()) Sub (RealConstant 3.94800380598526379e+188 (Real 8 [])) (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 []))))] (Real 8 []) (RealConstant 0.00000000000000000e+00 (Real 8 [])) ()) Lt (Var 2 eps) (Logical 4 []) () ()) ()) (= (Var 2 c1) (Cast (FunctionCall 1 complex@__lpython_overloaded_9__complex 2 complex [((IntegerConstant 4 (Integer 4 []))) ((IntegerConstant 5 (Integer 4 [])))] (Complex 8 []) (ComplexConstant 4.00000000000000000e+00 5.00000000000000000e+00 (Complex 8 [])) ()) ComplexToComplex (Complex 4 []) (ComplexConstant 4.00000000000000000e+00 5.00000000000000000e+00 (Complex 4 []))) ()) (= (Var 2 c1) (FunctionCall 1 pow@__lpython_overloaded_9__pow 2 pow [((Var 2 c1)) ((IntegerConstant 4 (Integer 4 [])))] (Complex 4 []) () ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_c_interop_01-e374f43.json b/tests/reference/asr-test_c_interop_01-e374f43.json index 7b987b3f5b..12895b4e8e 100644 --- a/tests/reference/asr-test_c_interop_01-e374f43.json +++ b/tests/reference/asr-test_c_interop_01-e374f43.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_c_interop_01-e374f43.stdout", - "stdout_hash": "b0dc2e9f4091bb837ed5035abf510cc6f66f68e7114e9ae126d3c82f", + "stdout_hash": "84bc8207c185e5369adea9f879f7f84297054ebb82856757fabb0dbf", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_c_interop_01-e374f43.stdout b/tests/reference/asr-test_c_interop_01-e374f43.stdout index 1e2af630fa..2de73f480c 100644 --- a/tests/reference/asr-test_c_interop_01-e374f43.stdout +++ b/tests/reference/asr-test_c_interop_01-e374f43.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lfortran_bgt32: (Function (SymbolTable 4 {_lpython_return_variable: (Variable 4 _lpython_return_variable ReturnVar () () Default (Integer 4 []) BindC Public Required .false.), i: (Variable 4 i In () () Default (Integer 4 []) BindC Public Required .true.), j: (Variable 4 j In () () Default (Integer 4 []) BindC Public Required .true.)}) _lfortran_bgt32 [(Var 4 i) (Var 4 j)] [] (Var 4 _lpython_return_variable) BindC Public Interface ()), _lfortran_bgt64: (Function (SymbolTable 5 {_lpython_return_variable: (Variable 5 _lpython_return_variable ReturnVar () () Default (Integer 4 []) BindC Public Required .false.), i: (Variable 5 i In () () Default (Integer 8 []) BindC Public Required .true.), j: (Variable 5 j In () () Default (Integer 8 []) BindC Public Required .true.)}) _lfortran_bgt64 [(Var 5 i) (Var 5 j)] [] (Var 5 _lpython_return_variable) BindC Public Interface ()), _lfortran_dsin: (Function (SymbolTable 2 {_lpython_return_variable: (Variable 2 _lpython_return_variable ReturnVar () () Default (Real 8 []) BindC Public Required .false.), x: (Variable 2 x In () () Default (Real 8 []) BindC Public Required .true.)}) _lfortran_dsin [(Var 2 x)] [] (Var 2 _lpython_return_variable) BindC Public Interface ()), _lfortran_ssin: (Function (SymbolTable 3 {_lpython_return_variable: (Variable 3 _lpython_return_variable ReturnVar () () Default (Real 4 []) BindC Public Required .false.), x: (Variable 3 x In () () Default (Real 4 []) BindC Public Required .true.)}) _lfortran_ssin [(Var 3 x)] [] (Var 3 _lpython_return_variable) BindC Public Interface ()), _lpython_main_program: (Subroutine (SymbolTable 104 {}) _lpython_main_program [] [(SubroutineCall 1 test_c_callbacks () [] ())] Source Public Implementation () .false. .false.), abs@__lpython_overloaded_0__abs: (ExternalSymbol 1 abs@__lpython_overloaded_0__abs 8 __lpython_overloaded_0__abs lpython_builtin [] __lpython_overloaded_0__abs Public), abs@__lpython_overloaded_1__abs: (ExternalSymbol 1 abs@__lpython_overloaded_1__abs 8 __lpython_overloaded_1__abs lpython_builtin [] __lpython_overloaded_1__abs Public), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 103 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())]), test_c_callbacks: (Subroutine (SymbolTable 6 {abs: (ExternalSymbol 6 abs 8 abs lpython_builtin [] abs Private), pi: (Variable 6 pi Local (RealConstant 3.14159265358979312e+00 (Real 8 [])) (RealConstant 3.14159265358979312e+00 (Real 8 [])) Default (Real 8 []) Source Public Required .false.)}) test_c_callbacks [] [(Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 6 abs [((RealBinOp (FunctionCall 1 _lfortran_dsin () [((Var 6 pi))] (Real 8 []) () ()) Sub (Cast (IntegerConstant 0 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()))] (Real 8 []) () ()) Lt (RealConstant 9.99999999999999980e-13 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 6 abs [((RealBinOp (FunctionCall 1 _lfortran_dsin () [((RealBinOp (Var 6 pi) Div (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()))] (Real 8 []) () ()) Sub (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()))] (Real 8 []) () ()) Lt (RealConstant 9.99999999999999980e-13 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (Cast (FunctionCall 1 abs@__lpython_overloaded_1__abs 6 abs [((RealBinOp (FunctionCall 1 _lfortran_ssin () [((Cast (Var 6 pi) RealToReal (Real 4 []) (RealConstant 3.14159265358979312e+00 (Real 4 []))))] (Real 4 []) () ()) Sub (Cast (IntegerConstant 0 (Integer 4 [])) IntegerToReal (Real 4 []) ()) (Real 4 []) ()))] (Real 4 []) () ()) RealToReal (Real 8 []) ()) Lt (RealConstant 9.99999999999999955e-07 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (Cast (FunctionCall 1 abs@__lpython_overloaded_1__abs 6 abs [((RealBinOp (FunctionCall 1 _lfortran_ssin () [((Cast (RealBinOp (Var 6 pi) Div (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()) RealToReal (Real 4 []) ()))] (Real 4 []) () ()) Sub (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToReal (Real 4 []) ()) (Real 4 []) ()))] (Real 4 []) () ()) RealToReal (Real 8 []) ()) Lt (RealConstant 9.99999999999999955e-07 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 _lfortran_bgt32 () [((IntegerConstant 3 (Integer 4 []))) ((IntegerConstant 4 (Integer 4 [])))] (Integer 4 []) () ()) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 _lfortran_bgt32 () [((IntegerConstant 4 (Integer 4 []))) ((IntegerConstant 3 (Integer 4 [])))] (Integer 4 []) () ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 _lfortran_bgt64 () [((Cast (IntegerConstant 3 (Integer 4 [])) IntegerToInteger (Integer 8 []) ())) ((Cast (IntegerConstant 4 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()))] (Integer 4 []) () ()) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 _lfortran_bgt64 () [((Cast (IntegerConstant 4 (Integer 4 [])) IntegerToInteger (Integer 8 []) ())) ((Cast (IntegerConstant 3 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()))] (Integer 4 []) () ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {_lfortran_bgt32: (Function (SymbolTable 4 {_lpython_return_variable: (Variable 4 _lpython_return_variable ReturnVar () () Default (Integer 4 []) BindC Public Required .false.), i: (Variable 4 i In () () Default (Integer 4 []) BindC Public Required .true.), j: (Variable 4 j In () () Default (Integer 4 []) BindC Public Required .true.)}) _lfortran_bgt32 [(Var 4 i) (Var 4 j)] [] (Var 4 _lpython_return_variable) BindC Public Interface ()), _lfortran_bgt64: (Function (SymbolTable 5 {_lpython_return_variable: (Variable 5 _lpython_return_variable ReturnVar () () Default (Integer 4 []) BindC Public Required .false.), i: (Variable 5 i In () () Default (Integer 8 []) BindC Public Required .true.), j: (Variable 5 j In () () Default (Integer 8 []) BindC Public Required .true.)}) _lfortran_bgt64 [(Var 5 i) (Var 5 j)] [] (Var 5 _lpython_return_variable) BindC Public Interface ()), _lfortran_dsin: (Function (SymbolTable 2 {_lpython_return_variable: (Variable 2 _lpython_return_variable ReturnVar () () Default (Real 8 []) BindC Public Required .false.), x: (Variable 2 x In () () Default (Real 8 []) BindC Public Required .true.)}) _lfortran_dsin [(Var 2 x)] [] (Var 2 _lpython_return_variable) BindC Public Interface ()), _lfortran_ssin: (Function (SymbolTable 3 {_lpython_return_variable: (Variable 3 _lpython_return_variable ReturnVar () () Default (Real 4 []) BindC Public Required .false.), x: (Variable 3 x In () () Default (Real 4 []) BindC Public Required .true.)}) _lfortran_ssin [(Var 3 x)] [] (Var 3 _lpython_return_variable) BindC Public Interface ()), _lpython_main_program: (Subroutine (SymbolTable 104 {}) _lpython_main_program [] [(SubroutineCall 1 test_c_callbacks () [] ())] Source Public Implementation () .false. .false.), abs@__lpython_overloaded_0__abs: (ExternalSymbol 1 abs@__lpython_overloaded_0__abs 8 __lpython_overloaded_0__abs lpython_builtin [] __lpython_overloaded_0__abs Public), abs@__lpython_overloaded_1__abs: (ExternalSymbol 1 abs@__lpython_overloaded_1__abs 8 __lpython_overloaded_1__abs lpython_builtin [] __lpython_overloaded_1__abs Public), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 103 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())]), test_c_callbacks: (Subroutine (SymbolTable 6 {abs: (ExternalSymbol 6 abs 8 abs lpython_builtin [] abs Private), pi: (Variable 6 pi Local () () Default (Real 8 []) Source Public Required .false.)}) test_c_callbacks [] [(= (Var 6 pi) (RealConstant 3.14159265358979312e+00 (Real 8 [])) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 6 abs [((RealBinOp (FunctionCall 1 _lfortran_dsin () [((Var 6 pi))] (Real 8 []) () ()) Sub (Cast (IntegerConstant 0 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()))] (Real 8 []) () ()) Lt (RealConstant 9.99999999999999980e-13 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 abs@__lpython_overloaded_0__abs 6 abs [((RealBinOp (FunctionCall 1 _lfortran_dsin () [((RealBinOp (Var 6 pi) Div (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()))] (Real 8 []) () ()) Sub (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()))] (Real 8 []) () ()) Lt (RealConstant 9.99999999999999980e-13 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (Cast (FunctionCall 1 abs@__lpython_overloaded_1__abs 6 abs [((RealBinOp (FunctionCall 1 _lfortran_ssin () [((Cast (Var 6 pi) RealToReal (Real 4 []) ()))] (Real 4 []) () ()) Sub (Cast (IntegerConstant 0 (Integer 4 [])) IntegerToReal (Real 4 []) ()) (Real 4 []) ()))] (Real 4 []) () ()) RealToReal (Real 8 []) ()) Lt (RealConstant 9.99999999999999955e-07 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (Cast (FunctionCall 1 abs@__lpython_overloaded_1__abs 6 abs [((RealBinOp (FunctionCall 1 _lfortran_ssin () [((Cast (RealBinOp (Var 6 pi) Div (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) ()) RealToReal (Real 4 []) ()))] (Real 4 []) () ()) Sub (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToReal (Real 4 []) ()) (Real 4 []) ()))] (Real 4 []) () ()) RealToReal (Real 8 []) ()) Lt (RealConstant 9.99999999999999955e-07 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 _lfortran_bgt32 () [((IntegerConstant 3 (Integer 4 []))) ((IntegerConstant 4 (Integer 4 [])))] (Integer 4 []) () ()) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 _lfortran_bgt32 () [((IntegerConstant 4 (Integer 4 []))) ((IntegerConstant 3 (Integer 4 [])))] (Integer 4 []) () ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 _lfortran_bgt64 () [((Cast (IntegerConstant 3 (Integer 4 [])) IntegerToInteger (Integer 8 []) ())) ((Cast (IntegerConstant 4 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()))] (Integer 4 []) () ()) Eq (IntegerConstant 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 _lfortran_bgt64 () [((Cast (IntegerConstant 4 (Integer 4 [])) IntegerToInteger (Integer 8 []) ())) ((Cast (IntegerConstant 3 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()))] (Integer 4 []) () ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_max_min-3c2fc51.json b/tests/reference/asr-test_max_min-3c2fc51.json index 406ccc5329..d02ad8554e 100644 --- a/tests/reference/asr-test_max_min-3c2fc51.json +++ b/tests/reference/asr-test_max_min-3c2fc51.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_max_min-3c2fc51.stdout", - "stdout_hash": "d688a82ba0efe7492b93c2b071389a65c8b5316fb8cc7e5f84cd5dcd", + "stdout_hash": "f5de6b13edd3e962742009122150f12886350e0e0c23f558479c5f1e", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_max_min-3c2fc51.stdout b/tests/reference/asr-test_max_min-3c2fc51.stdout index a15de2f67c..c6b327370c 100644 --- a/tests/reference/asr-test_max_min-3c2fc51.stdout +++ b/tests/reference/asr-test_max_min-3c2fc51.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Subroutine (SymbolTable 104 {}) _lpython_main_program [] [(SubroutineCall 1 check () [] ())] Source Public Implementation () .false. .false.), check: (Subroutine (SymbolTable 6 {}) check [] [(SubroutineCall 1 test_max_int () [] ()) (SubroutineCall 1 test_max_float () [] ()) (SubroutineCall 1 test_min_int () [] ()) (SubroutineCall 1 test_min_float () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 103 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())]), max@__lpython_overloaded_0__max: (ExternalSymbol 1 max@__lpython_overloaded_0__max 8 __lpython_overloaded_0__max lpython_builtin [] __lpython_overloaded_0__max Public), max@__lpython_overloaded_1__max: (ExternalSymbol 1 max@__lpython_overloaded_1__max 8 __lpython_overloaded_1__max lpython_builtin [] __lpython_overloaded_1__max Public), max@__lpython_overloaded_2__max: (ExternalSymbol 1 max@__lpython_overloaded_2__max 8 __lpython_overloaded_2__max lpython_builtin [] __lpython_overloaded_2__max Public), max@__lpython_overloaded_3__max: (ExternalSymbol 1 max@__lpython_overloaded_3__max 8 __lpython_overloaded_3__max lpython_builtin [] __lpython_overloaded_3__max Public), min@__lpython_overloaded_0__min: (ExternalSymbol 1 min@__lpython_overloaded_0__min 8 __lpython_overloaded_0__min lpython_builtin [] __lpython_overloaded_0__min Public), min@__lpython_overloaded_1__min: (ExternalSymbol 1 min@__lpython_overloaded_1__min 8 __lpython_overloaded_1__min lpython_builtin [] __lpython_overloaded_1__min Public), min@__lpython_overloaded_2__min: (ExternalSymbol 1 min@__lpython_overloaded_2__min 8 __lpython_overloaded_2__min lpython_builtin [] __lpython_overloaded_2__min Public), min@__lpython_overloaded_3__min: (ExternalSymbol 1 min@__lpython_overloaded_3__min 8 __lpython_overloaded_3__min lpython_builtin [] __lpython_overloaded_3__min Public), test_max_float: (Subroutine (SymbolTable 3 {d: (Variable 3 d Local (RealConstant 2.32330000000000005e+01 (Real 8 [])) (RealConstant 2.32330000000000005e+01 (Real 8 [])) Default (Real 8 []) Source Public Required .false.), e: (Variable 3 e Local (RealConstant 2.32232999999999983e+01 (Real 8 [])) (RealConstant 2.32232999999999983e+01 (Real 8 [])) Default (Real 8 []) Source Public Required .false.), f: (Variable 3 f Local (RealConstant 2.12300000000000004e+01 (Real 8 [])) (RealConstant 2.12300000000000004e+01 (Real 8 [])) Default (Real 8 []) Source Public Required .false.), max: (ExternalSymbol 3 max 8 max lpython_builtin [] max Private)}) test_max_float [] [(Assert (Compare (FunctionCall 1 max@__lpython_overloaded_2__max 3 max [((Var 3 d)) ((Var 3 e)) ((Var 3 f))] (Real 8 []) (RealConstant 2.32330000000000005e+01 (Real 8 [])) ()) Eq (Var 3 d) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_3__max 3 max [((Var 3 e)) ((Var 3 f))] (Real 8 []) (RealConstant 2.32232999999999983e+01 (Real 8 [])) ()) Eq (Var 3 e) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_max_int: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local (IntegerConstant 1 (Integer 4 [])) (IntegerConstant 1 (Integer 4 [])) Default (Integer 4 []) Source Public Required .false.), b: (Variable 2 b Local (IntegerConstant 2 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])) Default (Integer 4 []) Source Public Required .false.), c: (Variable 2 c Local (IntegerConstant 3 (Integer 4 [])) (IntegerConstant 3 (Integer 4 [])) Default (Integer 4 []) Source Public Required .false.), max: (ExternalSymbol 2 max 8 max lpython_builtin [] max Private)}) test_max_int [] [(Assert (Compare (FunctionCall 1 max@__lpython_overloaded_0__max 2 max [((Var 2 a)) ((Var 2 b))] (Integer 4 []) (IntegerConstant 2 (Integer 4 [])) ()) Eq (Var 2 b) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_1__max 2 max [((Var 2 a)) ((Var 2 b)) ((Var 2 c))] (Integer 4 []) (IntegerConstant 3 (Integer 4 [])) ()) Eq (Var 2 c) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_1__max 2 max [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 []))) ((IntegerConstant 3 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 3 (Integer 4 [])) ()) Eq (IntegerConstant 3 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_0__max 2 max [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 6 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 6 (Integer 4 [])) ()) Eq (IntegerConstant 6 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_min_float: (Subroutine (SymbolTable 5 {d: (Variable 5 d Local (RealConstant 2.32330000000000005e+01 (Real 8 [])) (RealConstant 2.32330000000000005e+01 (Real 8 [])) Default (Real 8 []) Source Public Required .false.), e: (Variable 5 e Local (RealConstant 2.32232999999999983e+01 (Real 8 [])) (RealConstant 2.32232999999999983e+01 (Real 8 [])) Default (Real 8 []) Source Public Required .false.), f: (Variable 5 f Local (RealConstant 2.12300000000000004e+01 (Real 8 [])) (RealConstant 2.12300000000000004e+01 (Real 8 [])) Default (Real 8 []) Source Public Required .false.), min: (ExternalSymbol 5 min 8 min lpython_builtin [] min Private)}) test_min_float [] [(Assert (Compare (FunctionCall 1 min@__lpython_overloaded_2__min 5 min [((Var 5 d)) ((Var 5 e)) ((Var 5 f))] (Real 8 []) (RealConstant 2.12300000000000004e+01 (Real 8 [])) ()) Eq (Var 5 f) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_3__min 5 min [((Var 5 e)) ((Var 5 f))] (Real 8 []) (RealConstant 2.12300000000000004e+01 (Real 8 [])) ()) Eq (Var 5 f) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_min_int: (Subroutine (SymbolTable 4 {a: (Variable 4 a Local (IntegerConstant 1 (Integer 4 [])) (IntegerConstant 1 (Integer 4 [])) Default (Integer 4 []) Source Public Required .false.), b: (Variable 4 b Local (IntegerConstant 2 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])) Default (Integer 4 []) Source Public Required .false.), c: (Variable 4 c Local (IntegerConstant 3 (Integer 4 [])) (IntegerConstant 3 (Integer 4 [])) Default (Integer 4 []) Source Public Required .false.), min: (ExternalSymbol 4 min 8 min lpython_builtin [] min Private)}) test_min_int [] [(Assert (Compare (FunctionCall 1 min@__lpython_overloaded_0__min 4 min [((Var 4 a)) ((Var 4 b))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (Var 4 a) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_1__min 4 min [((Var 4 a)) ((Var 4 b)) ((Var 4 c))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (Var 4 a) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_1__min 4 min [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 []))) ((IntegerConstant 3 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_0__min 4 min [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 6 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Subroutine (SymbolTable 104 {}) _lpython_main_program [] [(SubroutineCall 1 check () [] ())] Source Public Implementation () .false. .false.), check: (Subroutine (SymbolTable 6 {}) check [] [(SubroutineCall 1 test_max_int () [] ()) (SubroutineCall 1 test_max_float () [] ()) (SubroutineCall 1 test_min_int () [] ()) (SubroutineCall 1 test_min_float () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 103 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())]), max@__lpython_overloaded_0__max: (ExternalSymbol 1 max@__lpython_overloaded_0__max 8 __lpython_overloaded_0__max lpython_builtin [] __lpython_overloaded_0__max Public), max@__lpython_overloaded_1__max: (ExternalSymbol 1 max@__lpython_overloaded_1__max 8 __lpython_overloaded_1__max lpython_builtin [] __lpython_overloaded_1__max Public), max@__lpython_overloaded_2__max: (ExternalSymbol 1 max@__lpython_overloaded_2__max 8 __lpython_overloaded_2__max lpython_builtin [] __lpython_overloaded_2__max Public), max@__lpython_overloaded_3__max: (ExternalSymbol 1 max@__lpython_overloaded_3__max 8 __lpython_overloaded_3__max lpython_builtin [] __lpython_overloaded_3__max Public), min@__lpython_overloaded_0__min: (ExternalSymbol 1 min@__lpython_overloaded_0__min 8 __lpython_overloaded_0__min lpython_builtin [] __lpython_overloaded_0__min Public), min@__lpython_overloaded_1__min: (ExternalSymbol 1 min@__lpython_overloaded_1__min 8 __lpython_overloaded_1__min lpython_builtin [] __lpython_overloaded_1__min Public), min@__lpython_overloaded_2__min: (ExternalSymbol 1 min@__lpython_overloaded_2__min 8 __lpython_overloaded_2__min lpython_builtin [] __lpython_overloaded_2__min Public), min@__lpython_overloaded_3__min: (ExternalSymbol 1 min@__lpython_overloaded_3__min 8 __lpython_overloaded_3__min lpython_builtin [] __lpython_overloaded_3__min Public), test_max_float: (Subroutine (SymbolTable 3 {d: (Variable 3 d Local () () Default (Real 8 []) Source Public Required .false.), e: (Variable 3 e Local () () Default (Real 8 []) Source Public Required .false.), f: (Variable 3 f Local () () Default (Real 8 []) Source Public Required .false.), max: (ExternalSymbol 3 max 8 max lpython_builtin [] max Private)}) test_max_float [] [(= (Var 3 d) (RealConstant 2.32330000000000005e+01 (Real 8 [])) ()) (= (Var 3 e) (RealConstant 2.32232999999999983e+01 (Real 8 [])) ()) (= (Var 3 f) (RealConstant 2.12300000000000004e+01 (Real 8 [])) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_2__max 3 max [((Var 3 d)) ((Var 3 e)) ((Var 3 f))] (Real 8 []) () ()) Eq (Var 3 d) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_3__max 3 max [((Var 3 e)) ((Var 3 f))] (Real 8 []) () ()) Eq (Var 3 e) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.), test_max_int: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 2 b Local () () Default (Integer 4 []) Source Public Required .false.), c: (Variable 2 c Local () () Default (Integer 4 []) Source Public Required .false.), max: (ExternalSymbol 2 max 8 max lpython_builtin [] max Private)}) test_max_int [] [(= (Var 2 a) (IntegerConstant 1 (Integer 4 [])) ()) (= (Var 2 b) (IntegerConstant 2 (Integer 4 [])) ()) (= (Var 2 c) (IntegerConstant 3 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_0__max 2 max [((Var 2 a)) ((Var 2 b))] (Integer 4 []) () ()) Eq (Var 2 b) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_1__max 2 max [((Var 2 a)) ((Var 2 b)) ((Var 2 c))] (Integer 4 []) () ()) Eq (Var 2 c) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_1__max 2 max [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 []))) ((IntegerConstant 3 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 3 (Integer 4 [])) ()) Eq (IntegerConstant 3 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 max@__lpython_overloaded_0__max 2 max [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 6 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 6 (Integer 4 [])) ()) Eq (IntegerConstant 6 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_min_float: (Subroutine (SymbolTable 5 {d: (Variable 5 d Local () () Default (Real 8 []) Source Public Required .false.), e: (Variable 5 e Local () () Default (Real 8 []) Source Public Required .false.), f: (Variable 5 f Local () () Default (Real 8 []) Source Public Required .false.), min: (ExternalSymbol 5 min 8 min lpython_builtin [] min Private)}) test_min_float [] [(= (Var 5 d) (RealConstant 2.32330000000000005e+01 (Real 8 [])) ()) (= (Var 5 e) (RealConstant 2.32232999999999983e+01 (Real 8 [])) ()) (= (Var 5 f) (RealConstant 2.12300000000000004e+01 (Real 8 [])) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_2__min 5 min [((Var 5 d)) ((Var 5 e)) ((Var 5 f))] (Real 8 []) () ()) Eq (Var 5 f) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_3__min 5 min [((Var 5 e)) ((Var 5 f))] (Real 8 []) () ()) Eq (Var 5 f) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.), test_min_int: (Subroutine (SymbolTable 4 {a: (Variable 4 a Local () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 4 b Local () () Default (Integer 4 []) Source Public Required .false.), c: (Variable 4 c Local () () Default (Integer 4 []) Source Public Required .false.), min: (ExternalSymbol 4 min 8 min lpython_builtin [] min Private)}) test_min_int [] [(= (Var 4 a) (IntegerConstant 1 (Integer 4 [])) ()) (= (Var 4 b) (IntegerConstant 2 (Integer 4 [])) ()) (= (Var 4 c) (IntegerConstant 3 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_0__min 4 min [((Var 4 a)) ((Var 4 b))] (Integer 4 []) () ()) Eq (Var 4 a) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_1__min 4 min [((Var 4 a)) ((Var 4 b)) ((Var 4 c))] (Integer 4 []) () ()) Eq (Var 4 a) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_1__min 4 min [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 []))) ((IntegerConstant 3 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 1 min@__lpython_overloaded_0__min 4 min [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 6 (Integer 4 [])))] (Integer 4 []) (IntegerConstant 1 (Integer 4 [])) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) (LogicalConstant .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/cpp-test_builtin_pow-56b3f92.json b/tests/reference/cpp-test_builtin_pow-56b3f92.json index 38a76e4a69..35ec41fd5a 100644 --- a/tests/reference/cpp-test_builtin_pow-56b3f92.json +++ b/tests/reference/cpp-test_builtin_pow-56b3f92.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "cpp-test_builtin_pow-56b3f92.stdout", - "stdout_hash": "bca42a3d6f19c83bdea0631d6382d42b4a29ec1a0cf226019d92f358", + "stdout_hash": "168a9774b017f9d4ec424040d0ab5bfc8b1b065f9612cc129fc8e1c9", "stderr": "cpp-test_builtin_pow-56b3f92.stderr", "stderr_hash": "180e1adfbb0d9c63a2fffa31951bbd629b3f1950cf0d97ca1389efe5", "returncode": 0 diff --git a/tests/reference/cpp-test_builtin_pow-56b3f92.stdout b/tests/reference/cpp-test_builtin_pow-56b3f92.stdout index f13418da43..0a1d20402f 100644 --- a/tests/reference/cpp-test_builtin_pow-56b3f92.stdout +++ b/tests/reference/cpp-test_builtin_pow-56b3f92.stdout @@ -63,12 +63,18 @@ void test_pow() p = __lpython_overloaded_2__pow(f1, f2); f1 = __lpython_overloaded_4__pow(a, f2); f1 = __lpython_overloaded_5__pow(f2, a); + b1 = true; + b2 = false; assert (__lpython_overloaded_8__pow(b1, b2) == 1); assert (__lpython_overloaded_8__pow(b2, b1) == 0); assert (__lpython_overloaded_8__pow(b1, b2) == 1); assert (__lpython_overloaded_8__pow(false, false) == 1); + a1 = 4.50000000000000000e+00; + a2 = 2.29999999999999982e+00; assert (__lpython_overloaded_0__abs(__lpython_overloaded_3__pow(a1, a2) - 3.17971929089206000e+01) < eps); assert (__lpython_overloaded_0__abs(__lpython_overloaded_3__pow(a2, a1) - 4.24399889427765871e+01) < eps); + x = 3; + y = 2.29999999999999982e+00; assert (__lpython_overloaded_0__abs(__lpython_overloaded_6__pow(x, y) - 1.25135025328431819e+01) < eps); assert (__lpython_overloaded_0__abs(__lpython_overloaded_7__pow(y, x) - 1.21669999999999980e+01) < eps); assert (__lpython_overloaded_0__abs(__lpython_overloaded_6__pow(x, 5.50000000000000000e+00) - 4.20888346239237194e+02) < eps); diff --git a/tests/tests.toml b/tests/tests.toml index 4c54d2bb66..7d10aabc12 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -140,6 +140,14 @@ ast = true asr = true llvm = true +[[test]] +filename = "../integration_tests/expr_07.py" +asr = true + +[[test]] +filename = "../integration_tests/expr_09.py" +asr = true + [[test]] filename = "loop1.py" ast = true From 53e45afa42570073cecc8e10754450109cedd838 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 21 Jun 2022 15:38:02 +0530 Subject: [PATCH 6/9] Added a print statement in expr_09 --- integration_tests/expr_09.py | 1 + 1 file changed, 1 insertion(+) diff --git a/integration_tests/expr_09.py b/integration_tests/expr_09.py index 76c75f6102..e79bd3010a 100644 --- a/integration_tests/expr_09.py +++ b/integration_tests/expr_09.py @@ -5,6 +5,7 @@ def main0(): i2: i32 = 4 i1 = 3 i2 = 5 + print(-i1 ^ -i2) assert -i1 ^ -i2 == 6 main0() From 2614f5f5893320dbd0b3f1939a153d92f97f8b7c Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 21 Jun 2022 18:37:17 +0530 Subject: [PATCH 7/9] Convert initialisation at declaration to assignment only when current_body is available --- src/lpython/semantics/python_ast_to_asr.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 81d6e70c37..b4a0e71bb0 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -1375,14 +1375,12 @@ class CommonVisitor : public AST::BaseVisitor { // Convert initialisation at declaration to assignment // only for non-global variables. For global variables // keep relying on `m_symbolic_value`. - if( init_expr && current_scope->parent != nullptr) { + if( init_expr && current_body) { ASR::expr_t* v_expr = ASRUtils::EXPR(ASR::make_Var_t(al, x.base.base.loc, v_sym)); init_expr = cast_helper(ASRUtils::expr_type(v_expr), init_expr, true); ASR::asr_t* assign = ASR::make_Assignment_t(al, x.base.base.loc, v_expr, init_expr, nullptr); - if( current_body ) { - current_body->push_back(al, ASRUtils::STMT(assign)); - } + current_body->push_back(al, ASRUtils::STMT(assign)); ASR::Variable_t* v_variable = ASR::down_cast(v_sym); v_variable->m_symbolic_value = nullptr; v_variable->m_value = nullptr; From efb7f4254b35ea104f7f79122ab1e7a58fdc569e Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 21 Jun 2022 18:37:55 +0530 Subject: [PATCH 8/9] Added LLVM support for bitwise XOR, AND and OR --- src/libasr/codegen/asr_to_llvm.cpp | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/libasr/codegen/asr_to_llvm.cpp b/src/libasr/codegen/asr_to_llvm.cpp index 784f5d6117..e2edf5a6af 100644 --- a/src/libasr/codegen/asr_to_llvm.cpp +++ b/src/libasr/codegen/asr_to_llvm.cpp @@ -4691,6 +4691,35 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor pop_nested_stack(s); } + void handle_bitwise_args(const ASR::FunctionCall_t& x, llvm::Value*& arg1, + llvm::Value*& arg2) { + LFORTRAN_ASSERT(x.n_args == 2); + tmp = nullptr; + this->visit_expr_wrapper(x.m_args[0].m_value, true); + arg1 = tmp; + tmp = nullptr; + this->visit_expr_wrapper(x.m_args[1].m_value, true); + arg2 = tmp; + } + + void handle_bitwise_xor(const ASR::FunctionCall_t& x) { + llvm::Value *arg1 = nullptr, *arg2 = nullptr; + handle_bitwise_args(x, arg1, arg2); + tmp = builder->CreateXor(arg1, arg2); + } + + void handle_bitwise_and(const ASR::FunctionCall_t& x) { + llvm::Value *arg1 = nullptr, *arg2 = nullptr; + handle_bitwise_args(x, arg1, arg2); + tmp = builder->CreateAnd(arg1, arg2); + } + + void handle_bitwise_or(const ASR::FunctionCall_t& x) { + llvm::Value *arg1 = nullptr, *arg2 = nullptr; + handle_bitwise_args(x, arg1, arg2); + tmp = builder->CreateOr(arg1, arg2); + } + void visit_FunctionCall(const ASR::FunctionCall_t &x) { if( ASRUtils::is_intrinsic_optimization(x.m_name) ) { ASR::Function_t* routine = ASR::down_cast( @@ -4721,6 +4750,21 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor if( s == nullptr ) { s = ASR::down_cast(symbol_get_past_external(x.m_name)); } + if( ASRUtils::is_intrinsic_function2(s) ) { + std::string symbol_name = ASRUtils::symbol_name(x.m_name); + if( startswith(symbol_name, "_bitwise_xor") ) { + handle_bitwise_xor(x); + return ; + } + if( startswith(symbol_name, "_bitwise_and") ) { + handle_bitwise_and(x); + return ; + } + if( startswith(symbol_name, "_bitwise_or") ) { + handle_bitwise_or(x); + return ; + } + } if (parent_function){ push_nested_stack(parent_function); } else if (parent_subroutine){ From cbf74831ee2b95476560ab56fe29e5fe3ff6333e Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 21 Jun 2022 18:38:38 +0530 Subject: [PATCH 9/9] Remove expr_08 from cpython and add expr_09 for bitwise verification --- integration_tests/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index a5df50532d..b41ea03755 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -133,8 +133,8 @@ RUN(NAME expr_04 LABELS cpython llvm c) RUN(NAME expr_05 LABELS cpython llvm) RUN(NAME expr_06 LABELS cpython llvm) RUN(NAME expr_07 LABELS cpython llvm) -RUN(NAME expr_08 LABELS cpython llvm c) -RUN(NAME expr_09 LABELS cpython llvm c) +RUN(NAME expr_08 LABELS llvm c) +RUN(NAME expr_09 LABELS cpython llvm) RUN(NAME test_types_01 LABELS cpython llvm) RUN(NAME test_str_01 LABELS cpython llvm) RUN(NAME test_str_02 LABELS cpython llvm)