Skip to content

Commit

Permalink
Implement .Pos <-> .Int coercing
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jul 27, 2015
1 parent ed945eb commit 9ed640c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/Cool.pm
Expand Up @@ -272,6 +272,9 @@ my class Cool { # declared in BOOTSTRAP
proto method Int(|) { * }
multi method Int() { self.Numeric.Int }

proto method Pos(|) { * }
multi method Pos() { self.Numeric.Int.Pos }

proto method UInt(|) { * }
multi method UInt() {
my $got := self.Int;
Expand Down
2 changes: 2 additions & 0 deletions src/core/Int.pm
Expand Up @@ -28,6 +28,7 @@ my class Int does Real { # declared in BOOTSTRAP
}

method Int() { self }
multi method Pos(Int:D:) { nqp::box_i(nqp::unbox_i(self),Pos) }

multi method Str(Int:D:) {
nqp::p6box_s(nqp::tostr_I(self));
Expand Down Expand Up @@ -165,6 +166,7 @@ my class Int does Real { # declared in BOOTSTRAP
my class Pos is Int {
multi method Bool(Pos:U:) { False };
multi method Bool(Pos:D:) { True };
multi method Int(Pos:D:) { nqp::box_i(nqp::unbox_i(self),Int) }
}

multi sub prefix:<++>(Int:D $a is rw) {
Expand Down

0 comments on commit 9ed640c

Please sign in to comment.