From b8ee78c8a2e226b0358e64915082384d27720771 Mon Sep 17 00:00:00 2001 From: Peter M Date: Sun, 10 Aug 2025 23:11:28 +0200 Subject: [PATCH 1/3] Script for updating priv/funcs.txt Generated from previous snippets: https://github.com/atomvm/exatomvm/commit/6eda00318a7490edd78f92e31bc92d1658b1c8c7 and https://github.com/atomvm/exatomvm/commit/0b6d98b73343aafc6b7fcb68260ca650cc96d3c0 The FuncsDiffAnalyzer is perhaps not needed beyond this PR, where sorting is enforced, but it's nice to have. Signed-off-by: Peter M --- priv/funcs.txt | 567 +++++++++++++++++++-------------- scripts/analyze_funcs_diff.exs | 83 +++++ scripts/update_all_funcs.exs | 113 +++++++ 3 files changed, 528 insertions(+), 235 deletions(-) create mode 100644 scripts/analyze_funcs_diff.exs create mode 100644 scripts/update_all_funcs.exs diff --git a/priv/funcs.txt b/priv/funcs.txt index 060235f..290c448 100644 --- a/priv/funcs.txt +++ b/priv/funcs.txt @@ -33,8 +33,8 @@ alisp_stdlib:numberp/1 alisp_stdlib:pidp/1 alisp_stdlib:print/1 alisp_stdlib:refp/1 -alisp_stdlib:remove-if/1 alisp_stdlib:remove-if-not/1 +alisp_stdlib:remove-if/1 alisp_stdlib:tuple/1 alisp_stdlib:tuplep/1 arepl:module_info/0 @@ -43,6 +43,7 @@ arepl:start/0 atomvm:add_avm_pack_binary/2 atomvm:add_avm_pack_file/2 atomvm:close_avm_pack/2 +atomvm:get_creation/0 atomvm:get_start_beam/1 atomvm:module_info/0 atomvm:module_info/1 @@ -64,6 +65,7 @@ atomvm:posix_write/2 atomvm:rand_bytes/1 atomvm:random/0 atomvm:read_priv/2 +atomvm:subprocess/4 avm_pubsub:handle_call/3 avm_pubsub:handle_info/2 avm_pubsub:init/1 @@ -91,19 +93,25 @@ binary:encode_hex/1 binary:encode_hex/2 binary:first/1 binary:last/1 +binary:match/2 +binary:match/3 binary:module_info/0 binary:module_info/1 binary:part/3 +binary:replace/3 +binary:replace/4 binary:split/2 binary:split/3 -calendar:datetime_to_gregorian_seconds/1 calendar:date_to_gregorian_days/1 calendar:date_to_gregorian_days/3 +calendar:datetime_to_gregorian_seconds/1 calendar:day_of_the_week/1 calendar:day_of_the_week/3 calendar:module_info/0 calendar:module_info/1 calendar:system_time_to_universal_time/2 +code:all_available/0 +code:all_loaded/0 code:ensure_loaded/1 code:load_abs/1 code:load_binary/3 @@ -123,6 +131,8 @@ crypto:hash/2 crypto:module_info/0 crypto:module_info/1 crypto:strong_rand_bytes/1 +elixir_env:to_caller/1 +elixir_erl_pass:no_parens_remote/2 emscripten:module_info/0 emscripten:module_info/1 emscripten:promise_reject/1 @@ -223,11 +233,20 @@ emscripten:unregister_touchend_callback/1 emscripten:unregister_touchmove_callback/1 emscripten:unregister_touchstart_callback/1 emscripten:unregister_wheel_callback/1 -erlang:-/1 +epmd:handle_call/3 +epmd:handle_cast/2 +epmd:handle_info/2 +epmd:init/1 +epmd:module_info/0 +epmd:module_info/1 +epmd:start_link/1 +epmd:terminate/2 erlang:!/2 erlang:*/2 erlang:++/2 erlang:+/2 +erlang:--/2 +erlang:-/1 erlang:-/2 erlang:/=/2 erlang:>>/2 +Elixir.Bitwise:MACRO-__using__/2 Elixir.Bitwise:^^^/2 -Elixir.Bitwise:|||/2 +Elixir.Bitwise:__info__/1 Elixir.Bitwise:band/2 Elixir.Bitwise:bnot/1 Elixir.Bitwise:bor/2 Elixir.Bitwise:bsl/2 Elixir.Bitwise:bsr/2 Elixir.Bitwise:bxor/2 -Elixir.Bitwise:__info__/1 -Elixir.Bitwise:MACRO-__using__/2 Elixir.Bitwise:module_info/0 Elixir.Bitwise:module_info/1 -Elixir.CaseClauseError:exception/1 +Elixir.Bitwise:|||/2 +Elixir.Bitwise:~~~/1 Elixir.CaseClauseError:__info__/1 +Elixir.CaseClauseError:__struct__/0 +Elixir.CaseClauseError:__struct__/1 +Elixir.CaseClauseError:exception/1 Elixir.CaseClauseError:message/1 Elixir.CaseClauseError:module_info/0 Elixir.CaseClauseError:module_info/1 -Elixir.CaseClauseError:__struct__/0 -Elixir.CaseClauseError:__struct__/1 +Elixir.Code:__info__/1 Elixir.Code:ensure_compiled/1 Elixir.Code:ensure_compiled?/1 -Elixir.Code:__info__/1 Elixir.Code:module_info/0 Elixir.Code:module_info/1 -Elixir.Collectable:behaviour_info/1 -Elixir.Collectable:impl_for!/1 -Elixir.Collectable:impl_for/1 -Elixir.Collectable:__info__/1 -Elixir.Collectable:into/1 Elixir.Collectable.List:__impl__/1 Elixir.Collectable.List:__info__/1 Elixir.Collectable.List:into/1 @@ -1175,24 +1241,30 @@ Elixir.Collectable.MapSet:__info__/1 Elixir.Collectable.MapSet:into/1 Elixir.Collectable.MapSet:module_info/0 Elixir.Collectable.MapSet:module_info/1 +Elixir.Collectable:__info__/1 +Elixir.Collectable:__protocol__/1 +Elixir.Collectable:behaviour_info/1 +Elixir.Collectable:impl_for!/1 +Elixir.Collectable:impl_for/1 +Elixir.Collectable:into/1 Elixir.Collectable:module_info/0 Elixir.Collectable:module_info/1 -Elixir.Collectable:__protocol__/1 -Elixir.CondClauseError:exception/1 Elixir.CondClauseError:__info__/1 +Elixir.CondClauseError:__struct__/0 +Elixir.CondClauseError:__struct__/1 +Elixir.CondClauseError:exception/1 Elixir.CondClauseError:message/1 Elixir.CondClauseError:module_info/0 Elixir.CondClauseError:module_info/1 -Elixir.CondClauseError:__struct__/0 -Elixir.CondClauseError:__struct__/1 +Elixir.Console:__info__/1 Elixir.Console:flush/0 Elixir.Console:flush/1 -Elixir.Console:__info__/1 Elixir.Console:module_info/0 Elixir.Console:module_info/1 Elixir.Console:print/1 Elixir.Console:puts/1 Elixir.Console:puts/2 +Elixir.Enum:__info__/1 Elixir.Enum:all?/1 Elixir.Enum:all?/2 Elixir.Enum:any?/1 @@ -1203,83 +1275,88 @@ Elixir.Enum:chunk_by/2 Elixir.Enum:chunk_while/4 Elixir.Enum:count/1 Elixir.Enum:each/2 -Elixir.Enumerable:behaviour_info/1 -Elixir.Enumerable:count/1 -Elixir.Enumerable:impl_for!/1 -Elixir.Enumerable:impl_for/1 -Elixir.Enumerable:__info__/1 -Elixir.Enumerable.List:count/1 +Elixir.Enum:filter/2 +Elixir.Enum:find/2 +Elixir.Enum:find/3 +Elixir.Enum:find_index/2 +Elixir.Enum:find_value/2 +Elixir.Enum:find_value/3 +Elixir.Enum:flat_map/2 +Elixir.Enum:into/2 +Elixir.Enum:into/3 +Elixir.Enum:join/1 +Elixir.Enum:join/2 +Elixir.Enum:map/2 +Elixir.Enum:map_join/2 +Elixir.Enum:map_join/3 +Elixir.Enum:member?/2 +Elixir.Enum:module_info/0 +Elixir.Enum:module_info/1 +Elixir.Enum:reduce/3 +Elixir.Enum:reject/2 +Elixir.Enum:reverse/1 +Elixir.Enum:slice/2 +Elixir.Enum:slice/3 +Elixir.Enum:split_with/2 +Elixir.Enum:to_list/1 Elixir.Enumerable.List:__impl__/1 Elixir.Enumerable.List:__info__/1 +Elixir.Enumerable.List:count/1 Elixir.Enumerable.List:member?/2 Elixir.Enumerable.List:module_info/0 Elixir.Enumerable.List:module_info/1 Elixir.Enumerable.List:reduce/3 Elixir.Enumerable.List:slice/1 Elixir.Enumerable.List:slice/4 -Elixir.Enumerable.Map:count/1 Elixir.Enumerable.Map:__impl__/1 Elixir.Enumerable.Map:__info__/1 +Elixir.Enumerable.Map:count/1 Elixir.Enumerable.Map:member?/2 Elixir.Enumerable.Map:module_info/0 Elixir.Enumerable.Map:module_info/1 Elixir.Enumerable.Map:reduce/3 -Elixir.Enumerable.MapSet:count/1 +Elixir.Enumerable.Map:slice/1 Elixir.Enumerable.MapSet:__impl__/1 Elixir.Enumerable.MapSet:__info__/1 +Elixir.Enumerable.MapSet:count/1 Elixir.Enumerable.MapSet:member?/2 Elixir.Enumerable.MapSet:module_info/0 Elixir.Enumerable.MapSet:module_info/1 Elixir.Enumerable.MapSet:reduce/3 Elixir.Enumerable.MapSet:slice/1 -Elixir.Enumerable.Map:slice/1 -Elixir.Enumerable:member?/2 -Elixir.Enumerable:module_info/0 -Elixir.Enumerable:module_info/1 -Elixir.Enumerable:__protocol__/1 -Elixir.Enumerable.Range:count/1 Elixir.Enumerable.Range:__impl__/1 Elixir.Enumerable.Range:__info__/1 +Elixir.Enumerable.Range:count/1 Elixir.Enumerable.Range:member?/2 Elixir.Enumerable.Range:module_info/0 Elixir.Enumerable.Range:module_info/1 Elixir.Enumerable.Range:reduce/3 Elixir.Enumerable.Range:slice/1 +Elixir.Enumerable:__info__/1 +Elixir.Enumerable:__protocol__/1 +Elixir.Enumerable:behaviour_info/1 +Elixir.Enumerable:count/1 +Elixir.Enumerable:impl_for!/1 +Elixir.Enumerable:impl_for/1 +Elixir.Enumerable:member?/2 +Elixir.Enumerable:module_info/0 +Elixir.Enumerable:module_info/1 Elixir.Enumerable:reduce/3 Elixir.Enumerable:slice/1 -Elixir.Enum:filter/2 -Elixir.Enum:find/2 -Elixir.Enum:find/3 -Elixir.Enum:find_index/2 -Elixir.Enum:find_value/2 -Elixir.Enum:find_value/3 -Elixir.Enum:flat_map/2 -Elixir.Enum:__info__/1 -Elixir.Enum:into/2 -Elixir.Enum:into/3 -Elixir.Enum:join/1 -Elixir.Enum:join/2 -Elixir.Enum:map/2 -Elixir.Enum:map_join/2 -Elixir.Enum:map_join/3 -Elixir.Enum:member?/2 -Elixir.Enum:module_info/0 -Elixir.Enum:module_info/1 -Elixir.Enum:reduce/3 -Elixir.Enum:reject/2 -Elixir.Enum:reverse/1 -Elixir.Enum:slice/2 -Elixir.Enum:slice/3 -Elixir.Enum:split_with/2 -Elixir.Enum:to_list/1 -Elixir.ErlangError:exception/1 Elixir.ErlangError:__info__/1 +Elixir.ErlangError:__struct__/0 +Elixir.ErlangError:__struct__/1 +Elixir.ErlangError:exception/1 Elixir.ErlangError:message/1 Elixir.ErlangError:module_info/0 Elixir.ErlangError:module_info/1 Elixir.ErlangError:normalize/2 -Elixir.ErlangError:__struct__/0 -Elixir.ErlangError:__struct__/1 +Elixir.Esp.ADC:acquire/4 +Elixir.Esp.ADC:deinit/1 +Elixir.Esp.ADC:init/0 +Elixir.Esp.ADC:release_channel/1 +Elixir.Esp.ADC:sample/3 +Elixir.Exception:__info__/1 Elixir.Exception:behaviour_info/1 Elixir.Exception:blame/3 Elixir.Exception:exception?/1 @@ -1295,24 +1372,26 @@ Elixir.Exception:format_mfa/3 Elixir.Exception:format_stacktrace/0 Elixir.Exception:format_stacktrace/1 Elixir.Exception:format_stacktrace_entry/1 -Elixir.Exception:__info__/1 Elixir.Exception:message/1 Elixir.Exception:module_info/0 Elixir.Exception:module_info/1 Elixir.Exception:normalize/2 Elixir.Exception:normalize/3 -Elixir.Esp.ADC:acquire/4 -Elixir.Esp.ADC:deinit/1 -Elixir.Esp.ADC:init/0 -Elixir.Esp.ADC:release_channel/1 -Elixir.Esp.ADC:sample/3 -Elixir.FunctionClauseError:exception/1 +Elixir.Function:__info__/1 +Elixir.Function:capture/3 +Elixir.Function:identity/1 +Elixir.Function:info/1 +Elixir.Function:info/2 +Elixir.Function:module_info/0 +Elixir.Function:module_info/1 Elixir.FunctionClauseError:__info__/1 +Elixir.FunctionClauseError:__struct__/0 +Elixir.FunctionClauseError:__struct__/1 +Elixir.FunctionClauseError:exception/1 Elixir.FunctionClauseError:message/1 Elixir.FunctionClauseError:module_info/0 Elixir.FunctionClauseError:module_info/1 -Elixir.FunctionClauseError:__struct__/0 -Elixir.FunctionClauseError:__struct__/1 +Elixir.GPIO:__info__/1 Elixir.GPIO:attach_interrupt/2 Elixir.GPIO:close/1 Elixir.GPIO:deep_sleep_hold_dis/0 @@ -1323,7 +1402,6 @@ Elixir.GPIO:digital_read/1 Elixir.GPIO:digital_write/2 Elixir.GPIO:hold_dis/1 Elixir.GPIO:hold_en/1 -Elixir.GPIO:__info__/1 Elixir.GPIO:init/1 Elixir.GPIO:module_info/0 Elixir.GPIO:module_info/1 @@ -1336,10 +1414,10 @@ Elixir.GPIO:set_level/3 Elixir.GPIO:set_pin_mode/2 Elixir.GPIO:set_pin_pull/2 Elixir.GPIO:stop/0 +Elixir.I2C:__info__/1 Elixir.I2C:begin_transmission/2 Elixir.I2C:close/1 Elixir.I2C:end_transmission/1 -Elixir.I2C:__info__/1 Elixir.I2C:module_info/0 Elixir.I2C:module_info/1 Elixir.I2C:open/1 @@ -1349,11 +1427,18 @@ Elixir.I2C:write_byte/2 Elixir.I2C:write_bytes/2 Elixir.I2C:write_bytes/3 Elixir.I2C:write_bytes/4 -Elixir.Integer:floor_div/2 -Elixir.Integer:gcd/2 -Elixir.Integer:__info__/1 +Elixir.IO:__info__/1 +Elixir.IO:chardata_to_string/1 +Elixir.IO:inspect/1 +Elixir.IO:iodata_to_binary/1 +Elixir.IO:module_info/0 +Elixir.IO:module_info/1 +Elixir.IO:puts/1 Elixir.Integer:MACRO-is_even/2 Elixir.Integer:MACRO-is_odd/2 +Elixir.Integer:__info__/1 +Elixir.Integer:floor_div/2 +Elixir.Integer:gcd/2 Elixir.Integer:mod/2 Elixir.Integer:module_info/0 Elixir.Integer:module_info/1 @@ -1361,16 +1446,9 @@ Elixir.Integer:to_charlist/1 Elixir.Integer:to_charlist/2 Elixir.Integer:to_string/1 Elixir.Integer:to_string/2 -Elixir.IO:chardata_to_string/1 -Elixir.IO:__info__/1 -Elixir.IO:inspect/1 -Elixir.IO:iodata_to_binary/1 -Elixir.IO:module_info/0 -Elixir.IO:module_info/1 -Elixir.IO:puts/1 +Elixir.Kernel:__info__/1 Elixir.Kernel:abs/1 Elixir.Kernel:div/2 -Elixir.Kernel:__info__/1 Elixir.Kernel:inspect/1 Elixir.Kernel:inspect/2 Elixir.Kernel:max/2 @@ -1379,18 +1457,19 @@ Elixir.Kernel:module_info/0 Elixir.Kernel:module_info/1 Elixir.Kernel:rem/2 Elixir.Kernel:struct!/1 -Elixir.Kernel:struct/1 Elixir.Kernel:struct!/2 +Elixir.Kernel:struct/1 Elixir.Kernel:struct/2 +Elixir.KeyError:__info__/1 +Elixir.KeyError:__struct__/0 +Elixir.KeyError:__struct__/1 Elixir.KeyError:blame/2 Elixir.KeyError:exception/1 -Elixir.KeyError:__info__/1 Elixir.KeyError:message/1 Elixir.KeyError:message/2 Elixir.KeyError:module_info/0 Elixir.KeyError:module_info/1 -Elixir.KeyError:__struct__/0 -Elixir.KeyError:__struct__/1 +Elixir.Keyword:__info__/1 Elixir.Keyword:delete/2 Elixir.Keyword:fetch!/2 Elixir.Keyword:fetch/2 @@ -1398,7 +1477,6 @@ Elixir.Keyword:get/2 Elixir.Keyword:get/3 Elixir.Keyword:get_lazy/3 Elixir.Keyword:has_key?/2 -Elixir.Keyword:__info__/1 Elixir.Keyword:keyword?/1 Elixir.Keyword:merge/2 Elixir.Keyword:module_info/0 @@ -1409,6 +1487,7 @@ Elixir.Keyword:pop/3 Elixir.Keyword:put/3 Elixir.Keyword:split/2 Elixir.Keyword:take/2 +Elixir.LEDC:__info__/1 Elixir.LEDC:channel_config/1 Elixir.LEDC:fade_func_install/1 Elixir.LEDC:fade_func_uninstall/0 @@ -1418,7 +1497,6 @@ Elixir.LEDC:fade_wait_done/0 Elixir.LEDC:get_duty/2 Elixir.LEDC:get_freq/2 Elixir.LEDC:high_speed_mode/0 -Elixir.LEDC:__info__/1 Elixir.LEDC:low_speed_mode/0 Elixir.LEDC:module_info/0 Elixir.LEDC:module_info/1 @@ -1429,14 +1507,11 @@ Elixir.LEDC:set_freq/3 Elixir.LEDC:stop/3 Elixir.LEDC:timer_config/1 Elixir.LEDC:update_duty/2 -Elixir.List:ascii_printable?/1 -Elixir.List:ascii_printable?/2 Elixir.List.Chars.Atom:__impl__/1 Elixir.List.Chars.Atom:__info__/1 Elixir.List.Chars.Atom:module_info/0 Elixir.List.Chars.Atom:module_info/1 Elixir.List.Chars.Atom:to_charlist/1 -Elixir.List.Chars:behaviour_info/1 Elixir.List.Chars.BitString:__impl__/1 Elixir.List.Chars.BitString:__info__/1 Elixir.List.Chars.BitString:module_info/0 @@ -1447,9 +1522,6 @@ Elixir.List.Chars.Float:__info__/1 Elixir.List.Chars.Float:module_info/0 Elixir.List.Chars.Float:module_info/1 Elixir.List.Chars.Float:to_charlist/1 -Elixir.List.Chars:impl_for!/1 -Elixir.List.Chars:impl_for/1 -Elixir.List.Chars:__info__/1 Elixir.List.Chars.Integer:__impl__/1 Elixir.List.Chars.Integer:__info__/1 Elixir.List.Chars.Integer:module_info/0 @@ -1460,10 +1532,17 @@ Elixir.List.Chars.List:__info__/1 Elixir.List.Chars.List:module_info/0 Elixir.List.Chars.List:module_info/1 Elixir.List.Chars.List:to_charlist/1 +Elixir.List.Chars:__info__/1 +Elixir.List.Chars:__protocol__/1 +Elixir.List.Chars:behaviour_info/1 +Elixir.List.Chars:impl_for!/1 +Elixir.List.Chars:impl_for/1 Elixir.List.Chars:module_info/0 Elixir.List.Chars:module_info/1 -Elixir.List.Chars:__protocol__/1 Elixir.List.Chars:to_charlist/1 +Elixir.List:__info__/1 +Elixir.List:ascii_printable?/1 +Elixir.List:ascii_printable?/2 Elixir.List:delete/2 Elixir.List:duplicate/2 Elixir.List:first/1 @@ -1471,7 +1550,6 @@ Elixir.List:flatten/1 Elixir.List:foldl/3 Elixir.List:foldr/3 Elixir.List:improper?/1 -Elixir.List:__info__/1 Elixir.List:insert_at/3 Elixir.List:keydelete/3 Elixir.List:keyfind/3 @@ -1491,6 +1569,7 @@ Elixir.List:to_string/1 Elixir.List:to_tuple/1 Elixir.List:update_at/3 Elixir.List:wrap/1 +Elixir.Map:__info__/1 Elixir.Map:delete/2 Elixir.Map:equal?/2 Elixir.Map:fetch!/2 @@ -1499,7 +1578,6 @@ Elixir.Map:from_struct/1 Elixir.Map:get/2 Elixir.Map:get/3 Elixir.Map:has_key?/2 -Elixir.Map:__info__/1 Elixir.Map:merge/2 Elixir.Map:module_info/0 Elixir.Map:module_info/1 @@ -1507,12 +1585,14 @@ Elixir.Map:new/1 Elixir.Map:put/3 Elixir.Map:replace!/3 Elixir.Map:replace/3 +Elixir.MapSet:__info__/1 +Elixir.MapSet:__struct__/0 +Elixir.MapSet:__struct__/1 Elixir.MapSet:delete/2 Elixir.MapSet:difference/2 Elixir.MapSet:disjoint?/2 Elixir.MapSet:equal?/2 Elixir.MapSet:filter/2 -Elixir.MapSet:__info__/1 Elixir.MapSet:intersection/2 Elixir.MapSet:member?/2 Elixir.MapSet:module_info/0 @@ -1524,30 +1604,29 @@ Elixir.MapSet:put/2 Elixir.MapSet:reject/2 Elixir.MapSet:size/1 Elixir.MapSet:split_with/2 -Elixir.MapSet:__struct__/0 -Elixir.MapSet:__struct__/1 Elixir.MapSet:subset?/2 Elixir.MapSet:symmetric_difference/2 Elixir.MapSet:to_list/1 Elixir.MapSet:union/2 -Elixir.MatchError:exception/1 Elixir.MatchError:__info__/1 +Elixir.MatchError:__struct__/0 +Elixir.MatchError:__struct__/1 +Elixir.MatchError:exception/1 Elixir.MatchError:message/1 Elixir.MatchError:module_info/0 Elixir.MatchError:module_info/1 -Elixir.MatchError:__struct__/0 -Elixir.MatchError:__struct__/1 -Elixir.Module:concat/2 Elixir.Module:__info__/1 +Elixir.Module:concat/2 Elixir.Module:module_info/0 Elixir.Module:module_info/1 +Elixir.Process:__info__/1 Elixir.Process:alive?/1 Elixir.Process:cancel_timer/1 Elixir.Process:flag/2 Elixir.Process:flag/3 -Elixir.Process:__info__/1 Elixir.Process:info/1 Elixir.Process:info/2 +Elixir.Process:link/1 Elixir.Process:list/0 Elixir.Process:module_info/0 Elixir.Process:module_info/1 @@ -1558,35 +1637,54 @@ Elixir.Process:send_after/4 Elixir.Process:sleep/1 Elixir.Process:spawn/2 Elixir.Process:spawn/4 +Elixir.Process:unlink/1 Elixir.Process:unregister/1 Elixir.Process:whereis/1 -Elixir.Protocol.UndefinedError:exception/1 Elixir.Protocol.UndefinedError:__info__/1 +Elixir.Protocol.UndefinedError:__struct__/0 +Elixir.Protocol.UndefinedError:__struct__/1 +Elixir.Protocol.UndefinedError:exception/1 Elixir.Protocol.UndefinedError:message/1 Elixir.Protocol.UndefinedError:module_info/0 Elixir.Protocol.UndefinedError:module_info/1 -Elixir.Protocol.UndefinedError:__struct__/0 -Elixir.Protocol.UndefinedError:__struct__/1 -Elixir.Range:disjoint?/2 +Elixir.Protocol:MACRO-def/2 +Elixir.Protocol:MACRO-derive/3 +Elixir.Protocol:MACRO-derive/4 +Elixir.Protocol:__before_compile__/1 +Elixir.Protocol:__concat__/2 +Elixir.Protocol:__derive__/3 +Elixir.Protocol:__impl__!/3 +Elixir.Protocol:__impl__/4 +Elixir.Protocol:__info__/1 +Elixir.Protocol:__protocol__/2 +Elixir.Protocol:assert_impl!/2 +Elixir.Protocol:assert_protocol!/1 +Elixir.Protocol:behaviour_info/1 +Elixir.Protocol:consolidate/2 +Elixir.Protocol:consolidated?/1 +Elixir.Protocol:extract_impls/2 +Elixir.Protocol:extract_protocols/1 +Elixir.Protocol:module_info/0 +Elixir.Protocol:module_info/1 Elixir.Range:__info__/1 +Elixir.Range:__struct__/0 +Elixir.Range:__struct__/1 +Elixir.Range:disjoint?/2 Elixir.Range:module_info/0 Elixir.Range:module_info/1 Elixir.Range:new/2 -Elixir.Range:__struct__/0 -Elixir.Range:__struct__/1 -Elixir.RuntimeError:exception/1 Elixir.RuntimeError:__info__/1 +Elixir.RuntimeError:__struct__/0 +Elixir.RuntimeError:__struct__/1 +Elixir.RuntimeError:exception/1 Elixir.RuntimeError:message/1 Elixir.RuntimeError:module_info/0 Elixir.RuntimeError:module_info/1 -Elixir.RuntimeError:__struct__/0 -Elixir.RuntimeError:__struct__/1 Elixir.String.Chars.Atom:__impl__/1 Elixir.String.Chars.Atom:__info__/1 Elixir.String.Chars.Atom:module_info/0 Elixir.String.Chars.Atom:module_info/1 Elixir.String.Chars.Atom:to_string/1 -Elixir.String.Chars:behaviour_info/1 Elixir.String.Chars.BitString:__impl__/1 Elixir.String.Chars.BitString:__info__/1 Elixir.String.Chars.BitString:module_info/0 @@ -1597,9 +1695,6 @@ Elixir.String.Chars.Float:__info__/1 Elixir.String.Chars.Float:module_info/0 Elixir.String.Chars.Float:module_info/1 Elixir.String.Chars.Float:to_string/1 -Elixir.String.Chars:impl_for!/1 -Elixir.String.Chars:impl_for/1 -Elixir.String.Chars:__info__/1 Elixir.String.Chars.Integer:__impl__/1 Elixir.String.Chars.Integer:__info__/1 Elixir.String.Chars.Integer:module_info/0 @@ -1610,50 +1705,52 @@ Elixir.String.Chars.List:__info__/1 Elixir.String.Chars.List:module_info/0 Elixir.String.Chars.List:module_info/1 Elixir.String.Chars.List:to_string/1 +Elixir.String.Chars:__info__/1 +Elixir.String.Chars:__protocol__/1 +Elixir.String.Chars:behaviour_info/1 +Elixir.String.Chars:impl_for!/1 +Elixir.String.Chars:impl_for/1 Elixir.String.Chars:module_info/0 Elixir.String.Chars:module_info/1 -Elixir.String.Chars:__protocol__/1 Elixir.String.Chars:to_string/1 Elixir.System:__info__/1 -Elixir.SystemLimitError:exception/1 -Elixir.SystemLimitError:__info__/1 -Elixir.SystemLimitError:message/1 -Elixir.SystemLimitError:module_info/0 -Elixir.SystemLimitError:module_info/1 -Elixir.SystemLimitError:__struct__/0 -Elixir.SystemLimitError:__struct__/1 Elixir.System:module_info/0 Elixir.System:module_info/1 Elixir.System:monotonic_time/1 Elixir.System:system_time/1 -Elixir.TryClauseError:exception/1 +Elixir.SystemLimitError:__info__/1 +Elixir.SystemLimitError:__struct__/0 +Elixir.SystemLimitError:__struct__/1 +Elixir.SystemLimitError:exception/1 +Elixir.SystemLimitError:message/1 +Elixir.SystemLimitError:module_info/0 +Elixir.SystemLimitError:module_info/1 Elixir.TryClauseError:__info__/1 +Elixir.TryClauseError:__struct__/0 +Elixir.TryClauseError:__struct__/1 +Elixir.TryClauseError:exception/1 Elixir.TryClauseError:message/1 Elixir.TryClauseError:module_info/0 Elixir.TryClauseError:module_info/1 -Elixir.TryClauseError:__struct__/0 -Elixir.TryClauseError:__struct__/1 +Elixir.Tuple:__info__/1 Elixir.Tuple:delete_at/2 Elixir.Tuple:duplicate/2 -Elixir.Tuple:__info__/1 Elixir.Tuple:insert_at/3 Elixir.Tuple:module_info/0 Elixir.Tuple:module_info/1 Elixir.Tuple:to_list/1 +Elixir.UndefinedFunctionError:__info__/1 +Elixir.UndefinedFunctionError:__struct__/0 +Elixir.UndefinedFunctionError:__struct__/1 Elixir.UndefinedFunctionError:blame/2 Elixir.UndefinedFunctionError:exception/1 -Elixir.UndefinedFunctionError:__info__/1 Elixir.UndefinedFunctionError:message/1 Elixir.UndefinedFunctionError:module_info/0 Elixir.UndefinedFunctionError:module_info/1 -Elixir.UndefinedFunctionError:__struct__/0 -Elixir.UndefinedFunctionError:__struct__/1 -Elixir.WithClauseError:exception/1 Elixir.WithClauseError:__info__/1 +Elixir.WithClauseError:__struct__/0 +Elixir.WithClauseError:__struct__/1 +Elixir.WithClauseError:exception/1 Elixir.WithClauseError:message/1 Elixir.WithClauseError:module_info/0 Elixir.WithClauseError:module_info/1 -Elixir.WithClauseError:__struct__/0 -Elixir.WithClauseError:__struct__/1 -elixir_env:to_caller/1 -elixir_erl_pass:no_parens_remote/2 diff --git a/scripts/analyze_funcs_diff.exs b/scripts/analyze_funcs_diff.exs new file mode 100644 index 0000000..6f52657 --- /dev/null +++ b/scripts/analyze_funcs_diff.exs @@ -0,0 +1,83 @@ +#!/usr/bin/env elixir + +defmodule FuncsDiffAnalyzer do + @moduledoc """ + Analyzes git diff output for priv/funcs.txt to identify actual content changes. + + This script distinguishes between functions that are genuinely added/removed + versus functions that are simply reordered due to sorting changes. + It provides a mathematical consistency check between git diff statistics + and actual content changes. + """ + + @funcs_txt_path "priv/funcs.txt" + def run do + case System.cmd("git", ["diff", @funcs_txt_path], stderr_to_stdout: true) do + {output, 0} when output != "" -> output |> parse_and_analyze() |> display_results() + {_, 0} -> IO.puts("\nNo changes detected") + {error, _} -> IO.puts("Error: #{error}") + end + end + + defp parse_and_analyze(diff_output) do + {added, removed} = + diff_output + |> String.split("\n") + |> Enum.reduce({[], []}, fn + "+" <> line, {adds, removes} -> + if String.starts_with?(line, "++"), do: {adds, removes}, else: {[line | adds], removes} + + "-" <> line, {adds, removes} -> + if String.starts_with?(line, "--"), do: {adds, removes}, else: {adds, [line | removes]} + + _, acc -> + acc + end) + + added_set = MapSet.new(added) + removed_set = MapSet.new(removed) + reordered = MapSet.intersection(added_set, removed_set) + + {MapSet.difference(added_set, reordered) |> Enum.sort(), + MapSet.difference(removed_set, reordered) |> Enum.sort(), length(added), length(removed)} + end + + defp display_results({actual_added, actual_removed, total_added, total_removed}) do + git_net = total_added - total_removed + content_net = length(actual_added) - length(actual_removed) + + IO.puts("\nGit diff: +#{total_added} -#{total_removed} = #{git_net} net lines") + + IO.puts( + "Content: +#{length(actual_added)} -#{length(actual_removed)} = #{content_net} net functions" + ) + + IO.puts( + "Math check: #{if git_net == content_net, do: "āœ… CONSISTENT", else: "āŒ INCONSISTENT"}" + ) + + case {actual_added, actual_removed} do + {[], []} -> + IO.puts("\nšŸ”„ All changes are due to reordering") + + {funcs, []} -> + show_functions("šŸ“ˆ NEW", funcs) + + {[], funcs} -> + show_functions("šŸ“‰ REMOVED", funcs) + + {new_funcs, old_funcs} -> + [show_functions("šŸ“ˆ NEW", new_funcs), show_functions("šŸ“‰ REMOVED", old_funcs)] + end + end + + defp show_functions(label, funcs) do + IO.puts("\n#{label} FUNCTIONS (#{length(funcs)}):") + + funcs + |> Enum.each(&IO.puts(" #{if String.contains?(label, "NEW"), do: "+", else: "-"} #{&1}")) + end +end + +# Run the analysis +#FuncsDiffAnalyzer.run() diff --git a/scripts/update_all_funcs.exs b/scripts/update_all_funcs.exs new file mode 100644 index 0000000..64d300e --- /dev/null +++ b/scripts/update_all_funcs.exs @@ -0,0 +1,113 @@ +#!/usr/bin/env elixir + +Code.require_file("analyze_funcs_diff.exs", __DIR__) +defmodule AllFuncsUpdater do + @moduledoc """ + Script assumes that AtomVM is in same parent directory as ExAtomVM and that + AtomVM has been built in the AtomVM/build directory. + + run using 'elixir scripts/update_all_funcs.exs' in project root. + + Updates priv/funcs.txt with all available functions from AtomVM sources. + + This script extracts functions from three sources: + 1. NIFs from nifs.gperf file + 2. Erlang beam files from eavmlib + 3. Elixir beam files from exavmlib + + Functions ending with '_nif' are filtered out as they are internal + implementation details. The final list is sorted with Erlang functions + first, followed by Elixir functions. + """ + @nifs_gperf_path "../AtomVM/src/libAtomVM/nifs.gperf" + @erlang_beam_path "../AtomVM/build/libs/eavmlib/src/beams" + @elixir_beam_path "../AtomVM/build/libs/exavmlib/lib/beams" + @funcs_txt_path "priv/funcs.txt" + + def run do + IO.puts("Updating #{@funcs_txt_path}...") + + try do + nifs = extract_nifs() + beams = extract_beams() + + all_funcs = (read_current() ++ nifs ++ beams) + |> Enum.uniq() + |> sort_erlang_first() + + File.write!(@funcs_txt_path, Enum.join(all_funcs, "\n") <> "\n") + IO.puts("Total: #{length(all_funcs)} (nifs: #{length(nifs)}, beams: #{length(beams)})") + rescue + e in File.Error -> + IO.puts("File error: #{e.reason} - #{e.path}") + System.halt(1) + e -> + IO.puts("Unexpected error: #{inspect(e)}") + System.halt(1) + end + end + + defp read_current do + if File.exists?(@funcs_txt_path) do + @funcs_txt_path + |> File.read!() + |> String.split("\n", trim: true) + |> Enum.reject(&String.contains?(&1, "_nif/")) + else + [] + end + end + + defp extract_nifs do + path = @nifs_gperf_path + + if File.exists?(path) do + path + |> File.stream!() + |> Stream.filter(&(String.contains?(&1, ":") and Regex.match?(~r/\/[0-9]/, &1))) + |> Stream.map(&(&1 |> String.split(",", parts: 2) |> hd() |> String.trim())) + |> Stream.reject(&(String.contains?(&1, "_nif/") or &1 == "")) + |> Enum.to_list() + else + [] + end + end + + defp extract_beams do + [@erlang_beam_path, @elixir_beam_path] |> Enum.flat_map(&extract_from_dir/1) |> Enum.uniq() + end + + defp extract_from_dir(path) do + if File.exists?(path) do + path + |> File.ls!() + |> Enum.filter(&String.ends_with?(&1, ".beam")) + |> Enum.flat_map(&extract_from_beam(Path.join(path, &1))) + else + [] + end + end + + defp extract_from_beam(beam_path) do + case :beam_lib.chunks(String.to_charlist(beam_path), [:exports]) do + {:ok, {module, [{:exports, exports}]}} -> + module_name = Atom.to_string(module) + exports |> Enum.map(fn {f, a} -> "#{module_name}:#{f}/#{a}" end) |> Enum.reject(&String.contains?(&1, "_nif/")) + {:error, :beam_lib, {:file_error, _, reason}} -> + IO.puts("Warning: Could not read beam file #{beam_path}: #{reason}") + [] + _ -> + IO.puts("Warning: Unexpected format in beam file #{beam_path}") + [] + end + end + + defp sort_erlang_first(funcs) do + {elixir, erlang} = Enum.split_with(funcs, &String.starts_with?(&1, "Elixir.")) + Enum.sort(erlang) ++ Enum.sort(elixir) + end +end + +# Run the script +AllFuncsUpdater.run() +FuncsDiffAnalyzer.run() From 02403601db2a0aa48ca64445d696bdf608b780fb Mon Sep 17 00:00:00 2001 From: Peter M Date: Mon, 11 Aug 2025 23:05:05 +0200 Subject: [PATCH 2/3] Add estdlib funcs Signed-off-by: Peter M --- priv/funcs.txt | 144 +++++++++++++++++++++++++++++++++++ scripts/update_all_funcs.exs | 3 +- 2 files changed, 146 insertions(+), 1 deletion(-) diff --git a/priv/funcs.txt b/priv/funcs.txt index 290c448..6acdf1d 100644 --- a/priv/funcs.txt +++ b/priv/funcs.txt @@ -37,6 +37,10 @@ alisp_stdlib:remove-if-not/1 alisp_stdlib:remove-if/1 alisp_stdlib:tuple/1 alisp_stdlib:tuplep/1 +application:get_env/2 +application:get_env/3 +application:module_info/0 +application:module_info/1 arepl:module_info/0 arepl:module_info/1 arepl:start/0 @@ -113,10 +117,12 @@ calendar:system_time_to_universal_time/2 code:all_available/0 code:all_loaded/0 code:ensure_loaded/1 +code:is_loaded/1 code:load_abs/1 code:load_binary/3 code:module_info/0 code:module_info/1 +code:which/1 console:flush/0 console:flush/1 console:module_info/0 @@ -131,6 +137,16 @@ crypto:hash/2 crypto:module_info/0 crypto:module_info/1 crypto:strong_rand_bytes/1 +dist_util:cancel_timer/1 +dist_util:handshake_other_started/1 +dist_util:handshake_we_started/1 +dist_util:module_info/0 +dist_util:module_info/1 +dist_util:net_ticker_spawn_options/0 +dist_util:reset_timer/1 +dist_util:shutdown/3 +dist_util:shutdown/4 +dist_util:start_timer/1 elixir_env:to_caller/1 elixir_erl_pass:no_parens_remote/2 emscripten:module_info/0 @@ -241,6 +257,19 @@ epmd:module_info/0 epmd:module_info/1 epmd:start_link/1 epmd:terminate/2 +erl_epmd:code_change/3 +erl_epmd:handle_call/3 +erl_epmd:handle_cast/2 +erl_epmd:handle_info/2 +erl_epmd:init/1 +erl_epmd:module_info/0 +erl_epmd:module_info/1 +erl_epmd:names/1 +erl_epmd:port_please/2 +erl_epmd:register_node/2 +erl_epmd:start_link/0 +erl_epmd:stop/0 +erl_epmd:terminate/2 erlang:!/2 erlang:*/2 erlang:++/2 @@ -309,6 +338,7 @@ erlang:floor/1 erlang:fmul/2 erlang:fnegate/1 erlang:fsub/2 +erlang:fun_info/1 erlang:fun_info/2 erlang:fun_to_list/1 erlang:function_exported/3 @@ -316,6 +346,8 @@ erlang:garbage_collect/0 erlang:garbage_collect/1 erlang:get/0 erlang:get/1 +erlang:get_cookie/0 +erlang:get_cookie/1 erlang:get_module_info/1 erlang:get_module_info/2 erlang:group_leader/0 @@ -328,6 +360,7 @@ erlang:integer_to_list/1 erlang:integer_to_list/2 erlang:iolist_size/1 erlang:iolist_to_binary/1 +erlang:is_alive/0 erlang:is_atom/1 erlang:is_binary/1 erlang:is_bitstring/1 @@ -341,6 +374,7 @@ erlang:is_map_key/2 erlang:is_number/1 erlang:is_pid/1 erlang:is_process_alive/1 +erlang:is_record/2 erlang:is_reference/1 erlang:is_tuple/1 erlang:length/1 @@ -388,6 +422,8 @@ erlang:round/1 erlang:self/0 erlang:send/2 erlang:send_after/3 +erlang:set_cookie/1 +erlang:set_cookie/2 erlang:setelement/3 erlang:setnode/2 erlang:setnode/3 @@ -396,6 +432,8 @@ erlang:spawn/1 erlang:spawn/3 erlang:spawn_link/1 erlang:spawn_link/3 +erlang:spawn_monitor/1 +erlang:spawn_monitor/3 erlang:spawn_opt/2 erlang:spawn_opt/4 erlang:split_binary/2 @@ -411,11 +449,16 @@ erlang:tl/1 erlang:trunc/1 erlang:tuple_size/1 erlang:tuple_to_list/1 +erlang:unique_integer/0 +erlang:unique_integer/1 erlang:universaltime/0 erlang:unlink/1 erlang:unregister/1 erlang:whereis/1 erlang:xor/2 +erpc:execute_call/4 +erpc:module_info/0 +erpc:module_info/1 erts_debug:flat_size/1 erts_debug:module_info/0 erts_debug:module_info/1 @@ -509,6 +552,8 @@ ets:delete/2 ets:insert/2 ets:lookup/2 ets:lookup_element/3 +ets:module_info/0 +ets:module_info/1 ets:new/2 ets:update_counter/3 ets:update_counter/4 @@ -686,25 +731,55 @@ i2c:write_bytes/2 i2c:write_bytes/3 i2c:write_bytes/4 inet:close/1 +inet:getaddr/2 inet:module_info/0 inet:module_info/1 inet:peername/1 inet:port/1 inet:sockname/1 +init:boot/1 +init:get_argument/1 +init:get_plain_arguments/0 +init:module_info/0 +init:module_info/1 +init:notify_when_started/1 +io:columns/0 +io:columns/1 io:format/1 io:format/2 +io:format/3 +io:fwrite/1 +io:fwrite/2 +io:fwrite/3 io:get_line/1 +io:getopts/0 +io:getopts/1 io:module_info/0 io:module_info/1 +io:printable_range/0 io:put_chars/1 io:put_chars/2 +io:requests/1 +io:scan_erl_exprs/4 +io_lib:chars_length/1 io_lib:format/2 +io_lib:fwrite/2 io_lib:latin1_char_list/1 io_lib:module_info/0 io_lib:module_info/1 +io_lib:printable_list/1 +io_lib:write/1 +io_lib:write_atom/1 +io_lib:write_string/1 +io_lib:write_string/2 json_encoder:encode/1 json_encoder:module_info/0 json_encoder:module_info/1 +kernel:init/1 +kernel:module_info/0 +kernel:module_info/1 +kernel:start/2 +kernel:stop/1 ledc:channel_config/1 ledc:fade_func_install/1 ledc:fade_func_uninstall/0 @@ -722,10 +797,14 @@ ledc:timer_config/1 ledc:update_duty/2 lists:all/2 lists:any/2 +lists:append/1 +lists:append/2 lists:delete/2 +lists:dropwhile/2 lists:duplicate/2 lists:filter/2 lists:filtermap/2 +lists:flatmap/2 lists:flatten/1 lists:foldl/3 lists:foldr/3 @@ -735,12 +814,15 @@ lists:keydelete/3 lists:keyfind/3 lists:keymember/3 lists:keyreplace/4 +lists:keysort/2 lists:keystore/4 lists:keytake/3 lists:last/1 lists:map/2 lists:mapfoldl/3 lists:member/2 +lists:merge/2 +lists:merge/3 lists:module_info/0 lists:module_info/1 lists:nth/2 @@ -870,8 +952,34 @@ mdns:stop/1 mdns:terminate/2 net:getaddrinfo/1 net:getaddrinfo/2 +net:gethostname/0 net:module_info/0 net:module_info/1 +net_kernel:epmd_module/0 +net_kernel:get_cookie/0 +net_kernel:get_cookie/1 +net_kernel:get_net_ticktime/0 +net_kernel:get_state/0 +net_kernel:handle_call/3 +net_kernel:handle_cast/2 +net_kernel:handle_info/2 +net_kernel:init/1 +net_kernel:mark_nodeup/4 +net_kernel:mark_pending/4 +net_kernel:module_info/0 +net_kernel:module_info/1 +net_kernel:set_cookie/1 +net_kernel:set_cookie/2 +net_kernel:start/2 +net_kernel:start_link/1 +net_kernel:stop/0 +net_kernel:terminate/2 +net_kernel_sup:init/1 +net_kernel_sup:module_info/0 +net_kernel_sup:module_info/1 +net_kernel_sup:start/1 +net_kernel_sup:start_link/1 +net_kernel_sup:stop/0 network:handle_call/3 network:handle_cast/2 network:handle_continue/2 @@ -995,6 +1103,7 @@ socket:accept/2 socket:bind/2 socket:close/1 socket:connect/2 +socket:getopt/2 socket:listen/1 socket:listen/2 socket:module_info/0 @@ -1019,6 +1128,34 @@ socket:sendto/3 socket:setopt/3 socket:shutdown/2 socket:sockname/1 +socket_dist:accept/1 +socket_dist:accept_connection/5 +socket_dist:address/0 +socket_dist:close/1 +socket_dist:listen/1 +socket_dist:module_info/0 +socket_dist:module_info/1 +socket_dist:select/1 +socket_dist:setup/5 +socket_dist_controller:address/2 +socket_dist_controller:code_change/3 +socket_dist_controller:getll/1 +socket_dist_controller:getstat/1 +socket_dist_controller:handle_call/3 +socket_dist_controller:handle_cast/2 +socket_dist_controller:handle_info/2 +socket_dist_controller:handshake_complete/3 +socket_dist_controller:init/1 +socket_dist_controller:module_info/0 +socket_dist_controller:module_info/1 +socket_dist_controller:recv/3 +socket_dist_controller:send/2 +socket_dist_controller:setopts_post_nodeup/1 +socket_dist_controller:setopts_pre_nodeup/1 +socket_dist_controller:start/1 +socket_dist_controller:supervisor/2 +socket_dist_controller:terminate/2 +socket_dist_controller:tick/1 spi:close/1 spi:module_info/0 spi:module_info/1 @@ -1057,6 +1194,7 @@ ssl:stop/0 ssl:terminate/2 string:find/2 string:find/3 +string:length/1 string:module_info/0 string:module_info/1 string:split/2 @@ -1065,14 +1203,20 @@ string:to_lower/1 string:to_upper/1 string:trim/1 string:trim/2 +supervisor:delete_child/2 supervisor:handle_call/3 supervisor:handle_cast/2 supervisor:handle_info/2 supervisor:init/1 supervisor:module_info/0 supervisor:module_info/1 +supervisor:restart_child/2 +supervisor:start_child/2 supervisor:start_link/2 supervisor:start_link/3 +supervisor:terminate/2 +supervisor:terminate_child/2 +supervisor:which_children/1 timer:module_info/0 timer:module_info/1 timer:sleep/1 diff --git a/scripts/update_all_funcs.exs b/scripts/update_all_funcs.exs index 64d300e..7922210 100644 --- a/scripts/update_all_funcs.exs +++ b/scripts/update_all_funcs.exs @@ -20,6 +20,7 @@ defmodule AllFuncsUpdater do first, followed by Elixir functions. """ @nifs_gperf_path "../AtomVM/src/libAtomVM/nifs.gperf" + @estdlib_beam_path "../AtomVM/build/libs/estdlib/src/beams" @erlang_beam_path "../AtomVM/build/libs/eavmlib/src/beams" @elixir_beam_path "../AtomVM/build/libs/exavmlib/lib/beams" @funcs_txt_path "priv/funcs.txt" @@ -74,7 +75,7 @@ defmodule AllFuncsUpdater do end defp extract_beams do - [@erlang_beam_path, @elixir_beam_path] |> Enum.flat_map(&extract_from_dir/1) |> Enum.uniq() + [@estdlib_beam_path, @erlang_beam_path, @elixir_beam_path] |> Enum.flat_map(&extract_from_dir/1) |> Enum.uniq() end defp extract_from_dir(path) do From 866086e4d78a01890cf50c30b25dcb5c76a99ee7 Mon Sep 17 00:00:00 2001 From: Peter M Date: Mon, 11 Aug 2025 23:29:22 +0200 Subject: [PATCH 3/3] Allow arg for AtomVM path Signed-off-by: Peter M --- scripts/update_all_funcs.exs | 47 +++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/scripts/update_all_funcs.exs b/scripts/update_all_funcs.exs index 7922210..6743a75 100644 --- a/scripts/update_all_funcs.exs +++ b/scripts/update_all_funcs.exs @@ -3,10 +3,14 @@ Code.require_file("analyze_funcs_diff.exs", __DIR__) defmodule AllFuncsUpdater do @moduledoc """ - Script assumes that AtomVM is in same parent directory as ExAtomVM and that + Script to update priv/funcs.txt with all available functions from AtomVM sources. + By default, assumes AtomVM is in the same parent directory as ExAtomVM and that AtomVM has been built in the AtomVM/build directory. - run using 'elixir scripts/update_all_funcs.exs' in project root. + Usage: + elixir scripts/update_all_funcs.exs [atomvm_path] + + If atomvm_path is not provided, defaults to "../AtomVM". Updates priv/funcs.txt with all available functions from AtomVM sources. @@ -19,18 +23,22 @@ defmodule AllFuncsUpdater do implementation details. The final list is sorted with Erlang functions first, followed by Elixir functions. """ - @nifs_gperf_path "../AtomVM/src/libAtomVM/nifs.gperf" - @estdlib_beam_path "../AtomVM/build/libs/estdlib/src/beams" - @erlang_beam_path "../AtomVM/build/libs/eavmlib/src/beams" - @elixir_beam_path "../AtomVM/build/libs/exavmlib/lib/beams" + @default_atomvm_path "../AtomVM" + @nifs_gperf_path "src/libAtomVM/nifs.gperf" + @estdlib_beam_path "build/libs/estdlib/src/beams" + @erlang_beam_path "build/libs/eavmlib/src/beams" + @elixir_beam_path "build/libs/exavmlib/lib/beams" @funcs_txt_path "priv/funcs.txt" - def run do + def default_atomvm_path, do: @default_atomvm_path + + def run(atomvm_path \\ @default_atomvm_path) do IO.puts("Updating #{@funcs_txt_path}...") + IO.puts("Using AtomVM path: #{atomvm_path}") try do - nifs = extract_nifs() - beams = extract_beams() + nifs = extract_nifs(atomvm_path) + beams = extract_beams(atomvm_path) all_funcs = (read_current() ++ nifs ++ beams) |> Enum.uniq() @@ -59,8 +67,8 @@ defmodule AllFuncsUpdater do end end - defp extract_nifs do - path = @nifs_gperf_path + defp extract_nifs(atomvm_path) do + path = Path.join(atomvm_path, @nifs_gperf_path) if File.exists?(path) do path @@ -74,8 +82,11 @@ defmodule AllFuncsUpdater do end end - defp extract_beams do - [@estdlib_beam_path, @erlang_beam_path, @elixir_beam_path] |> Enum.flat_map(&extract_from_dir/1) |> Enum.uniq() + defp extract_beams(atomvm_path) do + [@estdlib_beam_path, @erlang_beam_path, @elixir_beam_path] + |> Enum.map(&Path.join(atomvm_path, &1)) + |> Enum.flat_map(&extract_from_dir/1) + |> Enum.uniq() end defp extract_from_dir(path) do @@ -110,5 +121,13 @@ defmodule AllFuncsUpdater do end # Run the script -AllFuncsUpdater.run() +atomvm_path = case System.argv() do + [path] -> path + [] -> AllFuncsUpdater.default_atomvm_path() + _ -> + IO.puts("Usage: elixir scripts/update_all_funcs.exs [atomvm_path]") + System.halt(1) +end + +AllFuncsUpdater.run(atomvm_path) FuncsDiffAnalyzer.run()