diff options
author | Eduardo Julian | 2019-11-16 22:40:58 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-11-16 22:40:58 -0400 |
commit | a5a71a224408b6a7a736fd2f4c06646bf5c89fd8 (patch) | |
tree | 6cee733ec9e636153e25f9a588098b45ed728868 /stdlib/source/lux/target/jvm/bytecode/environment/limit/registry.lux | |
parent | 7ddf25a555265b8cd8218b368fc66e416c60abe9 (diff) |
Tests for JVM bytecode machinery. [Part 5]
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/target/jvm/bytecode/environment/limit/registry.lux | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/stdlib/source/lux/target/jvm/bytecode/environment/limit/registry.lux b/stdlib/source/lux/target/jvm/bytecode/environment/limit/registry.lux index eb3820bfb..3a8bd4482 100644 --- a/stdlib/source/lux/target/jvm/bytecode/environment/limit/registry.lux +++ b/stdlib/source/lux/target/jvm/bytecode/environment/limit/registry.lux @@ -1,20 +1,30 @@ (.module: - [lux (#- for) + [lux (#- Type for static) [abstract ["." equivalence (#+ Equivalence)]] [control - ["." try]] + ["." try (#+ Try) ("#@." functor)]] [data + [number + ["n" nat]] [format - [binary (#+ Writer)]]] + [binary (#+ Writer)]] + [collection + ["." list ("#@." functor fold)]]] [type abstract]] ["." ///// #_ [encoding - ["#." unsigned (#+ U1 U2)]]]) + ["#." unsigned (#+ U1 U2)]] + ["#." type (#+ Type) + [category (#+ Method)] + ["#/." parser]]]) (type: #export Register U1) +(def: normal 1) +(def: wide 2) + (abstract: #export Registry {} @@ -24,9 +34,28 @@ (-> U2 Registry) (|>> :abstraction)) - (def: #export empty - Registry - (|> 0 /////unsigned.u2 try.assume :abstraction)) + (def: (minimal type) + (-> (Type Method) Nat) + (let [[inputs output exceptions] (/////type/parser.method type)] + (|> inputs + (list@map (function (_ input) + (if (or (is? /////type.long input) + (is? /////type.double input)) + ..wide + ..normal))) + (list@fold n.+ 0)))) + + (template [<start> <name>] + [(def: #export <name> + (-> (Type Method) (Try Registry)) + (|>> ..minimal + (n.+ <start>) + /////unsigned.u2 + (try@map ..registry)))] + + [0 static] + [1 virtual] + ) (def: #export equivalence (Equivalence Registry) @@ -53,8 +82,8 @@ try.assume :abstraction)))] - [for 1] - [for-wide 2] + [for ..normal] + [for-wide ..wide] ) ) |