From ba15bf1bd8b0a6b1309f1be562392e59d0f3e7ea Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Fri, 21 Apr 2023 14:59:17 +0530 Subject: [PATCH 1/2] Always insert global symbols to _global_symbols module --- integration_tests/CMakeLists.txt | 68 + integration_tests/import_order_01.py | 7 + integration_tests/import_order_01b.py | 4 + integration_tests/variable_decl_03.py | 2 +- src/libasr/pass/global_stmts.cpp | 254 +- src/libasr/pass/global_stmts_program.cpp | 42 +- src/lpython/semantics/python_ast_to_asr.cpp | 18 +- src/runtime/lpython/lpython.py | 5 +- tests/reference/asr-assert1-a8db80c.json | 2 +- tests/reference/asr-assert1-a8db80c.stdout | 153 +- tests/reference/asr-assign1-ec7ab8d.json | 2 +- tests/reference/asr-assign1-ec7ab8d.stdout | 333 +- tests/reference/asr-assign2-4778d3a.json | 2 +- tests/reference/asr-assign2-4778d3a.stdout | 173 +- tests/reference/asr-c_interop1-c0a6335.json | 2 +- tests/reference/asr-c_interop1-c0a6335.stdout | 989 ++--- tests/reference/asr-complex1-7ce1c89.json | 2 +- tests/reference/asr-complex1-7ce1c89.stdout | 1497 ++++---- tests/reference/asr-constants1-20d32ff.json | 2 +- tests/reference/asr-constants1-20d32ff.stdout | 3389 +++++++++-------- tests/reference/asr-dictionary1-789a50b.json | 2 +- .../reference/asr-dictionary1-789a50b.stdout | 1083 +++--- tests/reference/asr-expr1-dde511e.json | 2 +- tests/reference/asr-expr1-dde511e.stdout | 237 +- tests/reference/asr-expr10-31c163f.json | 2 +- tests/reference/asr-expr10-31c163f.stdout | 841 ++-- tests/reference/asr-expr11-1134d3f.json | 2 +- tests/reference/asr-expr11-1134d3f.stdout | 321 +- tests/reference/asr-expr13-10040d8.json | 2 +- tests/reference/asr-expr13-10040d8.stdout | 893 ++--- tests/reference/asr-expr2-5311701.json | 2 +- tests/reference/asr-expr2-5311701.stdout | 319 +- tests/reference/asr-expr4-cf512ef.json | 2 +- tests/reference/asr-expr4-cf512ef.stdout | 153 +- tests/reference/asr-expr5-375548a.json | 2 +- tests/reference/asr-expr5-375548a.stdout | 233 +- tests/reference/asr-expr6-bfb3384.json | 2 +- tests/reference/asr-expr6-bfb3384.stdout | 243 +- tests/reference/asr-expr8-2a4630a.json | 2 +- tests/reference/asr-expr8-2a4630a.stdout | 847 ++-- tests/reference/asr-list1-f15817d.json | 2 +- tests/reference/asr-list1-f15817d.stdout | 793 ++-- tests/reference/asr-loop3-e2afee9.json | 2 +- tests/reference/asr-loop3-e2afee9.stdout | 129 +- tests/reference/asr-set1-7de4081.json | 2 +- tests/reference/asr-set1-7de4081.stdout | 289 +- tests/reference/asr-subscript1-22a7138.json | 2 +- tests/reference/asr-subscript1-22a7138.stdout | 577 +-- tests/reference/asr-tuple1-ce358d9.json | 2 +- tests/reference/asr-tuple1-ce358d9.stdout | 1079 +++--- .../reference/c-variable_decl_03-fa1823b.json | 4 +- .../c-variable_decl_03-fa1823b.stdout | 2 +- 52 files changed, 7668 insertions(+), 7351 deletions(-) create mode 100644 integration_tests/import_order_01.py create mode 100644 integration_tests/import_order_01b.py diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 3b5d8edce3..47579c8162 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -203,6 +203,72 @@ macro(RUN) endif() endmacro(RUN) +# only compiles till object file +# to make sure that the generated code is syntactically correct +# but we cannot generate an executable due to --disable-main option enabled. +macro(COMPILE) + set(options FAIL) + set(oneValueArgs NAME IMPORT_PATH) + set(multiValueArgs LABELS EXTRAFILES) + cmake_parse_arguments(COMPILE "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN} ) + set(name ${COMPILE_NAME}) + set(import_path ${COMPILE_IMPORT_PATH}) + if (NOT name) + message(FATAL_ERROR "Must specify the NAME argument") + endif() + + if (${KIND} IN_LIST COMPILE_LABELS) + if (KIND STREQUAL "llvm") + if (import_path) + add_custom_command( + OUTPUT ${name}.o + COMMAND lpython --disable-main -c -I ${CMAKE_CURRENT_SOURCE_DIR}/${import_path} ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}.o + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py + VERBATIM) + else () + add_custom_command( + OUTPUT ${name}.o + COMMAND lpython --disable-main -c ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}.o + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py + VERBATIM) + endif() + + add_library(${name} OBJECT ${name}.o) + elseif(KIND STREQUAL "c") + if (import_path) + add_custom_command( + OUTPUT ${name}.c + COMMAND lpython --disable-main -I ${CMAKE_CURRENT_SOURCE_DIR}/${import_path} --show-c ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py > ${name}.c + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py + VERBATIM) + else () + add_custom_command( + OUTPUT ${name}.c + COMMAND lpython --disable-main --show-c ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py > ${name}.c + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py + VERBATIM) + endif() + + add_library(${name} OBJECT ${name}.c) + target_link_libraries(${name} lpython_rtlib) + elseif(KIND STREQUAL "cpython") + # CPython test + set(PY_MOD "") + + add_test(${name} python ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py) + set_tests_properties(${name} PROPERTIES + ENVIRONMENT "PYTHONPATH=${CMAKE_SOURCE_DIR}/../src/runtime/lpython:${CMAKE_SOURCE_DIR}/..;LPYTHON_PY_MOD_NAME=${PY_MOD};LPYTHON_PY_MOD_PATH=${CMAKE_CURRENT_BINARY_DIR}") + if (RUN_LABELS) + set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") + endif() + if (${RUN_FAIL}) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + endif() + endif() + endif() +endmacro(COMPILE) + # Test zero and non-zero exit code and assert statements RUN(NAME array_01_decl LABELS cpython llvm c) @@ -456,3 +522,5 @@ RUN(NAME global_syms_06 LABELS cpython llvm c) # Intrinsic Functions RUN(NAME intrinsics_01 LABELS cpython llvm) # any + +COMPILE(NAME import_order_01 LABELS cpython llvm c) # any diff --git a/integration_tests/import_order_01.py b/integration_tests/import_order_01.py new file mode 100644 index 0000000000..0d8724338d --- /dev/null +++ b/integration_tests/import_order_01.py @@ -0,0 +1,7 @@ +from import_order_01b import f +from lpython import i32, ccallback + +@ccallback +def main1(): + a: i32 = f() + print(a) diff --git a/integration_tests/import_order_01b.py b/integration_tests/import_order_01b.py new file mode 100644 index 0000000000..2dd1989d2a --- /dev/null +++ b/integration_tests/import_order_01b.py @@ -0,0 +1,4 @@ +from lpython import i32 + +def f() -> i32: + return 42 diff --git a/integration_tests/variable_decl_03.py b/integration_tests/variable_decl_03.py index f76dfe327c..f554b9fc5d 100644 --- a/integration_tests/variable_decl_03.py +++ b/integration_tests/variable_decl_03.py @@ -1,7 +1,7 @@ from lpython import f64 def f() -> f64: - return 5.5 + return abs(-5.5) def main(): t1: f64 = f() * 1e6 diff --git a/src/libasr/pass/global_stmts.cpp b/src/libasr/pass/global_stmts.cpp index a524830e3d..abb7bb2ac8 100644 --- a/src/libasr/pass/global_stmts.cpp +++ b/src/libasr/pass/global_stmts.cpp @@ -20,146 +20,148 @@ using ASRUtils::EXPR; */ void pass_wrap_global_stmts_into_function(Allocator &al, ASR::TranslationUnit_t &unit, const LCompilers::PassOptions& pass_options) { + if (unit.n_items == 0) { + return ; + } + std::string fn_name_s = pass_options.run_fun; - if (unit.n_items > 0) { - // Add an anonymous function - Str s; - s.from_str_view(fn_name_s); - char *fn_name = s.c_str(al); - SymbolTable *fn_scope = al.make_new(unit.m_global_scope); + // Add an anonymous function + Str s; + s.from_str_view(fn_name_s); + char *fn_name = s.c_str(al); + SymbolTable *fn_scope = al.make_new(unit.m_global_scope); - ASR::ttype_t *type; - Location loc = unit.base.base.loc; - ASR::asr_t *return_var=nullptr; - ASR::expr_t *return_var_ref=nullptr; - char *var_name; - int idx = 1; + ASR::ttype_t *type; + Location loc = unit.base.base.loc; + ASR::asr_t *return_var=nullptr; + ASR::expr_t *return_var_ref=nullptr; + char *var_name; + int idx = 1; - Vec body; - body.reserve(al, unit.n_items); - for (size_t i=0; itype == ASR::asrType::expr) { - ASR::expr_t *target; - ASR::expr_t *value = EXPR(unit.m_items[i]); - // Create a new variable with the right type - if (ASRUtils::expr_type(value)->type == ASR::ttypeType::Integer) { - s.from_str(al, fn_name_s + std::to_string(idx)); - var_name = s.c_str(al); + Vec body; + body.reserve(al, unit.n_items); + for (size_t i=0; itype == ASR::asrType::expr) { + ASR::expr_t *target; + ASR::expr_t *value = EXPR(unit.m_items[i]); + // Create a new variable with the right type + if (ASRUtils::expr_type(value)->type == ASR::ttypeType::Integer) { + s.from_str(al, fn_name_s + std::to_string(idx)); + var_name = s.c_str(al); - int a_kind = down_cast(ASRUtils::expr_type(value))->m_kind; + int a_kind = down_cast(ASRUtils::expr_type(value))->m_kind; - type = ASRUtils::TYPE(ASR::make_Integer_t(al, loc, a_kind, nullptr, 0)); - return_var = ASR::make_Variable_t(al, loc, - fn_scope, var_name, nullptr, 0, ASRUtils::intent_local, nullptr, nullptr, - ASR::storage_typeType::Default, type, - ASR::abiType::BindC, - ASR::Public, ASR::presenceType::Required, false); - return_var_ref = EXPR(ASR::make_Var_t(al, loc, - down_cast(return_var))); - fn_scope->add_symbol(std::string(var_name), down_cast(return_var)); - target = return_var_ref; - idx++; - } else if (ASRUtils::expr_type(value)->type == ASR::ttypeType::Real) { - s.from_str(al, fn_name_s + std::to_string(idx)); - var_name = s.c_str(al); - type = ASRUtils::expr_type(value); - return_var = ASR::make_Variable_t(al, loc, - fn_scope, var_name, nullptr, 0, ASRUtils::intent_local, nullptr, nullptr, - ASR::storage_typeType::Default, type, - ASR::abiType::BindC, - ASR::Public, ASR::presenceType::Required, false); - return_var_ref = EXPR(ASR::make_Var_t(al, loc, - down_cast(return_var))); - fn_scope->add_symbol(std::string(var_name), down_cast(return_var)); - target = return_var_ref; - idx++; - } else if (ASRUtils::expr_type(value)->type == ASR::ttypeType::Complex) { - s.from_str(al, fn_name_s + std::to_string(idx)); - var_name = s.c_str(al); - type = ASRUtils::expr_type(value); - return_var = ASR::make_Variable_t(al, loc, - fn_scope, var_name, nullptr, 0, ASRUtils::intent_local, nullptr, nullptr, - ASR::storage_typeType::Default, type, - ASR::abiType::BindC, - ASR::Public, ASR::presenceType::Required, false); - return_var_ref = EXPR(ASR::make_Var_t(al, loc, - down_cast(return_var))); - fn_scope->add_symbol(std::string(var_name), down_cast(return_var)); - target = return_var_ref; - idx++; - } else { - throw LCompilersException("Return type not supported in interactive mode"); - } - ASR::stmt_t* asr_stmt = ASRUtils::STMT(ASR::make_Assignment_t(al, loc, target, value, nullptr)); - body.push_back(al, asr_stmt); - } else if (unit.m_items[i]->type == ASR::asrType::stmt) { - ASR::stmt_t* asr_stmt = ASRUtils::STMT(unit.m_items[i]); - body.push_back(al, asr_stmt); - return_var = nullptr; + type = ASRUtils::TYPE(ASR::make_Integer_t(al, loc, a_kind, nullptr, 0)); + return_var = ASR::make_Variable_t(al, loc, + fn_scope, var_name, nullptr, 0, ASRUtils::intent_local, nullptr, nullptr, + ASR::storage_typeType::Default, type, + ASR::abiType::BindC, + ASR::Public, ASR::presenceType::Required, false); + return_var_ref = EXPR(ASR::make_Var_t(al, loc, + down_cast(return_var))); + fn_scope->add_symbol(std::string(var_name), down_cast(return_var)); + target = return_var_ref; + idx++; + } else if (ASRUtils::expr_type(value)->type == ASR::ttypeType::Real) { + s.from_str(al, fn_name_s + std::to_string(idx)); + var_name = s.c_str(al); + type = ASRUtils::expr_type(value); + return_var = ASR::make_Variable_t(al, loc, + fn_scope, var_name, nullptr, 0, ASRUtils::intent_local, nullptr, nullptr, + ASR::storage_typeType::Default, type, + ASR::abiType::BindC, + ASR::Public, ASR::presenceType::Required, false); + return_var_ref = EXPR(ASR::make_Var_t(al, loc, + down_cast(return_var))); + fn_scope->add_symbol(std::string(var_name), down_cast(return_var)); + target = return_var_ref; + idx++; + } else if (ASRUtils::expr_type(value)->type == ASR::ttypeType::Complex) { + s.from_str(al, fn_name_s + std::to_string(idx)); + var_name = s.c_str(al); + type = ASRUtils::expr_type(value); + return_var = ASR::make_Variable_t(al, loc, + fn_scope, var_name, nullptr, 0, ASRUtils::intent_local, nullptr, nullptr, + ASR::storage_typeType::Default, type, + ASR::abiType::BindC, + ASR::Public, ASR::presenceType::Required, false); + return_var_ref = EXPR(ASR::make_Var_t(al, loc, + down_cast(return_var))); + fn_scope->add_symbol(std::string(var_name), down_cast(return_var)); + target = return_var_ref; + idx++; } else { - throw LCompilersException("Unsupported type of global scope node"); + throw LCompilersException("Return type not supported in interactive mode"); } + ASR::stmt_t* asr_stmt = ASRUtils::STMT(ASR::make_Assignment_t(al, loc, target, value, nullptr)); + body.push_back(al, asr_stmt); + } else if (unit.m_items[i]->type == ASR::asrType::stmt) { + ASR::stmt_t* asr_stmt = ASRUtils::STMT(unit.m_items[i]); + body.push_back(al, asr_stmt); + return_var = nullptr; + } else { + throw LCompilersException("Unsupported type of global scope node"); } + } - if (return_var) { - // The last item was an expression, create a function returning it + if (return_var) { + // The last item was an expression, create a function returning it - // The last defined `return_var` is the actual return value - ASR::down_cast2(return_var)->m_intent = ASRUtils::intent_return_var; + // The last defined `return_var` is the actual return value + ASR::down_cast2(return_var)->m_intent = ASRUtils::intent_return_var; - ASR::asr_t *fn = ASRUtils::make_Function_t_util( - al, loc, - /* a_symtab */ fn_scope, - /* a_name */ fn_name, - nullptr, 0, - /* a_args */ nullptr, - /* n_args */ 0, - /* a_body */ body.p, - /* n_body */ body.size(), - /* a_return_var */ return_var_ref, - ASR::abiType::BindC, - ASR::Public, ASR::Implementation, - nullptr, - false, false, false, false, false, - nullptr, 0, - nullptr, 0, - false, false, false); - std::string sym_name = fn_name; - if (unit.m_global_scope->get_symbol(sym_name) != nullptr) { - throw LCompilersException("Function already defined"); - } - unit.m_global_scope->add_symbol(sym_name, down_cast(fn)); - } else { - // The last item was a statement, create a subroutine (returning - // nothing) - ASR::asr_t *fn = ASRUtils::make_Function_t_util( - al, loc, - /* a_symtab */ fn_scope, - /* a_name */ fn_name, - nullptr, 0, - /* a_args */ nullptr, - /* n_args */ 0, - /* a_body */ body.p, - /* n_body */ body.size(), - nullptr, - ASR::abiType::Source, - ASR::Public, ASR::Implementation, nullptr, - false, false, false, false, false, - nullptr, 0, - nullptr, 0, - false, false, false); - std::string sym_name = fn_name; - if (unit.m_global_scope->get_symbol(sym_name) != nullptr) { - throw LCompilersException("Function already defined"); - } - unit.m_global_scope->add_symbol(sym_name, down_cast(fn)); + ASR::asr_t *fn = ASRUtils::make_Function_t_util( + al, loc, + /* a_symtab */ fn_scope, + /* a_name */ fn_name, + nullptr, 0, + /* a_args */ nullptr, + /* n_args */ 0, + /* a_body */ body.p, + /* n_body */ body.size(), + /* a_return_var */ return_var_ref, + ASR::abiType::BindC, + ASR::Public, ASR::Implementation, + nullptr, + false, false, false, false, false, + nullptr, 0, + nullptr, 0, + false, false, false); + std::string sym_name = fn_name; + if (unit.m_global_scope->get_symbol(sym_name) != nullptr) { + throw LCompilersException("Function already defined"); + } + unit.m_global_scope->add_symbol(sym_name, down_cast(fn)); + } else { + // The last item was a statement, create a subroutine (returning + // nothing) + ASR::asr_t *fn = ASRUtils::make_Function_t_util( + al, loc, + /* a_symtab */ fn_scope, + /* a_name */ fn_name, + nullptr, 0, + /* a_args */ nullptr, + /* n_args */ 0, + /* a_body */ body.p, + /* n_body */ body.size(), + nullptr, + ASR::abiType::Source, + ASR::Public, ASR::Implementation, nullptr, + false, false, false, false, false, + nullptr, 0, + nullptr, 0, + false, false, false); + std::string sym_name = fn_name; + if (unit.m_global_scope->get_symbol(sym_name) != nullptr) { + throw LCompilersException("Function already defined"); } - unit.m_items = nullptr; - unit.n_items = 0; - PassUtils::UpdateDependenciesVisitor v(al); - v.visit_TranslationUnit(unit); + unit.m_global_scope->add_symbol(sym_name, down_cast(fn)); } + unit.m_items = nullptr; + unit.n_items = 0; + PassUtils::UpdateDependenciesVisitor v(al); + v.visit_TranslationUnit(unit); } } // namespace LCompilers diff --git a/src/libasr/pass/global_stmts_program.cpp b/src/libasr/pass/global_stmts_program.cpp index ba1b22c39a..1e3d1c1331 100644 --- a/src/libasr/pass/global_stmts_program.cpp +++ b/src/libasr/pass/global_stmts_program.cpp @@ -27,32 +27,34 @@ void pass_wrap_global_stmts_into_program(Allocator &al, prog_body.reserve(al, 1); SetChar prog_dep; prog_dep.reserve(al, 1); - if (unit.n_items > 0) { - pass_wrap_global_stmts_into_function(al, unit, pass_options); - pass_wrap_global_syms_into_module(al, unit, pass_options); + bool call_main_program = unit.n_items > 0; + pass_wrap_global_stmts_into_function(al, unit, pass_options); + pass_wrap_global_syms_into_module(al, unit, pass_options); + if( call_main_program ) { + // Call `_lpython_main_program` function ASR::Module_t *mod = ASR::down_cast( unit.m_global_scope->get_symbol("_global_symbols")); - // Call `_lpython_main_program` function ASR::symbol_t *fn_s = mod->m_symtab->get_symbol(program_fn_name); - if (ASR::is_a(*fn_s) - && ASR::down_cast(fn_s)->m_return_var == nullptr) { - ASR::Function_t *fn = ASR::down_cast(fn_s); - fn_s = ASR::down_cast(ASR::make_ExternalSymbol_t( - al, fn->base.base.loc, current_scope, s2c(al, program_fn_name), - fn_s, mod->m_name, nullptr, 0, s2c(al, program_fn_name), - ASR::accessType::Public)); - current_scope->add_symbol(program_fn_name, fn_s); - ASR::asr_t *stmt = ASR::make_SubroutineCall_t( - al, unit.base.base.loc, - fn_s, nullptr, - nullptr, 0, - nullptr); - prog_body.push_back(al, ASR::down_cast(stmt)); - prog_dep.push_back(al, s2c(al, "_global_symbols")); - } else { + if (!(ASR::is_a(*fn_s) + && ASR::down_cast(fn_s)->m_return_var == nullptr)) { throw LCompilersException("Return type not supported yet"); } + + ASR::Function_t *fn = ASR::down_cast(fn_s); + fn_s = ASR::down_cast(ASR::make_ExternalSymbol_t( + al, fn->base.base.loc, current_scope, s2c(al, program_fn_name), + fn_s, mod->m_name, nullptr, 0, s2c(al, program_fn_name), + ASR::accessType::Public)); + current_scope->add_symbol(program_fn_name, fn_s); + ASR::asr_t *stmt = ASR::make_SubroutineCall_t( + al, unit.base.base.loc, + fn_s, nullptr, + nullptr, 0, + nullptr); + prog_body.push_back(al, ASR::down_cast(stmt)); + prog_dep.push_back(al, s2c(al, "_global_symbols")); } + ASR::asr_t *prog = ASR::make_Program_t( al, unit.base.base.loc, /* a_symtab */ current_scope, diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 60b4cd7438..2968f70770 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -6705,6 +6705,7 @@ Result python_ast_to_asr(Allocator &al, LocationManager if (main_module) { // If it is a main module, turn it into a program // Note: we can modify this behavior for interactive mode later + LCompilers::PassOptions pass_options; if (compiler_options.disable_main) { if (tu->n_items > 0) { diagnostics.add(diag::Diagnostic( @@ -6719,18 +6720,17 @@ Result python_ast_to_asr(Allocator &al, LocationManager // LCOMPILERS_ASSERT(asr_verify(*tu)); } } else { - LCompilers::PassOptions pass_options; pass_options.run_fun = "_lpython_main_program"; pass_options.runtime_library_dir = get_runtime_library_dir(); - pass_wrap_global_stmts_into_program(al, *tu, pass_options); -#if defined(WITH_LFORTRAN_ASSERT) - diag::Diagnostics diagnostics; - if (!asr_verify(*tu, true, diagnostics)) { - std::cerr << diagnostics.render2(); - throw LCompilersException("Verify failed"); - }; -#endif } + pass_wrap_global_stmts_into_program(al, *tu, pass_options); + #if defined(WITH_LFORTRAN_ASSERT) + diag::Diagnostics diagnostics; + if (!asr_verify(*tu, true, diagnostics)) { + std::cerr << diagnostics.render2(); + throw LCompilersException("Verify failed"); + }; + #endif } return tu; diff --git a/src/runtime/lpython/lpython.py b/src/runtime/lpython/lpython.py index 4525781241..c47f5abf87 100644 --- a/src/runtime/lpython/lpython.py +++ b/src/runtime/lpython/lpython.py @@ -9,7 +9,7 @@ __slots__ = ["i8", "i16", "i32", "i64", "f32", "f64", "c32", "c64", "CPtr", "overload", "ccall", "TypeVar", "pointer", "c_p_pointer", "Pointer", "p_c_pointer", "vectorize", "inline", "Union", "static", "with_goto", - "packed", "Const", "sizeof", "ccallable"] + "packed", "Const", "sizeof", "ccallable", "ccallback"] # data-types @@ -483,3 +483,6 @@ def ccallable(f): if py_is_dataclass(f): return convert_to_ctypes_Structure(f) return f + +def ccallback(f): + return f diff --git a/tests/reference/asr-assert1-a8db80c.json b/tests/reference/asr-assert1-a8db80c.json index 0e54b8f7dd..2d50e9e64d 100644 --- a/tests/reference/asr-assert1-a8db80c.json +++ b/tests/reference/asr-assert1-a8db80c.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-assert1-a8db80c.stdout", - "stdout_hash": "3a14fc9641ee15d828bff99817ea049e418e5b1171821f18ec747853", + "stdout_hash": "1a3413c7e2357594d5ada818ae065fc50fbdaead940010001fb7bf8d", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-assert1-a8db80c.stdout b/tests/reference/asr-assert1-a8db80c.stdout index 0768abacb8..56651e88a7 100644 --- a/tests/reference/asr-assert1-a8db80c.stdout +++ b/tests/reference/asr-assert1-a8db80c.stdout @@ -2,88 +2,99 @@ (SymbolTable 1 { - main_program: - (Program + _global_symbols: + (Module (SymbolTable - 3 + 4 { - - }) - main_program - [] - [] - ), - test_assert: - (Function - (SymbolTable - 2 - { - a: - (Variable - 2 - a + test_assert: + (Function + (SymbolTable + 2 + { + a: + (Variable + 2 + a + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ) + }) + test_assert + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () + [] + [(= + (Var 2 a) + (IntegerConstant 5 (Integer 4 [])) + () + ) + (Assert + (IntegerCompare + (Var 2 a) + Eq + (IntegerConstant 5 (Integer 4 [])) + (Logical 4 []) + () + ) + (StringConstant + "a is not 5" + (Character 1 10 () []) + ) + ) + (Assert + (IntegerCompare + (Var 2 a) + NotEq + (IntegerConstant 10 (Integer 4 [])) + (Logical 4 []) + () + ) + () + )] () - Default - (Integer 4 []) - Source Public - Required + .false. .false. ) }) - test_assert - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] + _global_symbols [] - [(= - (Var 2 a) - (IntegerConstant 5 (Integer 4 [])) - () - ) - (Assert - (IntegerCompare - (Var 2 a) - Eq - (IntegerConstant 5 (Integer 4 [])) - (Logical 4 []) - () - ) - (StringConstant - "a is not 5" - (Character 1 10 () []) - ) - ) - (Assert - (IntegerCompare - (Var 2 a) - NotEq - (IntegerConstant 10 (Integer 4 [])) - (Logical 4 []) - () - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-assign1-ec7ab8d.json b/tests/reference/asr-assign1-ec7ab8d.json index 8fc42d6264..3c0292c6d9 100644 --- a/tests/reference/asr-assign1-ec7ab8d.json +++ b/tests/reference/asr-assign1-ec7ab8d.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-assign1-ec7ab8d.stdout", - "stdout_hash": "d8e31f6631d0aa73cc934be73bd4d98d0b85eee04fb85a8ca389ca15", + "stdout_hash": "8e9ca54edd6ace12792c11e099b27ca8c06e01031ace1d6cd0c9836c", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-assign1-ec7ab8d.stdout b/tests/reference/asr-assign1-ec7ab8d.stdout index f62818e2ba..8d69009a66 100644 --- a/tests/reference/asr-assign1-ec7ab8d.stdout +++ b/tests/reference/asr-assign1-ec7ab8d.stdout @@ -2,180 +2,191 @@ (SymbolTable 1 { - main_program: - (Program - (SymbolTable - 3 - { - - }) - main_program - [] - [] - ), - test_augassign: - (Function + _global_symbols: + (Module (SymbolTable - 2 + 4 { - a: - (Variable - 2 - a + test_augassign: + (Function + (SymbolTable + 2 + { + a: + (Variable + 2 + a + [] + Local + () + () + Default + (Character 1 -2 () []) + Source + Public + Required + .false. + ), + r: + (Variable + 2 + r + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + s: + (Variable + 2 + s + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ) + }) + test_augassign + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Character 1 -2 () []) - Source - Public - Required - .false. - ), - r: - (Variable - 2 - r [] - Local - () + [(= + (Var 2 r) + (IntegerConstant 0 (Integer 4 [])) + () + ) + (= + (Var 2 r) + (IntegerBinOp + (Var 2 r) + Add + (IntegerConstant 4 (Integer 4 [])) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 s) + (IntegerConstant 5 (Integer 4 [])) + () + ) + (= + (Var 2 r) + (IntegerBinOp + (Var 2 r) + Mul + (Var 2 s) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 r) + (IntegerBinOp + (Var 2 r) + Sub + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 s) + (IntegerConstant 10 (Integer 4 [])) + () + ) + (= + (Var 2 r) + (RealBinOp + (Cast + (Var 2 r) + IntegerToReal + (Real 8 []) + () + ) + Div + (Cast + (Var 2 s) + IntegerToReal + (Real 8 []) + () + ) + (Real 8 []) + () + ) + () + ) + (= + (Var 2 a) + (StringConstant + "" + (Character 1 0 () []) + ) + () + ) + (= + (Var 2 a) + (StringConcat + (Var 2 a) + (StringConstant + "test" + (Character 1 4 () []) + ) + (Character 1 2 () []) + () + ) + () + )] () - Default - (Integer 4 []) - Source Public - Required .false. - ), - s: - (Variable - 2 - s - [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required .false. ) }) - test_augassign - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) + _global_symbols [] - [] - [(= - (Var 2 r) - (IntegerConstant 0 (Integer 4 [])) - () - ) - (= - (Var 2 r) - (IntegerBinOp - (Var 2 r) - Add - (IntegerConstant 4 (Integer 4 [])) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 s) - (IntegerConstant 5 (Integer 4 [])) - () - ) - (= - (Var 2 r) - (IntegerBinOp - (Var 2 r) - Mul - (Var 2 s) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 r) - (IntegerBinOp - (Var 2 r) - Sub - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 s) - (IntegerConstant 10 (Integer 4 [])) - () - ) - (= - (Var 2 r) - (RealBinOp - (Cast - (Var 2 r) - IntegerToReal - (Real 8 []) - () - ) - Div - (Cast - (Var 2 s) - IntegerToReal - (Real 8 []) - () - ) - (Real 8 []) - () - ) - () - ) - (= - (Var 2 a) - (StringConstant - "" - (Character 1 0 () []) - ) - () - ) - (= - (Var 2 a) - (StringConcat - (Var 2 a) - (StringConstant - "test" - (Character 1 4 () []) - ) - (Character 1 2 () []) - () - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-assign2-4778d3a.json b/tests/reference/asr-assign2-4778d3a.json index 95d64e2f6a..3007b29256 100644 --- a/tests/reference/asr-assign2-4778d3a.json +++ b/tests/reference/asr-assign2-4778d3a.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-assign2-4778d3a.stdout", - "stdout_hash": "c5248d896f08f3c30c6b47435540837d5dabf455e37727c5196f7948", + "stdout_hash": "c8e957c49ef1c4d0abc06621479b12c13aa35f8e7efe0ed9f7381cf5", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-assign2-4778d3a.stdout b/tests/reference/asr-assign2-4778d3a.stdout index 717d05cae5..633cb56a49 100644 --- a/tests/reference/asr-assign2-4778d3a.stdout +++ b/tests/reference/asr-assign2-4778d3a.stdout @@ -2,89 +2,100 @@ (SymbolTable 1 { - f: - (Variable - 1 - f - [] - Local - (Cast - (RealConstant - 1.234568 - (Real 8 []) - ) - RealToReal - (Real 4 []) - (RealConstant - 1.234568 - (Real 4 []) - ) - ) - (RealConstant - 1.234568 - (Real 4 []) - ) - Default - (Real 4 []) - Source - Public - Required - .false. - ), - f2: - (Variable - 1 - f2 - [] - Local - (RealConstant - 1.234568 - (Real 8 []) - ) - (RealConstant - 1.234568 - (Real 8 []) - ) - Default - (Real 8 []) - Source - Public - Required - .false. - ), - i: - (Variable - 1 - i + _global_symbols: + (Module + (SymbolTable + 3 + { + f: + (Variable + 3 + f + [] + Local + (Cast + (RealConstant + 1.234568 + (Real 8 []) + ) + RealToReal + (Real 4 []) + (RealConstant + 1.234568 + (Real 4 []) + ) + ) + (RealConstant + 1.234568 + (Real 4 []) + ) + Default + (Real 4 []) + Source + Public + Required + .false. + ), + f2: + (Variable + 3 + f2 + [] + Local + (RealConstant + 1.234568 + (Real 8 []) + ) + (RealConstant + 1.234568 + (Real 8 []) + ) + Default + (Real 8 []) + Source + Public + Required + .false. + ), + i: + (Variable + 3 + i + [] + Local + (IntegerConstant 5 (Integer 4 [])) + (IntegerConstant 5 (Integer 4 [])) + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + i2: + (Variable + 3 + i2 + [] + Local + (Cast + (IntegerConstant 53430903434 (Integer 4 [])) + IntegerToInteger + (Integer 8 []) + (IntegerConstant 53430903434 (Integer 8 [])) + ) + (IntegerConstant 53430903434 (Integer 8 [])) + Default + (Integer 8 []) + Source + Public + Required + .false. + ) + }) + _global_symbols [] - 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 []) - (IntegerConstant 53430903434 (Integer 8 [])) - ) - (IntegerConstant 53430903434 (Integer 8 [])) - Default - (Integer 8 []) - Source - Public - Required .false. ), main_program: diff --git a/tests/reference/asr-c_interop1-c0a6335.json b/tests/reference/asr-c_interop1-c0a6335.json index 45042ccf51..25cd83a79c 100644 --- a/tests/reference/asr-c_interop1-c0a6335.json +++ b/tests/reference/asr-c_interop1-c0a6335.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-c_interop1-c0a6335.stdout", - "stdout_hash": "58790a781ef73a85eea048420b5504d95266db0cfa457308f58df9f3", + "stdout_hash": "f675a932d996a2f3ecc4237f8d5ddf4c3c4c86a17bd80ad91938f188", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-c_interop1-c0a6335.stdout b/tests/reference/asr-c_interop1-c0a6335.stdout index 5df6715809..d287545138 100644 --- a/tests/reference/asr-c_interop1-c0a6335.stdout +++ b/tests/reference/asr-c_interop1-c0a6335.stdout @@ -2,525 +2,536 @@ (SymbolTable 1 { - f: - (Function + _global_symbols: + (Module (SymbolTable - 2 + 8 { - _lpython_return_variable: - (Variable - 2 - _lpython_return_variable + f: + (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. + ) + }) + f + (FunctionType + [(Real 8 [])] + (Real 8 []) + BindC + Interface + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - ReturnVar - () - () - Default - (Real 8 []) - BindC - Public - Required - .false. - ), - x: - (Variable - 2 - x - [] - In - () - () - Default - (Real 8 []) - BindC - Public - Required - .true. - ) - }) - f - (FunctionType - [(Real 8 [])] - (Real 8 []) - BindC - Interface - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [(Var 2 x)] - [] - (Var 2 _lpython_return_variable) - Public - .false. - .false. - ), - g: - (Function - (SymbolTable - 3 - { - a: - (Variable - 3 - a - [] - In - () - () - Default - (Real 8 []) - BindC - Public - Required - .true. - ), - b: - (Variable - 3 - b - [] - In - () - () - Default - (Real 4 []) - BindC - Public - Required - .true. - ), - c: - (Variable - 3 - c + [(Var 2 x)] [] - In - () - () - Default - (Integer 8 []) - BindC + (Var 2 _lpython_return_variable) Public - Required - .true. - ), - d: - (Variable - 3 - d - [] - In - () - () - Default - (Integer 4 []) - BindC - Public - Required - .true. - ) - }) - g - (FunctionType - [(Real 8 []) - (Real 4 []) - (Integer 8 []) - (Integer 4 [])] - () - BindC - Interface - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [(Var 3 a) - (Var 3 b) - (Var 3 c) - (Var 3 d)] - [] - () - Public - .false. - .false. - ), - h: - (Function - (SymbolTable - 4 - { - _lpython_return_variable: - (Variable - 4 - _lpython_return_variable - [] - ReturnVar - () - () - Default - (Real 8 []) - BindC - Public - Required + .false. .false. ), - x: - (Variable - 4 - x - [] - In - () - () - Default - (Real 8 []) - BindC - Public - Required - .true. - ) - }) - h - (FunctionType - [(Real 8 [])] - (Real 8 []) - BindC - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [(Var 4 x)] - [(= - (Var 4 _lpython_return_variable) - (RealBinOp - (Var 4 x) - Add - (RealConstant - 1.000000 - (Real 8 []) - ) - (Real 8 []) - () - ) - () - ) - (Return)] - (Var 4 _lpython_return_variable) - Public - .false. - .false. - ), - l: - (Function - (SymbolTable - 5 - { - a: - (Variable - 5 - a - [] - In - () - () - Default - (Real 8 []) - BindC - Public - Required - .true. - ), - b: - (Variable - 5 - b - [] - In - () - () - Default - (Real 4 []) - BindC - Public - Required - .true. - ), - c: - (Variable - 5 - c - [] - In - () - () - Default - (Integer 8 []) - BindC - Public - Required - .true. - ), - d: - (Variable - 5 - d + g: + (Function + (SymbolTable + 3 + { + a: + (Variable + 3 + a + [] + In + () + () + Default + (Real 8 []) + BindC + Public + Required + .true. + ), + b: + (Variable + 3 + b + [] + In + () + () + Default + (Real 4 []) + BindC + Public + Required + .true. + ), + c: + (Variable + 3 + c + [] + In + () + () + Default + (Integer 8 []) + BindC + Public + Required + .true. + ), + d: + (Variable + 3 + d + [] + In + () + () + Default + (Integer 4 []) + BindC + Public + Required + .true. + ) + }) + g + (FunctionType + [(Real 8 []) + (Real 4 []) + (Integer 8 []) + (Integer 4 [])] + () + BindC + Interface + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - In - () - () - Default - (Integer 4 []) - BindC - Public - Required - .true. - ) - }) - l - (FunctionType - [(Real 8 []) - (Real 4 []) - (Integer 8 []) - (Integer 4 [])] - () - BindC - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [(Var 5 a) - (Var 5 b) - (Var 5 c) - (Var 5 d)] - [(Print - () - [(StringConstant - "OK" - (Character 1 2 () []) - )] - () - () - )] - () - Public - .false. - .false. - ), - main0: - (Function - (SymbolTable - 6 - { - i: - (Variable - 6 - i + [(Var 3 a) + (Var 3 b) + (Var 3 c) + (Var 3 d)] [] - Local - () () - Default - (Real 8 []) - Source Public - Required .false. - ), - x: - (Variable - 6 - x - [] - Local - () - () - Default - (Real 8 []) - Source - Public - Required .false. ), - y: - (Variable - 6 - y + h: + (Function + (SymbolTable + 4 + { + _lpython_return_variable: + (Variable + 4 + _lpython_return_variable + [] + ReturnVar + () + () + Default + (Real 8 []) + BindC + Public + Required + .false. + ), + x: + (Variable + 4 + x + [] + In + () + () + Default + (Real 8 []) + BindC + Public + Required + .true. + ) + }) + h + (FunctionType + [(Real 8 [])] + (Real 8 []) + BindC + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Real 4 []) - Source + [(Var 4 x)] + [(= + (Var 4 _lpython_return_variable) + (RealBinOp + (Var 4 x) + Add + (RealConstant + 1.000000 + (Real 8 []) + ) + (Real 8 []) + () + ) + () + ) + (Return)] + (Var 4 _lpython_return_variable) Public - Required + .false. .false. ), - z: - (Variable - 6 - z + l: + (Function + (SymbolTable + 5 + { + a: + (Variable + 5 + a + [] + In + () + () + Default + (Real 8 []) + BindC + Public + Required + .true. + ), + b: + (Variable + 5 + b + [] + In + () + () + Default + (Real 4 []) + BindC + Public + Required + .true. + ), + c: + (Variable + 5 + c + [] + In + () + () + Default + (Integer 8 []) + BindC + Public + Required + .true. + ), + d: + (Variable + 5 + d + [] + In + () + () + Default + (Integer 4 []) + BindC + Public + Required + .true. + ) + }) + l + (FunctionType + [(Real 8 []) + (Real 4 []) + (Integer 8 []) + (Integer 4 [])] + () + BindC + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () + [(Var 5 a) + (Var 5 b) + (Var 5 c) + (Var 5 d)] + [(Print + () + [(StringConstant + "OK" + (Character 1 2 () []) + )] + () + () + )] () - Default - (Integer 8 []) - Source Public - Required + .false. .false. ), - zz: - (Variable - 6 - zz + main0: + (Function + (SymbolTable + 6 + { + i: + (Variable + 6 + i + [] + Local + () + () + Default + (Real 8 []) + Source + Public + Required + .false. + ), + x: + (Variable + 6 + x + [] + Local + () + () + Default + (Real 8 []) + Source + Public + Required + .false. + ), + y: + (Variable + 6 + y + [] + Local + () + () + Default + (Real 4 []) + Source + Public + Required + .false. + ), + z: + (Variable + 6 + z + [] + Local + () + () + Default + (Integer 8 []) + Source + Public + Required + .false. + ), + zz: + (Variable + 6 + zz + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ) + }) + main0 + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) + [f + g + h + l] [] - Local - () + [(= + (Var 6 x) + (RealConstant + 5.000000 + (Real 8 []) + ) + () + ) + (= + (Var 6 i) + (FunctionCall + 8 f + () + [((Var 6 x))] + (Real 8 []) + () + () + ) + () + ) + (= + (Var 6 y) + (Cast + (RealConstant + 5.400000 + (Real 8 []) + ) + RealToReal + (Real 4 []) + (RealConstant + 5.400000 + (Real 4 []) + ) + ) + () + ) + (= + (Var 6 z) + (Cast + (IntegerConstant 3 (Integer 4 [])) + IntegerToInteger + (Integer 8 []) + (IntegerConstant 3 (Integer 8 [])) + ) + () + ) + (= + (Var 6 zz) + (IntegerConstant 2 (Integer 4 [])) + () + ) + (SubroutineCall + 8 g + () + [((Var 6 x)) + ((Var 6 y)) + ((Var 6 z)) + ((Var 6 zz))] + () + ) + (= + (Var 6 i) + (FunctionCall + 8 h + () + [((Var 6 x))] + (Real 8 []) + () + () + ) + () + ) + (SubroutineCall + 8 l + () + [((Var 6 x)) + ((Var 6 y)) + ((Var 6 z)) + ((Var 6 zz))] + () + )] () - Default - (Integer 4 []) - Source Public - Required + .false. .false. ) }) - main0 - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [f - g - h - l] + _global_symbols [] - [(= - (Var 6 x) - (RealConstant - 5.000000 - (Real 8 []) - ) - () - ) - (= - (Var 6 i) - (FunctionCall - 1 f - () - [((Var 6 x))] - (Real 8 []) - () - () - ) - () - ) - (= - (Var 6 y) - (Cast - (RealConstant - 5.400000 - (Real 8 []) - ) - RealToReal - (Real 4 []) - (RealConstant - 5.400000 - (Real 4 []) - ) - ) - () - ) - (= - (Var 6 z) - (Cast - (IntegerConstant 3 (Integer 4 [])) - IntegerToInteger - (Integer 8 []) - (IntegerConstant 3 (Integer 8 [])) - ) - () - ) - (= - (Var 6 zz) - (IntegerConstant 2 (Integer 4 [])) - () - ) - (SubroutineCall - 1 g - () - [((Var 6 x)) - ((Var 6 y)) - ((Var 6 z)) - ((Var 6 zz))] - () - ) - (= - (Var 6 i) - (FunctionCall - 1 h - () - [((Var 6 x))] - (Real 8 []) - () - () - ) - () - ) - (SubroutineCall - 1 l - () - [((Var 6 x)) - ((Var 6 y)) - ((Var 6 z)) - ((Var 6 zz))] - () - )] - () - Public .false. .false. ), diff --git a/tests/reference/asr-complex1-7ce1c89.json b/tests/reference/asr-complex1-7ce1c89.json index 2b73bddbb2..dce09ca7fc 100644 --- a/tests/reference/asr-complex1-7ce1c89.json +++ b/tests/reference/asr-complex1-7ce1c89.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-complex1-7ce1c89.stdout", - "stdout_hash": "84a3d6dc4de8f3aad997db4a221d93654bdcda77844adfdc95a66c9b", + "stdout_hash": "27d901ae2cdb27456efea06751d9c03b1edbadadd6cf98e3b80eb5d3", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-complex1-7ce1c89.stdout b/tests/reference/asr-complex1-7ce1c89.stdout index bb82a54cd1..88d32a4896 100644 --- a/tests/reference/asr-complex1-7ce1c89.stdout +++ b/tests/reference/asr-complex1-7ce1c89.stdout @@ -2,773 +2,784 @@ (SymbolTable 1 { - lpython_builtin: - (IntrinsicModule lpython_builtin), - main_program: - (Program + _global_symbols: + (Module (SymbolTable - 111 + 112 { - - }) - main_program - [] - [] - ), - test: - (Function - (SymbolTable - 3 - { - x: - (Variable - 3 - x - [] - Local - () - () - Default - (Complex 8 []) - Source - Public - Required - .false. - ), - y: - (Variable - 3 - y - [] - Local - () - () - Default - (Complex 8 []) - Source - Public - Required - .false. - ), - z: - (Variable - 3 - z - [] - Local - () - () - Default - (Complex 4 []) - Source - Public - Required - .false. - ) - }) - test - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [] - [(= - (Var 3 x) - (ComplexBinOp - (Cast - (IntegerConstant 2 (Integer 4 [])) - IntegerToComplex - (Complex 8 []) - (ComplexConstant - 2.000000 - 0.000000 - (Complex 8 []) - ) - ) - Add - (ComplexConstant - 0.000000 - 3.000000 - (Complex 8 []) - ) - (Complex 8 []) - (ComplexConstant - 2.000000 - 3.000000 - (Complex 8 []) - ) - ) - () - ) - (= - (Var 3 y) - (ComplexBinOp - (Cast - (IntegerConstant 5 (Integer 4 [])) - IntegerToComplex - (Complex 8 []) - (ComplexConstant - 5.000000 - 0.000000 - (Complex 8 []) - ) - ) - Add - (ComplexConstant - 0.000000 - 5.000000 - (Complex 8 []) - ) - (Complex 8 []) - (ComplexConstant - 5.000000 - 5.000000 - (Complex 8 []) - ) - ) - () - ) - (= - (Var 3 z) - (Cast - (ComplexBinOp - (Var 3 x) - Add - (Var 3 y) - (Complex 8 []) - () - ) - ComplexToComplex - (Complex 4 []) - () - ) - () - ) - (= - (Var 3 z) - (Cast - (ComplexBinOp - (Var 3 x) - Sub - (Var 3 y) - (Complex 8 []) - () - ) - ComplexToComplex - (Complex 4 []) - () - ) - () - ) - (= - (Var 3 z) - (Cast - (ComplexBinOp - (Cast - (IntegerConstant 2 (Integer 4 [])) - IntegerToComplex - (Complex 8 []) - (ComplexConstant - 2.000000 - 0.000000 - (Complex 8 []) + test: + (Function + (SymbolTable + 3 + { + x: + (Variable + 3 + x + [] + Local + () + () + Default + (Complex 8 []) + Source + Public + Required + .false. + ), + y: + (Variable + 3 + y + [] + Local + () + () + Default + (Complex 8 []) + Source + Public + Required + .false. + ), + z: + (Variable + 3 + z + [] + Local + () + () + Default + (Complex 4 []) + Source + Public + Required + .false. + ) + }) + test + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. ) - ) - Mul - (Var 3 x) - (Complex 8 []) - () - ) - ComplexToComplex - (Complex 4 []) - () - ) - () - )] - () - Public - .false. - .false. - ), - test_complex: - (Function - (SymbolTable - 2 - { - b: - (Variable - 2 - b - [] - Local - () - () - Default - (Logical 4 []) - Source - Public - Required - .false. - ), - c: - (Variable - 2 - c - [] - Local - () - () - Default - (Complex 4 []) - Source - Public - Required - .false. - ), - c1: - (Variable - 2 - c1 [] - Local - () - () - Default - (Complex 4 []) - Source - Public - Required - .false. - ), - c2: - (Variable - 2 - c2 [] - Local - () + [(= + (Var 3 x) + (ComplexBinOp + (Cast + (IntegerConstant 2 (Integer 4 [])) + IntegerToComplex + (Complex 8 []) + (ComplexConstant + 2.000000 + 0.000000 + (Complex 8 []) + ) + ) + Add + (ComplexConstant + 0.000000 + 3.000000 + (Complex 8 []) + ) + (Complex 8 []) + (ComplexConstant + 2.000000 + 3.000000 + (Complex 8 []) + ) + ) + () + ) + (= + (Var 3 y) + (ComplexBinOp + (Cast + (IntegerConstant 5 (Integer 4 [])) + IntegerToComplex + (Complex 8 []) + (ComplexConstant + 5.000000 + 0.000000 + (Complex 8 []) + ) + ) + Add + (ComplexConstant + 0.000000 + 5.000000 + (Complex 8 []) + ) + (Complex 8 []) + (ComplexConstant + 5.000000 + 5.000000 + (Complex 8 []) + ) + ) + () + ) + (= + (Var 3 z) + (Cast + (ComplexBinOp + (Var 3 x) + Add + (Var 3 y) + (Complex 8 []) + () + ) + ComplexToComplex + (Complex 4 []) + () + ) + () + ) + (= + (Var 3 z) + (Cast + (ComplexBinOp + (Var 3 x) + Sub + (Var 3 y) + (Complex 8 []) + () + ) + ComplexToComplex + (Complex 4 []) + () + ) + () + ) + (= + (Var 3 z) + (Cast + (ComplexBinOp + (Cast + (IntegerConstant 2 (Integer 4 [])) + IntegerToComplex + (Complex 8 []) + (ComplexConstant + 2.000000 + 0.000000 + (Complex 8 []) + ) + ) + Mul + (Var 3 x) + (Complex 8 []) + () + ) + ComplexToComplex + (Complex 4 []) + () + ) + () + )] () - Default - (Complex 4 []) - Source Public - Required .false. - ), - c3: - (Variable - 2 - c3 - [] - Local - () - () - Default - (Complex 8 []) - Source - Public - Required .false. ), - complex: - (ExternalSymbol - 2 - complex - 5 complex - lpython_builtin - [] - complex - Private - ), - complex@__lpython_overloaded_0__complex: - (ExternalSymbol - 2 - complex@__lpython_overloaded_0__complex - 5 __lpython_overloaded_0__complex - lpython_builtin - [] - __lpython_overloaded_0__complex - Public - ), - complex@__lpython_overloaded_13__complex: - (ExternalSymbol - 2 - complex@__lpython_overloaded_13__complex - 5 __lpython_overloaded_13__complex - lpython_builtin - [] - __lpython_overloaded_13__complex - Public - ), - complex@__lpython_overloaded_1__complex: - (ExternalSymbol - 2 + test_complex: + (Function + (SymbolTable + 2 + { + b: + (Variable + 2 + b + [] + Local + () + () + Default + (Logical 4 []) + Source + Public + Required + .false. + ), + c: + (Variable + 2 + c + [] + Local + () + () + Default + (Complex 4 []) + Source + Public + Required + .false. + ), + c1: + (Variable + 2 + c1 + [] + Local + () + () + Default + (Complex 4 []) + Source + Public + Required + .false. + ), + c2: + (Variable + 2 + c2 + [] + Local + () + () + Default + (Complex 4 []) + Source + Public + Required + .false. + ), + c3: + (Variable + 2 + c3 + [] + Local + () + () + Default + (Complex 8 []) + Source + Public + Required + .false. + ), + complex: + (ExternalSymbol + 2 + complex + 5 complex + lpython_builtin + [] + complex + Private + ), + complex@__lpython_overloaded_0__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_0__complex + 5 __lpython_overloaded_0__complex + lpython_builtin + [] + __lpython_overloaded_0__complex + Public + ), + complex@__lpython_overloaded_13__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_13__complex + 5 __lpython_overloaded_13__complex + lpython_builtin + [] + __lpython_overloaded_13__complex + Public + ), + complex@__lpython_overloaded_1__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_1__complex + 5 __lpython_overloaded_1__complex + lpython_builtin + [] + __lpython_overloaded_1__complex + Public + ), + complex@__lpython_overloaded_2__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_2__complex + 5 __lpython_overloaded_2__complex + lpython_builtin + [] + __lpython_overloaded_2__complex + Public + ), + complex@__lpython_overloaded_5__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_5__complex + 5 __lpython_overloaded_5__complex + lpython_builtin + [] + __lpython_overloaded_5__complex + Public + ), + complex@__lpython_overloaded_9__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_9__complex + 5 __lpython_overloaded_9__complex + lpython_builtin + [] + __lpython_overloaded_9__complex + Public + ) + }) + test_complex + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) + [complex@__lpython_overloaded_0__complex complex@__lpython_overloaded_1__complex - 5 __lpython_overloaded_1__complex - lpython_builtin - [] - __lpython_overloaded_1__complex - Public - ), - complex@__lpython_overloaded_2__complex: - (ExternalSymbol - 2 - complex@__lpython_overloaded_2__complex - 5 __lpython_overloaded_2__complex - lpython_builtin - [] - __lpython_overloaded_2__complex - Public - ), - complex@__lpython_overloaded_5__complex: - (ExternalSymbol - 2 complex@__lpython_overloaded_5__complex - 5 __lpython_overloaded_5__complex - lpython_builtin - [] - __lpython_overloaded_5__complex - Public - ), - complex@__lpython_overloaded_9__complex: - (ExternalSymbol - 2 + complex@__lpython_overloaded_2__complex complex@__lpython_overloaded_9__complex - 5 __lpython_overloaded_9__complex - lpython_builtin + complex@__lpython_overloaded_13__complex] [] - __lpython_overloaded_9__complex - Public - ) - }) - test_complex - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [complex@__lpython_overloaded_0__complex - complex@__lpython_overloaded_1__complex - complex@__lpython_overloaded_5__complex - complex@__lpython_overloaded_2__complex - complex@__lpython_overloaded_9__complex - complex@__lpython_overloaded_13__complex] - [] - [(= - (Var 2 c) - (Cast - (FunctionCall - 2 complex@__lpython_overloaded_0__complex - 2 complex - [] - (Complex 8 []) - (ComplexConstant - 0.000000 - 0.000000 - (Complex 8 []) - ) - () - ) - ComplexToComplex - (Complex 4 []) - (ComplexConstant - 0.000000 - 0.000000 - (Complex 4 []) - ) - ) - () - ) - (= - (Var 2 c) - (Cast - (FunctionCall - 2 complex@__lpython_overloaded_1__complex - 2 complex - [((RealConstant - 3.400000 - (Real 8 []) - ))] - (Complex 8 []) - (ComplexConstant - 3.400000 - 0.000000 - (Complex 8 []) - ) - () - ) - ComplexToComplex - (Complex 4 []) - (ComplexConstant - 3.400000 - 0.000000 - (Complex 4 []) - ) - ) - () - ) - (= - (Var 2 c) - (Cast - (FunctionCall - 2 complex@__lpython_overloaded_5__complex - 2 complex - [((RealConstant - 5.000000 - (Real 8 []) - )) - ((RealConstant - 4.300000 - (Real 8 []) - ))] - (Complex 8 []) - (ComplexConstant - 5.000000 - 4.300000 - (Complex 8 []) - ) - () - ) - ComplexToComplex - (Complex 4 []) - (ComplexConstant - 5.000000 - 4.300000 - (Complex 4 []) - ) - ) - () - ) - (= - (Var 2 c) - (FunctionCall - 2 complex@__lpython_overloaded_2__complex - 2 complex - [((IntegerConstant 1 (Integer 4 [])))] - (Complex 4 []) - (ComplexConstant - 1.000000 - 0.000000 - (Complex 8 []) - ) - () - ) - () - ) - (= - (Var 2 c1) - (Cast - (FunctionCall - 2 complex@__lpython_overloaded_9__complex - 2 complex - [((IntegerConstant 3 (Integer 4 []))) - ((IntegerConstant 4 (Integer 4 [])))] - (Complex 8 []) - (ComplexConstant - 3.000000 - 4.000000 - (Complex 8 []) - ) - () - ) - ComplexToComplex - (Complex 4 []) - (ComplexConstant - 3.000000 - 4.000000 - (Complex 4 []) - ) - ) - () - ) - (= - (Var 2 c2) - (Cast - (FunctionCall - 2 complex@__lpython_overloaded_13__complex - 2 complex - [((IntegerConstant 2 (Integer 4 []))) - ((RealConstant - 4.500000 - (Real 8 []) - ))] - (Complex 8 []) - (ComplexConstant - 2.000000 - 4.500000 - (Complex 8 []) - ) - () - ) - ComplexToComplex - (Complex 4 []) - (ComplexConstant - 2.000000 - 4.500000 - (Complex 4 []) - ) - ) - () - ) - (= - (Var 2 c3) - (FunctionCall - 2 complex@__lpython_overloaded_5__complex - 2 complex - [((RealConstant - 3.000000 - (Real 8 []) - )) - ((RealConstant - 4.000000 - (Real 8 []) - ))] - (Complex 8 []) - (ComplexConstant - 3.000000 - 4.000000 - (Complex 8 []) - ) - () - ) - () - ) - (= - (Var 2 b) - (ComplexCompare - (Var 2 c1) - NotEq - (Var 2 c2) - (Logical 4 []) - () - ) - () - ) - (= - (Var 2 b) - (ComplexCompare - (Cast - (Var 2 c1) - ComplexToComplex - (Complex 8 []) - () - ) - Eq - (Var 2 c3) - (Logical 4 []) - () - ) - () - ) - (= - (Var 2 c) - (ComplexBinOp - (Var 2 c1) - Add - (Var 2 c2) - (Complex 4 []) - () - ) - () - ) - (= - (Var 2 c) - (ComplexBinOp - (Var 2 c2) - Sub - (Var 2 c1) - (Complex 4 []) - () - ) - () - ) - (= - (Var 2 c) - (ComplexBinOp - (Var 2 c1) - Mul - (Var 2 c2) - (Complex 4 []) - () - ) - () - ) - (= - (Var 2 c) - (Cast - (ComplexBinOp - (FunctionCall - 2 complex@__lpython_overloaded_9__complex - 2 complex - [((IntegerConstant 1 (Integer 4 []))) - ((IntegerConstant 2 (Integer 4 [])))] - (Complex 8 []) - (ComplexConstant - 1.000000 - 2.000000 - (Complex 8 []) + [(= + (Var 2 c) + (Cast + (FunctionCall + 2 complex@__lpython_overloaded_0__complex + 2 complex + [] + (Complex 8 []) + (ComplexConstant + 0.000000 + 0.000000 + (Complex 8 []) + ) + () + ) + ComplexToComplex + (Complex 4 []) + (ComplexConstant + 0.000000 + 0.000000 + (Complex 4 []) + ) + ) + () ) - () - ) - Pow - (FunctionCall - 2 complex@__lpython_overloaded_5__complex - 2 complex - [((RealConstant - 3.345340 - (Real 8 []) - )) - ((RealConstant - 4.867868 - (Real 8 []) - ))] - (Complex 8 []) - (ComplexConstant - 3.345340 - 4.867868 - (Complex 8 []) + (= + (Var 2 c) + (Cast + (FunctionCall + 2 complex@__lpython_overloaded_1__complex + 2 complex + [((RealConstant + 3.400000 + (Real 8 []) + ))] + (Complex 8 []) + (ComplexConstant + 3.400000 + 0.000000 + (Complex 8 []) + ) + () + ) + ComplexToComplex + (Complex 4 []) + (ComplexConstant + 3.400000 + 0.000000 + (Complex 4 []) + ) + ) + () ) - () - ) - (Complex 8 []) - (ComplexConstant - 0.015553 - 0.065561 - (Complex 8 []) - ) - ) - ComplexToComplex - (Complex 4 []) - (ComplexConstant - 0.015553 - 0.065561 - (Complex 4 []) - ) - ) - () - ) - (= - (Var 2 c) - (Cast - (ComplexBinOp - (FunctionCall - 2 complex@__lpython_overloaded_9__complex - 2 complex - [((IntegerConstant 1 (Integer 4 []))) - ((IntegerConstant 2 (Integer 4 [])))] - (Complex 8 []) - (ComplexConstant - 1.000000 - 2.000000 - (Complex 8 []) + (= + (Var 2 c) + (Cast + (FunctionCall + 2 complex@__lpython_overloaded_5__complex + 2 complex + [((RealConstant + 5.000000 + (Real 8 []) + )) + ((RealConstant + 4.300000 + (Real 8 []) + ))] + (Complex 8 []) + (ComplexConstant + 5.000000 + 4.300000 + (Complex 8 []) + ) + () + ) + ComplexToComplex + (Complex 4 []) + (ComplexConstant + 5.000000 + 4.300000 + (Complex 4 []) + ) + ) + () ) - () - ) - Mul - (FunctionCall - 2 complex@__lpython_overloaded_9__complex - 2 complex - [((IntegerConstant 3 (Integer 4 []))) - ((IntegerConstant 4 (Integer 4 [])))] - (Complex 8 []) - (ComplexConstant - 3.000000 - 4.000000 - (Complex 8 []) + (= + (Var 2 c) + (FunctionCall + 2 complex@__lpython_overloaded_2__complex + 2 complex + [((IntegerConstant 1 (Integer 4 [])))] + (Complex 4 []) + (ComplexConstant + 1.000000 + 0.000000 + (Complex 8 []) + ) + () + ) + () ) - () - ) - (Complex 8 []) - (ComplexConstant - -5.000000 - 10.000000 - (Complex 8 []) - ) - ) - ComplexToComplex - (Complex 4 []) - (ComplexConstant - -5.000000 - 10.000000 - (Complex 4 []) - ) - ) - () - ) - (= - (Var 2 c) - (Cast - (ComplexBinOp - (FunctionCall - 2 complex@__lpython_overloaded_9__complex - 2 complex - [((IntegerConstant 4 (Integer 4 []))) - ((IntegerConstant 5 (Integer 4 [])))] - (Complex 8 []) - (ComplexConstant - 4.000000 - 5.000000 - (Complex 8 []) + (= + (Var 2 c1) + (Cast + (FunctionCall + 2 complex@__lpython_overloaded_9__complex + 2 complex + [((IntegerConstant 3 (Integer 4 []))) + ((IntegerConstant 4 (Integer 4 [])))] + (Complex 8 []) + (ComplexConstant + 3.000000 + 4.000000 + (Complex 8 []) + ) + () + ) + ComplexToComplex + (Complex 4 []) + (ComplexConstant + 3.000000 + 4.000000 + (Complex 4 []) + ) + ) + () ) - () - ) - Sub - (FunctionCall - 2 complex@__lpython_overloaded_9__complex - 2 complex - [((IntegerConstant 3 (Integer 4 []))) - ((IntegerConstant 4 (Integer 4 [])))] - (Complex 8 []) - (ComplexConstant - 3.000000 - 4.000000 - (Complex 8 []) + (= + (Var 2 c2) + (Cast + (FunctionCall + 2 complex@__lpython_overloaded_13__complex + 2 complex + [((IntegerConstant 2 (Integer 4 []))) + ((RealConstant + 4.500000 + (Real 8 []) + ))] + (Complex 8 []) + (ComplexConstant + 2.000000 + 4.500000 + (Complex 8 []) + ) + () + ) + ComplexToComplex + (Complex 4 []) + (ComplexConstant + 2.000000 + 4.500000 + (Complex 4 []) + ) + ) + () + ) + (= + (Var 2 c3) + (FunctionCall + 2 complex@__lpython_overloaded_5__complex + 2 complex + [((RealConstant + 3.000000 + (Real 8 []) + )) + ((RealConstant + 4.000000 + (Real 8 []) + ))] + (Complex 8 []) + (ComplexConstant + 3.000000 + 4.000000 + (Complex 8 []) + ) + () + ) + () ) + (= + (Var 2 b) + (ComplexCompare + (Var 2 c1) + NotEq + (Var 2 c2) + (Logical 4 []) + () + ) + () + ) + (= + (Var 2 b) + (ComplexCompare + (Cast + (Var 2 c1) + ComplexToComplex + (Complex 8 []) + () + ) + Eq + (Var 2 c3) + (Logical 4 []) + () + ) + () + ) + (= + (Var 2 c) + (ComplexBinOp + (Var 2 c1) + Add + (Var 2 c2) + (Complex 4 []) + () + ) + () + ) + (= + (Var 2 c) + (ComplexBinOp + (Var 2 c2) + Sub + (Var 2 c1) + (Complex 4 []) + () + ) + () + ) + (= + (Var 2 c) + (ComplexBinOp + (Var 2 c1) + Mul + (Var 2 c2) + (Complex 4 []) + () + ) + () + ) + (= + (Var 2 c) + (Cast + (ComplexBinOp + (FunctionCall + 2 complex@__lpython_overloaded_9__complex + 2 complex + [((IntegerConstant 1 (Integer 4 []))) + ((IntegerConstant 2 (Integer 4 [])))] + (Complex 8 []) + (ComplexConstant + 1.000000 + 2.000000 + (Complex 8 []) + ) + () + ) + Pow + (FunctionCall + 2 complex@__lpython_overloaded_5__complex + 2 complex + [((RealConstant + 3.345340 + (Real 8 []) + )) + ((RealConstant + 4.867868 + (Real 8 []) + ))] + (Complex 8 []) + (ComplexConstant + 3.345340 + 4.867868 + (Complex 8 []) + ) + () + ) + (Complex 8 []) + (ComplexConstant + 0.015553 + 0.065561 + (Complex 8 []) + ) + ) + ComplexToComplex + (Complex 4 []) + (ComplexConstant + 0.015553 + 0.065561 + (Complex 4 []) + ) + ) + () + ) + (= + (Var 2 c) + (Cast + (ComplexBinOp + (FunctionCall + 2 complex@__lpython_overloaded_9__complex + 2 complex + [((IntegerConstant 1 (Integer 4 []))) + ((IntegerConstant 2 (Integer 4 [])))] + (Complex 8 []) + (ComplexConstant + 1.000000 + 2.000000 + (Complex 8 []) + ) + () + ) + Mul + (FunctionCall + 2 complex@__lpython_overloaded_9__complex + 2 complex + [((IntegerConstant 3 (Integer 4 []))) + ((IntegerConstant 4 (Integer 4 [])))] + (Complex 8 []) + (ComplexConstant + 3.000000 + 4.000000 + (Complex 8 []) + ) + () + ) + (Complex 8 []) + (ComplexConstant + -5.000000 + 10.000000 + (Complex 8 []) + ) + ) + ComplexToComplex + (Complex 4 []) + (ComplexConstant + -5.000000 + 10.000000 + (Complex 4 []) + ) + ) + () + ) + (= + (Var 2 c) + (Cast + (ComplexBinOp + (FunctionCall + 2 complex@__lpython_overloaded_9__complex + 2 complex + [((IntegerConstant 4 (Integer 4 []))) + ((IntegerConstant 5 (Integer 4 [])))] + (Complex 8 []) + (ComplexConstant + 4.000000 + 5.000000 + (Complex 8 []) + ) + () + ) + Sub + (FunctionCall + 2 complex@__lpython_overloaded_9__complex + 2 complex + [((IntegerConstant 3 (Integer 4 []))) + ((IntegerConstant 4 (Integer 4 [])))] + (Complex 8 []) + (ComplexConstant + 3.000000 + 4.000000 + (Complex 8 []) + ) + () + ) + (Complex 8 []) + (ComplexConstant + 1.000000 + 1.000000 + (Complex 8 []) + ) + ) + ComplexToComplex + (Complex 4 []) + (ComplexConstant + 1.000000 + 1.000000 + (Complex 4 []) + ) + ) + () + )] () + Public + .false. + .false. ) - (Complex 8 []) - (ComplexConstant - 1.000000 - 1.000000 - (Complex 8 []) - ) - ) - ComplexToComplex - (Complex 4 []) - (ComplexConstant - 1.000000 - 1.000000 - (Complex 4 []) - ) - ) - () - )] - () - Public + }) + _global_symbols + [lpython_builtin] .false. .false. + ), + lpython_builtin: + (IntrinsicModule lpython_builtin), + main_program: + (Program + (SymbolTable + 111 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-constants1-20d32ff.json b/tests/reference/asr-constants1-20d32ff.json index 00b39b8492..fbf5be1917 100644 --- a/tests/reference/asr-constants1-20d32ff.json +++ b/tests/reference/asr-constants1-20d32ff.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-constants1-20d32ff.stdout", - "stdout_hash": "c6e5e46199c2e220a60fa7653b5abfe278957f410ebe2ad76db79ad7", + "stdout_hash": "33886cb1d94bb733f05a41a3722895ad19767a6707d6d90de5e4dcc3", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-constants1-20d32ff.stdout b/tests/reference/asr-constants1-20d32ff.stdout index 17eafd153c..4dbac35c8e 100644 --- a/tests/reference/asr-constants1-20d32ff.stdout +++ b/tests/reference/asr-constants1-20d32ff.stdout @@ -2,1766 +2,1777 @@ (SymbolTable 1 { - lpython_builtin: - (IntrinsicModule lpython_builtin), - main_program: - (Program + _global_symbols: + (Module (SymbolTable - 119 + 120 { - - }) - main_program - [] - [] - ), - test_abs: - (Function - (SymbolTable - 4 - { - a: - (Variable - 4 - a + test_abs: + (Function + (SymbolTable + 4 + { + a: + (Variable + 4 + a + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + b: + (Variable + 4 + b + [] + Local + () + () + Default + (Real 4 []) + Source + Public + Required + .false. + ), + complex: + (ExternalSymbol + 4 + complex + 13 complex + lpython_builtin + [] + complex + Private + ), + complex@__lpython_overloaded_5__complex: + (ExternalSymbol + 4 + complex@__lpython_overloaded_5__complex + 13 __lpython_overloaded_5__complex + lpython_builtin + [] + __lpython_overloaded_5__complex + Public + ) + }) + test_abs + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) + [complex@__lpython_overloaded_5__complex] [] - Local - () + [(= + (Var 4 a) + (IntrinsicFunction + Abs + [(IntegerConstant 5 (Integer 4 []))] + 0 + (Integer 4 []) + (IntegerConstant 5 (Integer 4 [])) + ) + () + ) + (= + (Var 4 a) + (IntrinsicFunction + Abs + [(IntegerUnaryMinus + (IntegerConstant 500 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -500 (Integer 4 [])) + )] + 0 + (Integer 4 []) + (IntegerConstant 500 (Integer 4 [])) + ) + () + ) + (= + (Var 4 a) + (IntrinsicFunction + Abs + [(Cast + (LogicalConstant + .false. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + )] + 0 + (Integer 4 []) + () + ) + () + ) + (= + (Var 4 a) + (IntrinsicFunction + Abs + [(Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + )] + 0 + (Integer 4 []) + () + ) + () + ) + (= + (Var 4 b) + (Cast + (IntrinsicFunction + Abs + [(RealConstant + 3.450000 + (Real 8 []) + )] + 0 + (Real 8 []) + (RealConstant + 3.450000 + (Real 8 []) + ) + ) + RealToReal + (Real 4 []) + (RealConstant + 3.450000 + (Real 4 []) + ) + ) + () + ) + (= + (Var 4 b) + (Cast + (IntrinsicFunction + Abs + [(RealUnaryMinus + (RealConstant + 5346.340000 + (Real 8 []) + ) + (Real 8 []) + (RealConstant + -5346.340000 + (Real 8 []) + ) + )] + 0 + (Real 8 []) + (RealConstant + 5346.340000 + (Real 8 []) + ) + ) + RealToReal + (Real 4 []) + (RealConstant + 5346.340000 + (Real 4 []) + ) + ) + () + ) + (= + (Var 4 b) + (Cast + (IntrinsicFunction + Abs + [(FunctionCall + 4 complex@__lpython_overloaded_5__complex + 4 complex + [((RealConstant + 3.450000 + (Real 8 []) + )) + ((RealConstant + 5.600000 + (Real 8 []) + ))] + (Complex 8 []) + (ComplexConstant + 3.450000 + 5.600000 + (Complex 8 []) + ) + () + )] + 0 + (Real 8 []) + (RealConstant + 6.577424 + (Real 8 []) + ) + ) + RealToReal + (Real 4 []) + (RealConstant + 6.577424 + (Real 4 []) + ) + ) + () + )] () - Default - (Integer 4 []) - Source Public - Required + .false. .false. ), - b: - (Variable - 4 - b + test_bool: + (Function + (SymbolTable + 6 + { + a: + (Variable + 6 + a + [] + Local + () + () + Default + (Logical 4 []) + Source + Public + Required + .false. + ), + complex: + (ExternalSymbol + 6 + complex + 13 complex + lpython_builtin + [] + complex + Private + ), + complex@__lpython_overloaded_9__complex: + (ExternalSymbol + 6 + complex@__lpython_overloaded_9__complex + 13 __lpython_overloaded_9__complex + lpython_builtin + [] + __lpython_overloaded_9__complex + Public + ) + }) + test_bool + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) + [complex@__lpython_overloaded_9__complex] [] - Local - () + [(= + (Var 6 a) + (Cast + (IntegerConstant 0 (Integer 4 [])) + IntegerToLogical + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 6 a) + (Cast + (IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + IntegerToLogical + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 6 a) + (Cast + (StringConstant + "" + (Character 1 0 () []) + ) + CharacterToLogical + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 6 a) + (Cast + (FunctionCall + 6 complex@__lpython_overloaded_9__complex + 6 complex + [((IntegerConstant 0 (Integer 4 []))) + ((IntegerConstant 0 (Integer 4 [])))] + (Complex 8 []) + (ComplexConstant + 0.000000 + 0.000000 + (Complex 8 []) + ) + () + ) + ComplexToLogical + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (Assert + (LogicalCompare + (Var 6 a) + Eq + (LogicalConstant + .false. + (Logical 4 []) + ) + (Logical 4 []) + () + ) + () + ) + (= + (Var 6 a) + (Cast + (StringConstant + "t" + (Character 1 1 () []) + ) + CharacterToLogical + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 6 a) + (Cast + (RealConstant + 2.300000 + (Real 8 []) + ) + RealToLogical + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (Assert + (LogicalCompare + (Var 6 a) + Eq + (LogicalConstant + .true. + (Logical 4 []) + ) + (Logical 4 []) + () + ) + () + )] () - Default - (Real 4 []) - Source Public - Required .false. - ), - complex: - (ExternalSymbol - 4 - complex - 13 complex - lpython_builtin - [] - complex - Private - ), - complex@__lpython_overloaded_5__complex: - (ExternalSymbol - 4 - complex@__lpython_overloaded_5__complex - 13 __lpython_overloaded_5__complex - lpython_builtin - [] - __lpython_overloaded_5__complex - Public - ) - }) - test_abs - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [complex@__lpython_overloaded_5__complex] - [] - [(= - (Var 4 a) - (IntrinsicFunction - Abs - [(IntegerConstant 5 (Integer 4 []))] - 0 - (Integer 4 []) - (IntegerConstant 5 (Integer 4 [])) - ) - () - ) - (= - (Var 4 a) - (IntrinsicFunction - Abs - [(IntegerUnaryMinus - (IntegerConstant 500 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -500 (Integer 4 [])) - )] - 0 - (Integer 4 []) - (IntegerConstant 500 (Integer 4 [])) - ) - () - ) - (= - (Var 4 a) - (IntrinsicFunction - Abs - [(Cast - (LogicalConstant .false. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - )] - 0 - (Integer 4 []) - () - ) - () - ) - (= - (Var 4 a) - (IntrinsicFunction - Abs - [(Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - )] - 0 - (Integer 4 []) - () - ) - () - ) - (= - (Var 4 b) - (Cast - (IntrinsicFunction - Abs - [(RealConstant - 3.450000 - (Real 8 []) - )] - 0 - (Real 8 []) - (RealConstant - 3.450000 - (Real 8 []) - ) - ) - RealToReal - (Real 4 []) - (RealConstant - 3.450000 - (Real 4 []) - ) - ) - () - ) - (= - (Var 4 b) - (Cast - (IntrinsicFunction - Abs - [(RealUnaryMinus - (RealConstant - 5346.340000 - (Real 8 []) - ) - (Real 8 []) - (RealConstant - -5346.340000 - (Real 8 []) - ) - )] - 0 - (Real 8 []) - (RealConstant - 5346.340000 - (Real 8 []) - ) - ) - RealToReal - (Real 4 []) - (RealConstant - 5346.340000 - (Real 4 []) - ) - ) - () - ) - (= - (Var 4 b) - (Cast - (IntrinsicFunction - Abs - [(FunctionCall - 4 complex@__lpython_overloaded_5__complex - 4 complex - [((RealConstant - 3.450000 - (Real 8 []) - )) - ((RealConstant - 5.600000 - (Real 8 []) - ))] - (Complex 8 []) - (ComplexConstant - 3.450000 - 5.600000 - (Complex 8 []) + ), + test_boz: + (Function + (SymbolTable + 2 + { + b: + (Variable + 2 + b + [] + Local + () + () + Default + (Character 1 -2 () []) + Source + Public + Required + .false. + ), + bin: + (ExternalSymbol + 2 + bin + 13 bin + lpython_builtin + [] + bin + Private + ), + hex: + (ExternalSymbol + 2 + hex + 13 hex + lpython_builtin + [] + hex + Private + ), + oct: + (ExternalSymbol + 2 + oct + 13 oct + lpython_builtin + [] + oct + Private + ) + }) + test_boz + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. ) - () - )] - 0 - (Real 8 []) - (RealConstant - 6.577424 - (Real 8 []) - ) - ) - RealToReal - (Real 4 []) - (RealConstant - 6.577424 - (Real 4 []) - ) - ) - () - )] - () - Public - .false. - .false. - ), - test_bool: - (Function - (SymbolTable - 6 - { - a: - (Variable - 6 - a + [bin + oct + hex] [] - Local - () + [(= + (Var 2 b) + (FunctionCall + 2 bin + () + [((IntegerConstant 5 (Integer 4 [])))] + (Character 1 -2 () []) + (StringConstant + "0b101" + (Character 1 5 () []) + ) + () + ) + () + ) + (= + (Var 2 b) + (FunctionCall + 2 bin + () + [((IntegerConstant 64 (Integer 4 [])))] + (Character 1 -2 () []) + (StringConstant + "0b1000000" + (Character 1 9 () []) + ) + () + ) + () + ) + (= + (Var 2 b) + (FunctionCall + 2 bin + () + [((IntegerUnaryMinus + (IntegerConstant 534 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -534 (Integer 4 [])) + ))] + (Character 1 -2 () []) + (StringConstant + "-0b1000010110" + (Character 1 13 () []) + ) + () + ) + () + ) + (= + (Var 2 b) + (FunctionCall + 2 oct + () + [((IntegerConstant 8 (Integer 4 [])))] + (Character 1 -2 () []) + (StringConstant + "0o10" + (Character 1 4 () []) + ) + () + ) + () + ) + (= + (Var 2 b) + (FunctionCall + 2 oct + () + [((IntegerConstant 56 (Integer 4 [])))] + (Character 1 -2 () []) + (StringConstant + "0o70" + (Character 1 4 () []) + ) + () + ) + () + ) + (= + (Var 2 b) + (FunctionCall + 2 oct + () + [((IntegerUnaryMinus + (IntegerConstant 534 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -534 (Integer 4 [])) + ))] + (Character 1 -2 () []) + (StringConstant + "-0o1026" + (Character 1 7 () []) + ) + () + ) + () + ) + (= + (Var 2 b) + (FunctionCall + 2 hex + () + [((IntegerConstant 42 (Integer 4 [])))] + (Character 1 -2 () []) + (StringConstant + "0x2a" + (Character 1 4 () []) + ) + () + ) + () + ) + (= + (Var 2 b) + (FunctionCall + 2 hex + () + [((IntegerConstant 12648430 (Integer 4 [])))] + (Character 1 -2 () []) + (StringConstant + "0xc0ffee" + (Character 1 8 () []) + ) + () + ) + () + ) + (= + (Var 2 b) + (FunctionCall + 2 hex + () + [((IntegerUnaryMinus + (IntegerConstant 534 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -534 (Integer 4 [])) + ))] + (Character 1 -2 () []) + (StringConstant + "-0x216" + (Character 1 6 () []) + ) + () + ) + () + )] () - Default - (Logical 4 []) - Source Public - Required + .false. .false. ), - complex: - (ExternalSymbol - 6 - complex - 13 complex - lpython_builtin - [] - complex - Private - ), - complex@__lpython_overloaded_9__complex: - (ExternalSymbol - 6 - complex@__lpython_overloaded_9__complex - 13 __lpython_overloaded_9__complex - lpython_builtin + test_callable: + (Function + (SymbolTable + 8 + { + a: + (Variable + 8 + a + [] + Local + () + () + Default + (Logical 4 []) + Source + Public + Required + .false. + ), + b: + (Variable + 8 + b + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ) + }) + test_callable + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - __lpython_overloaded_9__complex - Public - ) - }) - test_bool - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [complex@__lpython_overloaded_9__complex] - [] - [(= - (Var 6 a) - (Cast - (IntegerConstant 0 (Integer 4 [])) - IntegerToLogical - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 6 a) - (Cast - (IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - ) - IntegerToLogical - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 6 a) - (Cast - (StringConstant - "" - (Character 1 0 () []) - ) - CharacterToLogical - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 6 a) - (Cast - (FunctionCall - 6 complex@__lpython_overloaded_9__complex - 6 complex - [((IntegerConstant 0 (Integer 4 []))) - ((IntegerConstant 0 (Integer 4 [])))] - (Complex 8 []) - (ComplexConstant - 0.000000 - 0.000000 - (Complex 8 []) - ) - () - ) - ComplexToLogical - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (Assert - (LogicalCompare - (Var 6 a) - Eq - (LogicalConstant - .false. - (Logical 4 []) - ) - (Logical 4 []) - () - ) - () - ) - (= - (Var 6 a) - (Cast - (StringConstant - "t" - (Character 1 1 () []) - ) - CharacterToLogical - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 6 a) - (Cast - (RealConstant - 2.300000 - (Real 8 []) - ) - RealToLogical - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (Assert - (LogicalCompare - (Var 6 a) - Eq - (LogicalConstant - .true. - (Logical 4 []) - ) - (Logical 4 []) - () - ) - () - )] - () - Public - .false. - .false. - ), - test_boz: - (Function - (SymbolTable - 2 - { - b: - (Variable - 2 - b [] - Local - () + [(= + (Var 8 b) + (IntegerConstant 2 (Integer 4 [])) + () + ) + (= + (Var 8 a) + (LogicalConstant + .true. + (Logical 4 []) + ) + () + ) + (Assert + (LogicalCompare + (Var 8 a) + Eq + (LogicalConstant + .true. + (Logical 4 []) + ) + (Logical 4 []) + () + ) + () + ) + (= + (Var 8 a) + (LogicalConstant + .false. + (Logical 4 []) + ) + () + ) + (Assert + (LogicalCompare + (Var 8 a) + Eq + (LogicalConstant + .false. + (Logical 4 []) + ) + (Logical 4 []) + () + ) + () + ) + (= + (Var 8 a) + (LogicalConstant + .false. + (Logical 4 []) + ) + () + ) + (Assert + (LogicalCompare + (Var 8 a) + Eq + (LogicalConstant + .false. + (Logical 4 []) + ) + (Logical 4 []) + () + ) + () + )] () - Default - (Character 1 -2 () []) - Source Public - Required + .false. .false. ), - bin: - (ExternalSymbol - 2 - bin - 13 bin - lpython_builtin - [] - bin - Private - ), - hex: - (ExternalSymbol - 2 - hex - 13 hex - lpython_builtin - [] - hex - Private - ), - oct: - (ExternalSymbol - 2 - oct - 13 oct - lpython_builtin - [] - oct - Private - ) - }) - test_boz - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [bin - oct - hex] - [] - [(= - (Var 2 b) - (FunctionCall - 2 bin - () - [((IntegerConstant 5 (Integer 4 [])))] - (Character 1 -2 () []) - (StringConstant - "0b101" - (Character 1 5 () []) - ) - () - ) - () - ) - (= - (Var 2 b) - (FunctionCall - 2 bin - () - [((IntegerConstant 64 (Integer 4 [])))] - (Character 1 -2 () []) - (StringConstant - "0b1000000" - (Character 1 9 () []) - ) - () - ) - () - ) - (= - (Var 2 b) - (FunctionCall - 2 bin - () - [((IntegerUnaryMinus - (IntegerConstant 534 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -534 (Integer 4 [])) - ))] - (Character 1 -2 () []) - (StringConstant - "-0b1000010110" - (Character 1 13 () []) - ) - () - ) - () - ) - (= - (Var 2 b) - (FunctionCall - 2 oct - () - [((IntegerConstant 8 (Integer 4 [])))] - (Character 1 -2 () []) - (StringConstant - "0o10" - (Character 1 4 () []) - ) - () - ) - () - ) - (= - (Var 2 b) - (FunctionCall - 2 oct - () - [((IntegerConstant 56 (Integer 4 [])))] - (Character 1 -2 () []) - (StringConstant - "0o70" - (Character 1 4 () []) - ) - () - ) - () - ) - (= - (Var 2 b) - (FunctionCall - 2 oct - () - [((IntegerUnaryMinus - (IntegerConstant 534 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -534 (Integer 4 [])) - ))] - (Character 1 -2 () []) - (StringConstant - "-0o1026" - (Character 1 7 () []) - ) - () - ) - () - ) - (= - (Var 2 b) - (FunctionCall - 2 hex - () - [((IntegerConstant 42 (Integer 4 [])))] - (Character 1 -2 () []) - (StringConstant - "0x2a" - (Character 1 4 () []) - ) - () - ) - () - ) - (= - (Var 2 b) - (FunctionCall - 2 hex - () - [((IntegerConstant 12648430 (Integer 4 [])))] - (Character 1 -2 () []) - (StringConstant - "0xc0ffee" - (Character 1 8 () []) - ) - () - ) - () - ) - (= - (Var 2 b) - (FunctionCall - 2 hex - () - [((IntegerUnaryMinus - (IntegerConstant 534 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -534 (Integer 4 [])) - ))] - (Character 1 -2 () []) - (StringConstant - "-0x216" - (Character 1 6 () []) - ) - () - ) - () - )] - () - Public - .false. - .false. - ), - test_callable: - (Function - (SymbolTable - 8 - { - a: - (Variable - 8 - a + test_divmod: + (Function + (SymbolTable + 11 + { + a: + (Variable + 11 + a + [] + Local + () + () + Default + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + Source + Public + Required + .false. + ), + divmod: + (ExternalSymbol + 11 + divmod + 13 divmod + lpython_builtin + [] + divmod + Private + ) + }) + test_divmod + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) + [divmod] [] - Local - () + [(= + (Var 11 a) + (FunctionCall + 11 divmod + () + [((IntegerConstant 9 (Integer 4 []))) + ((IntegerConstant 3 (Integer 4 [])))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + (TupleConstant + [(IntegerConstant 3 (Integer 4 [])) + (IntegerConstant 0 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + ) + () + ) + () + ) + (= + (Var 11 a) + (FunctionCall + 11 divmod + () + [((IntegerConstant 9 (Integer 4 []))) + ((IntegerUnaryMinus + (IntegerConstant 3 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -3 (Integer 4 [])) + ))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + (TupleConstant + [(IntegerConstant -3 (Integer 4 [])) + (IntegerConstant 0 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + ) + () + ) + () + ) + (= + (Var 11 a) + (FunctionCall + 11 divmod + () + [((IntegerConstant 3 (Integer 4 []))) + ((IntegerConstant 3 (Integer 4 [])))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + (TupleConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 0 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + ) + () + ) + () + ) + (= + (Var 11 a) + (FunctionCall + 11 divmod + () + [((IntegerConstant 4 (Integer 4 []))) + ((IntegerConstant 5 (Integer 4 [])))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + (TupleConstant + [(IntegerConstant 0 (Integer 4 [])) + (IntegerConstant 4 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + ) + () + ) + () + ) + (= + (Var 11 a) + (FunctionCall + 11 divmod + () + [((IntegerConstant 0 (Integer 4 []))) + ((IntegerConstant 5 (Integer 4 [])))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + (TupleConstant + [(IntegerConstant 0 (Integer 4 [])) + (IntegerConstant 0 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + ) + () + ) + () + )] () - Default - (Logical 4 []) - Source Public - Required + .false. .false. ), - b: - (Variable - 8 - b + test_float: + (Function + (SymbolTable + 10 + { + a: + (Variable + 10 + a + [] + Local + () + () + Default + (Real 8 []) + Source + Public + Required + .false. + ) + }) + test_float + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ) - }) - test_callable - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [] - [(= - (Var 8 b) - (IntegerConstant 2 (Integer 4 [])) - () - ) - (= - (Var 8 a) - (LogicalConstant - .true. - (Logical 4 []) - ) - () - ) - (Assert - (LogicalCompare - (Var 8 a) - Eq - (LogicalConstant - .true. - (Logical 4 []) - ) - (Logical 4 []) - () - ) - () - ) - (= - (Var 8 a) - (LogicalConstant - .false. - (Logical 4 []) - ) - () - ) - (Assert - (LogicalCompare - (Var 8 a) - Eq - (LogicalConstant - .false. - (Logical 4 []) - ) - (Logical 4 []) - () - ) - () - ) - (= - (Var 8 a) - (LogicalConstant - .false. - (Logical 4 []) - ) - () - ) - (Assert - (LogicalCompare - (Var 8 a) - Eq - (LogicalConstant - .false. - (Logical 4 []) - ) - (Logical 4 []) - () - ) - () - )] - () - Public - .false. - .false. - ), - test_divmod: - (Function - (SymbolTable - 11 - { - a: - (Variable - 11 - a [] - Local - () - () - Default - (Tuple - [(Integer 4 []) - (Integer 4 [])] + [(= + (Var 10 a) + (RealConstant + 0.000000 + (Real 8 []) + ) + () + ) + (= + (Var 10 a) + (RealConstant + 4.560000 + (Real 8 []) + ) + () + ) + (= + (Var 10 a) + (Cast + (IntegerConstant 5 (Integer 4 [])) + IntegerToReal + (Real 8 []) + (RealConstant + 5.000000 + (Real 8 []) + ) + ) + () + ) + (= + (Var 10 a) + (Cast + (IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + IntegerToReal + (Real 8 []) + (RealConstant + -1.000000 + (Real 8 []) + ) + ) + () ) - Source + (= + (Var 10 a) + (Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToReal + (Real 8 []) + (RealConstant + 1.000000 + (Real 8 []) + ) + ) + () + ) + (= + (Var 10 a) + (Cast + (LogicalConstant + .false. + (Logical 4 []) + ) + LogicalToReal + (Real 8 []) + (RealConstant + 0.000000 + (Real 8 []) + ) + ) + () + )] + () Public - Required + .false. .false. ), - divmod: - (ExternalSymbol - 11 - divmod - 13 divmod - lpython_builtin + test_int: + (Function + (SymbolTable + 9 + { + a: + (Variable + 9 + a + [] + Local + () + () + Default + (Integer 8 []) + Source + Public + Required + .false. + ) + }) + test_int + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - divmod - Private - ) - }) - test_divmod - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [divmod] - [] - [(= - (Var 11 a) - (FunctionCall - 11 divmod - () - [((IntegerConstant 9 (Integer 4 []))) - ((IntegerConstant 3 (Integer 4 [])))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - (TupleConstant - [(IntegerConstant 3 (Integer 4 [])) - (IntegerConstant 0 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - () - ) - (= - (Var 11 a) - (FunctionCall - 11 divmod - () - [((IntegerConstant 9 (Integer 4 []))) - ((IntegerUnaryMinus - (IntegerConstant 3 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -3 (Integer 4 [])) - ))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - (TupleConstant - [(IntegerConstant -3 (Integer 4 [])) - (IntegerConstant 0 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - () - ) - (= - (Var 11 a) - (FunctionCall - 11 divmod - () - [((IntegerConstant 3 (Integer 4 []))) - ((IntegerConstant 3 (Integer 4 [])))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - (TupleConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 0 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - () - ) - (= - (Var 11 a) - (FunctionCall - 11 divmod - () - [((IntegerConstant 4 (Integer 4 []))) - ((IntegerConstant 5 (Integer 4 [])))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - (TupleConstant - [(IntegerConstant 0 (Integer 4 [])) - (IntegerConstant 4 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - () - ) - (= - (Var 11 a) - (FunctionCall - 11 divmod - () - [((IntegerConstant 0 (Integer 4 []))) - ((IntegerConstant 5 (Integer 4 [])))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - (TupleConstant - [(IntegerConstant 0 (Integer 4 [])) - (IntegerConstant 0 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - () - )] - () - Public - .false. - .false. - ), - test_float: - (Function - (SymbolTable - 10 - { - a: - (Variable - 10 - a [] - Local - () + [(= + (Var 9 a) + (IntegerConstant 0 (Integer 8 [])) + () + ) + (= + (Var 9 a) + (Cast + (RealConstant + 4.560000 + (Real 8 []) + ) + RealToInteger + (Integer 8 []) + (IntegerConstant 4 (Integer 8 [])) + ) + () + ) + (= + (Var 9 a) + (Cast + (IntegerConstant 5 (Integer 4 [])) + IntegerToInteger + (Integer 8 []) + (IntegerConstant 5 (Integer 8 [])) + ) + () + ) + (= + (Var 9 a) + (Cast + (RealUnaryMinus + (RealConstant + 5.000010 + (Real 8 []) + ) + (Real 8 []) + (RealConstant + -5.000010 + (Real 8 []) + ) + ) + RealToInteger + (Integer 8 []) + (IntegerConstant -5 (Integer 8 [])) + ) + () + ) + (= + (Var 9 a) + (Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToInteger + (Integer 8 []) + (IntegerConstant 1 (Integer 8 [])) + ) + () + ) + (= + (Var 9 a) + (Cast + (LogicalConstant + .false. + (Logical 4 []) + ) + LogicalToInteger + (Integer 8 []) + (IntegerConstant 0 (Integer 8 [])) + ) + () + ) + (= + (Var 9 a) + (IntegerConstant 5346 (Integer 8 [])) + () + )] () - Default - (Real 8 []) - Source Public - Required .false. - ) - }) - test_float - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [] - [(= - (Var 10 a) - (RealConstant - 0.000000 - (Real 8 []) - ) - () - ) - (= - (Var 10 a) - (RealConstant - 4.560000 - (Real 8 []) - ) - () - ) - (= - (Var 10 a) - (Cast - (IntegerConstant 5 (Integer 4 [])) - IntegerToReal - (Real 8 []) - (RealConstant - 5.000000 - (Real 8 []) - ) - ) - () - ) - (= - (Var 10 a) - (Cast - (IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - ) - IntegerToReal - (Real 8 []) - (RealConstant - -1.000000 - (Real 8 []) - ) - ) - () - ) - (= - (Var 10 a) - (Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToReal - (Real 8 []) - (RealConstant - 1.000000 - (Real 8 []) - ) - ) - () - ) - (= - (Var 10 a) - (Cast - (LogicalConstant - .false. - (Logical 4 []) - ) - LogicalToReal - (Real 8 []) - (RealConstant - 0.000000 - (Real 8 []) - ) - ) - () - )] - () - Public - .false. - .false. - ), - test_int: - (Function - (SymbolTable - 9 - { - a: - (Variable - 9 - a - [] - Local - () - () - Default - (Integer 8 []) - Source - Public - Required .false. - ) - }) - test_int - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [] - [(= - (Var 9 a) - (IntegerConstant 0 (Integer 8 [])) - () - ) - (= - (Var 9 a) - (Cast - (RealConstant - 4.560000 - (Real 8 []) - ) - RealToInteger - (Integer 8 []) - (IntegerConstant 4 (Integer 8 [])) - ) - () - ) - (= - (Var 9 a) - (Cast - (IntegerConstant 5 (Integer 4 [])) - IntegerToInteger - (Integer 8 []) - (IntegerConstant 5 (Integer 8 [])) - ) - () - ) - (= - (Var 9 a) - (Cast - (RealUnaryMinus - (RealConstant - 5.000010 - (Real 8 []) - ) - (Real 8 []) - (RealConstant - -5.000010 - (Real 8 []) - ) - ) - RealToInteger - (Integer 8 []) - (IntegerConstant -5 (Integer 8 [])) - ) - () - ) - (= - (Var 9 a) - (Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToInteger - (Integer 8 []) - (IntegerConstant 1 (Integer 8 [])) - ) - () - ) - (= - (Var 9 a) - (Cast - (LogicalConstant - .false. - (Logical 4 []) - ) - LogicalToInteger - (Integer 8 []) - (IntegerConstant 0 (Integer 8 [])) - ) - () - ) - (= - (Var 9 a) - (IntegerConstant 5346 (Integer 8 [])) - () - )] - () - Public - .false. - .false. - ), - test_len: - (Function - (SymbolTable - 5 - { - a: - (Variable - 5 - a + ), + test_len: + (Function + (SymbolTable + 5 + { + a: + (Variable + 5 + a + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + l: + (Variable + 5 + l + [] + Local + () + () + Default + (List + (Integer 4 []) + ) + Source + Public + Required + .false. + ) + }) + test_len + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () + [] + [(= + (Var 5 a) + (StringLen + (StringConstant + "" + (Character 1 0 () []) + ) + (Integer 4 []) + (IntegerConstant 0 (Integer 4 [])) + ) + () + ) + (= + (Var 5 a) + (StringLen + (StringConstant + "test" + (Character 1 4 () []) + ) + (Integer 4 []) + (IntegerConstant 4 (Integer 4 [])) + ) + () + ) + (= + (Var 5 a) + (StringLen + (StringConstant + "this is a test" + (Character 1 14 () []) + ) + (Integer 4 []) + (IntegerConstant 14 (Integer 4 [])) + ) + () + ) + (= + (Var 5 a) + (TupleLen + (TupleConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + ) + ) + (Integer 4 []) + (IntegerConstant 3 (Integer 4 [])) + ) + () + ) + (= + (Var 5 a) + (TupleLen + (TupleConstant + [(TupleConstant + [(StringConstant + "c" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + ) + (RealConstant + 3.400000 + (Real 8 []) + )] + (Tuple + [(Character 1 1 () []) + (Character 1 1 () []) + (Real 8 [])] + ) + ) + (TupleConstant + [(StringConstant + "c" + (Character 1 1 () []) + ) + (IntegerConstant 3 (Integer 4 [])) + (RealConstant + 5.600000 + (Real 8 []) + )] + (Tuple + [(Character 1 1 () []) + (Integer 4 []) + (Real 8 [])] + ) + )] + (Tuple + [(Tuple + [(Character 1 1 () []) + (Character 1 1 () []) + (Real 8 [])] + ) + (Tuple + [(Character 1 1 () []) + (Integer 4 []) + (Real 8 [])] + )] + ) + ) + (Integer 4 []) + (IntegerConstant 2 (Integer 4 [])) + ) + () + ) + (= + (Var 5 a) + (ListLen + (ListConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + (List + (Integer 4 []) + ) + ) + (Integer 4 []) + (IntegerConstant 3 (Integer 4 [])) + ) + () + ) + (= + (Var 5 a) + (ListLen + (ListConstant + [(ListConstant + [(IntegerUnaryMinus + (IntegerConstant 4 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -4 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 5 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -5 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 6 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -6 (Integer 4 [])) + )] + (List + (Integer 4 []) + ) + ) + (ListConstant + [(IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -2 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 3 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -3 (Integer 4 [])) + )] + (List + (Integer 4 []) + ) + )] + (List + (List + (Integer 4 []) + ) + ) + ) + (Integer 4 []) + (IntegerConstant 2 (Integer 4 [])) + ) + () + ) + (= + (Var 5 a) + (SetLen + (SetConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + (Set + (Integer 4 []) + ) + ) + (Integer 4 []) + (IntegerConstant 3 (Integer 4 [])) + ) + () + ) + (= + (Var 5 a) + (DictLen + (DictConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + [(StringConstant + "c" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + ) + (StringConstant + "c" + (Character 1 1 () []) + )] + (Dict + (Integer 4 []) + (Character 1 1 () []) + ) + ) + (Integer 4 []) + (IntegerConstant 3 (Integer 4 [])) + ) + () + ) + (= + (Var 5 l) + (ListConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 [])) + (IntegerConstant 4 (Integer 4 []))] + (List + (Integer 4 []) + ) + ) + () + ) + (= + (Var 5 a) + (ListLen + (Var 5 l) + (Integer 4 []) + () + ) + () + ) + (ListAppend + (Var 5 l) + (IntegerConstant 5 (Integer 4 [])) + ) + (= + (Var 5 a) + (ListLen + (Var 5 l) + (Integer 4 []) + () + ) + () + )] () - Default - (Integer 4 []) - Source Public - Required + .false. .false. ), - l: - (Variable - 5 - l + test_ord_chr: + (Function + (SymbolTable + 3 + { + a: + (Variable + 3 + a + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + s: + (Variable + 3 + s + [] + Local + () + () + Default + (Character 1 -2 () []) + Source + Public + Required + .false. + ) + }) + test_ord_chr + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (List - (Integer 4 []) + [] + [(= + (Var 3 a) + (StringOrd + (StringConstant + "5" + (Character 1 1 () []) + ) + (Integer 4 []) + (IntegerConstant 53 (Integer 4 [])) + ) + () ) - Source + (= + (Var 3 s) + (StringChr + (IntegerConstant 43 (Integer 4 [])) + (Character 1 1 () []) + (StringConstant + "+" + (Character 1 1 () []) + ) + ) + () + )] + () Public - Required .false. - ) - }) - test_len - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [] - [(= - (Var 5 a) - (StringLen - (StringConstant - "" - (Character 1 0 () []) - ) - (Integer 4 []) - (IntegerConstant 0 (Integer 4 [])) - ) - () - ) - (= - (Var 5 a) - (StringLen - (StringConstant - "test" - (Character 1 4 () []) - ) - (Integer 4 []) - (IntegerConstant 4 (Integer 4 [])) - ) - () - ) - (= - (Var 5 a) - (StringLen - (StringConstant - "this is a test" - (Character 1 14 () []) - ) - (Integer 4 []) - (IntegerConstant 14 (Integer 4 [])) - ) - () - ) - (= - (Var 5 a) - (TupleLen - (TupleConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] - ) - ) - (Integer 4 []) - (IntegerConstant 3 (Integer 4 [])) - ) - () - ) - (= - (Var 5 a) - (TupleLen - (TupleConstant - [(TupleConstant - [(StringConstant - "c" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - ) - (RealConstant - 3.400000 - (Real 8 []) - )] - (Tuple - [(Character 1 1 () []) - (Character 1 1 () []) - (Real 8 [])] + .false. + ), + test_str: + (Function + (SymbolTable + 7 + { + s: + (Variable + 7 + s + [] + Local + () + () + Default + (Character 1 -2 () []) + Source + Public + Required + .false. + ) + }) + test_str + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. ) - ) - (TupleConstant - [(StringConstant - "c" - (Character 1 1 () []) - ) - (IntegerConstant 3 (Integer 4 [])) - (RealConstant - 5.600000 - (Real 8 []) - )] - (Tuple - [(Character 1 1 () []) - (Integer 4 []) - (Real 8 [])] - ) - )] - (Tuple - [(Tuple - [(Character 1 1 () []) - (Character 1 1 () []) - (Real 8 [])] - ) - (Tuple - [(Character 1 1 () []) - (Integer 4 []) - (Real 8 [])] - )] - ) - ) - (Integer 4 []) - (IntegerConstant 2 (Integer 4 [])) - ) - () - ) - (= - (Var 5 a) - (ListLen - (ListConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - (List - (Integer 4 []) - ) - ) - (Integer 4 []) - (IntegerConstant 3 (Integer 4 [])) - ) - () - ) - (= - (Var 5 a) - (ListLen - (ListConstant - [(ListConstant - [(IntegerUnaryMinus - (IntegerConstant 4 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -4 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 5 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -5 (Integer 4 [])) + [] + [] + [(= + (Var 7 s) + (StringConstant + "" + (Character 1 0 () []) + ) + () ) - (IntegerUnaryMinus - (IntegerConstant 6 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -6 (Integer 4 [])) - )] - (List - (Integer 4 []) + (= + (Var 7 s) + (Cast + (IntegerConstant 5 (Integer 4 [])) + IntegerToCharacter + (Character 1 -2 () []) + (StringConstant + "5" + (Character 1 1 () []) + ) + ) + () ) - ) - (ListConstant - [(IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) + (= + (Var 7 s) + (Cast + (IntegerUnaryMinus + (IntegerConstant 4 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -4 (Integer 4 [])) + ) + IntegerToCharacter + (Character 1 -2 () []) + (StringConstant + "-4" + (Character 1 2 () []) + ) + ) + () ) - (IntegerUnaryMinus - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -2 (Integer 4 [])) + (= + (Var 7 s) + (Cast + (RealConstant + 5.600000 + (Real 8 []) + ) + RealToCharacter + (Character 1 -2 () []) + (StringConstant + "5.6" + (Character 1 3 () []) + ) + ) + () ) - (IntegerUnaryMinus - (IntegerConstant 3 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -3 (Integer 4 [])) - )] - (List - (Integer 4 []) + (= + (Var 7 s) + (Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToCharacter + (Character 1 -2 () []) + (StringConstant + "True" + (Character 1 4 () []) + ) + ) + () ) - )] - (List - (List - (Integer 4 []) + (= + (Var 7 s) + (Cast + (LogicalConstant + .false. + (Logical 4 []) + ) + LogicalToCharacter + (Character 1 -2 () []) + (StringConstant + "False" + (Character 1 5 () []) + ) + ) + () ) - ) - ) - (Integer 4 []) - (IntegerConstant 2 (Integer 4 [])) - ) - () - ) - (= - (Var 5 a) - (SetLen - (SetConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - (Set - (Integer 4 []) - ) - ) - (Integer 4 []) - (IntegerConstant 3 (Integer 4 [])) - ) - () - ) - (= - (Var 5 a) - (DictLen - (DictConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - [(StringConstant - "c" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - ) - (StringConstant - "c" - (Character 1 1 () []) - )] - (Dict - (Integer 4 []) - (Character 1 1 () []) - ) - ) - (Integer 4 []) - (IntegerConstant 3 (Integer 4 [])) - ) - () - ) - (= - (Var 5 l) - (ListConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 [])) - (IntegerConstant 4 (Integer 4 []))] - (List - (Integer 4 []) - ) - ) - () - ) - (= - (Var 5 a) - (ListLen - (Var 5 l) - (Integer 4 []) - () - ) - () - ) - (ListAppend - (Var 5 l) - (IntegerConstant 5 (Integer 4 [])) - ) - (= - (Var 5 a) - (ListLen - (Var 5 l) - (Integer 4 []) - () - ) - () - )] - () - Public - .false. - .false. - ), - test_ord_chr: - (Function - (SymbolTable - 3 - { - a: - (Variable - 3 - a - [] - Local - () + (= + (Var 7 s) + (StringConstant + "5346" + (Character 1 4 () []) + ) + () + )] () - Default - (Integer 4 []) - Source Public - Required .false. - ), - s: - (Variable - 3 - s - [] - Local - () - () - Default - (Character 1 -2 () []) - Source - Public - Required .false. ) }) - test_ord_chr - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [] - [(= - (Var 3 a) - (StringOrd - (StringConstant - "5" - (Character 1 1 () []) - ) - (Integer 4 []) - (IntegerConstant 53 (Integer 4 [])) - ) - () - ) - (= - (Var 3 s) - (StringChr - (IntegerConstant 43 (Integer 4 [])) - (Character 1 1 () []) - (StringConstant - "+" - (Character 1 1 () []) - ) - ) - () - )] - () - Public + _global_symbols + [lpython_builtin] .false. .false. ), - test_str: - (Function + lpython_builtin: + (IntrinsicModule lpython_builtin), + main_program: + (Program (SymbolTable - 7 + 119 { - s: - (Variable - 7 - s - [] - Local - () - () - Default - (Character 1 -2 () []) - Source - Public - Required - .false. - ) + }) - test_str - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) + main_program [] [] - [(= - (Var 7 s) - (StringConstant - "" - (Character 1 0 () []) - ) - () - ) - (= - (Var 7 s) - (Cast - (IntegerConstant 5 (Integer 4 [])) - IntegerToCharacter - (Character 1 -2 () []) - (StringConstant - "5" - (Character 1 1 () []) - ) - ) - () - ) - (= - (Var 7 s) - (Cast - (IntegerUnaryMinus - (IntegerConstant 4 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -4 (Integer 4 [])) - ) - IntegerToCharacter - (Character 1 -2 () []) - (StringConstant - "-4" - (Character 1 2 () []) - ) - ) - () - ) - (= - (Var 7 s) - (Cast - (RealConstant - 5.600000 - (Real 8 []) - ) - RealToCharacter - (Character 1 -2 () []) - (StringConstant - "5.6" - (Character 1 3 () []) - ) - ) - () - ) - (= - (Var 7 s) - (Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToCharacter - (Character 1 -2 () []) - (StringConstant - "True" - (Character 1 4 () []) - ) - ) - () - ) - (= - (Var 7 s) - (Cast - (LogicalConstant - .false. - (Logical 4 []) - ) - LogicalToCharacter - (Character 1 -2 () []) - (StringConstant - "False" - (Character 1 5 () []) - ) - ) - () - ) - (= - (Var 7 s) - (StringConstant - "5346" - (Character 1 4 () []) - ) - () - )] - () - Public - .false. - .false. ) }) [] diff --git a/tests/reference/asr-dictionary1-789a50b.json b/tests/reference/asr-dictionary1-789a50b.json index bd5d7bf5d8..e2807a9d38 100644 --- a/tests/reference/asr-dictionary1-789a50b.json +++ b/tests/reference/asr-dictionary1-789a50b.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-dictionary1-789a50b.stdout", - "stdout_hash": "b333afe5a08ea5f5ee15acad2dcb0a819c2807f4476c3722057be2f1", + "stdout_hash": "268d0bd6f2563f3bd16550d5c02f6a10487a1b757e9aa5ebe2e01c45", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-dictionary1-789a50b.stdout b/tests/reference/asr-dictionary1-789a50b.stdout index 2de09e476b..56065dea1f 100644 --- a/tests/reference/asr-dictionary1-789a50b.stdout +++ b/tests/reference/asr-dictionary1-789a50b.stdout @@ -2,585 +2,596 @@ (SymbolTable 1 { - f: - (Function + _global_symbols: + (Module (SymbolTable - 6 + 9 { - x: - (Variable - 6 - x - [] - In - () - () - Default - (Dict - (Integer 4 []) - (Integer 4 []) + f: + (Function + (SymbolTable + 6 + { + x: + (Variable + 6 + x + [] + In + () + () + Default + (Dict + (Integer 4 []) + (Integer 4 []) + ) + Source + Public + Required + .false. + ) + }) + f + (FunctionType + [(Dict + (Integer 4 []) + (Integer 4 []) + )] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. ) - Source - Public - Required - .false. - ) - }) - f - (FunctionType - [(Dict - (Integer 4 []) - (Integer 4 []) - )] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [(Var 6 x)] - [(DictInsert - (Var 6 x) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 4 (Integer 4 [])) - )] - () - Public - .false. - .false. - ), - main_program: - (Program - (SymbolTable - 8 - { - - }) - main_program - [] - [] - ), - test_Dict: - (Function - (SymbolTable - 2 - { - x: - (Variable - 2 - x [] - Local + [(Var 6 x)] + [(DictInsert + (Var 6 x) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 4 (Integer 4 [])) + )] () - () - Default - (Dict - (Integer 4 []) - (Integer 4 []) - ) - Source Public - Required + .false. .false. ), - y: - (Variable - 2 - y + test_Dict: + (Function + (SymbolTable + 2 + { + x: + (Variable + 2 + x + [] + Local + () + () + Default + (Dict + (Integer 4 []) + (Integer 4 []) + ) + Source + Public + Required + .false. + ), + y: + (Variable + 2 + y + [] + Local + () + () + Default + (Dict + (Character 1 -2 () []) + (Integer 4 []) + ) + Source + Public + Required + .false. + ), + z: + (Variable + 2 + z + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ) + }) + test_Dict + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Dict - (Character 1 -2 () []) - (Integer 4 []) + [] + [(= + (Var 2 x) + (DictConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + [(IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 4 (Integer 4 []))] + (Dict + (Integer 4 []) + (Integer 4 []) + ) + ) + () + ) + (= + (Var 2 y) + (DictConstant + [(StringConstant + "a" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + )] + [(IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -2 (Integer 4 [])) + )] + (Dict + (Character 1 1 () []) + (Integer 4 []) + ) + ) + () + ) + (= + (Var 2 z) + (DictItem + (Var 2 y) + (StringConstant + "a" + (Character 1 1 () []) + ) + () + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 z) + (DictItem + (Var 2 y) + (StringConstant + "b" + (Character 1 1 () []) + ) + () + (Integer 4 []) + () + ) + () ) - Source + (= + (Var 2 z) + (DictItem + (Var 2 x) + (IntegerConstant 1 (Integer 4 [])) + () + (Integer 4 []) + () + ) + () + )] + () Public - Required + .false. .false. ), - z: - (Variable - 2 - z + test_dict_get: + (Function + (SymbolTable + 4 + { + x: + (Variable + 4 + x + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + y: + (Variable + 4 + y + [] + Local + () + () + Default + (Dict + (Character 1 -2 () []) + (Integer 4 []) + ) + Source + Public + Required + .false. + ) + }) + test_dict_get + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ) - }) - test_Dict - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [] - [(= - (Var 2 x) - (DictConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - [(IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 4 (Integer 4 []))] - (Dict - (Integer 4 []) - (Integer 4 []) - ) - ) - () - ) - (= - (Var 2 y) - (DictConstant - [(StringConstant - "a" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - )] - [(IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -2 (Integer 4 [])) - )] - (Dict - (Character 1 1 () []) - (Integer 4 []) - ) - ) - () - ) - (= - (Var 2 z) - (DictItem - (Var 2 y) - (StringConstant - "a" - (Character 1 1 () []) - ) - () - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 z) - (DictItem - (Var 2 y) - (StringConstant - "b" - (Character 1 1 () []) - ) - () - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 z) - (DictItem - (Var 2 x) - (IntegerConstant 1 (Integer 4 [])) - () - (Integer 4 []) - () - ) - () - )] - () - Public - .false. - .false. - ), - test_dict_get: - (Function - (SymbolTable - 4 - { - x: - (Variable - 4 - x [] - Local - () + [(= + (Var 4 y) + (DictConstant + [(StringConstant + "a" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + )] + [(IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -2 (Integer 4 [])) + )] + (Dict + (Character 1 1 () []) + (Integer 4 []) + ) + ) + () + ) + (= + (Var 4 x) + (DictItem + (Var 4 y) + (StringConstant + "a" + (Character 1 1 () []) + ) + () + (Integer 4 []) + () + ) + () + ) + (= + (Var 4 x) + (DictItem + (Var 4 y) + (StringConstant + "a" + (Character 1 1 () []) + ) + (IntegerConstant 0 (Integer 4 [])) + (Integer 4 []) + () + ) + () + )] () - Default - (Integer 4 []) - Source Public - Required + .false. .false. ), - y: - (Variable - 4 - y - [] - Local - () - () - Default - (Dict - (Character 1 -2 () []) - (Integer 4 []) + test_dict_insert: + (Function + (SymbolTable + 3 + { + y: + (Variable + 3 + y + [] + Local + () + () + Default + (Dict + (Character 1 -2 () []) + (Integer 4 []) + ) + Source + Public + Required + .false. + ) + }) + test_dict_insert + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. ) - Source - Public - Required - .false. - ) - }) - test_dict_get - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [] - [(= - (Var 4 y) - (DictConstant - [(StringConstant - "a" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - )] - [(IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -2 (Integer 4 [])) - )] - (Dict - (Character 1 1 () []) - (Integer 4 []) - ) - ) - () - ) - (= - (Var 4 x) - (DictItem - (Var 4 y) - (StringConstant - "a" - (Character 1 1 () []) - ) - () - (Integer 4 []) - () - ) - () - ) - (= - (Var 4 x) - (DictItem - (Var 4 y) - (StringConstant - "a" - (Character 1 1 () []) - ) - (IntegerConstant 0 (Integer 4 [])) - (Integer 4 []) - () - ) - () - )] - () - Public - .false. - .false. - ), - test_dict_insert: - (Function - (SymbolTable - 3 - { - y: - (Variable - 3 - y [] - Local - () - () - Default - (Dict - (Character 1 -2 () []) - (Integer 4 []) + [] + [(= + (Var 3 y) + (DictConstant + [(StringConstant + "a" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + )] + [(IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -2 (Integer 4 [])) + )] + (Dict + (Character 1 1 () []) + (Integer 4 []) + ) + ) + () ) - Source + (DictInsert + (Var 3 y) + (StringConstant + "c" + (Character 1 1 () []) + ) + (IntegerUnaryMinus + (IntegerConstant 3 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -3 (Integer 4 [])) + ) + )] + () Public - Required .false. - ) - }) - test_dict_insert - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] - [] - [(= - (Var 3 y) - (DictConstant - [(StringConstant - "a" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - )] - [(IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -2 (Integer 4 [])) - )] - (Dict - (Character 1 1 () []) - (Integer 4 []) - ) - ) - () - ) - (DictInsert - (Var 3 y) - (StringConstant - "c" - (Character 1 1 () []) - ) - (IntegerUnaryMinus - (IntegerConstant 3 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -3 (Integer 4 [])) - ) - )] - () - Public - .false. - .false. - ), - test_dict_pop: - (Function - (SymbolTable - 5 - { - x: - (Variable - 5 - x + .false. + ), + test_dict_pop: + (Function + (SymbolTable + 5 + { + x: + (Variable + 5 + x + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + y: + (Variable + 5 + y + [] + Local + () + () + Default + (Dict + (Character 1 -2 () []) + (Integer 4 []) + ) + Source + Public + Required + .false. + ) + }) + test_dict_pop + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () + [] + [(= + (Var 5 y) + (DictConstant + [(StringConstant + "a" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + )] + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 []))] + (Dict + (Character 1 1 () []) + (Integer 4 []) + ) + ) + () + ) + (= + (Var 5 x) + (DictPop + (Var 5 y) + (StringConstant + "a" + (Character 1 1 () []) + ) + (Integer 4 []) + () + ) + () + )] () - Default - (Integer 4 []) - Source Public - Required + .false. .false. ), - y: - (Variable - 5 - y + test_issue_204: + (Function + (SymbolTable + 7 + { + x: + (Variable + 7 + x + [] + Local + () + () + Default + (Dict + (Integer 4 []) + (Integer 4 []) + ) + Source + Public + Required + .false. + ) + }) + test_issue_204 + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) + [f] [] - Local - () + [(SubroutineCall + 9 f + () + [((Var 7 x))] + () + )] () - Default - (Dict - (Character 1 -2 () []) - (Integer 4 []) - ) - Source Public - Required + .false. .false. ) }) - test_dict_pop - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) + _global_symbols [] - [] - [(= - (Var 5 y) - (DictConstant - [(StringConstant - "a" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - )] - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 []))] - (Dict - (Character 1 1 () []) - (Integer 4 []) - ) - ) - () - ) - (= - (Var 5 x) - (DictPop - (Var 5 y) - (StringConstant - "a" - (Character 1 1 () []) - ) - (Integer 4 []) - () - ) - () - )] - () - Public .false. .false. ), - test_issue_204: - (Function + main_program: + (Program (SymbolTable - 7 + 8 { - x: - (Variable - 7 - x - [] - Local - () - () - Default - (Dict - (Integer 4 []) - (Integer 4 []) - ) - Source - Public - Required - .false. - ) + }) - test_issue_204 - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [f] + main_program + [] [] - [(SubroutineCall - 1 f - () - [((Var 7 x))] - () - )] - () - Public - .false. - .false. ) }) [] diff --git a/tests/reference/asr-expr1-dde511e.json b/tests/reference/asr-expr1-dde511e.json index ca639a9199..6a41683e9b 100644 --- a/tests/reference/asr-expr1-dde511e.json +++ b/tests/reference/asr-expr1-dde511e.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr1-dde511e.stdout", - "stdout_hash": "1cbaa794f1c9d544e71573851dcece0b7bf509260178339ffcda2906", + "stdout_hash": "429c12d784d25c4cc2087aab2911f365eb097bada6132cb82328c762", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr1-dde511e.stdout b/tests/reference/asr-expr1-dde511e.stdout index 0ccc3d0bf9..fa1eed85d6 100644 --- a/tests/reference/asr-expr1-dde511e.stdout +++ b/tests/reference/asr-expr1-dde511e.stdout @@ -2,132 +2,143 @@ (SymbolTable 1 { - main_program: - (Program + _global_symbols: + (Module (SymbolTable - 3 + 4 { - - }) - main_program - [] - [] - ), - test_namedexpr: - (Function - (SymbolTable - 2 - { - a: - (Variable - 2 - a + test_namedexpr: + (Function + (SymbolTable + 2 + { + a: + (Variable + 2 + a + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + x: + (Variable + 2 + x + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + y: + (Variable + 2 + y + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ) + }) + test_namedexpr + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ), - x: - (Variable - 2 - x [] - Local + [(= + (Var 2 x) + (NamedExpr + (Var 2 y) + (IntegerConstant 0 (Integer 4 [])) + (Integer 4 []) + ) + () + ) + (If + (NamedExpr + (Var 2 a) + (StringOrd + (StringConstant + "3" + (Character 1 1 () []) + ) + (Integer 4 []) + (IntegerConstant 51 (Integer 4 [])) + ) + (Integer 4 []) + ) + [(= + (Var 2 x) + (IntegerConstant 1 (Integer 4 [])) + () + )] + [] + ) + (WhileLoop + () + (NamedExpr + (Var 2 a) + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + ) + [(= + (Var 2 y) + (IntegerConstant 1 (Integer 4 [])) + () + )] + )] () - () - Default - (Integer 4 []) - Source Public - Required .false. - ), - y: - (Variable - 2 - y - [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required .false. ) }) - test_namedexpr - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] + _global_symbols [] - [(= - (Var 2 x) - (NamedExpr - (Var 2 y) - (IntegerConstant 0 (Integer 4 [])) - (Integer 4 []) - ) - () - ) - (If - (NamedExpr - (Var 2 a) - (StringOrd - (StringConstant - "3" - (Character 1 1 () []) - ) - (Integer 4 []) - (IntegerConstant 51 (Integer 4 [])) - ) - (Integer 4 []) - ) - [(= - (Var 2 x) - (IntegerConstant 1 (Integer 4 [])) - () - )] - [] - ) - (WhileLoop - () - (NamedExpr - (Var 2 a) - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - ) - [(= - (Var 2 y) - (IntegerConstant 1 (Integer 4 [])) - () - )] - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-expr10-31c163f.json b/tests/reference/asr-expr10-31c163f.json index 5e58601bfd..f499940784 100644 --- a/tests/reference/asr-expr10-31c163f.json +++ b/tests/reference/asr-expr10-31c163f.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr10-31c163f.stdout", - "stdout_hash": "b7ea51e9b0ab3304617aeef019cb751f6339a7333cfb47e7ef2dd517", + "stdout_hash": "b69fee92b06f80b106a93930527129a89b2e9186d40b871d9e521803", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr10-31c163f.stdout b/tests/reference/asr-expr10-31c163f.stdout index 9bad710e8b..dd2ed7fef1 100644 --- a/tests/reference/asr-expr10-31c163f.stdout +++ b/tests/reference/asr-expr10-31c163f.stdout @@ -2,6 +2,432 @@ (SymbolTable 1 { + _global_symbols: + (Module + (SymbolTable + 111 + { + test_UnaryOp: + (Function + (SymbolTable + 2 + { + a: + (Variable + 2 + a + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + b: + (Variable + 2 + b + [] + Local + () + () + Default + (Logical 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. + ), + b3: + (Variable + 2 + b3 + [] + Local + () + () + Default + (Logical 4 []) + Source + Public + Required + .false. + ), + c: + (Variable + 2 + c + [] + Local + () + () + Default + (Complex 4 []) + Source + Public + Required + .false. + ), + complex: + (ExternalSymbol + 2 + complex + 4 complex + lpython_builtin + [] + complex + Private + ), + complex@__lpython_overloaded_13__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_13__complex + 4 __lpython_overloaded_13__complex + lpython_builtin + [] + __lpython_overloaded_13__complex + Public + ), + complex@__lpython_overloaded_9__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_9__complex + 4 __lpython_overloaded_9__complex + lpython_builtin + [] + __lpython_overloaded_9__complex + Public + ), + f: + (Variable + 2 + f + [] + Local + () + () + Default + (Real 4 []) + Source + Public + Required + .false. + ) + }) + test_UnaryOp + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) + [complex@__lpython_overloaded_13__complex] + [] + [(= + (Var 2 a) + (IntegerConstant 4 (Integer 4 [])) + () + ) + (= + (Var 2 a) + (IntegerUnaryMinus + (IntegerConstant 500 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -500 (Integer 4 [])) + ) + () + ) + (= + (Var 2 a) + (IntegerBitNot + (IntegerConstant 5 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -6 (Integer 4 [])) + ) + () + ) + (= + (Var 2 b) + (LogicalNot + (Cast + (IntegerConstant 5 (Integer 4 [])) + IntegerToLogical + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 b) + (LogicalNot + (Cast + (IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + IntegerToLogical + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 b) + (LogicalNot + (Cast + (IntegerConstant 0 (Integer 4 [])) + IntegerToLogical + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 f) + (RealConstant + 1.000000 + (Real 4 []) + ) + () + ) + (= + (Var 2 f) + (RealUnaryMinus + (Cast + (RealConstant + 183745.534000 + (Real 8 []) + ) + RealToReal + (Real 4 []) + (RealConstant + 183745.534000 + (Real 4 []) + ) + ) + (Real 4 []) + (RealConstant + -183745.534000 + (Real 4 []) + ) + ) + () + ) + (= + (Var 2 b1) + (LogicalConstant + .true. + (Logical 4 []) + ) + () + ) + (= + (Var 2 b2) + (LogicalNot + (LogicalConstant + .false. + (Logical 4 []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 b3) + (LogicalNot + (Var 2 b2) + (Logical 4 []) + () + ) + () + ) + (= + (Var 2 a) + (IntegerConstant 1 (Integer 4 [])) + () + ) + (= + (Var 2 a) + (IntegerUnaryMinus + (Cast + (LogicalConstant + .false. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + (IntegerConstant 0 (Integer 4 [])) + ) + (Integer 4 []) + (IntegerConstant 0 (Integer 4 [])) + ) + () + ) + (= + (Var 2 a) + (IntegerBitNot + (Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + (IntegerConstant -2 (Integer 4 [])) + ) + (Integer 4 []) + (IntegerConstant -2 (Integer 4 [])) + ) + () + ) + (= + (Var 2 c) + (ComplexConstant + 1.000000 + 2.000000 + (Complex 4 []) + ) + () + ) + (= + (Var 2 c) + (ComplexUnaryMinus + (Cast + (FunctionCall + 2 complex@__lpython_overloaded_13__complex + 2 complex + [((IntegerConstant 3 (Integer 4 []))) + ((RealConstant + 65.000000 + (Real 8 []) + ))] + (Complex 8 []) + (ComplexConstant + 3.000000 + 65.000000 + (Complex 8 []) + ) + () + ) + ComplexToComplex + (Complex 4 []) + (ComplexConstant + 3.000000 + 65.000000 + (Complex 4 []) + ) + ) + (Complex 4 []) + (ComplexConstant + -3.000000 + -65.000000 + (Complex 4 []) + ) + ) + () + ) + (= + (Var 2 b1) + (LogicalConstant + .false. + (Logical 4 []) + ) + () + ) + (= + (Var 2 b2) + (LogicalConstant + .true. + (Logical 4 []) + ) + () + )] + () + Public + .false. + .false. + ) + }) + _global_symbols + [lpython_builtin] + .false. + .false. + ), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: @@ -14,421 +440,6 @@ main_program [] [] - ), - test_UnaryOp: - (Function - (SymbolTable - 2 - { - a: - (Variable - 2 - a - [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ), - b: - (Variable - 2 - b - [] - Local - () - () - Default - (Logical 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. - ), - b3: - (Variable - 2 - b3 - [] - Local - () - () - Default - (Logical 4 []) - Source - Public - Required - .false. - ), - c: - (Variable - 2 - c - [] - Local - () - () - Default - (Complex 4 []) - Source - Public - Required - .false. - ), - complex: - (ExternalSymbol - 2 - complex - 4 complex - lpython_builtin - [] - complex - Private - ), - complex@__lpython_overloaded_13__complex: - (ExternalSymbol - 2 - complex@__lpython_overloaded_13__complex - 4 __lpython_overloaded_13__complex - lpython_builtin - [] - __lpython_overloaded_13__complex - Public - ), - complex@__lpython_overloaded_9__complex: - (ExternalSymbol - 2 - complex@__lpython_overloaded_9__complex - 4 __lpython_overloaded_9__complex - lpython_builtin - [] - __lpython_overloaded_9__complex - Public - ), - f: - (Variable - 2 - f - [] - Local - () - () - Default - (Real 4 []) - Source - Public - Required - .false. - ) - }) - test_UnaryOp - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [complex@__lpython_overloaded_13__complex] - [] - [(= - (Var 2 a) - (IntegerConstant 4 (Integer 4 [])) - () - ) - (= - (Var 2 a) - (IntegerUnaryMinus - (IntegerConstant 500 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -500 (Integer 4 [])) - ) - () - ) - (= - (Var 2 a) - (IntegerBitNot - (IntegerConstant 5 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -6 (Integer 4 [])) - ) - () - ) - (= - (Var 2 b) - (LogicalNot - (Cast - (IntegerConstant 5 (Integer 4 [])) - IntegerToLogical - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 b) - (LogicalNot - (Cast - (IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - ) - IntegerToLogical - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 b) - (LogicalNot - (Cast - (IntegerConstant 0 (Integer 4 [])) - IntegerToLogical - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 f) - (RealConstant - 1.000000 - (Real 4 []) - ) - () - ) - (= - (Var 2 f) - (RealUnaryMinus - (Cast - (RealConstant - 183745.534000 - (Real 8 []) - ) - RealToReal - (Real 4 []) - (RealConstant - 183745.534000 - (Real 4 []) - ) - ) - (Real 4 []) - (RealConstant - -183745.534000 - (Real 4 []) - ) - ) - () - ) - (= - (Var 2 b1) - (LogicalConstant - .true. - (Logical 4 []) - ) - () - ) - (= - (Var 2 b2) - (LogicalNot - (LogicalConstant - .false. - (Logical 4 []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 b3) - (LogicalNot - (Var 2 b2) - (Logical 4 []) - () - ) - () - ) - (= - (Var 2 a) - (IntegerConstant 1 (Integer 4 [])) - () - ) - (= - (Var 2 a) - (IntegerUnaryMinus - (Cast - (LogicalConstant - .false. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - (IntegerConstant 0 (Integer 4 [])) - ) - (Integer 4 []) - (IntegerConstant 0 (Integer 4 [])) - ) - () - ) - (= - (Var 2 a) - (IntegerBitNot - (Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - (IntegerConstant -2 (Integer 4 [])) - ) - (Integer 4 []) - (IntegerConstant -2 (Integer 4 [])) - ) - () - ) - (= - (Var 2 c) - (ComplexConstant - 1.000000 - 2.000000 - (Complex 4 []) - ) - () - ) - (= - (Var 2 c) - (ComplexUnaryMinus - (Cast - (FunctionCall - 2 complex@__lpython_overloaded_13__complex - 2 complex - [((IntegerConstant 3 (Integer 4 []))) - ((RealConstant - 65.000000 - (Real 8 []) - ))] - (Complex 8 []) - (ComplexConstant - 3.000000 - 65.000000 - (Complex 8 []) - ) - () - ) - ComplexToComplex - (Complex 4 []) - (ComplexConstant - 3.000000 - 65.000000 - (Complex 4 []) - ) - ) - (Complex 4 []) - (ComplexConstant - -3.000000 - -65.000000 - (Complex 4 []) - ) - ) - () - ) - (= - (Var 2 b1) - (LogicalConstant - .false. - (Logical 4 []) - ) - () - ) - (= - (Var 2 b2) - (LogicalConstant - .true. - (Logical 4 []) - ) - () - )] - () - Public - .false. - .false. ) }) [] diff --git a/tests/reference/asr-expr11-1134d3f.json b/tests/reference/asr-expr11-1134d3f.json index 133ca4ea4b..73fa09119b 100644 --- a/tests/reference/asr-expr11-1134d3f.json +++ b/tests/reference/asr-expr11-1134d3f.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr11-1134d3f.stdout", - "stdout_hash": "536fd12affea9c50bd8a614035f870cd0f6ed9f6182945e24b58638e", + "stdout_hash": "973808af34fba2092fc9e80550d67951ec29533e24c67d09881316c6", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr11-1134d3f.stdout b/tests/reference/asr-expr11-1134d3f.stdout index 396e4c7a0e..ea61875f01 100644 --- a/tests/reference/asr-expr11-1134d3f.stdout +++ b/tests/reference/asr-expr11-1134d3f.stdout @@ -2,172 +2,183 @@ (SymbolTable 1 { - main_program: - (Program - (SymbolTable - 3 - { - - }) - main_program - [] - [] - ), - test_StrOp_repeat: - (Function + _global_symbols: + (Module (SymbolTable - 2 + 4 { - s: - (Variable - 2 - s + test_StrOp_repeat: + (Function + (SymbolTable + 2 + { + s: + (Variable + 2 + s + [] + Local + () + () + Default + (Character 1 -2 () []) + Source + Public + Required + .false. + ) + }) + test_StrOp_repeat + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () + [] + [(= + (Var 2 s) + (StringRepeat + (StringConstant + "a" + (Character 1 1 () []) + ) + (IntegerConstant 2 (Integer 4 [])) + (Character 1 2 () []) + (StringConstant + "aa" + (Character 1 2 () []) + ) + ) + () + ) + (= + (Var 2 s) + (StringRepeat + (StringConstant + "a" + (Character 1 1 () []) + ) + (IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + (Character 1 0 () []) + (StringConstant + "" + (Character 1 0 () []) + ) + ) + () + ) + (= + (Var 2 s) + (StringRepeat + (StringConstant + "test" + (Character 1 4 () []) + ) + (IntegerConstant 5 (Integer 4 [])) + (Character 1 20 () []) + (StringConstant + "testtesttesttesttest" + (Character 1 20 () []) + ) + ) + () + ) + (= + (Var 2 s) + (StringRepeat + (StringConstant + "bb" + (Character 1 2 () []) + ) + (IntegerConstant 4 (Integer 4 [])) + (Character 1 8 () []) + (StringConstant + "bbbbbbbb" + (Character 1 8 () []) + ) + ) + () + ) + (= + (Var 2 s) + (StringRepeat + (StringConstant + "bb" + (Character 1 2 () []) + ) + (IntegerUnaryMinus + (IntegerConstant 40 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -40 (Integer 4 [])) + ) + (Character 1 0 () []) + (StringConstant + "" + (Character 1 0 () []) + ) + ) + () + ) + (= + (Var 2 s) + (StringRepeat + (StringRepeat + (StringConstant + "a" + (Character 1 1 () []) + ) + (IntegerConstant 3 (Integer 4 [])) + (Character 1 3 () []) + (StringConstant + "aaa" + (Character 1 3 () []) + ) + ) + (IntegerConstant 3 (Integer 4 [])) + (Character 1 9 () []) + (StringConstant + "aaaaaaaaa" + (Character 1 9 () []) + ) + ) + () + )] () - Default - (Character 1 -2 () []) - Source Public - Required + .false. .false. ) }) - test_StrOp_repeat - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) + _global_symbols [] - [] - [(= - (Var 2 s) - (StringRepeat - (StringConstant - "a" - (Character 1 1 () []) - ) - (IntegerConstant 2 (Integer 4 [])) - (Character 1 2 () []) - (StringConstant - "aa" - (Character 1 2 () []) - ) - ) - () - ) - (= - (Var 2 s) - (StringRepeat - (StringConstant - "a" - (Character 1 1 () []) - ) - (IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - ) - (Character 1 0 () []) - (StringConstant - "" - (Character 1 0 () []) - ) - ) - () - ) - (= - (Var 2 s) - (StringRepeat - (StringConstant - "test" - (Character 1 4 () []) - ) - (IntegerConstant 5 (Integer 4 [])) - (Character 1 20 () []) - (StringConstant - "testtesttesttesttest" - (Character 1 20 () []) - ) - ) - () - ) - (= - (Var 2 s) - (StringRepeat - (StringConstant - "bb" - (Character 1 2 () []) - ) - (IntegerConstant 4 (Integer 4 [])) - (Character 1 8 () []) - (StringConstant - "bbbbbbbb" - (Character 1 8 () []) - ) - ) - () - ) - (= - (Var 2 s) - (StringRepeat - (StringConstant - "bb" - (Character 1 2 () []) - ) - (IntegerUnaryMinus - (IntegerConstant 40 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -40 (Integer 4 [])) - ) - (Character 1 0 () []) - (StringConstant - "" - (Character 1 0 () []) - ) - ) - () - ) - (= - (Var 2 s) - (StringRepeat - (StringRepeat - (StringConstant - "a" - (Character 1 1 () []) - ) - (IntegerConstant 3 (Integer 4 [])) - (Character 1 3 () []) - (StringConstant - "aaa" - (Character 1 3 () []) - ) - ) - (IntegerConstant 3 (Integer 4 [])) - (Character 1 9 () []) - (StringConstant - "aaaaaaaaa" - (Character 1 9 () []) - ) - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-expr13-10040d8.json b/tests/reference/asr-expr13-10040d8.json index f5773fd89d..6b51f3d4a8 100644 --- a/tests/reference/asr-expr13-10040d8.json +++ b/tests/reference/asr-expr13-10040d8.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr13-10040d8.stdout", - "stdout_hash": "87c0d0affb66d187de2d6f0734a8c8b67487da5b487b597928bf7a04", + "stdout_hash": "96e33b2474cc67f0d4f5f94d8a75fd21970c4ebb5cc585cb36bbab29", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr13-10040d8.stdout b/tests/reference/asr-expr13-10040d8.stdout index 7c87d8f5ff..6d10d78277 100644 --- a/tests/reference/asr-expr13-10040d8.stdout +++ b/tests/reference/asr-expr13-10040d8.stdout @@ -2,6 +2,458 @@ (SymbolTable 1 { + _global_symbols: + (Module + (SymbolTable + 111 + { + test_Compare: + (Function + (SymbolTable + 2 + { + a: + (Variable + 2 + a + [] + Local + () + () + Default + (Logical 4 []) + Source + Public + Required + .false. + ), + complex: + (ExternalSymbol + 2 + complex + 4 complex + lpython_builtin + [] + complex + Private + ), + complex@__lpython_overloaded_5__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_5__complex + 4 __lpython_overloaded_5__complex + lpython_builtin + [] + __lpython_overloaded_5__complex + Public + ), + complex@__lpython_overloaded_9__complex: + (ExternalSymbol + 2 + complex@__lpython_overloaded_9__complex + 4 __lpython_overloaded_9__complex + lpython_builtin + [] + __lpython_overloaded_9__complex + Public + ) + }) + test_Compare + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) + [complex@__lpython_overloaded_9__complex + complex@__lpython_overloaded_5__complex] + [] + [(= + (Var 2 a) + (IntegerCompare + (IntegerConstant 5 (Integer 4 [])) + Gt + (IntegerConstant 4 (Integer 4 [])) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (IntegerCompare + (IntegerConstant 5 (Integer 4 [])) + LtE + (IntegerConstant 4 (Integer 4 [])) + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (IntegerCompare + (IntegerConstant 5 (Integer 4 [])) + Lt + (IntegerConstant 4 (Integer 4 [])) + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (RealCompare + (RealConstant + 5.600000 + (Real 8 []) + ) + GtE + (RealConstant + 5.599990 + (Real 8 []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (RealCompare + (RealConstant + 3.300000 + (Real 8 []) + ) + Eq + (RealConstant + 3.300000 + (Real 8 []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (RealCompare + (RealConstant + 3.300000 + (Real 8 []) + ) + NotEq + (RealConstant + 3.400000 + (Real 8 []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (ComplexCompare + (FunctionCall + 2 complex@__lpython_overloaded_9__complex + 2 complex + [((IntegerConstant 3 (Integer 4 []))) + ((IntegerConstant 4 (Integer 4 [])))] + (Complex 8 []) + (ComplexConstant + 3.000000 + 4.000000 + (Complex 8 []) + ) + () + ) + Eq + (FunctionCall + 2 complex@__lpython_overloaded_5__complex + 2 complex + [((RealConstant + 3.000000 + (Real 8 []) + )) + ((RealConstant + 4.000000 + (Real 8 []) + ))] + (Complex 8 []) + (ComplexConstant + 3.000000 + 4.000000 + (Complex 8 []) + ) + () + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (StringCompare + (StringConstant + "abc" + (Character 1 3 () []) + ) + Gt + (StringConstant + "abd" + (Character 1 3 () []) + ) + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (StringCompare + (StringConstant + "" + (Character 1 0 () []) + ) + Lt + (StringConstant + "s" + (Character 1 1 () []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (StringCompare + (StringConstant + "-abs" + (Character 1 4 () []) + ) + GtE + (StringConstant + "abs" + (Character 1 3 () []) + ) + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (StringCompare + (StringConstant + "abcd" + (Character 1 4 () []) + ) + LtE + (StringConstant + "abcde" + (Character 1 5 () []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (StringCompare + (StringConstant + "abc" + (Character 1 3 () []) + ) + Eq + (StringConstant + "abc" + (Character 1 3 () []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (StringCompare + (StringConstant + "abc" + (Character 1 3 () []) + ) + NotEq + (StringConstant + "abd" + (Character 1 3 () []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (StringCompare + (StringConstant + "" + (Character 1 0 () []) + ) + Eq + (StringConstant + "+" + (Character 1 1 () []) + ) + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (LogicalCompare + (LogicalConstant + .true. + (Logical 4 []) + ) + Gt + (LogicalConstant + .false. + (Logical 4 []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (LogicalCompare + (LogicalConstant + .true. + (Logical 4 []) + ) + Eq + (LogicalConstant + .true. + (Logical 4 []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (LogicalCompare + (LogicalConstant + .false. + (Logical 4 []) + ) + NotEq + (LogicalConstant + .true. + (Logical 4 []) + ) + (Logical 4 []) + (LogicalConstant + .true. + (Logical 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (LogicalCompare + (LogicalConstant + .false. + (Logical 4 []) + ) + GtE + (LogicalConstant + .true. + (Logical 4 []) + ) + (Logical 4 []) + (LogicalConstant + .false. + (Logical 4 []) + ) + ) + () + )] + () + Public + .false. + .false. + ) + }) + _global_symbols + [lpython_builtin] + .false. + .false. + ), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: @@ -14,447 +466,6 @@ main_program [] [] - ), - test_Compare: - (Function - (SymbolTable - 2 - { - a: - (Variable - 2 - a - [] - Local - () - () - Default - (Logical 4 []) - Source - Public - Required - .false. - ), - complex: - (ExternalSymbol - 2 - complex - 4 complex - lpython_builtin - [] - complex - Private - ), - complex@__lpython_overloaded_5__complex: - (ExternalSymbol - 2 - complex@__lpython_overloaded_5__complex - 4 __lpython_overloaded_5__complex - lpython_builtin - [] - __lpython_overloaded_5__complex - Public - ), - complex@__lpython_overloaded_9__complex: - (ExternalSymbol - 2 - complex@__lpython_overloaded_9__complex - 4 __lpython_overloaded_9__complex - lpython_builtin - [] - __lpython_overloaded_9__complex - Public - ) - }) - test_Compare - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [complex@__lpython_overloaded_9__complex - complex@__lpython_overloaded_5__complex] - [] - [(= - (Var 2 a) - (IntegerCompare - (IntegerConstant 5 (Integer 4 [])) - Gt - (IntegerConstant 4 (Integer 4 [])) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (IntegerCompare - (IntegerConstant 5 (Integer 4 [])) - LtE - (IntegerConstant 4 (Integer 4 [])) - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (IntegerCompare - (IntegerConstant 5 (Integer 4 [])) - Lt - (IntegerConstant 4 (Integer 4 [])) - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (RealCompare - (RealConstant - 5.600000 - (Real 8 []) - ) - GtE - (RealConstant - 5.599990 - (Real 8 []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (RealCompare - (RealConstant - 3.300000 - (Real 8 []) - ) - Eq - (RealConstant - 3.300000 - (Real 8 []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (RealCompare - (RealConstant - 3.300000 - (Real 8 []) - ) - NotEq - (RealConstant - 3.400000 - (Real 8 []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (ComplexCompare - (FunctionCall - 2 complex@__lpython_overloaded_9__complex - 2 complex - [((IntegerConstant 3 (Integer 4 []))) - ((IntegerConstant 4 (Integer 4 [])))] - (Complex 8 []) - (ComplexConstant - 3.000000 - 4.000000 - (Complex 8 []) - ) - () - ) - Eq - (FunctionCall - 2 complex@__lpython_overloaded_5__complex - 2 complex - [((RealConstant - 3.000000 - (Real 8 []) - )) - ((RealConstant - 4.000000 - (Real 8 []) - ))] - (Complex 8 []) - (ComplexConstant - 3.000000 - 4.000000 - (Complex 8 []) - ) - () - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (StringCompare - (StringConstant - "abc" - (Character 1 3 () []) - ) - Gt - (StringConstant - "abd" - (Character 1 3 () []) - ) - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (StringCompare - (StringConstant - "" - (Character 1 0 () []) - ) - Lt - (StringConstant - "s" - (Character 1 1 () []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (StringCompare - (StringConstant - "-abs" - (Character 1 4 () []) - ) - GtE - (StringConstant - "abs" - (Character 1 3 () []) - ) - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (StringCompare - (StringConstant - "abcd" - (Character 1 4 () []) - ) - LtE - (StringConstant - "abcde" - (Character 1 5 () []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (StringCompare - (StringConstant - "abc" - (Character 1 3 () []) - ) - Eq - (StringConstant - "abc" - (Character 1 3 () []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (StringCompare - (StringConstant - "abc" - (Character 1 3 () []) - ) - NotEq - (StringConstant - "abd" - (Character 1 3 () []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (StringCompare - (StringConstant - "" - (Character 1 0 () []) - ) - Eq - (StringConstant - "+" - (Character 1 1 () []) - ) - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (LogicalCompare - (LogicalConstant - .true. - (Logical 4 []) - ) - Gt - (LogicalConstant - .false. - (Logical 4 []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (LogicalCompare - (LogicalConstant - .true. - (Logical 4 []) - ) - Eq - (LogicalConstant - .true. - (Logical 4 []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (LogicalCompare - (LogicalConstant - .false. - (Logical 4 []) - ) - NotEq - (LogicalConstant - .true. - (Logical 4 []) - ) - (Logical 4 []) - (LogicalConstant - .true. - (Logical 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (LogicalCompare - (LogicalConstant - .false. - (Logical 4 []) - ) - GtE - (LogicalConstant - .true. - (Logical 4 []) - ) - (Logical 4 []) - (LogicalConstant - .false. - (Logical 4 []) - ) - ) - () - )] - () - Public - .false. - .false. ) }) [] diff --git a/tests/reference/asr-expr2-5311701.json b/tests/reference/asr-expr2-5311701.json index f1fdc5bb5b..3b3e7b456e 100644 --- a/tests/reference/asr-expr2-5311701.json +++ b/tests/reference/asr-expr2-5311701.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr2-5311701.stdout", - "stdout_hash": "6b62c9e5f3f15a1d9be76b3675fe0534de3f23d05ca432953612acd9", + "stdout_hash": "a00aff1f3effad5e875b2c6d774d5646717bf8d63fefa9ec2adb671c", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr2-5311701.stdout b/tests/reference/asr-expr2-5311701.stdout index 77d9d593c8..fb8e6b11f1 100644 --- a/tests/reference/asr-expr2-5311701.stdout +++ b/tests/reference/asr-expr2-5311701.stdout @@ -2,172 +2,183 @@ (SymbolTable 1 { - main_program: - (Program + _global_symbols: + (Module (SymbolTable - 3 + 4 { - - }) - main_program - [] - [] - ), - test_boolOp: - (Function - (SymbolTable - 2 - { - a: - (Variable - 2 - a + test_boolOp: + (Function + (SymbolTable + 2 + { + a: + (Variable + 2 + a + [] + Local + () + () + Default + (Logical 4 []) + Source + Public + Required + .false. + ), + b: + (Variable + 2 + b + [] + Local + () + () + Default + (Logical 4 []) + Source + Public + Required + .false. + ) + }) + test_boolOp + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Logical 4 []) - Source - Public - Required - .false. - ), - b: - (Variable - 2 - b [] - Local + [(= + (Var 2 a) + (LogicalConstant + .false. + (Logical 4 []) + ) + () + ) + (= + (Var 2 b) + (LogicalConstant + .true. + (Logical 4 []) + ) + () + ) + (= + (Var 2 a) + (LogicalBinOp + (Var 2 a) + And + (Var 2 b) + (Logical 4 []) + () + ) + () + ) + (= + (Var 2 b) + (LogicalBinOp + (Var 2 a) + Or + (LogicalConstant + .true. + (Logical 4 []) + ) + (Logical 4 []) + () + ) + () + ) + (= + (Var 2 a) + (LogicalBinOp + (Var 2 a) + Or + (Var 2 b) + (Logical 4 []) + () + ) + () + ) + (= + (Var 2 a) + (LogicalBinOp + (Var 2 a) + And + (LogicalCompare + (Var 2 b) + Eq + (Var 2 b) + (Logical 4 []) + () + ) + (Logical 4 []) + () + ) + () + ) + (= + (Var 2 a) + (LogicalBinOp + (Var 2 a) + And + (LogicalCompare + (Var 2 b) + NotEq + (Var 2 b) + (Logical 4 []) + () + ) + (Logical 4 []) + () + ) + () + ) + (= + (Var 2 a) + (LogicalBinOp + (Var 2 b) + Or + (Var 2 b) + (Logical 4 []) + () + ) + () + )] () - () - Default - (Logical 4 []) - Source Public - Required + .false. .false. ) }) - test_boolOp - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) + _global_symbols [] - [] - [(= - (Var 2 a) - (LogicalConstant - .false. - (Logical 4 []) - ) - () - ) - (= - (Var 2 b) - (LogicalConstant - .true. - (Logical 4 []) - ) - () - ) - (= - (Var 2 a) - (LogicalBinOp - (Var 2 a) - And - (Var 2 b) - (Logical 4 []) - () - ) - () - ) - (= - (Var 2 b) - (LogicalBinOp - (Var 2 a) - Or - (LogicalConstant - .true. - (Logical 4 []) - ) - (Logical 4 []) - () - ) - () - ) - (= - (Var 2 a) - (LogicalBinOp - (Var 2 a) - Or - (Var 2 b) - (Logical 4 []) - () - ) - () - ) - (= - (Var 2 a) - (LogicalBinOp - (Var 2 a) - And - (LogicalCompare - (Var 2 b) - Eq - (Var 2 b) - (Logical 4 []) - () - ) - (Logical 4 []) - () - ) - () - ) - (= - (Var 2 a) - (LogicalBinOp - (Var 2 a) - And - (LogicalCompare - (Var 2 b) - NotEq - (Var 2 b) - (Logical 4 []) - () - ) - (Logical 4 []) - () - ) - () - ) - (= - (Var 2 a) - (LogicalBinOp - (Var 2 b) - Or - (Var 2 b) - (Logical 4 []) - () - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-expr4-cf512ef.json b/tests/reference/asr-expr4-cf512ef.json index 2aea30807f..d5270468e5 100644 --- a/tests/reference/asr-expr4-cf512ef.json +++ b/tests/reference/asr-expr4-cf512ef.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr4-cf512ef.stdout", - "stdout_hash": "f971ead5a29a22e074c08695224502a7774fbd502e480b434f6699be", + "stdout_hash": "0b9af9d9e3e1bf1e3e90dc1576b0ea7c895bd72d369d6eefd64a0e98", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr4-cf512ef.stdout b/tests/reference/asr-expr4-cf512ef.stdout index 467add8f2f..f5ce7326f9 100644 --- a/tests/reference/asr-expr4-cf512ef.stdout +++ b/tests/reference/asr-expr4-cf512ef.stdout @@ -2,89 +2,100 @@ (SymbolTable 1 { - main_program: - (Program + _global_symbols: + (Module (SymbolTable - 3 + 4 { - - }) - main_program - [] - [] - ), - test_del: - (Function - (SymbolTable - 2 - { - a: - (Variable - 2 - a + test_del: + (Function + (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. + ) + }) + test_del + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ), - b: - (Variable - 2 - b [] - Local + [(= + (Var 2 a) + (IntegerConstant 4 (Integer 4 [])) + () + ) + (= + (Var 2 b) + (IntegerConstant 20 (Integer 4 [])) + () + ) + (ExplicitDeallocate + [(Var 2 a) + (Var 2 b)] + )] () - () - Default - (Integer 4 []) - Source Public - Required + .false. .false. ) }) - test_del - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) + _global_symbols [] - [] - [(= - (Var 2 a) - (IntegerConstant 4 (Integer 4 [])) - () - ) - (= - (Var 2 b) - (IntegerConstant 20 (Integer 4 [])) - () - ) - (ExplicitDeallocate - [(Var 2 a) - (Var 2 b)] - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-expr5-375548a.json b/tests/reference/asr-expr5-375548a.json index c99f52dd98..e4bb23820d 100644 --- a/tests/reference/asr-expr5-375548a.json +++ b/tests/reference/asr-expr5-375548a.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr5-375548a.stdout", - "stdout_hash": "7077d61ae1a796e6e775f4ad672f4caa9506e7c4a44a9dec20ebe7bd", + "stdout_hash": "3d2d2f721917587c7c5f4ccdc60eab393263a08242f3c9a58976e7bf", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr5-375548a.stdout b/tests/reference/asr-expr5-375548a.stdout index 6c7590bde6..257139f35b 100644 --- a/tests/reference/asr-expr5-375548a.stdout +++ b/tests/reference/asr-expr5-375548a.stdout @@ -2,128 +2,139 @@ (SymbolTable 1 { - main_program: - (Program + _global_symbols: + (Module (SymbolTable - 3 + 4 { - - }) - main_program - [] - [] - ), - test_StrOp_concat: - (Function - (SymbolTable - 2 - { - s: - (Variable - 2 - s + test_StrOp_concat: + (Function + (SymbolTable + 2 + { + s: + (Variable + 2 + s + [] + Local + () + () + Default + (Character 1 -2 () []) + Source + Public + Required + .false. + ) + }) + test_StrOp_concat + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () + [] + [(= + (Var 2 s) + (StringConcat + (StringConstant + "3" + (Character 1 1 () []) + ) + (StringConstant + "4" + (Character 1 1 () []) + ) + (Character 1 2 () []) + (StringConstant + "34" + (Character 1 2 () []) + ) + ) + () + ) + (= + (Var 2 s) + (StringConcat + (StringConstant + "a " + (Character 1 2 () []) + ) + (StringConstant + "test" + (Character 1 4 () []) + ) + (Character 1 6 () []) + (StringConstant + "a test" + (Character 1 6 () []) + ) + ) + () + ) + (= + (Var 2 s) + (StringConcat + (StringConcat + (StringConstant + "test" + (Character 1 4 () []) + ) + (StringConstant + "test" + (Character 1 4 () []) + ) + (Character 1 8 () []) + (StringConstant + "testtest" + (Character 1 8 () []) + ) + ) + (StringConstant + "test" + (Character 1 4 () []) + ) + (Character 1 12 () []) + (StringConstant + "testtesttest" + (Character 1 12 () []) + ) + ) + () + )] () - Default - (Character 1 -2 () []) - Source Public - Required + .false. .false. ) }) - test_StrOp_concat - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] + _global_symbols [] - [(= - (Var 2 s) - (StringConcat - (StringConstant - "3" - (Character 1 1 () []) - ) - (StringConstant - "4" - (Character 1 1 () []) - ) - (Character 1 2 () []) - (StringConstant - "34" - (Character 1 2 () []) - ) - ) - () - ) - (= - (Var 2 s) - (StringConcat - (StringConstant - "a " - (Character 1 2 () []) - ) - (StringConstant - "test" - (Character 1 4 () []) - ) - (Character 1 6 () []) - (StringConstant - "a test" - (Character 1 6 () []) - ) - ) - () - ) - (= - (Var 2 s) - (StringConcat - (StringConcat - (StringConstant - "test" - (Character 1 4 () []) - ) - (StringConstant - "test" - (Character 1 4 () []) - ) - (Character 1 8 () []) - (StringConstant - "testtest" - (Character 1 8 () []) - ) - ) - (StringConstant - "test" - (Character 1 4 () []) - ) - (Character 1 12 () []) - (StringConstant - "testtesttest" - (Character 1 12 () []) - ) - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-expr6-bfb3384.json b/tests/reference/asr-expr6-bfb3384.json index 05d71899bd..5a65183e40 100644 --- a/tests/reference/asr-expr6-bfb3384.json +++ b/tests/reference/asr-expr6-bfb3384.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr6-bfb3384.stdout", - "stdout_hash": "aa5c36e0409423141a2d244dbf64d406e8cafa6c41f9c9ef32e920dc", + "stdout_hash": "0676941f9cb946aadf18f6e420f63b7aa37457904e2bb00dfa27af52", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr6-bfb3384.stdout b/tests/reference/asr-expr6-bfb3384.stdout index 19cf112f1d..6862c2dce6 100644 --- a/tests/reference/asr-expr6-bfb3384.stdout +++ b/tests/reference/asr-expr6-bfb3384.stdout @@ -2,135 +2,146 @@ (SymbolTable 1 { - main_program: - (Program - (SymbolTable - 3 - { - - }) - main_program - [] - [] - ), - test_ifexp: - (Function + _global_symbols: + (Module (SymbolTable - 2 + 4 { - a: - (Variable - 2 - a + test_ifexp: + (Function + (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 + (Logical 4 []) + Source + Public + Required + .false. + ) + }) + test_ifexp + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ), - b: - (Variable - 2 - b [] - Local - () + [(= + (Var 2 a) + (IntegerConstant 2 (Integer 4 [])) + () + ) + (= + (Var 2 b) + (IfExp + (IntegerCompare + (Var 2 a) + Eq + (IntegerConstant 2 (Integer 4 [])) + (Logical 4 []) + () + ) + (IntegerConstant 6 (Integer 4 [])) + (IntegerConstant 8 (Integer 4 [])) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 c) + (IfExp + (IntegerCompare + (Var 2 b) + Gt + (IntegerConstant 5 (Integer 4 [])) + (Logical 4 []) + () + ) + (LogicalConstant + .true. + (Logical 4 []) + ) + (LogicalConstant + .false. + (Logical 4 []) + ) + (Logical 4 []) + () + ) + () + )] () - Default - (Integer 4 []) - Source Public - Required .false. - ), - c: - (Variable - 2 - c - [] - Local - () - () - Default - (Logical 4 []) - Source - Public - Required .false. ) }) - test_ifexp - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) + _global_symbols [] - [] - [(= - (Var 2 a) - (IntegerConstant 2 (Integer 4 [])) - () - ) - (= - (Var 2 b) - (IfExp - (IntegerCompare - (Var 2 a) - Eq - (IntegerConstant 2 (Integer 4 [])) - (Logical 4 []) - () - ) - (IntegerConstant 6 (Integer 4 [])) - (IntegerConstant 8 (Integer 4 [])) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 c) - (IfExp - (IntegerCompare - (Var 2 b) - Gt - (IntegerConstant 5 (Integer 4 [])) - (Logical 4 []) - () - ) - (LogicalConstant - .true. - (Logical 4 []) - ) - (LogicalConstant - .false. - (Logical 4 []) - ) - (Logical 4 []) - () - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-expr8-2a4630a.json b/tests/reference/asr-expr8-2a4630a.json index d0445c5043..63609d8929 100644 --- a/tests/reference/asr-expr8-2a4630a.json +++ b/tests/reference/asr-expr8-2a4630a.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr8-2a4630a.stdout", - "stdout_hash": "754071b8e6b84d4046925a228b32d4f935311169ebde5eb5a94bbc18", + "stdout_hash": "a22e4da241b85bdf144e88b696a0d8032845b004dfb1b9eee7fbe222", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr8-2a4630a.stdout b/tests/reference/asr-expr8-2a4630a.stdout index 24345ed3ee..8023eedc25 100644 --- a/tests/reference/asr-expr8-2a4630a.stdout +++ b/tests/reference/asr-expr8-2a4630a.stdout @@ -2,6 +2,435 @@ (SymbolTable 1 { + _global_symbols: + (Module + (SymbolTable + 111 + { + test_binop: + (Function + (SymbolTable + 2 + { + _lpython_floordiv: + (ExternalSymbol + 2 + _lpython_floordiv + 4 _lpython_floordiv + lpython_builtin + [] + _lpython_floordiv + Private + ), + _lpython_floordiv@__lpython_overloaded_6___lpython_floordiv: + (ExternalSymbol + 2 + _lpython_floordiv@__lpython_overloaded_6___lpython_floordiv + 4 __lpython_overloaded_6___lpython_floordiv + lpython_builtin + [] + __lpython_overloaded_6___lpython_floordiv + Public + ), + b1: + (Variable + 2 + b1 + [] + Local + () + () + Default + (Logical 4 []) + Source + Public + Required + .false. + ), + b2: + (Variable + 2 + b2 + [] + Local + () + () + Default + (Logical 4 []) + Source + Public + Required + .false. + ), + x: + (Variable + 2 + x + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + x2: + (Variable + 2 + x2 + [] + Local + () + () + Default + (Real 4 []) + Source + Public + Required + .false. + ) + }) + test_binop + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) + [_lpython_floordiv@__lpython_overloaded_6___lpython_floordiv] + [] + [(= + (Var 2 x) + (IntegerBinOp + (IntegerConstant 2 (Integer 4 [])) + Pow + (IntegerConstant 3 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant 8 (Integer 4 [])) + ) + () + ) + (= + (Var 2 x2) + (Cast + (RealBinOp + (RealConstant + 2.000000 + (Real 8 []) + ) + Pow + (RealConstant + 3.500000 + (Real 8 []) + ) + (Real 8 []) + (RealConstant + 11.313708 + (Real 8 []) + ) + ) + RealToReal + (Real 4 []) + (RealConstant + 11.313708 + (Real 4 []) + ) + ) + () + ) + (= + (Var 2 x) + (IntegerBinOp + (IntegerConstant 54 (Integer 4 [])) + Sub + (IntegerConstant 100 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -46 (Integer 4 [])) + ) + () + ) + (= + (Var 2 x2) + (Cast + (RealBinOp + (RealBinOp + (RealConstant + 3.454000 + (Real 8 []) + ) + Sub + (RealConstant + 765.430000 + (Real 8 []) + ) + (Real 8 []) + (RealConstant + -761.976000 + (Real 8 []) + ) + ) + Add + (RealConstant + 534.600000 + (Real 8 []) + ) + (Real 8 []) + (RealConstant + -227.376000 + (Real 8 []) + ) + ) + RealToReal + (Real 4 []) + (RealConstant + -227.376000 + (Real 4 []) + ) + ) + () + ) + (= + (Var 2 x2) + (Cast + (RealBinOp + (RealConstant + 5346.565000 + (Real 8 []) + ) + Mul + (RealConstant + 3.450000 + (Real 8 []) + ) + (Real 8 []) + (RealConstant + 18445.649250 + (Real 8 []) + ) + ) + RealToReal + (Real 4 []) + (RealConstant + 18445.649250 + (Real 4 []) + ) + ) + () + ) + (= + (Var 2 x2) + (Cast + (RealBinOp + (RealConstant + 5346.565000 + (Real 8 []) + ) + Pow + (RealConstant + 3.450000 + (Real 8 []) + ) + (Real 8 []) + (RealConstant + 7275422789925.217773 + (Real 8 []) + ) + ) + RealToReal + (Real 4 []) + (RealConstant + 7275422789925.217773 + (Real 4 []) + ) + ) + () + ) + (= + (Var 2 x) + (IntegerBinOp + (Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + ) + Add + (Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + ) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 x) + (IntegerBinOp + (Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + ) + Sub + (Cast + (LogicalConstant + .false. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + ) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 x) + (IntegerBinOp + (Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + ) + Mul + (Cast + (LogicalConstant + .false. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + ) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 x) + (IntegerBinOp + (Cast + (LogicalConstant + .true. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + ) + Pow + (Cast + (LogicalConstant + .false. + (Logical 4 []) + ) + LogicalToInteger + (Integer 4 []) + () + ) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 b1) + (LogicalConstant + .true. + (Logical 4 []) + ) + () + ) + (= + (Var 2 b2) + (LogicalConstant + .false. + (Logical 4 []) + ) + () + ) + (= + (Var 2 x) + (Cast + (FunctionCall + 2 _lpython_floordiv@__lpython_overloaded_6___lpython_floordiv + 2 _lpython_floordiv + [((Var 2 b1)) + ((Var 2 b1))] + (Logical 4 []) + () + () + ) + LogicalToInteger + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 x) + (IntegerBinOp + (Cast + (Var 2 b1) + LogicalToInteger + (Integer 4 []) + () + ) + Pow + (Cast + (Var 2 b2) + LogicalToInteger + (Integer 4 []) + () + ) + (Integer 4 []) + () + ) + () + )] + () + Public + .false. + .false. + ) + }) + _global_symbols + [lpython_builtin] + .false. + .false. + ), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: @@ -14,424 +443,6 @@ main_program [] [] - ), - test_binop: - (Function - (SymbolTable - 2 - { - _lpython_floordiv: - (ExternalSymbol - 2 - _lpython_floordiv - 4 _lpython_floordiv - lpython_builtin - [] - _lpython_floordiv - Private - ), - _lpython_floordiv@__lpython_overloaded_6___lpython_floordiv: - (ExternalSymbol - 2 - _lpython_floordiv@__lpython_overloaded_6___lpython_floordiv - 4 __lpython_overloaded_6___lpython_floordiv - lpython_builtin - [] - __lpython_overloaded_6___lpython_floordiv - Public - ), - b1: - (Variable - 2 - b1 - [] - Local - () - () - Default - (Logical 4 []) - Source - Public - Required - .false. - ), - b2: - (Variable - 2 - b2 - [] - Local - () - () - Default - (Logical 4 []) - Source - Public - Required - .false. - ), - x: - (Variable - 2 - x - [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ), - x2: - (Variable - 2 - x2 - [] - Local - () - () - Default - (Real 4 []) - Source - Public - Required - .false. - ) - }) - test_binop - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [_lpython_floordiv@__lpython_overloaded_6___lpython_floordiv] - [] - [(= - (Var 2 x) - (IntegerBinOp - (IntegerConstant 2 (Integer 4 [])) - Pow - (IntegerConstant 3 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant 8 (Integer 4 [])) - ) - () - ) - (= - (Var 2 x2) - (Cast - (RealBinOp - (RealConstant - 2.000000 - (Real 8 []) - ) - Pow - (RealConstant - 3.500000 - (Real 8 []) - ) - (Real 8 []) - (RealConstant - 11.313708 - (Real 8 []) - ) - ) - RealToReal - (Real 4 []) - (RealConstant - 11.313708 - (Real 4 []) - ) - ) - () - ) - (= - (Var 2 x) - (IntegerBinOp - (IntegerConstant 54 (Integer 4 [])) - Sub - (IntegerConstant 100 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -46 (Integer 4 [])) - ) - () - ) - (= - (Var 2 x2) - (Cast - (RealBinOp - (RealBinOp - (RealConstant - 3.454000 - (Real 8 []) - ) - Sub - (RealConstant - 765.430000 - (Real 8 []) - ) - (Real 8 []) - (RealConstant - -761.976000 - (Real 8 []) - ) - ) - Add - (RealConstant - 534.600000 - (Real 8 []) - ) - (Real 8 []) - (RealConstant - -227.376000 - (Real 8 []) - ) - ) - RealToReal - (Real 4 []) - (RealConstant - -227.376000 - (Real 4 []) - ) - ) - () - ) - (= - (Var 2 x2) - (Cast - (RealBinOp - (RealConstant - 5346.565000 - (Real 8 []) - ) - Mul - (RealConstant - 3.450000 - (Real 8 []) - ) - (Real 8 []) - (RealConstant - 18445.649250 - (Real 8 []) - ) - ) - RealToReal - (Real 4 []) - (RealConstant - 18445.649250 - (Real 4 []) - ) - ) - () - ) - (= - (Var 2 x2) - (Cast - (RealBinOp - (RealConstant - 5346.565000 - (Real 8 []) - ) - Pow - (RealConstant - 3.450000 - (Real 8 []) - ) - (Real 8 []) - (RealConstant - 7275422789925.217773 - (Real 8 []) - ) - ) - RealToReal - (Real 4 []) - (RealConstant - 7275422789925.217773 - (Real 4 []) - ) - ) - () - ) - (= - (Var 2 x) - (IntegerBinOp - (Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - ) - Add - (Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - ) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 x) - (IntegerBinOp - (Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - ) - Sub - (Cast - (LogicalConstant - .false. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - ) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 x) - (IntegerBinOp - (Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - ) - Mul - (Cast - (LogicalConstant - .false. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - ) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 x) - (IntegerBinOp - (Cast - (LogicalConstant - .true. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - ) - Pow - (Cast - (LogicalConstant - .false. - (Logical 4 []) - ) - LogicalToInteger - (Integer 4 []) - () - ) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 b1) - (LogicalConstant - .true. - (Logical 4 []) - ) - () - ) - (= - (Var 2 b2) - (LogicalConstant - .false. - (Logical 4 []) - ) - () - ) - (= - (Var 2 x) - (Cast - (FunctionCall - 2 _lpython_floordiv@__lpython_overloaded_6___lpython_floordiv - 2 _lpython_floordiv - [((Var 2 b1)) - ((Var 2 b1))] - (Logical 4 []) - () - () - ) - LogicalToInteger - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 x) - (IntegerBinOp - (Cast - (Var 2 b1) - LogicalToInteger - (Integer 4 []) - () - ) - Pow - (Cast - (Var 2 b2) - LogicalToInteger - (Integer 4 []) - () - ) - (Integer 4 []) - () - ) - () - )] - () - Public - .false. - .false. ) }) [] diff --git a/tests/reference/asr-list1-f15817d.json b/tests/reference/asr-list1-f15817d.json index aa1168181d..bb5644c724 100644 --- a/tests/reference/asr-list1-f15817d.json +++ b/tests/reference/asr-list1-f15817d.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-list1-f15817d.stdout", - "stdout_hash": "5f495046def92b0abed1cb401feed923d97c5ed5544efd3738159677", + "stdout_hash": "035fb99f1e4e18ded78713b733644f64881200701d8849ac4fd8d5ff", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-list1-f15817d.stdout b/tests/reference/asr-list1-f15817d.stdout index 04bff619f9..98c5cf9976 100644 --- a/tests/reference/asr-list1-f15817d.stdout +++ b/tests/reference/asr-list1-f15817d.stdout @@ -2,416 +2,427 @@ (SymbolTable 1 { - main_program: - (Program - (SymbolTable - 3 - { - - }) - main_program - [] - [] - ), - test_List: - (Function + _global_symbols: + (Module (SymbolTable - 2 + 4 { - a: - (Variable - 2 - a - [] - Local - () - () - Default - (List - (Integer 4 []) + test_List: + (Function + (SymbolTable + 2 + { + a: + (Variable + 2 + a + [] + Local + () + () + Default + (List + (Integer 4 []) + ) + Source + Public + Required + .false. + ), + a11: + (Variable + 2 + a11 + [] + Local + () + () + Default + (List + (Integer 4 []) + ) + Source + Public + Required + .false. + ), + b: + (Variable + 2 + b + [] + Local + () + () + Default + (List + (Character 1 -2 () []) + ) + Source + Public + Required + .false. + ), + b11: + (Variable + 2 + b11 + [] + Local + () + () + Default + (List + (Integer 4 []) + ) + Source + Public + Required + .false. + ), + c: + (Variable + 2 + c + [] + Local + () + () + Default + (List + (List + (Integer 4 []) + ) + ) + Source + Public + Required + .false. + ), + d: + (Variable + 2 + d + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + e: + (Variable + 2 + e + [] + Local + () + () + Default + (List + (List + (Character 1 -2 () []) + ) + ) + Source + Public + Required + .false. + ) + }) + test_List + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. ) - Source - Public - Required - .false. - ), - a11: - (Variable - 2 - a11 [] - Local - () - () - Default - (List - (Integer 4 []) - ) - Source - Public - Required - .false. - ), - b: - (Variable - 2 - b [] - Local - () - () - Default - (List - (Character 1 -2 () []) + [(= + (Var 2 a) + (ListConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + (List + (Integer 4 []) + ) + ) + () ) - Source - Public - Required - .false. - ), - b11: - (Variable - 2 - b11 - [] - Local - () - () - Default - (List - (Integer 4 []) + (= + (Var 2 a) + (ListConstant + [(IntegerUnaryMinus + (IntegerConstant 3 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -3 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -2 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + )] + (List + (Integer 4 []) + ) + ) + () ) - Source - Public - Required - .false. - ), - c: - (Variable - 2 - c - [] - Local - () - () - Default - (List - (List + (= + (Var 2 b) + (ListConstant + [(StringConstant + "a" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + ) + (StringConstant + "c" + (Character 1 1 () []) + )] + (List + (Character 1 1 () []) + ) + ) + () + ) + (= + (Var 2 c) + (ListConstant + [(ListConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + (List + (Integer 4 []) + ) + ) + (ListConstant + [(IntegerConstant 4 (Integer 4 [])) + (IntegerConstant 5 (Integer 4 [])) + (IntegerConstant 6 (Integer 4 []))] + (List + (Integer 4 []) + ) + )] + (List + (List + (Integer 4 []) + ) + ) + ) + () + ) + (= + (Var 2 d) + (ListItem + (Var 2 a) + (IntegerConstant 2 (Integer 4 [])) (Integer 4 []) + () ) + () ) - Source - Public - Required - .false. - ), - d: - (Variable - 2 - d - [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ), - e: - (Variable - 2 - e - [] - Local - () - () - Default - (List - (List - (Character 1 -2 () []) + (= + (Var 2 e) + (ListConstant + [(ListConstant + [(StringConstant + "a" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + ) + (StringConstant + "c" + (Character 1 1 () []) + )] + (List + (Character 1 1 () []) + ) + ) + (ListConstant + [(StringConstant + "d" + (Character 1 1 () []) + ) + (StringConstant + "e" + (Character 1 1 () []) + )] + (List + (Character 1 1 () []) + ) + )] + (List + (List + (Character 1 1 () []) + ) + ) + ) + () + ) + (ListAppend + (Var 2 a) + (IntegerConstant 10 (Integer 4 [])) + ) + (ListRemove + (Var 2 a) + (IntegerConstant 1 (Integer 4 [])) + ) + (ListInsert + (Var 2 a) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 13 (Integer 4 [])) + ) + (= + (Var 2 a) + (ListSection + (Var 2 a) + ((IntegerConstant 0 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + ()) + (List + (Integer 4 []) + ) + () + ) + () + ) + (= + (Var 2 d) + (ListPop + (Var 2 a) + (IntegerConstant -1 (Integer 4 [])) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 d) + (ListPop + (Var 2 a) + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + () + ) + () + ) + (= + (Var 2 a) + (ListConcat + (Var 2 a) + (ListConstant + [(IntegerConstant 4 (Integer 4 [])) + (IntegerConstant 5 (Integer 4 []))] + (List + (Integer 4 []) + ) + ) + (List + (Integer 4 []) + ) + () + ) + () + ) + (= + (Var 2 a) + (ListConcat + (ListConstant + [(IntegerConstant 6 (Integer 4 [])) + (IntegerConstant 7 (Integer 4 []))] + (List + (Integer 4 []) + ) + ) + (Var 2 a) + (List + (Integer 4 []) + ) + () + ) + () + ) + (= + (Var 2 a11) + (ListConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 []))] + (List + (Integer 4 []) + ) + ) + () + ) + (= + (Var 2 b11) + (ListConstant + [(IntegerConstant 3 (Integer 4 [])) + (IntegerConstant 4 (Integer 4 []))] + (List + (Integer 4 []) + ) ) + () ) - Source + (Assert + (ListCompare + (Var 2 a11) + Eq + (Var 2 b11) + (Logical 4 []) + () + ) + () + )] + () Public - Required + .false. .false. ) }) - test_List - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) + _global_symbols [] - [] - [(= - (Var 2 a) - (ListConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - (List - (Integer 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (ListConstant - [(IntegerUnaryMinus - (IntegerConstant 3 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -3 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -2 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - )] - (List - (Integer 4 []) - ) - ) - () - ) - (= - (Var 2 b) - (ListConstant - [(StringConstant - "a" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - ) - (StringConstant - "c" - (Character 1 1 () []) - )] - (List - (Character 1 1 () []) - ) - ) - () - ) - (= - (Var 2 c) - (ListConstant - [(ListConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - (List - (Integer 4 []) - ) - ) - (ListConstant - [(IntegerConstant 4 (Integer 4 [])) - (IntegerConstant 5 (Integer 4 [])) - (IntegerConstant 6 (Integer 4 []))] - (List - (Integer 4 []) - ) - )] - (List - (List - (Integer 4 []) - ) - ) - ) - () - ) - (= - (Var 2 d) - (ListItem - (Var 2 a) - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 e) - (ListConstant - [(ListConstant - [(StringConstant - "a" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - ) - (StringConstant - "c" - (Character 1 1 () []) - )] - (List - (Character 1 1 () []) - ) - ) - (ListConstant - [(StringConstant - "d" - (Character 1 1 () []) - ) - (StringConstant - "e" - (Character 1 1 () []) - )] - (List - (Character 1 1 () []) - ) - )] - (List - (List - (Character 1 1 () []) - ) - ) - ) - () - ) - (ListAppend - (Var 2 a) - (IntegerConstant 10 (Integer 4 [])) - ) - (ListRemove - (Var 2 a) - (IntegerConstant 1 (Integer 4 [])) - ) - (ListInsert - (Var 2 a) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 13 (Integer 4 [])) - ) - (= - (Var 2 a) - (ListSection - (Var 2 a) - ((IntegerConstant 0 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - ()) - (List - (Integer 4 []) - ) - () - ) - () - ) - (= - (Var 2 d) - (ListPop - (Var 2 a) - (IntegerConstant -1 (Integer 4 [])) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 d) - (ListPop - (Var 2 a) - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - () - ) - () - ) - (= - (Var 2 a) - (ListConcat - (Var 2 a) - (ListConstant - [(IntegerConstant 4 (Integer 4 [])) - (IntegerConstant 5 (Integer 4 []))] - (List - (Integer 4 []) - ) - ) - (List - (Integer 4 []) - ) - () - ) - () - ) - (= - (Var 2 a) - (ListConcat - (ListConstant - [(IntegerConstant 6 (Integer 4 [])) - (IntegerConstant 7 (Integer 4 []))] - (List - (Integer 4 []) - ) - ) - (Var 2 a) - (List - (Integer 4 []) - ) - () - ) - () - ) - (= - (Var 2 a11) - (ListConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 []))] - (List - (Integer 4 []) - ) - ) - () - ) - (= - (Var 2 b11) - (ListConstant - [(IntegerConstant 3 (Integer 4 [])) - (IntegerConstant 4 (Integer 4 []))] - (List - (Integer 4 []) - ) - ) - () - ) - (Assert - (ListCompare - (Var 2 a11) - Eq - (Var 2 b11) - (Logical 4 []) - () - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-loop3-e2afee9.json b/tests/reference/asr-loop3-e2afee9.json index 5e64d060aa..22e402e763 100644 --- a/tests/reference/asr-loop3-e2afee9.json +++ b/tests/reference/asr-loop3-e2afee9.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-loop3-e2afee9.stdout", - "stdout_hash": "330ff9c1346f954399186505a2ad5d4b296e470648bd9c58a03c4af0", + "stdout_hash": "c5cea6ff690e8212cbe418eae6a8997c88a4d0f6a7102e56b85a9b29", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-loop3-e2afee9.stdout b/tests/reference/asr-loop3-e2afee9.stdout index 352cb85b9f..59a613b8fa 100644 --- a/tests/reference/asr-loop3-e2afee9.stdout +++ b/tests/reference/asr-loop3-e2afee9.stdout @@ -2,76 +2,87 @@ (SymbolTable 1 { - main_program: - (Program + _global_symbols: + (Module (SymbolTable - 3 + 4 { - - }) - main_program - [] - [] - ), - test_pass: - (Function - (SymbolTable - 2 - { - a: - (Variable - 2 - a + test_pass: + (Function + (SymbolTable + 2 + { + a: + (Variable + 2 + a + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ) + }) + test_pass + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () + [] + [(= + (Var 2 a) + (IntegerConstant 1 (Integer 4 [])) + () + ) + (WhileLoop + () + (IntegerCompare + (Var 2 a) + Gt + (IntegerConstant 0 (Integer 4 [])) + (Logical 4 []) + () + ) + [] + )] () - Default - (Integer 4 []) - Source Public - Required + .false. .false. ) }) - test_pass - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] + _global_symbols [] - [(= - (Var 2 a) - (IntegerConstant 1 (Integer 4 [])) - () - ) - (WhileLoop - () - (IntegerCompare - (Var 2 a) - Gt - (IntegerConstant 0 (Integer 4 [])) - (Logical 4 []) - () - ) - [] - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-set1-7de4081.json b/tests/reference/asr-set1-7de4081.json index 1012d92ed7..c35c507b49 100644 --- a/tests/reference/asr-set1-7de4081.json +++ b/tests/reference/asr-set1-7de4081.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-set1-7de4081.stdout", - "stdout_hash": "47d199aa6823f48d9121a4991d72b8a279be79d94d55ff2ad7398b11", + "stdout_hash": "751b8344b31939eb8a815b9f2844d7a30aa64cf5f9367c8a2249f6f7", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-set1-7de4081.stdout b/tests/reference/asr-set1-7de4081.stdout index c485c0d959..1b420a6354 100644 --- a/tests/reference/asr-set1-7de4081.stdout +++ b/tests/reference/asr-set1-7de4081.stdout @@ -2,158 +2,169 @@ (SymbolTable 1 { - main_program: - (Program - (SymbolTable - 3 - { - - }) - main_program - [] - [] - ), - test_Set: - (Function + _global_symbols: + (Module (SymbolTable - 2 + 4 { - a: - (Variable - 2 - a - [] - Local - () - () - Default - (Set - (Integer 4 []) + test_Set: + (Function + (SymbolTable + 2 + { + a: + (Variable + 2 + a + [] + Local + () + () + Default + (Set + (Integer 4 []) + ) + Source + Public + Required + .false. + ), + b: + (Variable + 2 + b + [] + Local + () + () + Default + (Set + (Character 1 -2 () []) + ) + Source + Public + Required + .false. + ), + s: + (Variable + 2 + s + [] + Local + () + () + Default + (Character 1 -2 () []) + Source + Public + Required + .false. + ) + }) + test_Set + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. ) - Source - Public - Required - .false. - ), - b: - (Variable - 2 - b [] - Local - () - () - Default - (Set - (Character 1 -2 () []) - ) - Source - Public - Required - .false. - ), - s: - (Variable - 2 - s [] - Local - () + [(= + (Var 2 a) + (SetConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + (Set + (Integer 4 []) + ) + ) + () + ) + (= + (Var 2 a) + (SetConstant + [(IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 [])) + (IntegerConstant 4 (Integer 4 [])) + (IntegerConstant 5 (Integer 4 [])) + (IntegerConstant 5 (Integer 4 []))] + (Set + (Integer 4 []) + ) + ) + () + ) + (SetInsert + (Var 2 a) + (IntegerConstant 9 (Integer 4 [])) + ) + (SetRemove + (Var 2 a) + (IntegerConstant 4 (Integer 4 [])) + ) + (= + (Var 2 b) + (SetConstant + [(StringConstant + "a" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + ) + (StringConstant + "c" + (Character 1 1 () []) + )] + (Set + (Character 1 1 () []) + ) + ) + () + ) + (= + (Var 2 s) + (SetPop + (Var 2 b) + (Character 1 -2 () []) + () + ) + () + )] () - Default - (Character 1 -2 () []) - Source Public - Required + .false. .false. ) }) - test_Set - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) + _global_symbols [] - [] - [(= - (Var 2 a) - (SetConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - (Set - (Integer 4 []) - ) - ) - () - ) - (= - (Var 2 a) - (SetConstant - [(IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 [])) - (IntegerConstant 4 (Integer 4 [])) - (IntegerConstant 5 (Integer 4 [])) - (IntegerConstant 5 (Integer 4 []))] - (Set - (Integer 4 []) - ) - ) - () - ) - (SetInsert - (Var 2 a) - (IntegerConstant 9 (Integer 4 [])) - ) - (SetRemove - (Var 2 a) - (IntegerConstant 4 (Integer 4 [])) - ) - (= - (Var 2 b) - (SetConstant - [(StringConstant - "a" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - ) - (StringConstant - "c" - (Character 1 1 () []) - )] - (Set - (Character 1 1 () []) - ) - ) - () - ) - (= - (Var 2 s) - (SetPop - (Var 2 b) - (Character 1 -2 () []) - () - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-subscript1-22a7138.json b/tests/reference/asr-subscript1-22a7138.json index 1f48c12f90..8c46fec2ae 100644 --- a/tests/reference/asr-subscript1-22a7138.json +++ b/tests/reference/asr-subscript1-22a7138.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-subscript1-22a7138.stdout", - "stdout_hash": "cd1177bcacfdf6622467706a1abe1190e2afc5dd410df2c58032682e", + "stdout_hash": "b5d5d8d43cc8755344a7580608ababa8e1871afa3eaa5e6dd5397079", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-subscript1-22a7138.stdout b/tests/reference/asr-subscript1-22a7138.stdout index 0a944f6389..7cdfc108c7 100644 --- a/tests/reference/asr-subscript1-22a7138.stdout +++ b/tests/reference/asr-subscript1-22a7138.stdout @@ -2,302 +2,313 @@ (SymbolTable 1 { - main_program: - (Program + _global_symbols: + (Module (SymbolTable - 3 + 4 { - - }) - main_program - [] - [] - ), - test_subscript: - (Function - (SymbolTable - 2 - { - A: - (Variable - 2 - A + test_subscript: + (Function + (SymbolTable + 2 + { + A: + (Variable + 2 + A + [] + Local + () + () + Default + (Integer 4 [((IntegerConstant 0 (Integer 4 [])) + (IntegerConstant 5 (Integer 4 [])))]) + Source + Public + Required + .false. + ), + B: + (Variable + 2 + B + [] + Local + () + () + Default + (Integer 4 [((IntegerConstant 0 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])))]) + Source + Public + Required + .false. + ), + i: + (Variable + 2 + i + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + s: + (Variable + 2 + s + [] + Local + () + () + Default + (Character 1 -2 () []) + Source + Public + Required + .false. + ) + }) + test_subscript + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. + ) [] - Local - () - () - Default - (Integer 4 [((IntegerConstant 0 (Integer 4 [])) - (IntegerConstant 5 (Integer 4 [])))]) - Source - Public - Required - .false. - ), - B: - (Variable - 2 - B [] - Local + [(= + (Var 2 s) + (StringConstant + "abc" + (Character 1 3 () []) + ) + () + ) + (= + (Var 2 s) + (StringItem + (Var 2 s) + (IntegerBinOp + (IntegerConstant 0 (Integer 4 [])) + Add + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + () + ) + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 s) + (StringSection + (Var 2 s) + (IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + () + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 s) + (StringSection + (Var 2 s) + () + () + () + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 s) + (StringSection + (Var 2 s) + () + () + (IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 s) + (StringSection + (Var 2 s) + () + () + (IntegerConstant 2 (Integer 4 [])) + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 s) + (StringSection + (Var 2 s) + (IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 88 (Integer 4 [])) + (IntegerConstant 1 (Integer 4 [])) + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 s) + (StringSection + (Var 2 s) + () + (IntegerConstant 1 (Integer 4 [])) + (IntegerUnaryMinus + (IntegerConstant 4 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -4 (Integer 4 [])) + ) + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 s) + (StringSection + (Var 2 s) + (IntegerUnaryMinus + (IntegerConstant 89 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -89 (Integer 4 [])) + ) + () + (IntegerConstant 4 (Integer 4 [])) + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 s) + (StringSection + (Var 2 s) + (IntegerUnaryMinus + (IntegerConstant 3 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -3 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 3 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -3 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 3 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -3 (Integer 4 [])) + ) + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 s) + (StringSection + (Var 2 s) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 [])) + () + (Character 1 -2 () []) + () + ) + () + ) + (= + (Var 2 i) + (ArrayItem + (Var 2 A) + [(() + (IntegerConstant 0 (Integer 4 [])) + ())] + (Integer 4 []) + RowMajor + () + ) + () + ) + (= + (Var 2 B) + (ArraySection + (Var 2 A) + [((IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 [])) + ())] + (Integer 4 [((IntegerConstant 0 (Integer 4 [])) + (IntegerConstant 5 (Integer 4 [])))]) + () + ) + () + ) + (= + (Var 2 B) + (ArraySection + (Var 2 A) + [((IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 [])))] + (Integer 4 [((IntegerConstant 0 (Integer 4 [])) + (IntegerConstant 5 (Integer 4 [])))]) + () + ) + () + )] () - () - Default - (Integer 4 [((IntegerConstant 0 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])))]) - Source Public - Required .false. - ), - i: - (Variable - 2 - i - [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ), - s: - (Variable - 2 - s - [] - Local - () - () - Default - (Character 1 -2 () []) - Source - Public - Required .false. ) }) - test_subscript - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] + _global_symbols [] - [(= - (Var 2 s) - (StringConstant - "abc" - (Character 1 3 () []) - ) - () - ) - (= - (Var 2 s) - (StringItem - (Var 2 s) - (IntegerBinOp - (IntegerConstant 0 (Integer 4 [])) - Add - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - () - ) - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 s) - (StringSection - (Var 2 s) - (IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - () - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 s) - (StringSection - (Var 2 s) - () - () - () - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 s) - (StringSection - (Var 2 s) - () - () - (IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - ) - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 s) - (StringSection - (Var 2 s) - () - () - (IntegerConstant 2 (Integer 4 [])) - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 s) - (StringSection - (Var 2 s) - (IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 88 (Integer 4 [])) - (IntegerConstant 1 (Integer 4 [])) - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 s) - (StringSection - (Var 2 s) - () - (IntegerConstant 1 (Integer 4 [])) - (IntegerUnaryMinus - (IntegerConstant 4 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -4 (Integer 4 [])) - ) - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 s) - (StringSection - (Var 2 s) - (IntegerUnaryMinus - (IntegerConstant 89 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -89 (Integer 4 [])) - ) - () - (IntegerConstant 4 (Integer 4 [])) - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 s) - (StringSection - (Var 2 s) - (IntegerUnaryMinus - (IntegerConstant 3 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -3 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 3 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -3 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 3 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -3 (Integer 4 [])) - ) - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 s) - (StringSection - (Var 2 s) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 [])) - () - (Character 1 -2 () []) - () - ) - () - ) - (= - (Var 2 i) - (ArrayItem - (Var 2 A) - [(() - (IntegerConstant 0 (Integer 4 [])) - ())] - (Integer 4 []) - RowMajor - () - ) - () - ) - (= - (Var 2 B) - (ArraySection - (Var 2 A) - [((IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 [])) - ())] - (Integer 4 [((IntegerConstant 0 (Integer 4 [])) - (IntegerConstant 5 (Integer 4 [])))]) - () - ) - () - ) - (= - (Var 2 B) - (ArraySection - (Var 2 A) - [((IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 [])))] - (Integer 4 [((IntegerConstant 0 (Integer 4 [])) - (IntegerConstant 5 (Integer 4 [])))]) - () - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/asr-tuple1-ce358d9.json b/tests/reference/asr-tuple1-ce358d9.json index 1e2f79f4e9..435e38bd4a 100644 --- a/tests/reference/asr-tuple1-ce358d9.json +++ b/tests/reference/asr-tuple1-ce358d9.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-tuple1-ce358d9.stdout", - "stdout_hash": "2ba7b997ec4f778e5929ce11442ec0baf88b58020d2c68f79685ed0d", + "stdout_hash": "5ef6ec9d5b44cbe462de63e6935f96cf2098698fbee557d90f465b64", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-tuple1-ce358d9.stdout b/tests/reference/asr-tuple1-ce358d9.stdout index fe6c07a8c3..9c8504b6ae 100644 --- a/tests/reference/asr-tuple1-ce358d9.stdout +++ b/tests/reference/asr-tuple1-ce358d9.stdout @@ -2,562 +2,573 @@ (SymbolTable 1 { - main_program: - (Program - (SymbolTable - 3 - { - - }) - main_program - [] - [] - ), - test_Tuple: - (Function + _global_symbols: + (Module (SymbolTable - 2 + 4 { - a1: - (Variable - 2 - a1 - [] - Local - () - () - Default - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] + test_Tuple: + (Function + (SymbolTable + 2 + { + a1: + (Variable + 2 + a1 + [] + Local + () + () + Default + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + ) + Source + Public + Required + .false. + ), + a11: + (Variable + 2 + a11 + [] + Local + () + () + Default + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + Source + Public + Required + .false. + ), + a2: + (Variable + 2 + a2 + [] + Local + () + () + Default + (Tuple + [(Character 1 -2 () []) + (Character 1 -2 () []) + (Character 1 -2 () [])] + ) + Source + Public + Required + .false. + ), + a3: + (Variable + 2 + a3 + [] + Local + () + () + Default + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Real 4 []) + (Character 1 -2 () [])] + ) + Source + Public + Required + .false. + ), + a4: + (Variable + 2 + a4 + [] + Local + () + () + Default + (Tuple + [(Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + ) + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + )] + ) + Source + Public + Required + .false. + ), + a5: + (Variable + 2 + a5 + [] + Local + () + () + Default + (Tuple + [(Tuple + [(Character 1 -2 () []) + (Character 1 -2 () []) + (Real 4 [])] + ) + (Tuple + [(Character 1 -2 () []) + (Integer 4 []) + (Real 4 [])] + )] + ) + Source + Public + Required + .false. + ), + b0: + (Variable + 2 + b0 + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + b1: + (Variable + 2 + b1 + [] + Local + () + () + Default + (Integer 4 []) + Source + Public + Required + .false. + ), + b11: + (Variable + 2 + b11 + [] + Local + () + () + Default + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + Source + Public + Required + .false. + ), + float_mem: + (Variable + 2 + float_mem + [] + Local + () + () + Default + (Real 4 []) + Source + Public + Required + .false. + ), + float_mem1: + (Variable + 2 + float_mem1 + [] + Local + () + () + Default + (Real 4 []) + Source + Public + Required + .false. + ), + float_mem2: + (Variable + 2 + float_mem2 + [] + Local + () + () + Default + (Real 4 []) + Source + Public + Required + .false. + ) + }) + test_Tuple + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + [] + .false. ) - Source - Public - Required - .false. - ), - a11: - (Variable - 2 - a11 [] - Local - () - () - Default - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - Source - Public - Required - .false. - ), - a2: - (Variable - 2 - a2 [] - Local - () - () - Default - (Tuple - [(Character 1 -2 () []) - (Character 1 -2 () []) - (Character 1 -2 () [])] + [(= + (Var 2 a1) + (TupleConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + ) + ) + () ) - Source - Public - Required - .false. - ), - a3: - (Variable - 2 - a3 - [] - Local - () - () - Default - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Real 4 []) - (Character 1 -2 () [])] + (= + (Var 2 a1) + (TupleConstant + [(IntegerUnaryMinus + (IntegerConstant 3 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -3 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -2 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + )] + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + ) + ) + () ) - Source - Public - Required - .false. - ), - a4: - (Variable - 2 - a4 - [] - Local - () - () - Default - (Tuple - [(Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] + (= + (Var 2 a2) + (TupleConstant + [(StringConstant + "a" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + ) + (StringConstant + "c" + (Character 1 1 () []) + )] + (Tuple + [(Character 1 1 () []) + (Character 1 1 () []) + (Character 1 1 () [])] + ) ) - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] - )] + () ) - Source - Public - Required - .false. - ), - a5: - (Variable - 2 - a5 - [] - Local - () - () - Default - (Tuple - [(Tuple - [(Character 1 -2 () []) - (Character 1 -2 () []) - (Real 4 [])] + (= + (Var 2 float_mem) + (Cast + (RealConstant + 0.450000 + (Real 8 []) + ) + RealToReal + (Real 4 []) + (RealConstant + 0.450000 + (Real 4 []) + ) ) - (Tuple - [(Character 1 -2 () []) + () + ) + (= + (Var 2 a3) + (TupleConstant + [(IntegerUnaryMinus + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -2 (Integer 4 [])) + ) + (IntegerUnaryMinus + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + (IntegerConstant -1 (Integer 4 [])) + ) + (Var 2 float_mem) + (StringConstant + "d" + (Character 1 1 () []) + )] + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Real 4 []) + (Character 1 1 () [])] + ) + ) + () + ) + (= + (Var 2 a4) + (TupleConstant + [(TupleConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 [])) + (IntegerConstant 3 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + ) + ) + (TupleConstant + [(IntegerConstant 4 (Integer 4 [])) + (IntegerConstant 5 (Integer 4 [])) + (IntegerConstant 6 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + ) + )] + (Tuple + [(Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + ) + (Tuple + [(Integer 4 []) + (Integer 4 []) + (Integer 4 [])] + )] + ) + ) + () + ) + (= + (Var 2 float_mem1) + (Cast + (RealConstant + 3.400000 + (Real 8 []) + ) + RealToReal + (Real 4 []) + (RealConstant + 3.400000 + (Real 4 []) + ) + ) + () + ) + (= + (Var 2 float_mem2) + (Cast + (RealConstant + 5.600000 + (Real 8 []) + ) + RealToReal + (Real 4 []) + (RealConstant + 5.600000 + (Real 4 []) + ) + ) + () + ) + (= + (Var 2 a5) + (TupleConstant + [(TupleConstant + [(StringConstant + "a" + (Character 1 1 () []) + ) + (StringConstant + "b" + (Character 1 1 () []) + ) + (Var 2 float_mem1)] + (Tuple + [(Character 1 1 () []) + (Character 1 1 () []) + (Real 4 [])] + ) + ) + (TupleConstant + [(StringConstant + "c" + (Character 1 1 () []) + ) + (IntegerConstant 3 (Integer 4 [])) + (Var 2 float_mem2)] + (Tuple + [(Character 1 1 () []) + (Integer 4 []) + (Real 4 [])] + ) + )] + (Tuple + [(Tuple + [(Character 1 1 () []) + (Character 1 1 () []) + (Real 4 [])] + ) + (Tuple + [(Character 1 1 () []) + (Integer 4 []) + (Real 4 [])] + )] + ) + ) + () + ) + (= + (Var 2 b0) + (TupleItem + (Var 2 a1) + (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) - (Real 4 [])] - )] + () + ) + () ) - Source - Public - Required - .false. - ), - b0: - (Variable - 2 - b0 - [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ), - b1: - (Variable - 2 - b1 - [] - Local - () - () - Default - (Integer 4 []) - Source - Public - Required - .false. - ), - b11: - (Variable - 2 - b11 - [] - Local - () - () - Default - (Tuple - [(Integer 4 []) - (Integer 4 [])] + (= + (TupleConstant + [(Var 2 b0) + (Var 2 b1)] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + ) + (TupleConstant + [(TupleItem + (Var 2 a1) + (IntegerConstant 2 (Integer 4 [])) + (Integer 4 []) + () + ) + (TupleItem + (Var 2 a1) + (IntegerConstant 1 (Integer 4 [])) + (Integer 4 []) + () + )] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + ) + () ) - Source - Public - Required - .false. - ), - float_mem: - (Variable - 2 - float_mem - [] - Local - () - () - Default - (Real 4 []) - Source - Public - Required - .false. - ), - float_mem1: - (Variable - 2 - float_mem1 - [] - Local - () + (= + (Var 2 a11) + (TupleConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + ) + () + ) + (= + (Var 2 b11) + (TupleConstant + [(IntegerConstant 1 (Integer 4 [])) + (IntegerConstant 2 (Integer 4 []))] + (Tuple + [(Integer 4 []) + (Integer 4 [])] + ) + ) + () + ) + (Assert + (TupleCompare + (Var 2 a11) + Eq + (Var 2 b11) + (Logical 4 []) + () + ) + () + )] () - Default - (Real 4 []) - Source Public - Required .false. - ), - float_mem2: - (Variable - 2 - float_mem2 - [] - Local - () - () - Default - (Real 4 []) - Source - Public - Required .false. ) }) - test_Tuple - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - [] - .false. - ) - [] + _global_symbols [] - [(= - (Var 2 a1) - (TupleConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - (= - (Var 2 a1) - (TupleConstant - [(IntegerUnaryMinus - (IntegerConstant 3 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -3 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -2 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - )] - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - (= - (Var 2 a2) - (TupleConstant - [(StringConstant - "a" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - ) - (StringConstant - "c" - (Character 1 1 () []) - )] - (Tuple - [(Character 1 1 () []) - (Character 1 1 () []) - (Character 1 1 () [])] - ) - ) - () - ) - (= - (Var 2 float_mem) - (Cast - (RealConstant - 0.450000 - (Real 8 []) - ) - RealToReal - (Real 4 []) - (RealConstant - 0.450000 - (Real 4 []) - ) - ) - () - ) - (= - (Var 2 a3) - (TupleConstant - [(IntegerUnaryMinus - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -2 (Integer 4 [])) - ) - (IntegerUnaryMinus - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - (IntegerConstant -1 (Integer 4 [])) - ) - (Var 2 float_mem) - (StringConstant - "d" - (Character 1 1 () []) - )] - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Real 4 []) - (Character 1 1 () [])] - ) - ) - () - ) - (= - (Var 2 a4) - (TupleConstant - [(TupleConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 [])) - (IntegerConstant 3 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] - ) - ) - (TupleConstant - [(IntegerConstant 4 (Integer 4 [])) - (IntegerConstant 5 (Integer 4 [])) - (IntegerConstant 6 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] - ) - )] - (Tuple - [(Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] - ) - (Tuple - [(Integer 4 []) - (Integer 4 []) - (Integer 4 [])] - )] - ) - ) - () - ) - (= - (Var 2 float_mem1) - (Cast - (RealConstant - 3.400000 - (Real 8 []) - ) - RealToReal - (Real 4 []) - (RealConstant - 3.400000 - (Real 4 []) - ) - ) - () - ) - (= - (Var 2 float_mem2) - (Cast - (RealConstant - 5.600000 - (Real 8 []) - ) - RealToReal - (Real 4 []) - (RealConstant - 5.600000 - (Real 4 []) - ) - ) - () - ) - (= - (Var 2 a5) - (TupleConstant - [(TupleConstant - [(StringConstant - "a" - (Character 1 1 () []) - ) - (StringConstant - "b" - (Character 1 1 () []) - ) - (Var 2 float_mem1)] - (Tuple - [(Character 1 1 () []) - (Character 1 1 () []) - (Real 4 [])] - ) - ) - (TupleConstant - [(StringConstant - "c" - (Character 1 1 () []) - ) - (IntegerConstant 3 (Integer 4 [])) - (Var 2 float_mem2)] - (Tuple - [(Character 1 1 () []) - (Integer 4 []) - (Real 4 [])] - ) - )] - (Tuple - [(Tuple - [(Character 1 1 () []) - (Character 1 1 () []) - (Real 4 [])] - ) - (Tuple - [(Character 1 1 () []) - (Integer 4 []) - (Real 4 [])] - )] - ) - ) - () - ) - (= - (Var 2 b0) - (TupleItem - (Var 2 a1) - (IntegerConstant 0 (Integer 4 [])) - (Integer 4 []) - () - ) - () - ) - (= - (TupleConstant - [(Var 2 b0) - (Var 2 b1)] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - ) - (TupleConstant - [(TupleItem - (Var 2 a1) - (IntegerConstant 2 (Integer 4 [])) - (Integer 4 []) - () - ) - (TupleItem - (Var 2 a1) - (IntegerConstant 1 (Integer 4 [])) - (Integer 4 []) - () - )] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - (= - (Var 2 a11) - (TupleConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - (= - (Var 2 b11) - (TupleConstant - [(IntegerConstant 1 (Integer 4 [])) - (IntegerConstant 2 (Integer 4 []))] - (Tuple - [(Integer 4 []) - (Integer 4 [])] - ) - ) - () - ) - (Assert - (TupleCompare - (Var 2 a11) - Eq - (Var 2 b11) - (Logical 4 []) - () - ) - () - )] - () - Public .false. .false. + ), + main_program: + (Program + (SymbolTable + 3 + { + + }) + main_program + [] + [] ) }) [] diff --git a/tests/reference/c-variable_decl_03-fa1823b.json b/tests/reference/c-variable_decl_03-fa1823b.json index 5337c053d3..b2e5e47543 100644 --- a/tests/reference/c-variable_decl_03-fa1823b.json +++ b/tests/reference/c-variable_decl_03-fa1823b.json @@ -2,11 +2,11 @@ "basename": "c-variable_decl_03-fa1823b", "cmd": "lpython --no-color --show-c {infile}", "infile": "tests/../integration_tests/variable_decl_03.py", - "infile_hash": "f0ba55799f9f468efa5c0ae6b109f9e19850fef29a3de78c2b5af5a3", + "infile_hash": "1e6bd54d3ca0db90eec540b68eff063ae2186d623cf0d64335b09cfe", "outfile": null, "outfile_hash": null, "stdout": "c-variable_decl_03-fa1823b.stdout", - "stdout_hash": "f7c8200b6fc6095a0aa2b19014618e3fa02cf07243e4497a8ea4da05", + "stdout_hash": "519f8d68dfaed123bdcccee9795229b151fd3eeba857572254cc4abc", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-variable_decl_03-fa1823b.stdout b/tests/reference/c-variable_decl_03-fa1823b.stdout index 46d23e43b1..4b7d11bf63 100644 --- a/tests/reference/c-variable_decl_03-fa1823b.stdout +++ b/tests/reference/c-variable_decl_03-fa1823b.stdout @@ -49,7 +49,7 @@ double _lcompilers_abs_f64(double x) double f() { double _lpython_return_variable; - _lpython_return_variable = 5.50000000000000000e+00; + _lpython_return_variable = _lcompilers_abs_f64(- 5.50000000000000000e+00); return _lpython_return_variable; } From 1798e93ee058904c1ab8045af8ba2ce86769ae48 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Fri, 21 Apr 2023 15:47:43 +0530 Subject: [PATCH 2/2] Don't create _global_symbols if global_scope has no symbol --- src/libasr/pass/global_symbols.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libasr/pass/global_symbols.cpp b/src/libasr/pass/global_symbols.cpp index eca6ff833a..011c749b2d 100644 --- a/src/libasr/pass/global_symbols.cpp +++ b/src/libasr/pass/global_symbols.cpp @@ -17,6 +17,9 @@ namespace LCompilers { void pass_wrap_global_syms_into_module(Allocator &al, ASR::TranslationUnit_t &unit, const LCompilers::PassOptions &/*pass_options*/) { + if( unit.m_global_scope->get_scope().size() == 0 ) { + return ; + } Location loc = unit.base.base.loc; char *module_name = s2c(al, "_global_symbols"); SymbolTable *module_scope = al.make_new(unit.m_global_scope);