-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathsupported.ex
More file actions
165 lines (153 loc) · 3.41 KB
/
Copy pathsupported.ex
File metadata and controls
165 lines (153 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
defmodule ElixirScript.Gen.Supported do
@moduledoc false
@private_modules [
Kernel.Utils,
String.Normalizer,
Version.Parser,
IO.ANSI.Sequence,
Version.Parser.DSL,
String.Break,
IO.ANSI.Docs,
Kernel.LexicalTracker,
Task.Supervised,
Supervisor.Default,
Registry.Partition,
Module.LocalsTracker,
Kernel.CLI,
Registry.Supervisor,
Stream.Reducers,
Agent.Server,
]
def generate() do
File.open!("Supported.md", [:write], &write_to_file/1)
end
def write_to_file(file) do
IO.puts(file, "# Supported Elixir Modules")
IO.puts(file, "List all public modules in the Elixir Standard Libary. If a function or macro is supported in ElixirScript, it is checked")
module_map = get_module_list()
Enum.each(module_map, fn({elixir_module, elixir_script_module}) ->
IO.puts(file, "## #{inspect elixir_module}")
exports = elixir_module.__info__(:functions) ++ elixir_module.__info__(:macros)
elixir_script_exports = cond do
elixir_script_module == ElixirScript.Kernel.SpecialForms ->
extra(elixir_script_module)
Code.ensure_loaded?(elixir_script_module) ->
elixir_script_module.__info__(:functions) ++ elixir_script_module.__info__(:macros) ++ extra(elixir_script_module)
true ->
[]
end
Enum.each(exports, fn({func, arity}) ->
if Enum.member?(elixir_script_exports, {func, arity}) do
IO.puts(file, "- [X] `#{func}/#{arity}`")
else
IO.puts(file, "- [ ] `#{func}/#{arity}`")
end
end)
end)
end
defp get_module_list() do
Application.spec(:elixir, :modules)
|> Enum.filter(&is_public(&1))
|> Enum.sort(fn(x, y) -> to_string(x) >= to_string(y) end)
|> Enum.reduce(Keyword.new, fn(x, acc) ->
try do
elixirscript_module = (["ElixirScript"] ++ Module.split(x)) |> Module.concat()
Keyword.put(acc, x, elixirscript_module)
rescue
FunctionClauseError ->
acc
end
end)
end
defp is_public(m) when m in @private_modules do
false
end
defp is_public(_) do
true
end
defp extra(ElixirScript.Kernel.SpecialForms) do
[
%: 2,
%{}: 1,
&: 1,
".": 2,
"::": 2,
<<>>: 1,
=: 2,
^: 1,
__CALLER__: 0,
__DIR__: 0,
__ENV__: 0,
__MODULE__: 0,
__aliases__: 1,
__block__: 1,
alias: 2,
case: 2,
cond: 1,
fn: 1,
for: 1,
import: 2,
quote: 2,
require: 2,
super: 1,
try: 1,
unquote: 1,
unquote_splicing: 1,
with: 1,
{}: 1,
]
end
defp extra(ElixirScript.Kernel) do
[
!=: 2,
!==: 2,
*: 2,
+: 1,
+: 2,
++: 2,
-: 1,
-: 2,
--: 2,
/: 2,
<: 2,
<=: 2,
==: 2,
===: 2,
=~: 2,
>: 2,
>=: 2,
div: 2,
rem: 2,
!: 1,
&&: 2,
<>: 2,
@: 1,
and: 2,
def: 1,
def: 2,
defdelegate: 2,
defexception: 1,
defimpl: 2,
defimpl: 3,
defmacro: 1,
defmacro: 2,
defmacrop: 1,
defmacrop: 2,
defmodule: 2,
defoverridable: 1,
defp: 1,
defp: 2,
defprotocol: 2,
defstruct: 1,
raise: 1,
raise: 2,
or: 2,
use: 1,
use: 2,
||: 2,
]
end
defp extra(_) do
[]
end
end