UNPKG

@fink/loxia

Version:

A fink to JavaScript compiler.

94 lines (84 loc) 2.31 kB
import { add as add_0 } from "../context.js"; import { any as any_0 } from "../context.js"; import { unique_or_id as unique_or_id_0 } from "../context.js"; import { ir_fn as ir_fn_0 } from "../context.js"; import { inc_ref as inc_ref_0 } from "../context.js"; const bind_0 = (drec_0, ctx_0) => { const value_0 = drec_0.value; const val_0 = ctx_0.scopes; const dlst_0 = unique_or_id_0(value_0, { loc: drec_0.loc }, ctx_0); const id_0 = dlst_0[0]; return [id_0, { ...dlst_0[1], scopes: [{ ...val_0[0], [value_0]: id_0 }, ...val_0.slice(1)] }]; }; const bind_x_0 = (drec_2, id_1, ctx_1) => { const val_4 = ctx_1.scopes; return { ...ctx_1, scopes: [{ ...val_4[0], [drec_2.value]: id_1 }, ...val_4.slice(1)] }; }; const get_ident_0 = (...args_2) => { get_ident_0: do { const name_0 = args_2[0]; const dlst_1 = args_2[1]; const scope_2 = dlst_1[0]; const loc_1 = args_2[2].loc; const ctx_2 = args_2[3]; /* istanbul ignore else */ if (null != scope_2) { /* istanbul ignore else */ if (undefined !== scope_2[name_0]) { const id_2 = { ...scope_2[name_0], loc: loc_1 }; const next_ctx_1 = inc_ref_0(id_2, ctx_2); return [id_2, next_ctx_1]; } } /* istanbul ignore else */ if (undefined !== scope_2) { args_2 = [name_0, dlst_1.slice(1), { loc: loc_1 }, ctx_2]; continue get_ident_0; } return [{ i: name_0, loc: loc_1 }, ctx_2]; } while (true); }; const let_0 = (id_3, res_id_0, drec_5, ctx_3) => { const result_13 = ir_fn_0(`=`, [id_3], res_id_0, { loc: drec_5.loc }, ctx_3); return result_13; }; const transform_ident_0 = (drec_6, res_id_1, ctx_4) => { const loc_3 = drec_6.loc; const dlst_2 = get_ident_0(drec_6.value, ctx_4.scopes, { loc: loc_3 }, ctx_4); const dlst_3 = let_0(dlst_2[0], res_id_1, { loc: loc_3 }, dlst_2[1]); return [dlst_3[0], dlst_3[2]]; }; const add_ident_0 = ctx_5 => { const pfn_0 = add_0(`ident`, any_0, transform_ident_0); const ppr_0 = pfn_0(ctx_5); return ppr_0; }; export const bind = bind_0, bind_x = bind_x_0, get_ident = get_ident_0, ˆlet = let_0, transform_ident = transform_ident_0, add_ident = add_ident_0;