Skip to content

Commit

Permalink
Merge pull request #126 from fink-lang/cleanup
Browse files Browse the repository at this point in the history
chore: use partials
  • Loading branch information
kollhof authored Jul 18, 2021
2 parents cfb9667 + a1154e1 commit 4b8de3a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 38 deletions.
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions src/js/do-expression.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ babel_types = import '@babel/types'
assignmentExpression, returnStatement, expressionStatement
isDoExpression, isBlockStatement, isLabeledStatement
isVariableDeclarator, isArrowFunctionExpression, isExpressionStatement
isReturnStatement, arrowFunctionExpression, callExpression
isReturnStatement
arrowFunctionExpression, callExpression
} = babel_types
{set_props} = import '@fink/js-interop/reflect.fnk'
{undefined} = import '@fink/js-interop/nullish.fnk'
Expand All @@ -13,7 +14,7 @@ babel_types = import '@babel/types'
{lets, assign, undef} = import './types.fnk'


get_body = fn path: path.get 'body'
get_body = ?.get 'body'



Expand All @@ -34,6 +35,7 @@ simple = fn body, sl=false:
stmnt.node.body
# TODO:
# {sl: true, stmnt: isIfStatement ?}:
# console.log body
# body.node
else:
simple stmnt
Expand Down Expand Up @@ -66,8 +68,7 @@ last_expressions = fn path:
items = []
body.traverse
rec:
LabeledStatement: fn nested_match:
nested_match.skip _
LabeledStatement: ?.skip _

BreakStatement: fn brk:
last = brk.getSibling brk.key - 1
Expand Down Expand Up @@ -169,13 +170,12 @@ transform_do_expr = fn path:
replace_with_return path

else:
# e.g.
# fn:
# foo = match:
# spam:
# shrub
# ni
# foo
# TODO
# foo = match:
# spam:
# shrub
# ni
# foo
arrow = arrowFunctionExpression [], path.node
path.replaceWith
callExpression arrow, []
Expand Down
3 changes: 1 addition & 2 deletions src/lang/assignment/init.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ has_spread_not_last = fn {left}:
[...exprs, ] = left.exprs

[spread=false] = pipe exprs:
# TODO filter ?.type == 'spread'
filter fn {type}: type == 'spread'
filter ?.type == 'spread'

spread
else:
Expand Down
7 changes: 2 additions & 5 deletions src/lang/literals/string.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ transform_string = fn node, ctx:
{exprs: parts, tag} = node

quasies = pipe parts:
# TODO filter ?.type == 'string:text'
filter fn part:
part.type == 'string:text'
filter ?.type == 'string:text'

map fn part:
templateElement rec:
Expand All @@ -23,8 +21,7 @@ transform_string = fn node, ctx:
'\\$1$2'

[expressions, next_ctx] = pipe parts:
# TODO drop_if ?.type == 'string:text'
drop_if fn {type}: type == 'string:text'
drop_if ?.type == 'string:text'
map_with_ctx transform
collect_with_ctx ctx

Expand Down
4 changes: 2 additions & 2 deletions src/lang/runtime.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ use_runtime_fn = fn name, ctx:
runtime: rec:
...runtime
used: list:
name, # TODO: filter ? != name
...runtime.used | filter fn used_name: used_name != name
name,
...runtime.used | filter ? != name



Expand Down

0 comments on commit 4b8de3a

Please sign in to comment.