diff options
Diffstat (limited to 'stdlib/source/library/lux/target/jvm/bytecode.lux')
-rw-r--r-- | stdlib/source/library/lux/target/jvm/bytecode.lux | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 9b16b5be6..7e56004c3 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -51,14 +51,17 @@ ["." reflection] ["." parser]]]]) -(type: .public Label Nat) +(type: .public Label + Nat) -(type: .public Resolver (Dictionary Label [Stack (Maybe Address)])) +(type: .public Resolver + (Dictionary Label [Stack (Maybe Address)])) (type: .public Tracker - {#program_counter Address - #next Label - #known Resolver}) + (Record + {#program_counter Address + #next Label + #known Resolver})) (def: fresh Tracker @@ -82,7 +85,7 @@ (def: identity ..relative_identity) - (def: (compose left right) + (def: (composite left right) (cond (same? ..relative_identity left) right @@ -94,8 +97,8 @@ (do try.monad [[left_exceptions left_instruction] (left resolver) [right_exceptions right_instruction] (right resolver)] - (in [(\ row.monoid compose left_exceptions right_exceptions) - (_\compose left_instruction right_instruction)])))))) + (in [(\ row.monoid composite left_exceptions right_exceptions) + (_\composite left_instruction right_instruction)])))))) (type: .public (Bytecode a) (+State Try [Pool Environment Tracker] (Writer Relative a))) @@ -687,12 +690,14 @@ ["Start" (|> @from /address.value //unsigned.value %.nat)] ["Target" (|> jump //signed.value %.int)])) -(type: Any_Jump (Either Big_Jump Jump)) +(type: Any_Jump + (Either Big_Jump + Jump)) (def: (jump @from @to) (-> Address Address (Try Any_Jump)) (do {! try.monad} - [jump (\ ! map //signed.value + [jump (\ ! each //signed.value (/address.jump @from @to))] (let [big? (n.> (//unsigned.value //unsigned.maximum/2) (.nat (i.* (if (i.>= +0 jump) @@ -700,8 +705,8 @@ -1) jump)))] (if big? - (\ ! map (|>> #.Left) (//signed.s4 jump)) - (\ ! map (|>> #.Right) (//signed.s2 jump)))))) + (\ ! each (|>> #.Left) (//signed.s4 jump)) + (\ ! each (|>> #.Right) (//signed.s2 jump)))))) (exception: .public (unset_label {label Label}) (exception.report @@ -857,15 +862,15 @@ [@default (|> default get (monad.then ! product.right)) @at_minimum (|> at_minimum get (monad.then ! product.right)) @afterwards (|> afterwards - (monad.map ! get) - (monad.then ! (monad.map ! product.right)))] + (monad.each ! get) + (monad.then ! (monad.each ! product.right)))] (in [@default @at_minimum @afterwards])) (#.Some [@default @at_minimum @afterwards]) (do {! try.monad} - [>default (\ ! map ..big_jump (..jump @from @default)) - >at_minimum (\ ! map ..big_jump (..jump @from @at_minimum)) - >afterwards (monad.map ! (|>> (..jump @from) (\ ! map ..big_jump)) - @afterwards)] + [>default (\ ! each ..big_jump (..jump @from @default)) + >at_minimum (\ ! each ..big_jump (..jump @from @at_minimum)) + >afterwards (monad.each ! (|>> (..jump @from) (\ ! each ..big_jump)) + @afterwards)] (in [..no_exceptions (bytecode minimum >default [>at_minimum >afterwards])])) #.None @@ -890,7 +895,7 @@ (in (let [@from (value@ #program_counter tracker)] [[pool environment' - (|> (list\mix (..acknowledge_label actual) tracker (list& default (list\map product.right cases))) + (|> (list\mix (..acknowledge_label actual) tracker (list& default (list\each product.right cases))) (with@ #program_counter program_counter'))] [(function (_ resolver) (let [get (: (-> Label (Maybe [Stack (Maybe Address)])) @@ -899,15 +904,15 @@ (case (do {! maybe.monad} [@default (|> default get (monad.then ! product.right)) @cases (|> cases - (monad.map ! (|>> product.right get)) - (monad.then ! (monad.map ! product.right)))] + (monad.each ! (|>> product.right get)) + (monad.then ! (monad.each ! product.right)))] (in [@default @cases])) (#.Some [@default @cases]) (do {! try.monad} - [>default (\ ! map ..big_jump (..jump @from @default)) + [>default (\ ! each ..big_jump (..jump @from @default)) >cases (|> @cases - (monad.map ! (|>> (..jump @from) (\ ! map ..big_jump))) - (\ ! map (|>> (list.zipped/2 (list\map product.left cases)))))] + (monad.each ! (|>> (..jump @from) (\ ! each ..big_jump))) + (\ ! each (|>> (list.zipped/2 (list\each product.left cases)))))] (in [..no_exceptions (bytecode >default >cases)])) #.None @@ -974,7 +979,7 @@ {#//constant/pool.name method #//constant/pool.descriptor (type.descriptor type)}) .let [consumption (|> inputs - (list\map ..type_size) + (list\each ..type_size) (list\mix n.+ (if <static?> 0 1)) //unsigned.u1 try.trusted) |