aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial.lux')
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial.lux53
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 [])))