2 # Copyright (C) 2005-2009, Parrot Foundation.
5 # binarytrees.pir N (N = 16 for shootout)
6 # by Joshua Isom, modified by Leopold Toetsch
7 # modified by karl : default value of N=10 to match shootout output
33 .local pmc left, right, tree
35 unless dep > 0 goto else
39 left = bottomuptree($I0, dep)
40 right = bottomuptree(item2, dep)
46 tree = new 'FixedPMCArray'
57 .local int N, dep, mindepth, maxdepth, stretchdepth
58 .local pmc stretchtree, longlivedtree, tmptree
62 if argc == 1 goto default
67 unless N < 6 goto else
68 maxdepth = mindepth + 2
73 stretchdepth = maxdepth + 1
75 stretchtree = bottomuptree($I0, stretchdepth)
76 $I0 = itemcheck(stretchtree)
78 print "stretch tree of depth "
86 longlivedtree = bottomuptree($I0, maxdepth)
91 .local int i, iterations, check
105 tmptree = bottomuptree(i, dep)
106 $I0 = itemcheck(tmptree)
109 tmptree = bottomuptree($I0, dep)
110 $I0 = itemcheck(tmptree)
114 if i <= iterations goto beginfor_2
117 print "\t trees of depth "
125 if dep <= maxdepth goto beginfor_1
127 $I0 = itemcheck(longlivedtree)
128 print "long lived tree of depth "
140 # vim: expandtab shiftwidth=4 ft=pir: