Skip to content

Commit

Permalink
Remove a bunch of duplicate code, and mostly fix junction dispatch in…
Browse files Browse the repository at this point in the history
… the process.
  • Loading branch information
jnthn committed Oct 8, 2009
1 parent a67adbd commit ea0db83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
12 changes: 7 additions & 5 deletions src/builtins/control.pir
Expand Up @@ -507,7 +507,9 @@ on error.
# Build arguments based upon what the caller was originall invoked with,
# and tailcall the next candidate.
.local pmc pos_args, named_args
(pos_args, named_args) = '!get_original_args'(routine, lexpad)
$P0 = routine.'signature'()
$P0 = getattribute $P0, '$!ll_sig'
(pos_args, named_args) = '!get_original_args'($P0, lexpad)
next.'set_failure_mode'()
.tailcall next(pos_args :flat, named_args :flat :named)
.end
Expand All @@ -527,7 +529,9 @@ on error.
# get the result of the next candidate and use return to retrun from
# the caller, provided the defer did not fail.
.local pmc pos_args, named_args, result
(pos_args, named_args) = '!get_original_args'(routine, lexpad)
$P0 = routine.'signature'()
$P0 = getattribute $P0, '$!ll_sig'
(pos_args, named_args) = '!get_original_args'($P0, lexpad)
next.'set_failure_mode'()
(result) = next(pos_args :flat, named_args :flat :named)

Expand Down Expand Up @@ -570,17 +574,15 @@ of a hack.
=cut

.sub '!get_original_args'
.param pmc routine
.param pmc signature
.param pmc lexpad

# Get hold of the signature.
.local pmc signature, pos_args, named_args
pos_args = root_new ['parrot';'ResizablePMCArray']
named_args = root_new ['parrot';'Hash']
signature = routine.'signature'()
$I0 = defined signature
unless $I0 goto param_done
signature = getattribute signature, '$!ll_sig'
signature = descalarref signature

# Loop over the parameters.
Expand Down
27 changes: 3 additions & 24 deletions src/classes/Junction.pir
Expand Up @@ -366,30 +366,9 @@ parameters for the dispatcher.
.param pmc lexpad
.param pmc signature

# We build tuples of the args and pass them onto the main junction
# dispatcher.
.local pmc pos_args, name_args, it, param
pos_args = root_new ['parrot';'ResizablePMCArray']
name_args = root_new ['parrot';'Hash']
$P0 = signature.'params'()
it = iter $P0
param_loop:
unless it goto param_loop_end
.local pmc param
param = shift it
.local string name
.local pmc named, value
name = param['name']
named = param['named']
value = lexpad[name]
if null named goto pos_arg
name_args[named] = value
goto param_loop
pos_arg:
push pos_args, value
goto param_loop
param_loop_end:

# Get hold of arguments and defer to main junction dispatcher.
.local pmc pos_args, name_args
(pos_args, name_args) = '!get_original_args'(signature, lexpad)
.tailcall '!DISPATCH_JUNCTION'(sub, pos_args :flat, name_args :flat :named)
.end

Expand Down

0 comments on commit ea0db83

Please sign in to comment.