Skip to content

Commit

Permalink
fix: condition order and value destructuring in match
Browse files Browse the repository at this point in the history
  • Loading branch information
kollhof committed Sep 23, 2021
1 parent d4b0eab commit 8454c84
Show file tree
Hide file tree
Showing 40 changed files with 2,021 additions and 1,469 deletions.
13 changes: 12 additions & 1 deletion package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
"@babel/core": "^7.10.5",
"@babel/traverse": "^7.10.5",
"@babel/types": "^7.10.5",
"@fink/js-interop": ">=3.1.1",
"@fink/js-interop": ">=2.5",
"@fink/snippet": "^2.2.0",
"@fink/std-lib": "^8.5.0"
"@fink/std-lib": "^8.5.0",
"hamt": "^2.2.2"
},
"config": {
"commitizen": {
Expand Down
9 changes: 3 additions & 6 deletions src/generate.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@ babel_traverse = import '@babel/traverse'

{timed, log_timings} = import './perf.fnk'

try_catch_ = fn func:
r = func _
[false, r]


transform_file = fn fink_ast, code, filename, options:
ctx = init_ctx code, filename, options

[error, [js_ast]=[]] = try_catch_ fn:
[error, [js_ast]=[]] = try_catch fn:
[lir] = (timed transform) fink_ast, 'mod', ctx
[olir] = (timed optimize) lir, options
{js} = (timed transform_ir) olir, options
[js]

log_timings 'transform ${filename}'
# log_timings 'transform ${filename}'

extras = match options:
{module_type: 'cjs'}: module_transforms
Expand Down Expand Up @@ -70,7 +67,7 @@ generate = fn ast, filename, source, options={}:
js_ast = transform_file ast, source, filename, options

match js_ast:
{errors: [{}]}:
{errors: [?]}:
{code: '', source_map: '', errors: js_ast.errors}
else:
babel_generate js_ast, filename, source, options
Expand Down
4 changes: 2 additions & 2 deletions src/generate.test.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe 'source maps', fn:



skip.describe 'errors', fn:
describe 'errors', fn:
it 'handles parse errors', fn:
{errors: [{error}]} = fink2js '
foo = ['
Expand All @@ -103,7 +103,7 @@ skip.describe 'errors', fn:
Expected `,` or indented(>=1) new line or `]`.
'

it 'errors with code snippet', fn:
skip.it 'errors with code snippet', fn:
{errors: [{message}]} = fink2js '
foo = bar
123 = foo
Expand Down
41 changes: 27 additions & 14 deletions src/generate.test.fnk.snap
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,45 @@ const remove_unused_0 = (...args_0) => {
const tail_0 = items_0.slice(1);
const ctx_0 = args_0[1];
const out_0 = args_0[2];
const itm_4 = expr_0[2][0];
/* istanbul ignore else */
if (expr_0 === false) {
return [out_0, ctx_0];
}
/* istanbul ignore else */
if (true === _in_(expr_0[0], [\`mod\`, \`imp\`, \`af\`, \`ac\`, \`cc\`, \`cif\`, \`cf\`])) {
args_0 = [tail_0, ctx_0, [expr_0, ...args_0[2]]];
continue remove_unused_0;
if (null != expr_0) {
/* istanbul ignore else */
if (true === _in_(expr_0[0], [\`mod\`, \`imp\`, \`af\`, \`ac\`, \`cc\`, \`cif\`, \`cf\`])) {
args_0 = [tail_0, ctx_0, [expr_0, ...args_0[2]]];
continue remove_unused_0;
}
}
/* istanbul ignore else */
if (itm_4 === is_unused(itm_4, ctx_0)) {
args_0 = [tail_0, dec_refs(get_ref_args(expr_0), ctx_0), out_0];
continue remove_unused_0;
if (null != expr_0) {
const itm_1 = expr_0[2];
/* istanbul ignore else */
if (null != itm_1) {
/* istanbul ignore else */
if (true === is_unused(itm_1[0], ctx_0)) {
args_0 = [tail_0, dec_refs(get_ref_args(expr_0), ctx_0), out_0];
continue remove_unused_0;
}
}
}
/* istanbul ignore else */
if (true === _in_(expr_0[0], [\`fn\`, \`fnr\`, \`cn\`])) {
const tail_4 = expr_0.slice(1);
const items_2 = expr_0[1];
const right_1 = remove_unused_0(reverse(items_2[1]), ctx_0, []);
args_0 = [tail_0, right_1[1], [[expr_0[0], [items_2[0], right_1[0]], ...tail_4.slice(1)], ...args_0[2]]];
continue remove_unused_0;
if (null != expr_0) {
/* istanbul ignore else */
if (true === _in_(expr_0[0], [\`fn\`, \`fnr\`, \`cn\`])) {
const tail_5 = expr_0.slice(1);
const items_2 = expr_0[1];
const right_2 = remove_unused_0(reverse(items_2[1]), ctx_0, []);
args_0 = [tail_0, right_2[1], [[expr_0[0], [items_2[0], right_2[0]], ...tail_5.slice(1)], ...args_0[2]]];
continue remove_unused_0;
}
}
args_0 = [tail_0, ctx_0, [expr_0, ...args_0[2]]];
Expand All @@ -118,5 +131,5 @@ const remove_unused_0 = (...args_0) => {
};
export const remove_unused = remove_unused_0;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuZm5rIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O01BQWdCLGUsR0FBQTtBQUFBO0FBQUEsVUFBRyxPQUFILEdBQUcsU0FBSDtBQUFBLFVBQUcsTUFBSCxHQUFHLGVBQUg7QUFBQSxVQUFJLEtBQUosR0FBRyxPQUFDLEdBQUo7QUFBQSxVQUFJLE1BQUosR0FBSSxjQUFBLEtBQUksV0FBSixLQUFKO0FBQUEsVUFBSSxNQUFKLEdBQUcsT0FBQyxTQUFKO0FBQUEsVUFBMkIsS0FBM0IsR0FBMkIsU0FBM0I7QUFBQSxVQUFnQyxLQUFoQyxHQUFnQyxTQUFoQztBQUFBLFVBUU4sS0FSTSxHQUFJLE1BUVgsR0FBQyxHQVJNOztBQUFBO0FBRVosUUFGZ0IsTUFFaEI7QUFDUSxjQUhvQyxLQUdwQyxFQUgrQixLQUcvQjtBQUFJOztBQUhBO0FBS1gsc0JBTGUsTUFLZixLQUE2QyxDQUF0QyxLQUFzQyxFQUEvQixLQUErQixFQUF4QixJQUF3QixFQUFsQixJQUFrQixFQUFaLElBQVksRUFBTixLQUFNLEVBQUMsSUFBRCxDQUE3QyxHQUFEO0FBQUEsZUFDNEIsQ0FOWixNQU1ZLEVBTlcsS0FNWCxFQUFPLENBTm5CLE1BTW1CLEVBTl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biAgICAgIFtvdXQsIGN0eF1cblxuICAgIFs/IGluIFsnbW9kJywgJ2ltcCcsICdhZicsICdhYycsICdjYycsICdjaWYnLCAnY2YnXV06XG4gICAgICByZW1vdmVfdW51c2VkIGV4cHJzLCBjdHgsIFtleHByLCAuLi5vdXRdXG5cbiAgICBbLCAsIFtpc191bnVzZWQgPywgY3R4XV06XG4gICAgICBhcmdzID0gZ2V0X3JlZl9hcmdzIGV4cHJcbiAgICAgIG5leHRfY3R4ID0gZGVjX3JlZnMgYXJncywgY3R4XG4gICAgICByZW1vdmVfdW51c2VkIGV4cHJzLCBuZXh0X2N0eCwgb3V0XG5cbiAgICBbPyBpbiBbJ2ZuJywgJ2ZucicsICdjbiddXTpcbiAgICAgIFtvcCwgW2FyZ3MsIGJvZHldLCAuLi5yZXN0XSA9IGV4cHJcbiAgICAgIHJib2R5ID0gcmV2ZXJzZSBib2R5XG4gICAgICBbb2JvZHksIG5leHRfY3R4XSA9IHJlbW92ZV91bnVzZWQgcmJvZHksIGN0eCwgW11cbiAgICAgIG9leHByID0gW29wLCBbYXJncywgb2JvZHldLCAuLi5yZXN0XVxuICAgICAgcmVtb3ZlX3VudXNlZCBleHBycywgbmV4dF9jdHgsIFtvZXhwciwgLi4ub3V0XVxuXG4gICAgZWxzZTpcbiAgICAgIHJlbW92ZV91bnVzZWQgZXhwcnMsIGN0eCwgW2V4cHIsIC4uLm91dF1cbiJdfQ=="
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuZm5rIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O01BQWdCLGUsR0FBQTtBQUFBO0FBQUEsVUFBRyxPQUFILEdBQUcsU0FBSDtBQUFBLFVBQUcsTUFBSCxHQUFHLGVBQUg7QUFBQSxVQUFJLEtBQUosR0FBRyxPQUFDLEdBQUo7QUFBQSxVQUFJLE1BQUosR0FBSSxjQUFBLEtBQUksV0FBSixLQUFKO0FB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hwclxuICAgICAgcmJvZHkgPSByZXZlcnNlIGJvZHlcbiAgICAgIFtvYm9keSwgbmV4dF9jdHhdID0gcmVtb3ZlX3VudXNlZCByYm9keSwgY3R4LCBbXVxuICAgICAgb2V4cHIgPSBbb3AsIFthcmdzLCBvYm9keV0sIC4uLnJlc3RdXG4gICAgICByZW1vdmVfdW51c2VkIGV4cHJzLCBuZXh0X2N0eCwgW29leHByLCAuLi5vdXRdXG5cbiAgICBlbHNlOlxuICAgICAgcmVtb3ZlX3VudXNlZCBleHBycywgY3R4LCBbZXhwciwgLi4ub3V0XVxuIl19"
`;
22 changes: 11 additions & 11 deletions src/ir/assignment/init.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -63,48 +63,48 @@ get_key_val = fn expr, ctx:



transform_dr = fn [expr=false, ...exprs], rec_id, ctx, keys=[], prev=[], fallback:
transform_dr = fn [expr=false, ...exprs], rec_id, ctx, transform_dl, keys=[], prev=[], fallback:
match expr:
false:
[prev, rec_id, ctx]

{type: 'spread'}:
[val_id, next_ctx] = bind expr.right, ctx
out = ['rec_d', [rec_id, ...keys], [val_id], {loc: expr.loc}]
transform_dr exprs, rec_id, next_ctx, keys, [...prev, out]
transform_dr exprs, rec_id, next_ctx, transform_dl, keys, [...prev, out]

{right: false}:
[key, key_id, val_id, next_ctx] = get_key_val expr, ctx
[val, end_ctx] = rec_get rec_id, key_id, val_id, {loc: expr.loc}, next_ctx, fallback
transform_dr exprs, rec_id, end_ctx, [...keys, key_id], [...prev, ...key, ...val]
transform_dr exprs, rec_id, end_ctx, transform_dl, [...keys, key_id], [...prev, ...key, ...val]

{right.type: 'assign'}:
{left, right} = expr.right
[flbk, flbk_id, dl_ctx] = transform right, 'flbk', ctx
transform_dr
[{...expr, right: left}, ...exprs]
rec_id, dl_ctx, keys, [...prev, ...flbk], flbk_id
rec_id, dl_ctx, transform_dl, keys, [...prev, ...flbk], flbk_id

{left.type: 'member'}:
{exprs: rx} = members_as_rec expr.left, expr.right
transform_dr [...rx, ...exprs], rec_id, ctx, keys, prev, fallback
transform_dr [...rx, ...exprs], rec_id, ctx, transform_dl, keys, prev, fallback

{right.type: ? in ['ident', 'empty']}:
[key, key_id, val_id, next_ctx] = get_key_val expr, ctx
[val, end_ctx] = rec_get rec_id, key_id, val_id, {loc: expr.loc}, next_ctx, fallback
transform_dr exprs, rec_id, end_ctx, [...keys, key_id], [...prev, ...key, ...val]
transform_dr exprs, rec_id, end_ctx, transform_dl, [...keys, key_id], [...prev, ...key, ...val]

{right.type: 'rec'}:
[key, key_id, val_id, next_ctx] = get_key_val expr, ctx
[val, items_ctx] = rec_get rec_id, key_id, val_id, {loc: expr.loc}, next_ctx, fallback
[out, , end_ctx] = transform_dr expr.right.exprs, val_id, items_ctx
transform_dr exprs, rec_id, end_ctx, [...keys, key_id], [...prev, ...key, ...val, ...out]
[out, , end_ctx] = transform_dr expr.right.exprs, val_id, items_ctx, transform_dl
transform_dr exprs, rec_id, end_ctx, transform_dl, [...keys, key_id], [...prev, ...key, ...val, ...out]

{right.type: 'list'}:
[key, key_id, val_id, next_ctx] = get_key_val expr, ctx
[rest, items_ctx] = rec_get rec_id, key_id, val_id, {loc: expr.loc}, next_ctx, fallback
[out, , end_ctx] = transform_dl expr.right.exprs, val_id, items_ctx, []
transform_dr exprs, rec_id, end_ctx, [...keys, key_id], [...prev, ...key, ...rest, ...out]
transform_dr exprs, rec_id, end_ctx, transform_dl, [...keys, key_id], [...prev, ...key, ...rest, ...out]



Expand Down Expand Up @@ -167,7 +167,7 @@ transform_dl = fn [expr=false, ...exprs], tpl_id, ctx, prev=[], fallback:
{type: 'rec'}:
[val_id, items_ctx] = unique_ident 'drec', ctx
# TODO: reverse next two lines?
[out, , rest_ctx] = transform_dr expr.exprs, val_id, items_ctx, []
[out, , rest_ctx] = transform_dr expr.exprs, val_id, items_ctx, transform_dl, []
[items, tail_id, end_ctx] = head_tail tpl_id, val_id, {loc: expr.loc}, rest_ctx, fallback
transform_dl exprs, tail_id, end_ctx, [...prev, ...items, ...out]

Expand All @@ -183,7 +183,7 @@ transform_assign = fn node, , ctx:

{type: 'rec'}:
[right, r_id, next_ctx] = transform node.right, 'right', ctx
[left, , end_ctx] = transform_dr node.left.exprs, r_id, next_ctx
[left, , end_ctx] = transform_dr node.left.exprs, r_id, next_ctx, transform_dl
[[...right, ...left], end_ctx]

{type: 'ident'}:
Expand Down
10 changes: 5 additions & 5 deletions src/ir/async/init.test.fnk.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ rec >> exports_0:
lst_h args_3 >> hdm_0:
ifv hdm_0, hdm_0, flbk_0 >> curr_0:
lst_t args_3 >> tail_3:
cn ret_4:
= shrub >> value_0:
= shrub >> value_0:
cn ret_4:
cn:
= curr_0 >> left_2:
int 1 >> right_3:
Expand All @@ -65,9 +65,9 @@ rec >> exports_0:
cc ret_4, result_6
>> match_res_0:
cif cond_0, match_res_0, else_0
>> match_0:
ac match_0 >> result_4:
cc ret_3, result_4
>> match_0:
ac match_0 >> result_4:
cc ret_3, result_4
>> arg_0:
lst_a cargs_1, arg_0 >> cargs_4:
af callee_1, cargs_4 >> a_gen_0:
Expand Down
2 changes: 1 addition & 1 deletion src/ir/call/call.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ transform_all_args = fn [expr=false, ...exprs], args_id, ctx, out=[]:
next_ctx = rec:
...foo_ctx
partial_ident: ctx.partial_ident
# has_partial: ctx.has_partial or foo_ctx.has_partial
has_partial: ctx.has_partial or foo_ctx.has_partial
transform_all_args exprs, next_args_id, next_ctx, [...out, ...arg]


Expand Down
6 changes: 3 additions & 3 deletions src/ir/call/pipe.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ pipe_all = fn [expr=false, ...exprs], prev_res_id, ctx, out=[]:

{type: ? in ['ident', 'call']}:
[callee, callee_id, next_ctx] = transform expr, 'pfn', ctx
[call, res_id, end_ctx] = apply_fun callee_id, prev_res_id, {loc: expr.loc}, next_ctx
[call, res_id, end_ctx] = apply_fun callee_id, prev_res_id, expr, next_ctx
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, next_ctx] = transform_with_partial expr, 'pfn', ctx
[call, res_id, end_ctx] = apply_fun callee_id, prev_res_id, {loc: expr.loc}, next_ctx
[callee, callee_id, {has_partial: _, partial_ident: _, ...next_ctx}] = transform_with_partial expr, 'pfn', ctx
[call, res_id, end_ctx] = apply_fun callee_id, prev_res_id, expr, next_ctx
pipe_all exprs, res_id, end_ctx, [...out, ...callee, ...call]


Expand Down
26 changes: 15 additions & 11 deletions src/ir/call/pipe.test.fnk.snap
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,19 @@ rec >> exports_0:
af pfn_4, args_7 >> ppr_2:
= shrub >> callee_2:
lst >> cargs_5:
= prtl_3 >> left_0:
int 1 >> right_0:
> left_0, right_0 >> arg_3:
lst_a cargs_5, arg_3 >> cargs_6:
af callee_2, cargs_6 >> pfn_5:
lst >> args_8:
lst_a args_8, ppr_2 >> args_9:
af pfn_5, args_9 >> ppr_3:
= ppr_3 >> mex_0:
lst >> drctvs_0:
mod exports_0, drctvs_0 >> mod_0:"
fn args_8, ret_2:
lst_h args_8 >> prtl_4:
= prtl_4 >> left_0:
int 1 >> right_0:
> left_0, right_0 >> arg_3:
cc ret_2, arg_3
>> pfn_6:
lst_a cargs_5, pfn_6 >> cargs_6:
af callee_2, cargs_6 >> pfn_5:
lst >> args_9:
lst_a args_9, ppr_2 >> args_10:
af pfn_5, args_10 >> ppr_3:
= ppr_3 >> mex_0:
lst >> drctvs_0:
mod exports_0, drctvs_0 >> mod_0:"
`;
29 changes: 0 additions & 29 deletions src/ir/comments/init.fnk

This file was deleted.

Loading

0 comments on commit 8454c84

Please sign in to comment.