Commits

Anonymous committed 84342e7

Modify AST generation to delete keyed items as well as entire
variables (only handled variables before).

Comments (0)

Files changed (1)

Grammar/Actions.nqp

 method del_stmt($/) {
     our $?BLOCK;
 
+    my $pir;
     my $targets := $( $<target_list> );
 
     my $past := PAST::Stmts.new( :node($/) );
 
-    my $pir := "    .local pmc ns\n"
-             ~ '    ns = get_hll_namespace';
+    my $ns := "    .local pmc ns\n"
+             ~ "    ns = get_hll_namespace\n";
 
-    $past.push( PAST::Op.new( :inline($pir), :node($/) ) );
     for @($targets) {
-        $pir := '    delete ns["' ~ $_.name() ~ '"]';
-        $past.push( PAST::Op.new( :inline($pir), :node($/) ) );
+	if $_.scope() ne 'keyed' {
+            $pir := $ns ~ '    delete ns["' ~ $_.name() ~ '"]';
+            $past.push( PAST::Op.new( :inline($pir), :node($/) ) );
+            $ns := '';
+	} else {
+            $pir := '    delete %0[' ~ $_[1].value() ~ ']';
+            $past.push( PAST::Op.new($_[0], :inline($pir), :node($/) ) );
+	}
     }
 
     make $past;