@@ -131,7 +131,7 @@ inline std::string get_intrinsic_name(int x) {
131131typedef ASR::expr_t * (*impl_function)(
132132 Allocator&, const Location &,
133133 SymbolTable*, Vec<ASR::ttype_t *>&, ASR::ttype_t *,
134- Vec<ASR::call_arg_t >&, int64_t , ASR:: expr_t * );
134+ Vec<ASR::call_arg_t >&, int64_t );
135135
136136typedef ASR::expr_t * (*eval_intrinsic_function)(
137137 Allocator&, const Location &, ASR::ttype_t *,
@@ -709,11 +709,7 @@ namespace UnaryIntrinsicFunction {
709709static inline ASR::expr_t * instantiate_functions (Allocator &al,
710710 const Location &loc, SymbolTable *scope, std::string new_name,
711711 ASR::ttype_t *arg_type, ASR::ttype_t *return_type,
712- Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ,
713- ASR::expr_t *value) {
714- if (value) {
715- return value;
716- }
712+ Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ) {
717713 std::string c_func_name;
718714 switch (arg_type->type ) {
719715 case ASR::ttypeType::Complex : {
@@ -738,7 +734,7 @@ static inline ASR::expr_t* instantiate_functions(Allocator &al,
738734 if (scope->get_symbol (new_name)) {
739735 ASR::symbol_t *s = scope->get_symbol (new_name);
740736 ASR::Function_t *f = ASR::down_cast<ASR::Function_t>(s);
741- return b.Call (s, new_args, expr_type (f->m_return_var ), value );
737+ return b.Call (s, new_args, expr_type (f->m_return_var ));
742738 }
743739 fill_func_arg (" x" , arg_type);
744740 auto result = declare (new_name, return_type, ReturnVar);
@@ -768,7 +764,7 @@ static inline ASR::expr_t* instantiate_functions(Allocator &al,
768764 ASR::symbol_t *new_symbol = make_Function_t (fn_name, fn_symtab, dep, args,
769765 body, result, Source, Implementation, nullptr );
770766 scope->add_symbol (fn_name, new_symbol);
771- return b.Call (new_symbol, new_args, return_type, value );
767+ return b.Call (new_symbol, new_args, return_type);
772768}
773769
774770static inline ASR::asr_t * create_UnaryFunction (Allocator& al, const Location& loc,
@@ -904,7 +900,9 @@ static inline ASR::asr_t* create_LogGamma(Allocator& al, const Location& loc,
904900 const std::function<void (const std::string &, const Location &)> err) {
905901 ASR::ttype_t *type = ASRUtils::expr_type (args[0 ]);
906902
907- if (!ASRUtils::is_real (*type)) {
903+ if (args.n != 1 ) {
904+ err (" Intrinsic `log_gamma` accepts exactly one argument" , loc);
905+ } else if (!ASRUtils::is_real (*type)) {
908906 err (" `x` argument of `log_gamma` must be real" ,
909907 args[0 ]->base .loc );
910908 }
@@ -917,12 +915,11 @@ static inline ASR::asr_t* create_LogGamma(Allocator& al, const Location& loc,
917915static inline ASR::expr_t * instantiate_LogGamma (Allocator &al,
918916 const Location &loc, SymbolTable *scope, Vec<ASR::ttype_t *>& arg_types,
919917 ASR::ttype_t *return_type, Vec<ASR::call_arg_t >& new_args,
920- int64_t overload_id,ASR::expr_t * compile_time_value) {
921- if (compile_time_value) return compile_time_value;
918+ int64_t overload_id) {
922919 LCOMPILERS_ASSERT (arg_types.size () == 1 );
923920 ASR::ttype_t * arg_type = arg_types[0 ];
924921 return UnaryIntrinsicFunction::instantiate_functions (al, loc, scope,
925- " log_gamma" , arg_type, return_type, new_args, overload_id, nullptr );
922+ " log_gamma" , arg_type, return_type, new_args, overload_id);
926923}
927924
928925} // namespace LogGamma
@@ -956,7 +953,9 @@ namespace X {
956953 const std::function<void (const std::string &, const Location &)> err) \
957954 { \
958955 ASR::ttype_t *type = ASRUtils::expr_type (args[0 ]); \
959- if (!ASRUtils::is_real (*type) && !ASRUtils::is_complex (*type)) { \
956+ if (args.n != 1 ) { \
957+ err (" Intrinsic `" #X" ` accepts exactly one argument" , loc); \
958+ } else if (!ASRUtils::is_real (*type) && !ASRUtils::is_complex (*type)) { \
960959 err (" `x` argument of `" #X" ` must be real or complex" , \
961960 args[0 ]->base .loc ); \
962961 } \
@@ -967,14 +966,10 @@ namespace X {
967966 static inline ASR::expr_t * instantiate_##X (Allocator &al, \
968967 const Location &loc, SymbolTable *scope, \
969968 Vec<ASR::ttype_t *>& arg_types, ASR::ttype_t *return_type, \
970- Vec<ASR::call_arg_t >& new_args,int64_t overload_id, \
971- ASR::expr_t * compile_time_value) { \
972- if (compile_time_value) return compile_time_value; \
973- LCOMPILERS_ASSERT (arg_types.size () == 1 ); \
969+ Vec<ASR::call_arg_t >& new_args,int64_t overload_id) { \
974970 ASR::ttype_t * arg_type = arg_types[0 ]; \
975971 return UnaryIntrinsicFunction::instantiate_functions (al, loc, scope, \
976- #lcompilers_name, arg_type, return_type, new_args, overload_id, \
977- nullptr ); \
972+ #lcompilers_name, arg_type, return_type, new_args, overload_id); \
978973 } \
979974} // namespace X
980975
@@ -1068,10 +1063,7 @@ namespace Abs {
10681063
10691064 static inline ASR::expr_t * instantiate_Abs (Allocator &al, const Location &loc,
10701065 SymbolTable *scope, Vec<ASR::ttype_t *>& arg_types, ASR::ttype_t *return_type,
1071- Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ , ASR::expr_t * compile_time_value) {
1072- if (compile_time_value) {
1073- return compile_time_value;
1074- }
1066+ Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ) {
10751067 std::string func_name = " _lcompilers_abs_" + type_to_str_python (arg_types[0 ]);
10761068 declare_basic_variables (func_name);
10771069 if (scope->get_symbol (func_name)) {
@@ -1238,11 +1230,7 @@ namespace Sign {
12381230
12391231 static inline ASR::expr_t * instantiate_Sign (Allocator &al, const Location &loc,
12401232 SymbolTable *scope, Vec<ASR::ttype_t *>& arg_types, ASR::ttype_t *return_type,
1241- Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ,
1242- ASR::expr_t * compile_time_value) {
1243- if (compile_time_value) {
1244- return compile_time_value;
1245- }
1233+ Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ) {
12461234 declare_basic_variables (" _lcompilers_sign_" + type_to_str_python (arg_types[0 ]));
12471235 fill_func_arg (" x" , arg_types[0 ]);
12481236 fill_func_arg (" y" , arg_types[0 ]);
@@ -1333,11 +1321,7 @@ namespace FMA {
13331321
13341322 static inline ASR::expr_t * instantiate_FMA (Allocator &al, const Location &loc,
13351323 SymbolTable *scope, Vec<ASR::ttype_t *>& arg_types, ASR::ttype_t *return_type,
1336- Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ,
1337- ASR::expr_t * compile_time_value) {
1338- if (compile_time_value) {
1339- return compile_time_value;
1340- }
1324+ Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ) {
13411325 declare_basic_variables (" _lcompilers_optimization_fma_" + type_to_str_python (arg_types[0 ]));
13421326 fill_func_arg (" a" , arg_types[0 ]);
13431327 fill_func_arg (" b" , arg_types[0 ]);
@@ -1880,10 +1864,7 @@ namespace Max {
18801864
18811865 static inline ASR::expr_t * instantiate_Max (Allocator &al, const Location &loc,
18821866 SymbolTable *scope, Vec<ASR::ttype_t *>& arg_types, ASR::ttype_t *return_type,
1883- Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ , ASR::expr_t * compile_time_value) {
1884- if (compile_time_value) {
1885- return compile_time_value;
1886- }
1867+ Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ) {
18871868 std::string func_name = " _lcompilers_max0_" + type_to_str_python (arg_types[0 ]);
18881869 std::string fn_name = scope->get_unique_name (func_name);
18891870 SymbolTable *fn_symtab = al.make_new <SymbolTable>(scope);
@@ -1995,10 +1976,7 @@ namespace Min {
19951976
19961977 static inline ASR::expr_t * instantiate_Min (Allocator &al, const Location &loc,
19971978 SymbolTable *scope, Vec<ASR::ttype_t *>& arg_types, ASR::ttype_t *return_type,
1998- Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ , ASR::expr_t * compile_time_value) {
1999- if (compile_time_value) {
2000- return compile_time_value;
2001- }
1979+ Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ) {
20021980 std::string func_name = " _lcompilers_min0_" + type_to_str_python (arg_types[0 ]);
20031981 std::string fn_name = scope->get_unique_name (func_name);
20041982 SymbolTable *fn_symtab = al.make_new <SymbolTable>(scope);
@@ -2130,11 +2108,7 @@ namespace Partition {
21302108 static inline ASR::expr_t *instantiate_Partition (Allocator &al,
21312109 const Location &loc, SymbolTable *scope,
21322110 Vec<ASR::ttype_t *>& /* arg_types*/ , ASR::ttype_t *return_type,
2133- Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ,
2134- ASR::expr_t * compile_time_value) {
2135- if (compile_time_value) {
2136- return compile_time_value;
2137- }
2111+ Vec<ASR::call_arg_t >& new_args, int64_t /* overload_id*/ ) {
21382112 // TODO: show runtime error for empty separator or pattern
21392113 declare_basic_variables (" _lpython_str_partition" );
21402114 fill_func_arg (" target_string" , character (-2 ));
0 commit comments