Skip to content

Commit 73f3135

Browse files
committed
Remove references to experimental backend
1 parent 69e85ab commit 73f3135

File tree

11 files changed

+43
-31
lines changed

11 files changed

+43
-31
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
erlang ref-OTP-20.0-rc1
2-
elixir ref-9825280
2+
elixir ref-9873e42
33
nodejs 7.10.0

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ The goal is to convert a subset (or full set) of Elixir code to JavaScript, prov
44

55
Requirements
66
===========
7-
* Elixir
7+
* Erlang 20 or greater
8+
* Elixir 1.5 or greater
89
* Node (only for development)
910

1011
Usage

lib/elixir_script/next/beam.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ defmodule ElixirScript.Beam do
2323
{:error, "Unknown module"}
2424
{:error,:beam_lib,{:unknown_chunk,"non_existing.beam",:debug_info}} ->
2525
{:error, "Unsupported version of Erlang"}
26+
{:error,:beam_lib,{:missing_chunk, _ , _}} ->
27+
{:error, "Debug info not available"}
2628
{:error,:beam_lib,{:file_error,"non_existing.beam",:enoent}} ->
2729
{:error, "Debug info not available"}
2830
end

lib/elixir_script/next/passes/find_used.ex

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@ defmodule ElixirScript.FindUsed do
22
@moduledoc false
33
alias ElixirScript.State, as: ModuleState
44

5+
@erlang_modules [
6+
:erlang,
7+
:maps,
8+
:lists,
9+
:gen,
10+
:elixir_errors,
11+
:supervisor,
12+
:application,
13+
:code,
14+
:elixir_utils,
15+
:file
16+
]
17+
518
@doc """
619
Takes a list of entry modules and finds modules they use along with
720
documenting the functions used. The data collected about used functions
@@ -127,7 +140,8 @@ defmodule ElixirScript.FindUsed do
127140
do_execute(module, state.pid)
128141
end
129142
end
130-
Enum.each(params, &walk(&1, state))
143+
144+
walk(params, state)
131145
end
132146

133147
defp walk({:for, _, generators}, state) do
@@ -181,11 +195,11 @@ defmodule ElixirScript.FindUsed do
181195

182196
if rescue_block do
183197
Enum.each(rescue_block, fn
184-
{:->, _, [ [{:in, _, [param, names]}], body]} ->
185-
walk({[], [param], [{{:., [], [Enum, :member?]}, [], [param, names]}], body}, state)
186-
{:->, _, [ [param], body]} ->
187-
walk({[], [param], [], body}, state)
188-
end)
198+
{:->, _, [ [{:in, _, [param, names]}], body]} ->
199+
walk({[], [param], [{{:., [], [Enum, :member?]}, [], [param, names]}], body}, state)
200+
{:->, _, [ [param], body]} ->
201+
walk({[], [param], [], body}, state)
202+
end)
189203
end
190204

191205
if catch_block do
@@ -205,15 +219,8 @@ defmodule ElixirScript.FindUsed do
205219
Enum.each(clauses, &walk(&1, state))
206220
end
207221

208-
defp walk({{:., _, [:erlang, _]}, _, _}, _state) do
209-
nil
210-
end
211-
212-
defp walk({{:., _, [:lists, _]}, _, _}, _state) do
213-
nil
214-
end
215-
216-
defp walk({{:., _, [:maps, _]}, _, _}, _state) do
222+
defp walk({{:., _, [module, function]}, _, params}, _state) when module in @erlang_modules do
223+
IO.inspect {module, function, length(params)}
217224
nil
218225
end
219226

lib/elixir_script/next/passes/translate.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defmodule ElixirScript.Translate do
4040
|> Generator.generate
4141

4242
concat(js_code)
43-
|> IO.puts
43+
#|> IO.puts
4444
end
4545

4646
defp concat(code) do
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
defmodule Example do
22
def new() do
3-
newnew()
4-
end
5-
6-
def newnew() do
7-
Atom.to_string("hello")
3+
Base.encode16("hello")
84
end
95

106
end
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
defprotocol Example.Size do
2-
@compile {:undocumented_elixir_backend_option, ElixirScript.Translate.Backend}
32
def size(data)
43
end
54

65
defimpl Example.Size, for: BitString do
7-
@compile {:undocumented_elixir_backend_option, ElixirScript.Translate.Backend}
86

97
def size(string), do: byte_size(string)
108
end
119

1210
defimpl Example.Size, for: Map do
13-
@compile {:undocumented_elixir_backend_option, ElixirScript.Translate.Backend}
14-
1511
def size(map), do: map_size(map)
1612
end
1713

1814
defimpl Example.Size, for: Tuple do
19-
@compile {:undocumented_elixir_backend_option, ElixirScript.Translate.Backend}
20-
2115
def size(tuple), do: tuple_size(tuple)
2216
end

lib/elixir_script/next/passes/translate/module.ex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule ElixirScript.Translate.Module do
1717
file: _file,
1818
line: _line,
1919
module: ^module,
20-
unreachable: _unreachable,
20+
unreachable: unreachable,
2121
used: used
2222
} = info
2323

@@ -27,7 +27,13 @@ defmodule ElixirScript.Translate.Module do
2727

2828
# Filter so that we only have the
2929
# Used functions to compile
30-
used_defs = Enum.filter(defs, fn
30+
used_defs = defs
31+
|> Enum.filter(fn
32+
{ _, type, _, _} when type in [:defmacro, :defmacrop] -> false
33+
{ name, _, _, _} -> not(name in unreachable)
34+
_ -> true
35+
end)
36+
|> Enum.filter(fn
3137
{ name, _, _, _} -> name in used
3238
_ -> false
3339
end)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
// http://erlang.org/doc/man/erlang.html
2+
13
export default {};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
// http://erlang.org/doc/man/lists.html
2+
13
export default {};

0 commit comments

Comments
 (0)