diff options
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase')
3 files changed, 48 insertions, 67 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/apply.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/apply.lux index 68e81845b..ba9b80add 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/apply.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/apply.lux @@ -89,16 +89,12 @@ _.areturn) _ (do _.monad [@default _.new-label - #let [failure ($_ _.compose - (_.set-label @default) - ////runtime.apply-failure - _.aconst-null - _.areturn)] @labelsH _.new-label @labelsT (|> _.new-label (list.repeat (dec num-partials)) (monad.seq _.monad)) - #let [cases (|> (#.Cons [@labelsH @labelsT]) + #let [cases (|> (list@compose (#.Cons [@labelsH @labelsT]) + (list @default)) list.enumerate (list@map (function (_ [stage @case]) (let [current-partials (|> (list.indices stage) @@ -107,53 +103,51 @@ already-partial? (n.> 0 stage) exact-match? (i.= over-extent (.int stage)) has-more-than-necessary? (i.> over-extent (.int stage))] - (cond exact-match? - ($_ _.compose - (_.set-label @case) - ////reference.this - (if already-partial? - (_.invokevirtual class //reset.name (//reset.type class)) - (_@wrap [])) - current-partials - (..inputs ..this-offset apply-arity) - (_.invokevirtual class //implementation.name (//implementation.type function-arity)) - _.areturn) - - has-more-than-necessary? - (let [inputs-to-completion (|> function-arity (n.- stage)) - inputs-left (|> apply-arity (n.- inputs-to-completion))] - ($_ _.compose - (_.set-label @case) - ////reference.this - (_.invokevirtual class //reset.name (//reset.type class)) - current-partials - (..inputs ..this-offset inputs-to-completion) - (_.invokevirtual class //implementation.name (//implementation.type function-arity)) - (apply (n.+ ..this-offset inputs-to-completion) inputs-left) - _.areturn)) + ($_ _.compose + (_.set-label @case) + (cond exact-match? + ($_ _.compose + ////reference.this + (if already-partial? + (_.invokevirtual class //reset.name (//reset.type class)) + (_@wrap [])) + current-partials + (..inputs ..this-offset apply-arity) + (_.invokevirtual class //implementation.name (//implementation.type function-arity)) + _.areturn) + + has-more-than-necessary? + (let [inputs-to-completion (|> function-arity (n.- stage)) + inputs-left (|> apply-arity (n.- inputs-to-completion))] + ($_ _.compose + ////reference.this + (_.invokevirtual class //reset.name (//reset.type class)) + current-partials + (..inputs ..this-offset inputs-to-completion) + (_.invokevirtual class //implementation.name (//implementation.type function-arity)) + (apply (n.+ ..this-offset inputs-to-completion) inputs-left) + _.areturn)) - ## (i.< over-extent (.int stage)) - (let [current-environment (|> (list.indices (list.size environment)) - (list@map (///foreign.get class)) - (monad.seq _.monad)) - missing-partials (|> _.aconst-null - (list.repeat (|> num-partials (n.- apply-arity) (n.- stage))) - (monad.seq _.monad))] - ($_ _.compose - (_.set-label @case) - (_.new class) - _.dup - current-environment - ///partial/count.value - (..increment apply-arity) - current-partials - (..inputs ..this-offset apply-arity) - missing-partials - (_.invokevirtual class //init.name (//init.type environment function-arity)) - _.areturn)))))) + ## (i.< over-extent (.int stage)) + (let [current-environment (|> (list.indices (list.size environment)) + (list@map (///foreign.get class)) + (monad.seq _.monad)) + missing-partials (|> _.aconst-null + (list.repeat (|> num-partials (n.- apply-arity) (n.- stage))) + (monad.seq _.monad))] + ($_ _.compose + (_.new class) + _.dup + current-environment + ///partial/count.value + (..increment apply-arity) + current-partials + (..inputs ..this-offset apply-arity) + missing-partials + (_.invokevirtual class //init.name (//init.type environment function-arity)) + _.areturn))))))) (monad.seq _.monad))]] ($_ _.compose ///partial/count.value (_.tableswitch (try.assume (signed.s4 +0)) @default [@labelsH @labelsT]) - ## cases - failure))))))) + cases))))))) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/init.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/init.lux index 0a51d555d..7308c0734 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/init.lux @@ -41,7 +41,7 @@ (def: (partials arity) (-> Arity (List (Type Value))) - (list.repeat arity ////type.value)) + (list.repeat (dec arity) ////type.value)) (def: #export (type environment arity) (-> Environment Arity (Type category.Method)) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux index 89a1b94c1..99a8ed79a 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux @@ -230,12 +230,6 @@ (..illegal-state-exception message) _.athrow)))) -(def: apply-failure::name "apply_failure") -(def: #export apply-failure (..procedure ..apply-failure::name ..failure::type)) - -(def: apply-failure::method - (..failure ..apply-failure::name "Error while applying function.")) - (def: pm-failure::name "pm_failure") (def: #export pm-failure (..procedure ..pm-failure::name ..failure::type)) @@ -515,7 +509,6 @@ (list ..decode-frac::method ..variant::method - ..apply-failure::method ..pm-failure::method ..push::method @@ -547,16 +540,10 @@ (_.aload arity) (_.invokevirtual //function.class ..apply::name (..apply::type //function/arity.minimum)) _.areturn)))))) - (list& (method.method method.public + (list& (method.method (modifier@compose method.public method.abstract) ..apply::name (..apply::type //function/arity.minimum) (list) - ## TODO: It shouldn't be necessary to set the code for this method, since it's abstract. - ## Setting this might be a bug. Verify & fix ASAP. - (#.Some - ($_ _.compose - ..apply-failure - ..this - _.areturn))))) + #.None))) <init>::method (method.method method.public "<init>" //function.init (list) (#.Some |