develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35169 - in branches/rvar2/languages/perl6/src: classes parser

From:
jonathan
Date:
January 7, 2009 11:38
Subject:
[svn:parrot] r35169 - in branches/rvar2/languages/perl6/src: classes parser
Message ID:
20090107193759.24FA2CB9F9@x12.develooper.com
Author: jonathan
Date: Wed Jan  7 11:37:58 2009
New Revision: 35169

Modified:
   branches/rvar2/languages/perl6/src/classes/Signature.pir
   branches/rvar2/languages/perl6/src/parser/actions.pm

Log:
[rakudo] Restore a bunch of type stuff, which in turn corrects a bunch of multi things. This is, mostly, just copy/pasted back into the branch from trunk; it was hard enough to get right once. :-)

Modified: branches/rvar2/languages/perl6/src/classes/Signature.pir
==============================================================================
--- branches/rvar2/languages/perl6/src/classes/Signature.pir	(original)
+++ branches/rvar2/languages/perl6/src/classes/Signature.pir	Wed Jan  7 11:37:58 2009
@@ -62,12 +62,52 @@
     attr['multi_invocant'] = 1
   have_mi:
 
-    # For now, if no type, set it to Any.
-    $P0 = attr['type']
-    unless null $P0 goto have_type
-    $P0 = get_hll_global 'Any'
-    attr['type'] = $P0
+    # Get constraints list, which may have class and role types as well as
+    # subset types. If we have no unique role or class type, they all become
+    # constraints; otherwise, we find the unique type. Finally, we turn the
+    # list of constraints into a junction.
+    .local pmc cur_list, cur_list_iter, constraints, type, test_item
+    constraints = 'list'()
+    type = null
+    cur_list = attr["constraints"]
+    if null cur_list goto cur_list_loop_end
+    cur_list_iter = iter cur_list
+  cur_list_loop:
+    unless cur_list_iter goto cur_list_loop_end
+    test_item = shift cur_list_iter
+    $I0 = isa test_item, "Role"
+    if $I0 goto is_type
+    $P0 = getprop "subtype_realtype", test_item
+    if null $P0 goto not_refinement
+    unless null type goto all_constraints
+    type = $P0
+    push constraints, test_item
+    goto cur_list_loop
+  not_refinement:
+    $I0 = isa test_item, "P6protoobject"
+    if $I0 goto is_type
+    push constraints, test_item
+    goto cur_list_loop
+  is_type:
+    unless null type goto all_constraints
+    type = test_item
+    goto cur_list_loop
+  all_constraints:
+    type = null
+    constraints = cur_list
+  cur_list_loop_end:
+    unless null type goto have_type
+    type = get_hll_global 'Any'
   have_type:
+    attr["type"] = type
+    $I0 = elements constraints
+    if $I0 == 0 goto no_constraints
+    constraints = 'all'(constraints)
+    goto set_constraints
+  no_constraints:
+    constraints = null
+  set_constraints:
+    attr["constraints"] = constraints
 
     # Add to parameters list.
     .local pmc params

Modified: branches/rvar2/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/rvar2/languages/perl6/src/parser/actions.pm	(original)
+++ branches/rvar2/languages/perl6/src/parser/actions.pm	Wed Jan  7 11:37:58 2009
@@ -958,9 +958,7 @@
             ##  add any typechecks
             my $type := $var<type>;
             if +@($type) > 0 {
-                ##  don't need the 'and' junction for only one type
-                if +@($type) == 1 { $type := $type[0] }
-                $type.named('type');
+                $type.named('constraints');
                 $sigparam.push($type);
             }
 
@@ -1047,7 +1045,7 @@
     }
 
     ##  keep track of any type constraints
-    my $typelist := PAST::Op.new( :name('and'), :pasttype('call') );
+    my $typelist := PAST::Op.new( :name('list'), :pasttype('call') );
     $var<type> := $typelist;
     if $<type_constraint> {
         for @($<type_constraint>) {



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About