@@ -67,6 +67,9 @@ package body LKQL.Builtin_Functions is
67
67
function Eval_Profile
68
68
(Ctx : Eval_Context; Args : Primitive_Array) return Primitive;
69
69
70
+ function Eval_Get_Symbols
71
+ (Ctx : Eval_Context; Args : Primitive_Array) return Primitive;
72
+
70
73
function Eval_Help
71
74
(Ctx : Eval_Context; Args : Primitive_Array) return Primitive;
72
75
@@ -356,6 +359,53 @@ package body LKQL.Builtin_Functions is
356
359
return Make_Unit_Primitive;
357
360
end Eval_Help ;
358
361
362
+ -- --------------------------
363
+ -- Eval_Get_Local_Symbols --
364
+ -- --------------------------
365
+
366
+ function Eval_Get_Symbols
367
+ (Ctx : Eval_Context; Args : Primitive_Array) return Primitive
368
+ is
369
+ procedure Get_Symbols_In_Frame
370
+ (C : Eval_Contexts.Environment_Access; Recurse : Boolean);
371
+
372
+ S : Symbol_Set;
373
+
374
+ procedure Get_Symbols_In_Frame
375
+ (C : Eval_Contexts.Environment_Access; Recurse : Boolean)
376
+ is
377
+ begin
378
+ if C = null then
379
+ return ;
380
+ end if ;
381
+ for I in Get_Env_Map (C).Iterate loop
382
+ S.Include (String_Value_Maps.Key (I));
383
+ end loop ;
384
+
385
+ if Recurse then
386
+ Get_Symbols_In_Frame (Get_Parent (C), True);
387
+ end if ;
388
+ end Get_Symbols_In_Frame ;
389
+
390
+ Pkg : constant Primitive := Args (1 );
391
+ Ret : constant Primitive := Make_Empty_List;
392
+ begin
393
+
394
+ if Booleanize (Pkg) then
395
+ Get_Symbols_In_Frame
396
+ (Eval_Contexts.Environment_Access (Pkg.Unchecked_Get.Namespace),
397
+ Recurse => False);
398
+ else
399
+ Get_Symbols_In_Frame (Ctx.Frames, Recurse => True);
400
+ end if ;
401
+
402
+ for El of S loop
403
+ Ret.Get.List_Val.Elements.Append (To_Primitive (El.all ));
404
+ end loop ;
405
+ return Ret;
406
+
407
+ end Eval_Get_Symbols ;
408
+
359
409
-- ---------------------
360
410
-- Builtin_Functions --
361
411
-- ---------------------
@@ -424,6 +474,13 @@ package body LKQL.Builtin_Functions is
424
474
Eval_Profile'Access ,
425
475
" Given any object, if it is a callable, return its profile as text" ),
426
476
477
+ Create
478
+ (" get_symbols" ,
479
+ (1 => Param (" package" , Kind_Namespace, Make_Unit_Primitive)),
480
+ Eval_Get_Symbols'Access ,
481
+ " Given a module, return the symbols stored in it. If given no module"
482
+ & " , return the local symbols" ),
483
+
427
484
Create
428
485
(" help" ,
429
486
(1 => Param (" obj" )),
0 commit comments