Skip to content

Commit

Permalink
Revert "Protect List from freezing on self-recursion"
Browse files Browse the repository at this point in the history
  • Loading branch information
vrurg committed Sep 15, 2019
1 parent 7dede2d commit bfe4613
Showing 1 changed file with 58 additions and 60 deletions.
118 changes: 58 additions & 60 deletions src/core.c/List.pm6
Expand Up @@ -1248,71 +1248,69 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
}

method join(List:D: Str(Cool) $separator = '') is nodal {
self.gistseen(self.^name, {
nqp::stmts(
nqp::stmts(
nqp::if(
nqp::isconcrete($!todo),
nqp::stmts( # need to reify first
$!todo.reify-until-lazy,
nqp::if(
nqp::isconcrete($!todo),
nqp::stmts( # need to reify first
$!todo.reify-until-lazy,
$!todo.fully-reified,
($!todo := nqp::null), # all reified
(my int $infinite = 1) # still stuff left to do
)
)
),
nqp::if(
nqp::isconcrete($!reified)
&& (my int $elems = nqp::elems($!reified)),
nqp::stmts( # something to join
(my $strings := nqp::list_s),
(my int $i = -1),
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::stmts( # something left to check
(my $tmp := nqp::ifnull(
nqp::atpos($!reified,$i),
nqp::if(
nqp::isconcrete(my $default),
$default, # seen before
($default := nqp::if( # first time we see null
nqp::can(self,'default'),
self.default.Str,
''
))
)
)),
nqp::if(
$!todo.fully-reified,
($!todo := nqp::null), # all reified
(my int $infinite = 1) # still stuff left to do
)
)
),
nqp::if(
nqp::isconcrete($!reified)
&& (my int $elems = nqp::elems($!reified)),
nqp::stmts( # something to join
(my $strings := nqp::list_s),
(my int $i = -1),
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::stmts( # something left to check
(my $tmp := nqp::ifnull(
nqp::atpos($!reified,$i),
nqp::if(
nqp::isconcrete(my $default),
$default, # seen before
($default := nqp::if( # first time we see null
nqp::can(self,'default'),
self.default.Str,
''
))
)
nqp::isconcrete($tmp),
nqp::if( # not a type object
nqp::istype($tmp,Junction),
(return self!JUNCTIONIZE( # follow Junction path
$separator, $strings, $i, $elems, $tmp
)),
nqp::if(
nqp::isconcrete($tmp),
nqp::if( # not a type object
nqp::istype($tmp,Junction),
(return self!JUNCTIONIZE( # follow Junction path
$separator, $strings, $i, $elems, $tmp
)),
nqp::push_s( # no special action needed
$strings,
nqp::if(
nqp::istype($tmp,Str),
$tmp,
nqp::if(
nqp::can($tmp,'Str'),
$tmp.Str,
nqp::box_s($tmp,Str)
)
)
nqp::push_s( # no special action needed
$strings,
nqp::if(
nqp::istype($tmp,Str),
$tmp,
nqp::if(
nqp::can($tmp,'Str'),
$tmp.Str,
nqp::box_s($tmp,Str)
)
),
nqp::push_s($strings,$tmp.Str) # type object
)
)
)
),
nqp::if($infinite,nqp::push_s($strings,'...')),
nqp::p6box_s(nqp::join($separator,$strings)) # done
),
nqp::if($infinite,'...','') # nothing to join
)
)
})
),
nqp::push_s($strings,$tmp.Str) # type object
)
)
),
nqp::if($infinite,nqp::push_s($strings,'...')),
nqp::p6box_s(nqp::join($separator,$strings)) # done
),
nqp::if($infinite,'...','') # nothing to join
)
)
}

# When we find a Junction in the list, start handling the rest
Expand Down

0 comments on commit bfe4613

Please sign in to comment.