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

« back to all changes in this revision

Viewing changes to src/glue/types.pir

  • 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
## $Id$
 
2
 
 
3
=head1 NAME
 
4
 
 
5
src/glue/types.pir - internals bits to do with types
 
6
 
 
7
=head1 SUBS
 
8
 
 
9
=over 4
 
10
 
 
11
.namespace []
 
12
 
 
13
=item !have_exact_same_type
 
14
 
 
15
Takes two types and returns true if they match exactly (not accounting for any
 
16
subtyping relations, etc).
 
17
 
 
18
=cut
 
19
 
 
20
.sub '!have_exact_same_type'
 
21
    .param pmc t1
 
22
    .param pmc t2
 
23
 
 
24
    # If they have equal address, obviously the same.
 
25
    .local pmc t1meta, t2meta
 
26
    t1meta = t1.'HOW'()
 
27
    t2meta = t2.'HOW'()
 
28
    eq_addr t1meta, t2meta, same
 
29
 
 
30
    # If they are junctions, compare inside them recursively.
 
31
    $I0 = isa t1, 'Junction'
 
32
    unless $I0 goto not_junc
 
33
    $I1 = isa t2, 'Junction'
 
34
    unless $I0 == $I1 goto not_junc
 
35
    .local pmc j1, j2
 
36
    .local int max, i
 
37
    j1 = t1.'eigenstates'()
 
38
    j2 = t1.'eigenstates'()
 
39
    max = elements j1
 
40
    i = 0
 
41
  junc_loop:
 
42
    if i >= max goto junc_loop_end
 
43
    $P0 = j1[i]
 
44
    $P1 = j2[i]
 
45
    $I0 = '!have_exact_same_type'($P0, $P1)
 
46
    unless $I0 goto not_same
 
47
    inc i
 
48
    goto junc_loop
 
49
  junc_loop_end:
 
50
  not_junc:
 
51
 
 
52
  not_same:
 
53
    .return(0)
 
54
  same:
 
55
    .return (1)
 
56
.end
 
57
 
 
58
 
 
59
.sub '&CREATE_HASH_FROM_LOW_LEVEL'
 
60
    .param pmc storage :optional
 
61
    unless null storage goto have_storage
 
62
    storage = root_new ['parrot';'Hash']
 
63
  have_storage:
 
64
    $P0 = get_hll_global 'Hash'
 
65
    $P0 = $P0.'CREATE'()
 
66
    setattribute $P0, '$!storage', storage
 
67
    .return ($P0)
 
68
.end
 
69
 
 
70
 
 
71
.sub '!Undef_to_False'
 
72
    .param pmc x
 
73
    $I0 = isa x, 'Undef'
 
74
    unless $I0 goto done
 
75
    x = get_hll_global ['Bool'], 'False'
 
76
  done:
 
77
    .return (x)
 
78
.end
 
79
 
 
80
=back
 
81
 
 
82
=cut
 
83
 
 
84
# Local Variables:
 
85
#   mode: pir
 
86
#   fill-column: 100
 
87
# End:
 
88
# vim: expandtab shiftwidth=4 ft=pir: