diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/target/jvm/method.lux | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/stdlib/source/lux/target/jvm/method.lux b/stdlib/source/lux/target/jvm/method.lux index 060ad1bc1..cd62830ea 100644 --- a/stdlib/source/lux/target/jvm/method.lux +++ b/stdlib/source/lux/target/jvm/method.lux @@ -16,14 +16,14 @@ [type [abstract (#+)]]] ["." // #_ - ["#." modifier (#+ Modifier modifiers:)] + ["#." modifier (#+ Modifier modifiers:) ("#@." monoid)] ["#." index (#+ Index)] ["#." attribute (#+ Attribute) ["#/." code]] ["#." constant (#+ UTF8) ["#/." pool (#+ Pool Resource)]] ["#." bytecode (#+ Bytecode) - ["#/." environment] + ["#/." environment (#+ Environment)] ["#/." instruction]] ["#." type (#+ Type) ["#/." category] @@ -51,22 +51,39 @@ ) (def: #export (method modifier name type attributes code) - (-> (Modifier Method) UTF8 (Type //type/category.Method) (List (Resource Attribute)) (Bytecode Any) + (-> (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 (monad.seq @ attributes) - [environment exceptions instruction output] (//bytecode.resolve code) - #let [bytecode (|> instruction //bytecode/instruction.run format.instance)] - @code (//attribute.code {#//attribute/code.limit (get@ #//bytecode/environment.limit environment) - #//attribute/code.code bytecode - #//attribute/code.exception-table exceptions - #//attribute/code.attributes (row.row)})] + attributes (|> attributes + (monad.seq @) + (:: @ map row.from-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) + (wrap environment) + + (#try.Failure error) + (function (_ _) (#try.Failure error))) + [environment exceptions instruction output] (//bytecode.resolve environment code) + #let [bytecode (|> instruction //bytecode/instruction.run format.instance)] + @code (//attribute.code {#//attribute/code.limit (get@ #//bytecode/environment.limit environment) + #//attribute/code.code bytecode + #//attribute/code.exception-table exceptions + #//attribute/code.attributes (row.row)})] + (wrap (row.add @code attributes))) + + #.None + (wrap attributes))] (wrap {#modifier modifier #name @name #descriptor @descriptor - #attributes (|> attributes row.from-list (row.add @code))}))) + #attributes attributes}))) (def: #export equivalence (Equivalence Method) |