@@ -226,51 +226,10 @@ static value_t fl_julia_scalar(fl_context_t *fl_ctx, value_t *args, uint32_t nar
226
226
227
227
static jl_value_t * scm_to_julia_ (fl_context_t * fl_ctx , value_t e , jl_module_t * mod );
228
228
229
- static value_t fl_julia_logmsg (fl_context_t * fl_ctx , value_t * args , uint32_t nargs )
230
- {
231
- int kwargs_len = (int )nargs - 6 ;
232
- if (nargs < 6 || kwargs_len % 2 != 0 ) {
233
- lerror (fl_ctx , fl_ctx -> ArgError , "julia-logmsg: bad argument list - expected "
234
- "level (symbol) group (symbol) id file line msg . kwargs" );
235
- }
236
- value_t arg_level = args [0 ];
237
- value_t arg_group = args [1 ];
238
- value_t arg_id = args [2 ];
239
- value_t arg_file = args [3 ];
240
- value_t arg_line = args [4 ];
241
- value_t arg_msg = args [5 ];
242
- value_t * arg_kwargs = args + 6 ;
243
- if (!isfixnum (arg_level ) || !issymbol (arg_group ) || !issymbol (arg_id ) ||
244
- !issymbol (arg_file ) || !isfixnum (arg_line ) || !fl_isstring (fl_ctx , arg_msg )) {
245
- lerror (fl_ctx , fl_ctx -> ArgError ,
246
- "julia-logmsg: Unexpected type in argument list" );
247
- }
248
-
249
- // Abuse scm_to_julia here to convert arguments. This is meant for `Expr`s
250
- // but should be good enough provided we're only passing simple numbers,
251
- // symbols and strings.
252
- jl_value_t * group = NULL , * id = NULL , * file = NULL , * line = NULL , * msg = NULL ;
253
- jl_array_t * kwargs = NULL ;
254
- JL_GC_PUSH6 (& group , & id , & file , & line , & msg , & kwargs );
255
- group = scm_to_julia (fl_ctx , arg_group , NULL );
256
- id = scm_to_julia (fl_ctx , arg_id , NULL );
257
- file = scm_to_julia (fl_ctx , arg_file , NULL );
258
- line = scm_to_julia (fl_ctx , arg_line , NULL );
259
- msg = scm_to_julia (fl_ctx , arg_msg , NULL );
260
- kwargs = jl_alloc_vec_any (kwargs_len );
261
- for (int i = 0 ; i < kwargs_len ; ++ i ) {
262
- jl_array_ptr_set (kwargs , i , scm_to_julia (fl_ctx , arg_kwargs [i ], NULL ));
263
- }
264
- jl_log (numval (arg_level ), NULL , group , id , file , line , (jl_value_t * )kwargs , msg );
265
- JL_GC_POP ();
266
- return fl_ctx -> T ;
267
- }
268
-
269
229
static const builtinspec_t julia_flisp_ast_ext [] = {
270
230
{ "defined-julia-global" , fl_defined_julia_global }, // TODO: can we kill this safepoint
271
231
{ "current-julia-module-counter" , fl_current_module_counter },
272
232
{ "julia-scalar?" , fl_julia_scalar }, // TODO: can we kill this safepoint? (from jl_isa)
273
- { "julia-logmsg" , fl_julia_logmsg }, // TODO: kill this safepoint
274
233
{ "julia-current-file" , fl_julia_current_file },
275
234
{ "julia-current-line" , fl_julia_current_line },
276
235
{ NULL , NULL }
@@ -299,7 +258,6 @@ static void jl_init_ast_ctx(jl_ast_context_t *ast_ctx) JL_NOTSAFEPOINT
299
258
ctx -> slot_sym = symbol (fl_ctx , "slot" );
300
259
ctx -> task = NULL ;
301
260
ctx -> module = NULL ;
302
- set (symbol (fl_ctx , "*depwarn-opt*" ), fixnum (jl_options .depwarn ));
303
261
set (symbol (fl_ctx , "*scopewarn-opt*" ), fixnum (jl_options .warn_scope ));
304
262
}
305
263
@@ -1282,7 +1240,8 @@ JL_DLLEXPORT jl_value_t *jl_expand_with_loc_warn(jl_value_t *expr, jl_module_t *
1282
1240
const char * file , int line )
1283
1241
{
1284
1242
JL_TIMING (LOWERING );
1285
- JL_GC_PUSH1 (& expr );
1243
+ jl_array_t * kwargs = NULL ;
1244
+ JL_GC_PUSH2 (& expr , & kwargs );
1286
1245
expr = jl_copy_ast (expr );
1287
1246
expr = jl_expand_macros (expr , inmodule , NULL , 0 , ~(size_t )0 , 1 );
1288
1247
jl_ast_context_t * ctx = jl_ast_ctx_enter ();
@@ -1294,6 +1253,34 @@ JL_DLLEXPORT jl_value_t *jl_expand_with_loc_warn(jl_value_t *expr, jl_module_t *
1294
1253
expr = scm_to_julia (fl_ctx , e , inmodule );
1295
1254
JL_AST_PRESERVE_POP (ctx , old_roots );
1296
1255
jl_ast_ctx_leave (ctx );
1256
+ jl_sym_t * warn_sym = jl_symbol ("warn" );
1257
+ if (jl_is_expr (expr ) && ((jl_expr_t * )expr )-> head == warn_sym ) {
1258
+ size_t nargs = jl_expr_nargs (expr );
1259
+ for (int i = 0 ; i < nargs - 1 ; i ++ ) {
1260
+ jl_value_t * warning = jl_exprarg (expr , i );
1261
+ size_t nargs = 0 ;
1262
+ if (jl_is_expr (warning ) && ((jl_expr_t * )warning )-> head == warn_sym )
1263
+ nargs = jl_expr_nargs (warning );
1264
+ int kwargs_len = (int )nargs - 6 ;
1265
+ if (nargs < 6 || kwargs_len % 2 != 0 ) {
1266
+ jl_error ("julia-logmsg: bad argument list - expected "
1267
+ ":warn level (symbol) group (symbol) id file line msg . kwargs" );
1268
+ }
1269
+ jl_value_t * level = jl_exprarg (warning , 0 );
1270
+ jl_value_t * group = jl_exprarg (warning , 1 );
1271
+ jl_value_t * id = jl_exprarg (warning , 2 );
1272
+ jl_value_t * file = jl_exprarg (warning , 3 );
1273
+ jl_value_t * line = jl_exprarg (warning , 4 );
1274
+ jl_value_t * msg = jl_exprarg (warning , 5 );
1275
+ kwargs = jl_alloc_vec_any (kwargs_len );
1276
+ for (int i = 0 ; i < kwargs_len ; ++ i ) {
1277
+ jl_array_ptr_set (kwargs , i , jl_exprarg (warning , i + 6 ));
1278
+ }
1279
+ JL_TYPECHK (logmsg , long , level );
1280
+ jl_log (jl_unbox_long (level ), NULL , group , id , file , line , (jl_value_t * )kwargs , msg );
1281
+ }
1282
+ expr = jl_exprarg (expr , nargs - 1 );
1283
+ }
1297
1284
JL_GC_POP ();
1298
1285
return expr ;
1299
1286
}
0 commit comments