-
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 #134 from fink-lang/ir
AST -> IR -> Optimizer -> JS
- Loading branch information
Showing
166 changed files
with
13,016 additions
and
4,675 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
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,21 @@ | ||
{add, any} = import '../context.fnk' | ||
{transform_binary, transform_unary} = import '../transform.fnk' | ||
|
||
|
||
|
||
transform_arithmitic = fn node, res_id, ctx: | ||
transform_binary node.op, node.left, node.right, res_id, {loc: node.loc}, ctx | ||
|
||
|
||
|
||
transform_prefix = fn node, res_id, ctx: | ||
transform_unary node.op, node.right, res_id, {loc: node.loc}, ctx | ||
|
||
|
||
|
||
add_arithmitic = fn ctx: | ||
pipe ctx: | ||
add 'arithm', any, transform_arithmitic | ||
add 'arithm:right', any, transform_arithmitic | ||
add 'arithm:prefix', any, transform_prefix | ||
|
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,44 @@ | ||
{fink2lir} = import '../../testing/generate.fnk' | ||
{describe, it, expect, to_match_snapshot} = import '@fink/jest/test.fnk' | ||
|
||
|
||
describe 'binary', fn: | ||
it 'compiles simple', fn: | ||
expect | ||
fink2lir ' | ||
r = foo + bar | ||
' | ||
to_match_snapshot | ||
|
||
|
||
it 'compiles precedence', fn: | ||
expect | ||
fink2lir ' | ||
r = (1 + 2) * ni | ||
' | ||
to_match_snapshot | ||
|
||
|
||
it 'compiles nested', fn: | ||
expect | ||
fink2lir ' | ||
foo * bar + ni | ||
' | ||
to_match_snapshot | ||
|
||
|
||
|
||
describe 'unary', fn: | ||
it 'compiles simple', fn: | ||
expect | ||
fink2lir ' | ||
-foo | ||
' | ||
to_match_snapshot | ||
|
||
it 'compiles nested', fn: | ||
expect | ||
fink2lir ' | ||
foo * -bar | ||
' | ||
to_match_snapshot |
Oops, something went wrong.