Skip to content

Commit

Permalink
Add translation to rewrite Elixir.Enum to Bootstrap.Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjos committed Feb 24, 2017
1 parent a2de707 commit 7e12e63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/elixir_script/passes/ast_from_file.ex
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
defmodule ElixirScript.Passes.ASTFromFile do
@moduledoc false
@moduledoc false

def execute(compiler_data, opts) do
data = Enum.reduce(compiler_data.data, [], fn({dep, paths}, list) ->

file_paths = paths
|> Enum.flat_map(fn(path) -> Path.join(path, "**/*.{ex,exs,exjs}") |> Path.wildcard end)
|> Enum.flat_map(fn(path) -> Path.join([path, "**", "*.{ex,exs,exjs}"]) |> Path.wildcard end)
|> Enum.reduce([], fn(path, list) ->
quoted = path
|> File.read!
|> Code.string_to_quoted!

stat = File.stat!(path)

list ++ [%{ path: path, app: dep, stat: stat, ast: quoted }]
list ++ [%{path: path, app: dep, stat: stat, ast: quoted}]
end)


Expand Down
6 changes: 5 additions & 1 deletion lib/elixir_script/translator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ defmodule ElixirScript.Translator do
end
end

defp do_translate({{:., context1, [{:__aliases__, context2, [:Elixir, :Enum]}, function_name]}, context3, params }, env) do
translate({{:., context1, [{:__aliases__, context2, [:Enum]}, function_name]}, context3, params }, env)
end

defp do_translate({{:., context1, [{:__aliases__, context2, [:Enum]}, function_name]}, context3, params }, env) do
translate({{:., context1, [{:__aliases__, context2, [:Bootstrap, :Enum]}, function_name]}, context3, params }, env)
end
Expand Down Expand Up @@ -628,7 +632,7 @@ defmodule ElixirScript.Translator do
def create_module_name(module_name, env) do
case module_name do
{:__aliases__, _, _} ->
candiate_module_name = ElixirScript.Translator.State.get_module_name(env.state,
candiate_module_name = ElixirScript.Translator.State.get_module_name(env.state,
Utils.quoted_to_name(module_name))

if ElixirScript.Translator.LexicalScope.get_module_name(env, candiate_module_name) in ElixirScript.Translator.State.list_module_names(env.state) do
Expand Down

0 comments on commit 7e12e63

Please sign in to comment.