@@ -131,7 +131,7 @@ inline std::string get_intrinsic_name(int x) {
131
131
typedef ASR::expr_t * (*impl_function)(
132
132
Allocator&, const Location &,
133
133
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 );
135
135
136
136
typedef ASR::expr_t * (*eval_intrinsic_function)(
137
137
Allocator&, const Location &, ASR::ttype_t *,
@@ -709,11 +709,7 @@ namespace UnaryIntrinsicFunction {
709
709
static inline ASR::expr_t * instantiate_functions (Allocator &al,
710
710
const Location &loc, SymbolTable *scope, std::string new_name,
711
711
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*/ ) {
717
713
std::string c_func_name;
718
714
switch (arg_type->type ) {
719
715
case ASR::ttypeType::Complex : {
@@ -738,7 +734,7 @@ static inline ASR::expr_t* instantiate_functions(Allocator &al,
738
734
if (scope->get_symbol (new_name)) {
739
735
ASR::symbol_t *s = scope->get_symbol (new_name);
740
736
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 ));
742
738
}
743
739
fill_func_arg (" x" , arg_type);
744
740
auto result = declare (new_name, return_type, ReturnVar);
@@ -768,7 +764,7 @@ static inline ASR::expr_t* instantiate_functions(Allocator &al,
768
764
ASR::symbol_t *new_symbol = make_Function_t (fn_name, fn_symtab, dep, args,
769
765
body, result, Source, Implementation, nullptr );
770
766
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);
772
768
}
773
769
774
770
static 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,
904
900
const std::function<void (const std::string &, const Location &)> err) {
905
901
ASR::ttype_t *type = ASRUtils::expr_type (args[0 ]);
906
902
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)) {
908
906
err (" `x` argument of `log_gamma` must be real" ,
909
907
args[0 ]->base .loc );
910
908
}
@@ -917,12 +915,11 @@ static inline ASR::asr_t* create_LogGamma(Allocator& al, const Location& loc,
917
915
static inline ASR::expr_t * instantiate_LogGamma (Allocator &al,
918
916
const Location &loc, SymbolTable *scope, Vec<ASR::ttype_t *>& arg_types,
919
917
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) {
922
919
LCOMPILERS_ASSERT (arg_types.size () == 1 );
923
920
ASR::ttype_t * arg_type = arg_types[0 ];
924
921
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);
926
923
}
927
924
928
925
} // namespace LogGamma
@@ -956,7 +953,9 @@ namespace X {
956
953
const std::function<void (const std::string &, const Location &)> err) \
957
954
{ \
958
955
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)) { \
960
959
err (" `x` argument of `" #X" ` must be real or complex" , \
961
960
args[0 ]->base .loc ); \
962
961
} \
@@ -967,14 +966,10 @@ namespace X {
967
966
static inline ASR::expr_t * instantiate_##X (Allocator &al, \
968
967
const Location &loc, SymbolTable *scope, \
969
968
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) { \
974
970
ASR::ttype_t * arg_type = arg_types[0 ]; \
975
971
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); \
978
973
} \
979
974
} // namespace X
980
975
@@ -1068,10 +1063,7 @@ namespace Abs {
1068
1063
1069
1064
static inline ASR::expr_t * instantiate_Abs (Allocator &al, const Location &loc,
1070
1065
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*/ ) {
1075
1067
std::string func_name = " _lcompilers_abs_" + type_to_str_python (arg_types[0 ]);
1076
1068
declare_basic_variables (func_name);
1077
1069
if (scope->get_symbol (func_name)) {
@@ -1238,11 +1230,7 @@ namespace Sign {
1238
1230
1239
1231
static inline ASR::expr_t * instantiate_Sign (Allocator &al, const Location &loc,
1240
1232
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*/ ) {
1246
1234
declare_basic_variables (" _lcompilers_sign_" + type_to_str_python (arg_types[0 ]));
1247
1235
fill_func_arg (" x" , arg_types[0 ]);
1248
1236
fill_func_arg (" y" , arg_types[0 ]);
@@ -1333,11 +1321,7 @@ namespace FMA {
1333
1321
1334
1322
static inline ASR::expr_t * instantiate_FMA (Allocator &al, const Location &loc,
1335
1323
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*/ ) {
1341
1325
declare_basic_variables (" _lcompilers_optimization_fma_" + type_to_str_python (arg_types[0 ]));
1342
1326
fill_func_arg (" a" , arg_types[0 ]);
1343
1327
fill_func_arg (" b" , arg_types[0 ]);
@@ -1880,10 +1864,7 @@ namespace Max {
1880
1864
1881
1865
static inline ASR::expr_t * instantiate_Max (Allocator &al, const Location &loc,
1882
1866
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*/ ) {
1887
1868
std::string func_name = " _lcompilers_max0_" + type_to_str_python (arg_types[0 ]);
1888
1869
std::string fn_name = scope->get_unique_name (func_name);
1889
1870
SymbolTable *fn_symtab = al.make_new <SymbolTable>(scope);
@@ -1995,10 +1976,7 @@ namespace Min {
1995
1976
1996
1977
static inline ASR::expr_t * instantiate_Min (Allocator &al, const Location &loc,
1997
1978
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*/ ) {
2002
1980
std::string func_name = " _lcompilers_min0_" + type_to_str_python (arg_types[0 ]);
2003
1981
std::string fn_name = scope->get_unique_name (func_name);
2004
1982
SymbolTable *fn_symtab = al.make_new <SymbolTable>(scope);
@@ -2130,11 +2108,7 @@ namespace Partition {
2130
2108
static inline ASR::expr_t *instantiate_Partition (Allocator &al,
2131
2109
const Location &loc, SymbolTable *scope,
2132
2110
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*/ ) {
2138
2112
// TODO: show runtime error for empty separator or pattern
2139
2113
declare_basic_variables (" _lpython_str_partition" );
2140
2114
fill_func_arg (" target_string" , character (-2 ));
0 commit comments