Author: pmichaud Date: Sun Dec 2 16:37:06 2007 New Revision: 23389 Added: branches/perl6-devel/languages/perl6/src/classes/Object.pir (contents, props changed) Modified: branches/perl6-devel/languages/perl6/config/makefiles/root.in branches/perl6-devel/languages/perl6/perl6.pir branches/perl6-devel/languages/perl6/src/classes/List.pir branches/perl6-devel/languages/perl6/src/classes/Str.pir branches/perl6-devel/languages/perl6/src/parser/actions.pl
Log: [perl6-devel]: * Add Object and List builtin types. * Remove some inline pir from src/parser/actions.pl . Modified: branches/perl6-devel/languages/perl6/config/makefiles/root.in ============================================================================== --- branches/perl6-devel/languages/perl6/config/makefiles/root.in (original) +++ branches/perl6-devel/languages/perl6/config/makefiles/root.in Sun Dec 2 16:37:06 2007 @@ -39,11 +39,13 @@ $(PERL6_GROUP) BUILTINS_PIR = \ + src/classes/Object.pir \ + src/classes/Str.pir \ + src/classes/List.pir \ src/builtins/cmp.pir \ src/builtins/io.pir \ src/builtins/list.pir \ src/builtins/op.pir \ - src/classes/Str.pir \ PMCS = perl6str PMC_SOURCES = $(PMC_DIR)/perl6str.pmc Modified: branches/perl6-devel/languages/perl6/perl6.pir ============================================================================== --- branches/perl6-devel/languages/perl6/perl6.pir (original) +++ branches/perl6-devel/languages/perl6/perl6.pir Sun Dec 2 16:37:06 2007 @@ -21,6 +21,8 @@ =cut +.include 'src/gen_builtins.pir' + .namespace [ 'Perl6::Compiler' ] .loadlib 'perl6_group' @@ -35,10 +37,14 @@ $P2 = split '::', 'Perl6::Grammar::Actions' $P1.'parseactions'($P2) - $P0 = new 'ResizablePMCArray' + $P0 = new 'List' set_hll_global ['Perl6';'Grammar';'Actions'], '@?BLOCK', $P0 .end +.include 'src/gen_grammar.pir' +.include 'src/gen_actions.pir' + +.namespace ['Perl6::Compiler'] =item main(args :slurpy) :main @@ -54,11 +60,6 @@ $P1 = $P0.'command_line'(args) .end -.include 'src/gen_grammar.pir' - -.include 'src/gen_actions.pir' - -.include 'src/gen_builtins.pir' =back Modified: branches/perl6-devel/languages/perl6/src/classes/List.pir ============================================================================== --- branches/perl6-devel/languages/perl6/src/classes/List.pir (original) +++ branches/perl6-devel/languages/perl6/src/classes/List.pir Sun Dec 2 16:37:06 2007 @@ -14,69 +14,33 @@ .sub '__onload' :load :init $P0 = subclass 'ResizablePMCArray', 'List' -.end + $P1 = get_class 'Perl6Object' + $P0.add_parent($P1) -# FIXME: The 'clone' opcode doesn't seem to naturally work -# for subclasses of ResizablePMCArray, so we write our own here. -# FIXME: #2 - iterators don't properly work for subclasses -# of ResizablePMCArray (RT #40958), so we have to enumerate the -# elements by index. - -.namespace [ 'List' ] - -.sub 'clone' :vtable :method - $P0 = new 'List' - $I1 = elements self - $I0 = 0 - loop: - if $I0 >= $I1 goto end - $P1 = self[$I0] - $P0[$I0] = $P1 - inc $I0 - goto loop - end: - .return ($P0) + $P1 = new $P0 + set_hll_global 'List', $P1 .end +.namespace ['List'] -.sub 'set_pmc' :vtable :method - .param pmc value - self = 0 - $P0 = new 'Iterator', value - iter_loop: - unless $P0 goto iter_end - $P1 = shift $P0 - push self, $P1 - goto iter_loop - iter_end: - .return () +.sub 'elems' :method + $I0 = elements self + .return ($I0) .end -.sub 'get_string' :vtable :method - $S0 = '' - $I1 = elements self - if $I1 < 1 goto end - $I0 = 1 - $S0 = self[0] - loop: - if $I0 >= $I1 goto end - $S1 = self[$I0] - $S0 = concat $S0, ' ' - $S0 .= $S1 - inc $I0 - goto loop - end: - .return ($S0) +.sub 'unshift' :method + .param pmc x + unshift self, x .end -.sub 'elems' :method - $I0 = elements self - .return ($I0) +.sub 'shift' :method + .local pmc x + x = shift self + .return (x) .end - =back =cut Added: branches/perl6-devel/languages/perl6/src/classes/Object.pir ============================================================================== --- (empty file) +++ branches/perl6-devel/languages/perl6/src/classes/Object.pir Sun Dec 2 16:37:06 2007 @@ -0,0 +1,34 @@ +=head1 TITLE + +Object - Perl 6 Object class + +=cut + +.sub '__onload' :init :load + $P0 = newclass 'Perl6Object' + $P1 = new $P0 + set_hll_global 'Object', $P1 +.end + + +.namespace ['Perl6Object'] + +.sub 'new' :method + $P0 = typeof self + $P1 = new $P0 + .return ($P1) +.end + + +.sub 'WHAT' :method + $S0 = typeof self + .return ($S0) +.end + + +# Local Variables: +# mode: pir +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: + Modified: branches/perl6-devel/languages/perl6/src/classes/Str.pir ============================================================================== --- branches/perl6-devel/languages/perl6/src/classes/Str.pir (original) +++ branches/perl6-devel/languages/perl6/src/classes/Str.pir Sun Dec 2 16:37:06 2007 @@ -2,4 +2,9 @@ .sub __onload :init :load $P0 = subclass 'Perl6Str', 'Str' + $P1 = get_class ['Perl6Object'] + $P0.'add_parent'($P1) + + $P1 = new $P0 + set_hll_global 'Str', $P1 .end Modified: branches/perl6-devel/languages/perl6/src/parser/actions.pl ============================================================================== --- branches/perl6-devel/languages/perl6/src/parser/actions.pl (original) +++ branches/perl6-devel/languages/perl6/src/parser/actions.pl Sun Dec 2 16:37:06 2007 @@ -16,15 +16,10 @@ :blocktype('immediate'), :node($/) ); - PIR q< $P0 = get_global '$?BLOCK' >; # FIXME: @?BLOCK.unshift(...) - PIR q< $P1 = get_global '@?BLOCK' >; - PIR q< unshift $P1, $P0 >; + @?BLOCK.unshift($?BLOCK); } if ($key eq 'close') { - my $past; - PIR q< $P0 = get_global '@?BLOCK' >; - PIR q< $P0 = shift $P0 >; - PIR q< store_lex '$past', $P0 >; + my $past := @?BLOCK.shift(); $?BLOCK := @?BLOCK[0]; $past.push($($<statementlist>)); make $past;