Skip to content

Commit 4f982c0

Browse files
committed
Add binary.copy erlang function to compat layer
Upgrade tailored version. Now ignores variables that begin with underscores. Updated pattern.ex to follow suit
1 parent f57bba9 commit 4f982c0

File tree

8 files changed

+30
-21
lines changed

8 files changed

+30
-21
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ defmodule ElixirScript.Translate.Forms.Pattern do
6262
end
6363

6464
defp process_pattern({:_, _, _}, _) do
65-
{ [PM.parameter()], [J.identifier(:_)] }
65+
{ [PM.parameter(J.literal("_"))], [] }
6666
end
6767

6868
defp process_pattern({a, b}, state) do
@@ -92,6 +92,14 @@ defmodule ElixirScript.Translate.Forms.Pattern do
9292
{ [PM.type(tuple, pattern)], params }
9393
end
9494

95+
defp process_pattern([{:|, _, [head, tail]}], state) do
96+
{ head_patterns, head_params } = process_pattern(head, state)
97+
{ tail_patterns, tail_params } = process_pattern(tail, state)
98+
params = head_params ++ tail_params
99+
100+
{ [PM.head_tail(hd(head_patterns), hd(tail_patterns))], params }
101+
end
102+
95103
defp process_pattern(list, state) when is_list(list) do
96104
{ patterns, params } = list
97105
|> Enum.map(&do_compile([&1], state))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ defmodule ElixirScript.Translate.Forms.Remote do
1616
:code,
1717
:elixir_utils,
1818
:file,
19-
:io
19+
:io,
20+
:binary
2021
]
2122

2223
@doc """

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"clean": "rm -rf priv/build",
1414
"test": "nyc ava src/javascript/tests",
1515
"build:test-app": "MIX_ENV=test mix elixirscript Main -f common -o test/app/build/",
16-
"test-app": "yarn run build:test-app && NODE_ENV=test ava 'test/app/spec/**/*.spec.js'"
16+
"test-app": "yarn build:test-app && NODE_ENV=test ava 'test/app/spec/**/*.spec.js'"
1717
},
1818
"repository": {
1919
"type": "git",
@@ -23,7 +23,7 @@
2323
"license": "MIT",
2424
"dependencies": {
2525
"erlang-types": "^1.0.1",
26-
"tailored": "^2.6.1"
26+
"tailored": "^2.6.3"
2727
},
2828
"devDependencies": {
2929
"ava": "^0.21.0",

priv/build/iife/ElixirScript.Core.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/lib/core.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import maps from './core/erlang_compat/maps';
77
import lists from './core/erlang_compat/lists';
88
import elixir_errors from './core/erlang_compat/elixir_errors';
99
import io from './core/erlang_compat/io';
10+
import binary from './core/erlang_compat/binary';
1011
import Store from './core/store';
1112

1213
class Integer {}
@@ -45,5 +46,6 @@ export default {
4546
maps,
4647
lists,
4748
elixir_errors,
48-
io
49+
io,
50+
binary
4951
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function copy(subject, n = 1) {
2+
return subject.repeat(n);
3+
}
4+
5+
export default {
6+
copy
7+
};

test/support/main.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
defmodule Main do
22
def start(:normal, [callback]) do
33
callback.("started")
4+
5+
IO.inspect 1
46
end
57
end

yarn.lock

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,6 @@ babel-plugin-syntax-exponentiation-operator@^6.8.0:
605605
version "6.13.0"
606606
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de"
607607

608-
babel-plugin-syntax-object-rest-spread@^6.8.0:
609-
version "6.13.0"
610-
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"
611-
612608
babel-plugin-syntax-trailing-function-commas@^6.20.0, babel-plugin-syntax-trailing-function-commas@^6.22.0:
613609
version "6.22.0"
614610
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3"
@@ -813,13 +809,6 @@ babel-plugin-transform-minify-booleans@^6.8.2:
813809
version "6.8.2"
814810
resolved "https://registry.yarnpkg.com/babel-plugin-transform-minify-booleans/-/babel-plugin-transform-minify-booleans-6.8.2.tgz#8451579f706e702c1e1ab2756de5c8ea369cf07c"
815811

816-
babel-plugin-transform-object-rest-spread@^6.23.0:
817-
version "6.23.0"
818-
resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.23.0.tgz#875d6bc9be761c58a2ae3feee5dc4895d8c7f921"
819-
dependencies:
820-
babel-plugin-syntax-object-rest-spread "^6.8.0"
821-
babel-runtime "^6.22.0"
822-
823812
babel-plugin-transform-property-literals@^6.8.4:
824813
version "6.8.4"
825814
resolved "https://registry.yarnpkg.com/babel-plugin-transform-property-literals/-/babel-plugin-transform-property-literals-6.8.4.tgz#6ad311110b80a192a56efb5ddf4fe3ca6f7a61da"
@@ -3689,9 +3678,9 @@ table@^4.0.1:
36893678
slice-ansi "0.0.4"
36903679
string-width "^2.0.0"
36913680

3692-
tailored@^2.6.1:
3693-
version "2.6.1"
3694-
resolved "https://registry.yarnpkg.com/tailored/-/tailored-2.6.1.tgz#afac1114f4622eceba11d87fcc35b42a658ded84"
3681+
tailored@^2.6.3:
3682+
version "2.6.3"
3683+
resolved "https://registry.yarnpkg.com/tailored/-/tailored-2.6.3.tgz#27d1069dd3f5b2f2009d6437efcb26c595bccfda"
36953684
dependencies:
36963685
erlang-types "^1.0.1"
36973686

0 commit comments

Comments
 (0)