aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2019-06-20 03:10:30 -0400
committerEduardo Julian2019-06-20 03:10:30 -0400
commit67687850677bb34df37d6e9d1a2578d1198108d6 (patch)
treea95fd8c582b073e75a5ac9323d984dc9c797e290 /stdlib/source
parent940bd554301c495740aae543dd553dcb6e5fee54 (diff)
Re-factored exceptions.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/target/jvm/attribute/code.lux53
-rw-r--r--stdlib/source/lux/target/jvm/attribute/code/exception.lux51
2 files changed, 58 insertions, 46 deletions
diff --git a/stdlib/source/lux/target/jvm/attribute/code.lux b/stdlib/source/lux/target/jvm/attribute/code.lux
index 120b56d9c..4cc47b5af 100644
--- a/stdlib/source/lux/target/jvm/attribute/code.lux
+++ b/stdlib/source/lux/target/jvm/attribute/code.lux
@@ -7,54 +7,15 @@
["<>" parser]]
[data
[format
- [".F" binary (#+ Reader Writer Format) ("#@." monoid)]]
+ [".F" binary (#+ Reader Writer) ("#@." monoid)]]
[collection
["." row (#+ Row) ("#@." functor fold)]]]
[world
["." binary (#+ Binary)]]]
["." /// #_
- [constant (#+ Class)]
- ["#." encoding (#+ U2)]
- ["#." index (#+ Index)]]
+ ["#." encoding (#+ U2)]]
["." / #_
- ["#." label (#+ Label)]])
-
-(type: #export Exception
- {#start-pc Label
- #end-pc Label
- #handler-pc Label
- #catch-type (Index Class)})
-
-(def: #export exception-equivalence
- (Equivalence Exception)
- ($_ equivalence.product
- /label.equivalence
- /label.equivalence
- /label.equivalence
- ///index.equivalence
- ))
-
-## https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3
-(def: exception-frame-length
- ($_ n/+
- ## u2 start_pc;
- ///encoding.u2-bytes
- ## u2 end_pc;
- ///encoding.u2-bytes
- ## u2 handler_pc;
- ///encoding.u2-bytes
- ## u2 catch_type;
- ///encoding.u2-bytes
- ))
-
-(def: exception-format
- (Format Exception)
- ($_ binaryF.and
- /label.format
- /label.format
- /label.format
- ///index.format
- ))
+ ["#." exception (#+ Exception)]])
(type: #export (Code Attribute)
{#max-stack U2
@@ -80,7 +41,7 @@
(|> code
(get@ #exception-table)
row.size
- (n/* ..exception-frame-length))
+ (n/* /exception.length))
## u2 attributes_count;
///encoding.u2-bytes
## attribute_info attributes[attributes_count];
@@ -96,7 +57,7 @@
///encoding.u2-equivalence
///encoding.u2-equivalence
binary.equivalence
- (row.equivalence ..exception-equivalence)
+ (row.equivalence /exception.equivalence)
(row.equivalence attribute-equivalence)
))
@@ -117,7 +78,7 @@
## u2 exception_table_length;
## exception_table[exception_table_length];
(get@ #binaryF.reader
- (binaryF.row/16 ..exception-format))
+ (binaryF.row/16 /exception.format))
## u2 attributes_count;
## attribute_info attributes[attributes_count];
(get@ #binaryF.reader
@@ -142,7 +103,7 @@
(get@ #code code))
## u2 exception_table_length;
## exception_table[exception_table_length];
- ((get@ #binaryF.writer (binaryF.row/16 exception-format))
+ ((get@ #binaryF.writer (binaryF.row/16 /exception.format))
(get@ #exception-table code))
## u2 attributes_count;
## attribute_info attributes[attributes_count];
diff --git a/stdlib/source/lux/target/jvm/attribute/code/exception.lux b/stdlib/source/lux/target/jvm/attribute/code/exception.lux
new file mode 100644
index 000000000..6ec0a1773
--- /dev/null
+++ b/stdlib/source/lux/target/jvm/attribute/code/exception.lux
@@ -0,0 +1,51 @@
+(.module:
+ [lux #*
+ [abstract
+ ["." equivalence (#+ Equivalence)]]
+ [data
+ [format
+ [".F" binary (#+ Format)]]]]
+ ["." // #_
+ ["#." label (#+ Label)]
+ ["//#" /// #_
+ [constant (#+ Class)]
+ ["#." encoding (#+ U2)]
+ ["#." index (#+ Index)]]])
+
+(type: #export Exception
+ {#start-pc Label
+ #end-pc Label
+ #handler-pc Label
+ #catch-type (Index Class)})
+
+(def: #export equivalence
+ (Equivalence Exception)
+ ($_ equivalence.product
+ //label.equivalence
+ //label.equivalence
+ //label.equivalence
+ ////index.equivalence
+ ))
+
+## https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3
+(def: #export length
+ Nat
+ ($_ n/+
+ ## u2 start_pc;
+ ////encoding.u2-bytes
+ ## u2 end_pc;
+ ////encoding.u2-bytes
+ ## u2 handler_pc;
+ ////encoding.u2-bytes
+ ## u2 catch_type;
+ ////encoding.u2-bytes
+ ))
+
+(def: #export format
+ (Format Exception)
+ ($_ binaryF.and
+ //label.format
+ //label.format
+ //label.format
+ ////index.format
+ ))