Skip to content

Commit

Permalink
Update charms.ex
Browse files Browse the repository at this point in the history
  • Loading branch information
jackalcooper committed Oct 7, 2024
1 parent d5d2f51 commit c3fc332
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/charms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,18 @@ defmodule Charms do
quote do
@defm unquote(Macro.escape({env, {call, ret_types, body}}))
def unquote(name)(unquote_splicing(invoke_args)) do
if @init_at_fun_call do
{_, %Charms.JIT{}} = Charms.JIT.init(__MODULE__)
end
mfa = {unquote(env.module), unquote(name), unquote(invoke_args)}

cond do
@init_at_fun_call ->
{_, %Charms.JIT{engine: engine} = jit} = Charms.JIT.init(__MODULE__)
Charms.JIT.invoke(engine, mfa)

f =
&Charms.JIT.invoke(&1, {unquote(env.module), unquote(name), unquote(invoke_args)})
(engine = Charms.JIT.engine(__MODULE__)) != nil ->
Charms.JIT.invoke(engine, mfa)

if engine = Charms.JIT.engine(__MODULE__) do
f.(engine)
else
f
true ->
&Charms.JIT.invoke(&1, mfa)
end
end
end
Expand Down

0 comments on commit c3fc332

Please sign in to comment.