~ubuntu-branches/ubuntu/precise/rakudo/precise

« back to all changes in this revision

Viewing changes to src/glue/subset.pm

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghedini
  • Date: 2011-05-17 11:31:09 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517113109-rmfir654u1axbpt4
Tags: 0.1~2011.04-1
* New upstream release (Closes: #601862, #585762, #577502)
* New maintainer
* Switch to 3.0 (quilt) format
* Update dependencies (Closes: #584498)
* Update debian/copyright to lastest DEP5 revision
* Do not generate/install perl6 manpage (now done by the build system)
* Enable tests
* Bump Standards-Version to 3.9.2 (no changes needed)
* Do not install extra LICENSE files and duplicated docs
* Remove debian/clean (no more needed)
* Add Vcs-* fields in debian/control
* Rewrite (short) description
* Update upstream copyright years
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Note: this file probably wants to be in some Perl6::CompilerGuts namespace.
 
2
 
 
3
role SubType {
 
4
    has $!checker;
 
5
    method ACCEPTS(Mu $topic) {
 
6
        unless callsame() {
 
7
            return Bool::False
 
8
        }
 
9
        $!checker.ACCEPTS($topic)
 
10
    }
 
11
}
 
12
 
 
13
our sub CREATE_SUBSET_TYPE(Mu \$original, $checker) {
 
14
    # XXX Ideally we'd be able to just replace all of what follows
 
15
    # with a simple:
 
16
    #     my $subtype = $original but SubType($checker);
 
17
    # However, that won't quite work until we improve type object
 
18
    # handling.
 
19
    Q:PIR {
 
20
        $P0 = find_lex '$original'
 
21
        $P1 = class $P0
 
22
        $P2 = get_hll_global 'SubType'
 
23
        $P2 = $P2.'!select'()
 
24
        $P3 = new ['Class']
 
25
        $P3.'add_parent'($P1)
 
26
        $P3.'add_role'($P2)
 
27
        addattribute $P3, '$!checker'
 
28
        $P4 = getprop 'metaclass', $P1
 
29
        setprop $P3, 'metaclass', $P4
 
30
        %r = new $P3
 
31
        transform_to_p6opaque %r
 
32
        $P5 = find_lex '$checker'
 
33
        setattribute %r, '$!checker', $P5
 
34
        $P6 = getprop 'subtype_realtype', $P0
 
35
        if null $P6 goto original_unrefined
 
36
        setprop %r, 'subtype_realtype', $P6
 
37
        goto refinement_done
 
38
      original_unrefined:
 
39
        setprop %r, 'subtype_realtype', $P0
 
40
      refinement_done:
 
41
    };
 
42
}