-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from fink-lang/upgrade
upgrade to latest larix
- Loading branch information
Showing
19 changed files
with
554 additions
and
462 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{unaryExpression} = import '@babel/types' | ||
|
||
|
||
transform_unary= fn node, {transform}: | ||
transform_unary = fn node, {transform}: | ||
right = transform:: node.right | ||
unaryExpression:: node.op, right |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{booleanLiteral, nullLiteral} = import '@babel/types' | ||
|
||
|
||
transform_keyword = fn node: | ||
match node: | ||
{'value': 'true'}: booleanLiteral:: true | ||
{'value': 'false'}: booleanLiteral:: false | ||
{'value': 'null'}: nullLiteral() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{fink2js} = import '../../testing' | ||
{describe, it, expect, to_match_snapshot} = import '@fink/jest' | ||
|
||
|
||
describe:: 'keywords', fn: | ||
it:: 'transforms literals', fn: | ||
expect:: | ||
fink2js` | ||
x = false | ||
y = true | ||
z = null | ||
` | ||
to_match_snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`keywords transforms literals 1`] = ` | ||
"const x = false; | ||
const y = true; | ||
const z = null; | ||
Object.assign(module.exports, { | ||
x, | ||
y, | ||
z | ||
});" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,39 @@ | ||
{logicalExpression} = import '@babel/types' | ||
{logicalExpression, unaryExpression} = import '@babel/types' | ||
{add, any} = import '../context' | ||
{transform_unary} = import '../generic/unary' | ||
|
||
|
||
transform_op = { | ||
'&&': '&&' | ||
'||': '||' | ||
'!': '!' | ||
'and': '&&' | ||
'or': '||' | ||
'not': '!' | ||
} | ||
|
||
|
||
transform_not = fn node, {transform}: | ||
{(node.op): op} = transform_op | ||
right = transform:: node.right | ||
|
||
unaryExpression:: op, right | ||
|
||
|
||
transform_logical = fn node, {transform}: | ||
{(node.op): op} = transform_op | ||
left = transform:: node.left | ||
right = transform:: node.right | ||
logicalExpression:: node.op, left, right | ||
|
||
logicalExpression:: op, left, right | ||
|
||
|
||
add_logical = fn ctx: | ||
pipe ctx: | ||
add:: any, '&&', transform_logical | ||
add:: any, '||', transform_logical | ||
add:: any, '!', transform_unary | ||
add:: any, '!', transform_not | ||
|
||
add:: any, 'and', transform_logical | ||
add:: any, 'or', transform_logical | ||
add:: any, 'not', transform_not | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`logical compiles operators 1`] = ` | ||
"const logical = a || b || c && d < 1 <= s; | ||
exports[`logical compiles 1`] = ` | ||
"const foo = a || b || c; | ||
const bar = a && b && c; | ||
const spam = !a; | ||
Object.assign(module.exports, { | ||
logical | ||
foo, | ||
bar, | ||
spam | ||
});" | ||
`; | ||
|
||
exports[`logical compiles 2`] = ` | ||
"const foo = a || b || c; | ||
const bar = a && b && c; | ||
const spam = !a; | ||
Object.assign(module.exports, { | ||
foo, | ||
bar, | ||
spam | ||
});" | ||
`; |