Skip to content

Commit a6e4b61

Browse files
committed
Save last modified time for beam files in debug info
1 parent f7ed05f commit a6e4b61

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lib/elixir_script/beam.ex

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ defmodule ElixirScript.Beam do
4040
end
4141

4242
defp do_debug_info(module) when is_atom(module) do
43-
#TODO: Get modified date from _beam_path to check for cached version?
44-
with {_, beam, _beam_path} <- :code.get_object_code(module),
43+
with {_, beam, beam_path} <- :code.get_object_code(module),
4544
{:ok, {^module, [debug_info: {:debug_info_v1, backend, data}]}} <- :beam_lib.chunks(beam, [:debug_info]),
4645
{:ok, {^module, attribute_info}} = :beam_lib.chunks(beam, [:attributes]) do
4746

4847
if Keyword.get(attribute_info[:attributes], :protocol) do
4948
get_protocol_implementations(module)
5049
else
5150
backend.debug_info(:elixir_v1, module, data, [])
51+
|> process_debug_info(beam_path)
5252
end
5353
else
5454
:error ->
@@ -62,6 +62,21 @@ defmodule ElixirScript.Beam do
6262
end
6363
end
6464

65+
defp process_debug_info({:ok, info}, beam_path) do
66+
info = case File.stat(beam_path, time: :posix) do
67+
{:ok, file_info} ->
68+
Map.put(info, :last_modified, file_info.mtime)
69+
_ ->
70+
Map.put(info, :last_modified, nil)
71+
end
72+
73+
{:ok, info}
74+
end
75+
76+
defp process_debug_info(error, _) do
77+
error
78+
end
79+
6580
defp get_protocol_implementations(module) do
6681
implementations = module
6782
|> Protocol.extract_impls(:code.get_path())

0 commit comments

Comments
 (0)