Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kollhof committed Sep 28, 2021
1 parent 7172ed2 commit 31d913e
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 406 deletions.
6 changes: 3 additions & 3 deletions src/ir/call/call.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ transform_all_args = fn [expr=false, ...exprs], args_id, ctx, out=[]:
transform_all_args exprs, next_args_id, next_ctx, [...out, ...arg]

else:
[arg, next_args_id, foo_ctx] = transform_arg expr, args_id, ctx
[arg, next_args_id, arg_ctx] = transform_arg expr, args_id, ctx
next_ctx = rec:
...foo_ctx
...arg_ctx
partial_ident: ctx.partial_ident
has_partial: ctx.has_partial or foo_ctx.has_partial
has_partial: ctx.has_partial or arg_ctx.has_partial
transform_all_args exprs, next_args_id, next_ctx, [...out, ...arg]


Expand Down
9 changes: 2 additions & 7 deletions src/ir/call/pipe.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ pipe_all = fn [expr=false, ...exprs], prev_res_id, ctx, out=[]:
pipe_all exprs, res_id, end_ctx, [...out, ...callee, ...call]

else:
# [res, res_id, {partial_ident, has_partial, ...next_ctx}] = transform expr, 'res', {...ctx, partial_ident: prev_res_id}
# pipe_all exprs, res_id, next_ctx, [...out, ...res]

[callee, callee_id, {has_partial: _, partial_ident: _, ...next_ctx}] = transform_with_partial expr, 'pfn', ctx
[callee, callee_id, step_ctx] = transform_with_partial expr, 'pfn', ctx
{has_partial: _, partial_ident: _, ...next_ctx} = step_ctx
[call, res_id, end_ctx] = apply_step callee_id, prev_res_id, expr, next_ctx
pipe_all exprs, res_id, end_ctx, [...out, ...callee, ...call]





transform_pipe = fn expr, result, ctx:
[val, val_id, pipe_ctx] = match expr.args:
[?]:
Expand All @@ -51,7 +47,6 @@ transform_pipe = fn expr, result, ctx:
[[], false, ctx]

[calls, res_id, next_ctx] = pipe_all expr.exprs, val_id, pipe_ctx
# TODO can pipeall not handle it?
[res, , end_ctx] = let res_id, result, expr, next_ctx
[[...val, ...calls, ...res], end_ctx]

Expand Down
4 changes: 1 addition & 3 deletions src/ir/conditionals/match.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,10 @@ match_rec = fn [val_id, val_prereq], expr, gen_true, else_id, ctx, match_expr:

[if_exp, , cn_ctx] = cif is_rec_id, match_id, else_id, , expr, cif_ctx


body = list:
...val_prereq
# TODO: move down like in list?
...props_match
...rec_check
...props_match
...if_exp

cn [], body, 'match_rec', expr, cn_ctx
Expand Down
778 changes: 389 additions & 389 deletions src/ir/conditionals/match.test.fnk.snap

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/ir/literals/init.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{transform_keyword} = import './keywords.fnk'



add_literals = fn ctx:
pipe ctx:
add 'number', any, transform_number
Expand Down
1 change: 0 additions & 1 deletion src/ir/logical/init.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ add_logical = fn ctx:
add any, 'and', transform_logical
add any, 'or', transform_logical
add any, 'not', transform_not
# TODO: should this live in iterables?
add any, 'in', transform_in
1 change: 0 additions & 1 deletion src/js/async/init.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ types = import '@babel/types'


transform_async = fn path:
# TODO: should avoid mutating nodes
match path:
isArrowFunctionExpression ?:
set_props path.node, {async: true}
Expand Down
2 changes: 1 addition & 1 deletion src/js/context.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ add_runtime_requirement = fn func, {runtime, ...ctx}:
{...ctx, runtime: {...runtime, (func): true}}


# TODO: inlining should be handled at optimization level in ir
get_js_literal = fn id, ctx:
# TODO: inlining should be handled at optimization level in ir
{js=get_js id, ctx} = get_value id, ctx
js

Expand Down
1 change: 0 additions & 1 deletion src/optimize/tail-calls.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ optimize_af = fn [expr, res], exprs, ctx:




optimize_tails = fn [expr=false, ...exprs], ctx, out=[]:
match expr:
false:
Expand Down

0 comments on commit 31d913e

Please sign in to comment.