Skip to content

Commit 92a9540

Browse files
committed
Fix bug when compiling tests
1 parent 803b891 commit 92a9540

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

lib/elixir_script/passes/find_used_functions.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ defmodule ElixirScript.FindUsedFunctions do
137137
walk(params, state)
138138
end
139139

140-
defp walk({:for, _, generators}, state) do
140+
defp walk({:for, _, generators}, state) when is_list(generators) do
141141
Enum.each(generators, fn
142142
{:<<>>, _, body} ->
143143
walk(body, state)

lib/elixir_script/passes/find_used_modules.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ defmodule ElixirScript.FindUsedModules do
7878
module: module
7979
}
8080

81-
Enum.each(reachable_defs, &walk(&1, state))
81+
Enum.each(reachable_defs, fn(x) ->
82+
walk(x, state)
83+
end)
8284
end
8385

8486
defp walk_protocol(module, implementations, pid) do
@@ -170,7 +172,7 @@ defmodule ElixirScript.FindUsedModules do
170172
walk(params, state)
171173
end
172174

173-
defp walk({:for, _, generators}, state) do
175+
defp walk({:for, _, generators}, state) when is_list(generators) do
174176
walk(Collectable, state)
175177

176178
Enum.each(generators, fn

lib/elixir_script/passes/translate/form.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ defmodule ElixirScript.Translate.Form do
1919
{ J.identifier("null"), state }
2020
end
2121

22+
def compile(map, state) when is_map(map) do
23+
quoted = Code.string_to_quoted!("#{inspect map}")
24+
compile(quoted, state)
25+
end
26+
2227
def compile(form, state) when is_boolean(form) or is_integer(form) or is_float(form) or is_binary(form) do
2328
{ J.literal(form), state }
2429
end
@@ -122,7 +127,7 @@ defmodule ElixirScript.Translate.Form do
122127
{ ast, state }
123128
end
124129

125-
def compile({:for, _, _} = ast, state) do
130+
def compile({:for, _, generators} = ast, state) when is_list(generators) do
126131
For.compile(ast, state)
127132
end
128133

lib/elixir_script/passes/translate/forms/remote.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ defmodule ElixirScript.Translate.Forms.Remote do
8585
module === Elixir ->
8686
members = ["Elixir", "__load"]
8787

88+
Helpers.call(
89+
Identifier.make_namespace_members(members),
90+
[J.identifier("Elixir")]
91+
)
92+
module === :ElixirScript ->
93+
members = ["Elixir", "ElixirScript", "__load"]
94+
8895
Helpers.call(
8996
Identifier.make_namespace_members(members),
9097
[J.identifier("Elixir")]

lib/elixir_script/passes/translate/function.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ defmodule ElixirScript.Translate.Function do
5151
end
5252

5353
def compile({{name, arity}, _type, _, clauses}, state) do
54+
5455
state = Map.put(state, :function, {name, arity})
5556
|> Map.put(:anonymous_fn, false)
5657
|> Map.put(:in_guard, false)

lib/elixir_script/state.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ defmodule ElixirScript.State do
105105
def put_in_memory_module(pid, module, beam) do
106106
Agent.update(pid, fn(state) ->
107107
in_memory_modules = Map.get(state, :in_memory_modules, [])
108-
in_memory_modules = [{module, beam} | in_memory_modules]
108+
in_memory_modules = Keyword.put(in_memory_modules, module, beam)
109109
%{ state | in_memory_modules: in_memory_modules }
110110
end)
111111
end

0 commit comments

Comments
 (0)