diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial.lux | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial.lux new file mode 100644 index 000000000..0f3c9ced5 --- /dev/null +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial.lux @@ -0,0 +1,53 @@ +(.module: + [lux #* + [abstract + ["." monad]] + [control + [state (#+ State)]] + [data + [number + ["n" nat]] + [collection + ["." list ("#@." functor)] + ["." row]]] + [target + [jvm + ["." field (#+ Field)] + ["_" instruction (#+ Label Instruction) ("#@." monad)] + [constant + [pool (#+ Pool)]]]]] + ["." / #_ + ["#." count] + ["/#" // + ["/#" // #_ + ["#." arity] + ["/#" // #_ + ["#." reference] + [//// + ["." arity (#+ Arity)]]]]]]) + +(def: #export (initial amount) + (-> Nat (Instruction Any)) + ($_ _.compose + (|> _.aconst-null + (list.repeat amount) + (monad.seq _.monad)) + (_@wrap []))) + +(def: #export fields + (-> Arity (List (State Pool Field))) + (|>> (n.- ///arity.minimum) + list.indices + (list@map (function (_ index) + (field.field //.modifier + (////reference.partial-name index) + //.type + (row.row)))))) + +(def: #export (new arity) + (-> Arity (Instruction Any)) + (if (arity.multiary? arity) + ($_ _.compose + /count.initial + (initial (n.- ///arity.minimum arity))) + (_@wrap []))) |