Index: CREDITS =================================================================== --- CREDITS (revision 31289) +++ CREDITS (working copy) @@ -311,6 +311,9 @@ N: Ion Alexandru Morega D: string.pmc, complex.pmc +N: isop +D: various Pynie patches + N: James E Keenan (Jim) D: Testing of configuration and build tools W: http://thenceforward.net/parrot/ Index: MANIFEST =================================================================== --- MANIFEST (revision 31289) +++ MANIFEST (working copy) @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Fri Sep 19 21:36:19 2008 UT +# generated by tools/dev/mk_manifest_and_skip.pl Sat Sep 20 19:49:16 2008 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -2453,6 +2453,7 @@ languages/pynie/t/00-parrot/10-augop.t [pynie] languages/pynie/t/00-parrot/11-boolop.t [pynie] languages/pynie/t/00-parrot/12-try.t [pynie] +languages/pynie/t/00-parrot/13-builtins.t [pynie] languages/pynie/t/harness [pynie] languages/regex/01_basic.pir [regex] languages/regex/02_date.pir [regex] Index: languages/pynie/src/builtins/funcs.pir =================================================================== --- languages/pynie/src/builtins/funcs.pir (revision 31290) +++ languages/pynie/src/builtins/funcs.pir (working copy) @@ -16,6 +16,8 @@ =cut +.namespace [] + =item abs(x) Return the absolute value of a number. The argument may be a plain or @@ -760,6 +762,10 @@ .sub 'len' .param pmc s + $I0 = elements s + $P0 = new 'Integer' + $P0 = $I0 + .return ($P0) .end @@ -776,6 +782,8 @@ .sub 'list' .param pmc sequence :optional + $P0 = 'listmaker'(sequence :flat) + .return ($P0) .end =item locals() @@ -1067,6 +1075,26 @@ =cut .sub 'range' + .param pmc stop + # XXX start, step + + .local int stopn + .local pmc lst + .local pmc tmp + + $I0 = 0 + lst = new 'ResizablePMCArray' + stopn = stop +loop: + unless $I0 < stopn goto done + tmp = new 'Integer' + tmp = $I0 + lst.push(tmp) + + inc $I0 + goto loop +done: + .return (lst) .end @@ -1349,6 +1377,13 @@ .sub 'str' .param pmc obj :optional + .param int has_obj :opt_flag + $P0 = new 'String' + unless has_obj goto done + $S0 = obj + $P0 = $S0 +done: + .return ($P0) .end =item sum(sequence[, start]) Index: languages/pynie/t/00-parrot/13-builtins.t =================================================================== --- languages/pynie/t/00-parrot/13-builtins.t (revision 0) +++ languages/pynie/t/00-parrot/13-builtins.t (revision 0) @@ -0,0 +1,35 @@ +#!./parrot pynie.pbc + +print '1..5' + +#len +n = len([1,2,3,4]) +if n == 4: print 'ok 1' +else: print 'not ok 1' + +#list +lst1 = [ 1,2,3,4 ] +lst2 = list(lst1) +lst1.pop() +lst1.pop() +lst1.pop() +lst1.pop() +if lst2[2] == 3: print 'ok 2' +else: print 'not ok 2' + +#range +lst = range(4) +ok = 0 +n = -1 +for i in lst: + n += 1 + if n == i: ok += 1 +if ok == 4: print 'ok 3' +else: print 'not ok 3' + +#str +if str(5) == '5': print 'ok 4' +else: print 'not ok 4' + +if len(str(861)) == 3: print 'ok 5' +else: print 'not ok 5'