(.module: [library [lux {"-" [Type static public private]} [abstract [equivalence {"+" [Equivalence]}] ["[0]" monad {"+" [do]}]] [control ["[0]" try]] [data ["[0]" product] ["[0]" format "_" ["[1]" binary {"+" [Writer]} ("[1]\[0]" monoid)]] [collection ["[0]" row {"+" [Row]}]]]]] ["[0]" // "_" ["[1][0]" modifier {"+" [Modifier modifiers:]}] ["[1][0]" index {"+" [Index]}] ["[1][0]" attribute {"+" [Attribute]} ["[1]/[0]" code]] ["[1][0]" constant {"+" [UTF8]} ["[1]/[0]" pool {"+" [Pool Resource]}]] ["[1][0]" bytecode {"+" [Bytecode]} ["[1]/[0]" environment {"+" [Environment]}] ["[1]/[0]" instruction]] ["[1][0]" type {"+" [Type]} ["[1]/[0]" category] ["[1][0]" descriptor {"+" [Descriptor]}]]]) (type: .public Method (Rec Method (Record [#modifier (Modifier Method) #name (Index UTF8) #descriptor (Index (Descriptor //type/category.Method)) #attributes (Row Attribute)]))) (modifiers: Method ["0001" public] ["0002" private] ["0004" protected] ["0008" static] ["0010" final] ["0020" synchronized] ["0040" bridge] ["0080" var_args] ["0100" native] ["0400" abstract] ["0800" strict] ["1000" synthetic] ) (def: .public (method modifier name type attributes code) (-> (Modifier Method) UTF8 (Type //type/category.Method) (List (Resource Attribute)) (Maybe (Bytecode Any)) (Resource Method)) (do [! //constant/pool.monad] [@name (//constant/pool.utf8 name) @descriptor (//constant/pool.descriptor (//type.descriptor type)) attributes (|> attributes (monad.all !) (\ ! each row.of_list)) attributes (case code (#.Some code) (do ! [environment (case (if (//modifier.has? static modifier) (//bytecode/environment.static type) (//bytecode/environment.virtual type)) (#try.Success environment) (in environment) (#try.Failure error) (function (_ _) (#try.Failure error))) [environment exceptions instruction output] (//bytecode.resolve environment code) .let [bytecode (|> instruction //bytecode/instruction.result format.instance)] @code (//attribute.code [#//attribute/code.limit (value@ #//bytecode/environment.limit environment) #//attribute/code.code bytecode #//attribute/code.exception_table exceptions #//attribute/code.attributes (row.row)])] (in (row.suffix @code attributes))) #.None (in attributes))] (in [#modifier modifier #name @name #descriptor @descriptor #attributes attributes]))) (def: .public equivalence (Equivalence Method) ($_ product.equivalence //modifier.equivalence //index.equivalence //index.equivalence (row.equivalence //attribute.equivalence) )) (def: .public (writer field) (Writer Method) (`` ($_ format\composite (~~ (template [ ] [( (value@ field))] [//modifier.writer #modifier] [//index.writer #name] [//index.writer #descriptor] [(format.row/16 //attribute.writer) #attributes])) )))