cvsuser     04/05/29 22:08:46

  Modified:    languages/perl6/P6C Addcontext.pm IMCC.pm
  Log:
  Allow declarations in non-void context. For example, a block that ends
  with a 'my' statement. Probably simple things like 'my $x = my $y = 4'
  too.  Needs tests.
  
  Revision  Changes    Path
  1.27      +1 -3      parrot/languages/perl6/P6C/Addcontext.pm
  
  Index: Addcontext.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/perl6/P6C/Addcontext.pm,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -w -r1.26 -r1.27
  --- Addcontext.pm     30 May 2004 05:03:51 -0000      1.26
  +++ Addcontext.pm     30 May 2004 05:08:46 -0000      1.27
  @@ -565,9 +565,7 @@
   ##############################
   sub P6C::decl::ctx_right {
       my ($x, $ctx) = @_;
  -    unless ($ctx->type eq 'void') {
  -     unimp "declaration in non-void context";
  -    }
  +    $x->{ctx} = $ctx->copy;
       if (ref $x->vars eq 'ARRAY') {
        $_->ctx_right($ctx) for @{$x->vars};
       } else {
  
  
  
  1.42      +14 -8     parrot/languages/perl6/P6C/IMCC.pm
  
  Index: IMCC.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/perl6/P6C/IMCC.pm,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -w -r1.41 -r1.42
  --- IMCC.pm   30 May 2004 05:03:51 -0000      1.41
  +++ IMCC.pm   30 May 2004 05:08:46 -0000      1.42
  @@ -1851,6 +1851,14 @@
   use P6C::Util 'unimp';
   use P6C::Context;
   
  +sub vars_in_context {
  +    my ($vars, $ctx) = @_;
  +    return undef if $ctx->type eq 'void';
  +    my $vlist = new P6C::ValueList vals => $vars;
  +    $vlist->ctx_right($ctx);
  +    return $vlist->val;
  +}
  +
   sub val {
       my $x = shift;
       code("# " . $x->{comment}) if $x->{comment};
  @@ -1860,12 +1868,10 @@
       if (@{$x->props}) {
        unimp 'variable properties';
       }
  -    if (ref $x->vars eq 'ARRAY') {
  -     add_localvar($_->name, $_->type) for @{$x->vars};
  -    } else {
  -     add_localvar($x->vars->name, $x->vars->type);
  -    }
  -    return undef;
  +    my $vars = $x->vars;
  +    $vars = [ $vars ] unless ref $vars eq 'ARRAY';
  +    add_localvar($_->name, $_->type) foreach @$vars;
  +    return vars_in_context($vars, $x->{ctx});
   }
   
   # A declaration with initializers shows up as assigning to a decl.
  @@ -1880,7 +1886,7 @@
       if ($thing->isa('P6C::sv_literal')) {
        add_localvar($x->vars->name, $x->vars->type);
        $x->vars->assign($thing);
  -     return undef;
  +     return vars_in_context([ $x->vars ], $thing->{ctx});
       }
   
       my $tmpv = $thing->val;
  
  
  

Reply via email to