Skip to content

Commit e972eab

Browse files
committed
Update for translation
1 parent 4d491ef commit e972eab

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [0.26.1] - 2017-02-27
8+
9+
### Fixed
10+
- Fixed `for` translation
11+
- Updated documentation
12+
713
## [0.26.0] - 2017-02-27
814

915
### Added

lib/elixir_script/translator/kernel/special_forms/for.ex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ defmodule ElixirScript.Translator.For do
66
alias ElixirScript.Translator.Primitive
77
alias ElixirScript.Translator.Function
88
alias ElixirScript.Translator.Utils
9+
alias ElixirScript.Translator.Identifier
910

1011
def make_for(generators, env) do
1112
ElixirScript.Translator.State.add_module_reference(env.state, env.module, ElixirScript.Collectable)
@@ -17,6 +18,14 @@ defmodule ElixirScript.Translator.For do
1718
filter = args.filter || JS.function_expression([], [], JS.block_statement([JS.return_statement(JS.identifier("true"))]))
1819
fun = args.fun
1920

21+
members = ["Elixir"] ++ Module.split(ElixirScript.Collectable) ++ ["__load"]
22+
23+
collectable_module = JS.call_expression(
24+
Identifier.make_namespace_members(members),
25+
[JS.identifier("Elixir")]
26+
)
27+
28+
2029
expression = JS.call_expression(
2130
JS.member_expression(
2231
JS.member_expression(
@@ -36,7 +45,7 @@ defmodule ElixirScript.Translator.For do
3645
Primitive.special_forms(),
3746
JS.identifier("_for")
3847
),
39-
[expression, generators, JS.identifier(Utils.name_to_js_name(ElixirScript.Collectable)), into]
48+
[expression, generators, collectable_module, into]
4049
)
4150

4251
{js_ast, env}

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule ElixirScript.Mixfile do
44
def project do
55
[
66
app: :elixir_script,
7-
version: "0.26.0",
7+
version: "0.26.1",
88
elixir: "~> 1.0",
99
elixirc_paths: elixirc_paths(),
1010
escript: escript_config(),

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elixirscript",
3-
"version": "0.25.0",
3+
"version": "0.26.1",
44
"description": "Convert Elixir to JavaScript",
55
"main": "elixir.js",
66
"bin": {
@@ -44,4 +44,4 @@
4444
"rollup-plugin-node-resolve": "^2.0.0",
4545
"rollup-plugin-uglify": "^1.0.1"
4646
}
47-
}
47+
}

test/translator/for_test.exs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule ElixirScript.Translator.For.Test do
2424
Object.freeze([1, 2, 3, 4])
2525
)
2626
],
27-
Elixir$ElixirScript$Collectable,
27+
Elixir.ElixirScript.Collectable.__load(Elixir),
2828
Object.freeze([])
2929
)
3030
"""
@@ -54,7 +54,7 @@ defmodule ElixirScript.Translator.For.Test do
5454
Object.freeze([1, 2, 3, 4])
5555
)
5656
],
57-
Elixir$ElixirScript$Collectable,
57+
Elixir.ElixirScript.Collectable.__load(Elixir),
5858
Object.freeze([])
5959
)
6060
"""
@@ -88,7 +88,7 @@ defmodule ElixirScript.Translator.For.Test do
8888
Object.freeze([2, 3])
8989
)
9090
],
91-
Elixir$ElixirScript$Collectable,
91+
Elixir.ElixirScript.Collectable.__load(Elixir),
9292
Object.freeze([])
9393
)
9494
"""
@@ -126,7 +126,7 @@ defmodule ElixirScript.Translator.For.Test do
126126
Object.freeze([2, 3])
127127
)
128128
],
129-
Elixir$ElixirScript$Collectable,
129+
Elixir.ElixirScript.Collectable.__load(Elixir),
130130
Object.freeze([])
131131
)
132132
);
@@ -157,7 +157,7 @@ defmodule ElixirScript.Translator.For.Test do
157157
Object.freeze([1, 2, 3, 4, 5, 6])
158158
)
159159
],
160-
Elixir$ElixirScript$Collectable,
160+
Elixir.ElixirScript.Collectable.__load(Elixir),
161161
Object.freeze([])
162162
)
163163
"""
@@ -186,7 +186,7 @@ defmodule ElixirScript.Translator.For.Test do
186186
values: [Symbol.for('user'), Bootstrap.Core.Patterns.variable()]
187187
}), Object.freeze([new Bootstrap.Core.Tuple(Symbol.for('user'), 'john'), new Bootstrap.Core.Tuple(Symbol.for('admin'), 'john'), new Bootstrap.Core.Tuple(Symbol.for('user'), 'meg')]))
188188
],
189-
Elixir$ElixirScript$Collectable,
189+
Elixir.ElixirScript.Collectable.__load(Elixir),
190190
Object.freeze([]))
191191
"""
192192

@@ -218,7 +218,7 @@ defmodule ElixirScript.Translator.For.Test do
218218
'value': Bootstrap.Core.Patterns.variable()
219219
}, 8), Bootstrap.Core.BitString.size({
220220
'value': Bootstrap.Core.Patterns.variable()
221-
}, 8)), pixels)], Elixir$ElixirScript$Collectable, Object.freeze([]))
221+
}, 8)), pixels)], Elixir.ElixirScript.Collectable.__load(Elixir), Object.freeze([]))
222222
"""
223223

224224
assert_translation(ex_ast, js_code)

0 commit comments

Comments
 (0)