diff options
Diffstat (limited to 'stdlib/source/library/lux/meta/target/jvm/attribute')
-rw-r--r-- | stdlib/source/library/lux/meta/target/jvm/attribute/line_number_table.lux | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/stdlib/source/library/lux/meta/target/jvm/attribute/line_number_table.lux b/stdlib/source/library/lux/meta/target/jvm/attribute/line_number_table.lux new file mode 100644 index 000000000..1a3e73ece --- /dev/null +++ b/stdlib/source/library/lux/meta/target/jvm/attribute/line_number_table.lux @@ -0,0 +1,71 @@ +... https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.12 +(.require + [library + [lux (.except) + [abstract + [equivalence (.only Equivalence)]] + [data + ["[0]" product] + ["[0]" binary + ["![1]" \\format (.only Format) (.use "[1]#[0]" monoid)]] + [collection + ["[0]" sequence (.only Sequence)]]] + [math + [number + ["n" nat]]]]] + [/// + [encoding + ["[0]" unsigned (.only U2)]]]) + +(type .public Entry + (Record + [#start_program_counter U2 + #line_number U2])) + +(def entry_length + Nat + (all n.+ + ... u2 start_pc; + unsigned.bytes/2 + ... u2 line_number; + unsigned.bytes/2 + )) + +(def entry_equivalence + (Equivalence Entry) + (all product.equivalence + unsigned.equivalence + unsigned.equivalence + )) + +(def (entry_format it) + (Format Entry) + (all !binary#composite + (unsigned.format/2 (the #start_program_counter it)) + (unsigned.format/2 (the #line_number it)) + )) + +(type .public Line_Number_Table + (Sequence Entry)) + +(def .public empty + Line_Number_Table + sequence.empty) + +(def .public (length it) + (-> Line_Number_Table + Nat) + (all n.+ + ... u2 line_number_table_length; + unsigned.bytes/2 + ... line_number_table[line_number_table_length]; + (n.* entry_length (sequence.size it)) + )) + +(def .public equivalence + (Equivalence Line_Number_Table) + (sequence.equivalence entry_equivalence)) + +(def .public format + (Format Line_Number_Table) + (!binary.sequence_16 entry_format)) |