From 1b39b9e8e962da3dc0c0750495de4eeeda7f27fd Mon Sep 17 00:00:00 2001 From: Smit-create Date: Sat, 29 Jul 2023 16:54:24 +0530 Subject: [PATCH 1/2] Allow Const argument in jitting --- src/libasr/codegen/asr_to_c_cpp.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libasr/codegen/asr_to_c_cpp.h b/src/libasr/codegen/asr_to_c_cpp.h index ef718db8f6..48f0d8df94 100644 --- a/src/libasr/codegen/asr_to_c_cpp.h +++ b/src/libasr/codegen/asr_to_c_cpp.h @@ -694,6 +694,8 @@ R"(#include } } case ASR::ttypeType::Logical : { return "p"; + } case ASR::ttypeType::Const : { + return get_type_format(ASR::down_cast(type)->m_type); } case ASR::ttypeType::Array : { return "O"; } default: { From 8b983e2740cc0a4efe412d5ccb2db262646dc5f2 Mon Sep 17 00:00:00 2001 From: Smit-create Date: Sat, 29 Jul 2023 16:56:00 +0530 Subject: [PATCH 2/2] Add a test --- integration_tests/lpython_decorator_02.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/integration_tests/lpython_decorator_02.py b/integration_tests/lpython_decorator_02.py index 423243f7cd..31cb14c6ba 100644 --- a/integration_tests/lpython_decorator_02.py +++ b/integration_tests/lpython_decorator_02.py @@ -1,5 +1,5 @@ from numpy import array -from lpython import i32, i64, f64, lpython, TypeVar +from lpython import i32, i64, f64, lpython, TypeVar, Const n = TypeVar("n") @@ -17,6 +17,10 @@ def multiply_02(n: i32, x: i64[:], y: i64[:]) -> i64[n]: z[i] = x[i] * y[i] return z +@lpython +def const_arg_sum(x: Const[i32]) -> i32: + return 10 + x + def test_01(): size = 5 @@ -30,5 +34,6 @@ def test_01(): z = multiply_02(size, x, y) for i in range(size): assert z[i] == x[i] * y[i] + assert const_arg_sum(size) == size + 10 test_01()