aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/target/jvm/bytecode/environment/limit.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/target/jvm/bytecode/environment/limit.lux')
-rw-r--r--stdlib/source/lux/target/jvm/bytecode/environment/limit.lux42
1 files changed, 42 insertions, 0 deletions
diff --git a/stdlib/source/lux/target/jvm/bytecode/environment/limit.lux b/stdlib/source/lux/target/jvm/bytecode/environment/limit.lux
new file mode 100644
index 000000000..2e2312fb5
--- /dev/null
+++ b/stdlib/source/lux/target/jvm/bytecode/environment/limit.lux
@@ -0,0 +1,42 @@
+(.module:
+ [lux #*
+ [abstract
+ ["." equivalence (#+ Equivalence)]]
+ [data
+ [number
+ ["n" nat]]
+ ["." format #_
+ ["#" binary (#+ Writer) ("#@." monoid)]]]]
+ ["." / #_
+ ["#." stack (#+ Stack)]
+ ["#." registry (#+ Registry)]])
+
+(type: #export Limit
+ {#stack Stack
+ #registry Registry})
+
+(def: #export start
+ Limit
+ {#stack /stack.empty
+ #registry /registry.empty})
+
+(def: #export length
+ ($_ n.+
+ ## u2 max_stack;
+ /stack.length
+ ## u2 max_locals;
+ /registry.length))
+
+(def: #export equivalence
+ (Equivalence Limit)
+ ($_ equivalence.product
+ /stack.equivalence
+ /registry.equivalence
+ ))
+
+(def: #export (writer limit)
+ (Writer Limit)
+ ($_ format@compose
+ (/stack.writer (get@ #stack limit))
+ (/registry.writer (get@ #registry limit))
+ ))