@@ -110,10 +110,10 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
110
110
std::string header = " symengine/cwrapper.h" ;
111
111
SymbolTable *fn_symtab = al.make_new <SymbolTable>(current_scope->parent );
112
112
113
- Vec<ASR::expr_t *> args; args.reserve (al, 1 );
114
- for (size_t i = 0 ; i < args_type. size (); i ++ ) {
115
- std::string arg_name = " x_0" + std::to_string (i+ 1 ) ;
116
- args.push_back (al, b.Variable (fn_symtab, arg_name, args_type[i] ,
113
+ Vec<ASR::expr_t *> args; args.reserve (al, 1 ); int i = 1 ;
114
+ for (auto &type: args_type) {
115
+ std::string arg_name = " x_0" + std::to_string (i); i++ ;
116
+ args.push_back (al, b.Variable (fn_symtab, arg_name, type ,
117
117
ASR::intentType::In, ASR::abiType::BindC, true ));
118
118
}
119
119
ASR::expr_t *return_var = nullptr ;
@@ -155,38 +155,11 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
155
155
}
156
156
157
157
ASR::expr_t *vecbasic_new (const Location& loc) {
158
- std::string fn_name = " vecbasic_new" ;
159
- symbolic_dependencies.push_back (fn_name);
160
- ASR::symbol_t *vecbasic_new_sym = current_scope->resolve_symbol (fn_name);
161
- if ( !vecbasic_new_sym ) {
162
- std::string header = " symengine/cwrapper.h" ;
163
- SymbolTable* fn_symtab = al.make_new <SymbolTable>(current_scope->parent );
164
-
165
- Vec<ASR::expr_t *> args;
166
- args.reserve (al, 1 );
167
- char *arg_name = s2c (al, " _lpython_return_variable" );
168
- ASR::symbol_t * arg1 = ASR::down_cast<ASR::symbol_t >(
169
- ASR::make_Variable_t (al, loc, fn_symtab, arg_name, nullptr , 0 ,
170
- ASR::intentType::ReturnVar, nullptr , nullptr ,
171
- ASR::storage_typeType::Default, ASRUtils::TYPE ((ASR::make_CPtr_t (al, loc))),
172
- nullptr , ASR::abiType::BindC, ASR::Public, ASR::presenceType::Required, false ));
173
- fn_symtab->add_symbol (arg_name, arg1);
174
-
175
- Vec<ASR::stmt_t *> body; body.reserve (al, 1 );
176
- Vec<char *> dep; dep.reserve (al, 1 );
177
- ASR::expr_t * return_var = ASRUtils::EXPR (ASR::make_Var_t (al, loc, arg1));
178
- vecbasic_new_sym = ASR::down_cast<ASR::symbol_t >(
179
- ASRUtils::make_Function_t_util (al, loc, fn_symtab, s2c (al, fn_name),
180
- dep.p , dep.n , args.p , args.n , body.p , body.n , return_var,
181
- ASR::abiType::BindC, ASR::accessType::Public,
182
- ASR::deftypeType::Interface, s2c (al, fn_name), false , false , false ,
183
- false , false , nullptr , 0 , false , false , false , s2c (al, header)));
184
- current_scope->parent ->add_symbol (s2c (al, fn_name), vecbasic_new_sym);
185
- }
158
+ ASR::symbol_t * vecbasic_new_sym = create_bindc_function (loc,
159
+ " vecbasic_new" , {}, ASRUtils::TYPE ((ASR::make_CPtr_t (al, loc))));
186
160
Vec<ASR::call_arg_t > call_args; call_args.reserve (al, 1 );
187
- return ASRUtils::EXPR (ASRUtils::make_FunctionCall_t_util (al, loc,
188
- vecbasic_new_sym, vecbasic_new_sym, call_args.p , call_args.n ,
189
- ASRUtils::TYPE (ASR::make_CPtr_t (al, loc)), nullptr , nullptr ));
161
+ return FunctionCall (loc, vecbasic_new_sym, {},
162
+ ASRUtils::TYPE (ASR::make_CPtr_t (al, loc)));
190
163
}
191
164
192
165
ASR::stmt_t * vecbasic_get (const Location& loc, ASR::expr_t *x, ASR::expr_t *y, ASR::expr_t *z) {
0 commit comments