Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Re-enable list (Parcel) assignment, although my() declarations still …

…have a bug.

Add a LHF for Nil scalar assignment.
  • Loading branch information...
commit 492389692b42ed3f5ca6a9d436624dd767b61048 1 parent a7fa958
Patrick R. Michaud pmichaud authored

Showing 2 changed files with 42 additions and 0 deletions. Show diff stats Hide diff stats

  1. +3 0  LHF.markdown
  2. +39 0 src/core/Parcel.pm
3  LHF.markdown
Source Rendered
@@ -14,3 +14,6 @@ of the IO class should be do-able.
14 14
15 15 ## Built-ins
16 16 Str.chop
  17 +
  18 +## Nil assignment
  19 +my Int $b = 3; $b = Nil;
39 src/core/Parcel.pm
@@ -37,6 +37,45 @@ my class Parcel {
37 37
38 38 method RPA() { $!storage }
39 39
  40 + method STORE(|$) {
  41 + # get the list of rvalues to store and lhs containers
  42 + my Mu $args := pir::perl6_current_args_rpa__P();
  43 + nqp::shift($args);
  44 + my $rhs := nqp::p6list($args, List, 1.Bool); # XXX this might need to be Seq
  45 +
  46 + # first pass -- scan lhs containers and pick out
  47 + # scalar versus list assignment. This also reifies
  48 + # the rhs values
  49 + my Mu $lhs := nqp::clone($!storage);
  50 + my Mu $tv := nqp::list();
  51 + while ($lhs) {
  52 + my Mu $x := $lhs.shift;
  53 + if nqp::iscont($x) {
  54 + # container: scalar assignment
  55 + nqp::push($tv, $x);
  56 + nqp::push($tv, $rhs ?? pir::perl6_decontainerize__PP($rhs.shift) !! Nil);
  57 + }
  58 + elsif nqp::istype($x, Whatever) {
  59 + # Whatever: skip assigning value
  60 + $rhs.shift;
  61 + }
  62 + elsif nqp::istype($x, Parcel) {
  63 + # Parcel: splice into current lhs
  64 + nqp::splice($lhs, nqp::getattr($x, Parcel, '$!storage'), 0, 0)
  65 + }
  66 + else {
  67 + # store entire rhs
  68 + nqp::push($tv, $x);
  69 + nqp::push($tv, $rhs);
  70 + $rhs := ().list;
  71 + }
  72 + }
  73 +
  74 + # second pass, perform the assignments
  75 + while ($tv) { my $x := nqp::shift($tv); $x = nqp::shift($tv); }
  76 + self
  77 + }
  78 +
40 79 multi method DUMP(Parcel:D:) {
41 80 self.DUMP-ID() ~ '(:storage(' ~ DUMP($!storage) ~ '))'
42 81 }

0 comments on commit 4923896

Please sign in to comment.
Something went wrong with that request. Please try again.