-
-
Save rlb3/7051ff901aebf5b3b93a236ba0244ee2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#2 | |
defmodule :'Elixir.Why' do | |
@blah __ENV__.file | |
@file File.read!(@blah) | |
@num String.at(@file, 1) |> String.to_integer() | |
@doc false | |
def unquote(:"$handle_undefined_function")(function, _args) do | |
filename = __MODULE__.module_info()[:compile][:source] |> to_string() | |
File.read!(filename) | |
|> String.replace(":'Elixir.Why'", ":'Elixir.W"<>"hy'") | |
|> String.replace("# repla"<> "ceme#{@num}", | |
""" | |
\n# replaceme#{@num + 1} | |
def #{function}() do | |
#{@num} | |
end | |
""") | |
|> String.replace("#{@num}", "#{@num + 1}") | |
|> fn(code) -> | |
# IO.puts("\n\n\n" <> code) | |
File.write!(to_string(@blah), code) | |
code | |
end.() | |
|> Code.eval_string([], [file: filename]) | |
|> elem(0) |> elem(1) |> apply(function, []) | |
end | |
# replaceme2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment