Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 98 lines (82 sloc) 1.867 kb
2f806d3 @jnthn Here starteth the NQP setting.
authored
1 knowhow NQPInt is repr('P6int') {
2 method new() {
3 nqp::instance_of(self.WHAT);
4 }
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equality...
authored
5 method Bool() {
c9eb002 @jnthn Infinite recursion is kind of a drag...
authored
6 nqp::logical_not_int(nqp::equal_ints(self, 0, NQPInt), NQPInt)
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equality...
authored
7 }
2f806d3 @jnthn Here starteth the NQP setting.
authored
8 method Int() {
9 self
10 }
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equality...
authored
11 method Num() {
12 nqp::coerce_int_to_num(self, NQPNum)
13 }
8c6b5ae @jnthn Add Str methods to setting for NQPNum and NQPInt.
authored
14 method Str() {
15 nqp::coerce_int_to_str(self, NQPStr)
16 }
2f806d3 @jnthn Here starteth the NQP setting.
authored
17 }
18
19 knowhow NQPStr is repr('P6str') {
20 method new() {
21 nqp::instance_of(self.WHAT);
22 }
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equality...
authored
23 method Bool() {
c9eb002 @jnthn Infinite recursion is kind of a drag...
authored
24 nqp::logical_not_int(nqp::equal_strs(self, "", NQPInt), NQPInt)
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equality...
authored
25 }
2f806d3 @jnthn Here starteth the NQP setting.
authored
26 method Str() {
27 self
28 }
29 }
30
31 knowhow NQPNum is repr('P6num') {
32 method new() {
33 nqp::instance_of(self.WHAT);
34 }
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equality...
authored
35 method Bool() {
c9eb002 @jnthn Infinite recursion is kind of a drag...
authored
36 nqp::logical_not_int(nqp::equal_nums(self, 0.0, NQPInt), NQPInt)
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equality...
authored
37 }
38 method Int() {
39 nqp::coerce_num_to_int(self, NQPStr)
40 }
2f806d3 @jnthn Here starteth the NQP setting.
authored
41 method Num() {
42 self
43 }
8c6b5ae @jnthn Add Str methods to setting for NQPNum and NQPInt.
authored
44 method Str() {
45 nqp::coerce_num_to_str(self, NQPStr)
46 }
2f806d3 @jnthn Here starteth the NQP setting.
authored
47 }
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equality...
authored
48
49 ## XXX All of these should become multi when we can do that.
50
51 sub &infix:<==>($x, $y) {
52 nqp::equal_nums($x.Num, $y.Num, NQPInt)
53 }
54
55 sub &infix:<!=>($x, $y) {
56 !nqp::equal_nums($x.Num, $y.Num, NQPInt)
57 }
58
59 sub &infix:<eq>($x, $y) {
60 nqp::equal_strs($x.Str, $y.Str, NQPInt)
61 }
62
63 sub &infix:<ne>($x, $y) {
64 !nqp::equal_strs($x.Str, $y.Str, NQPInt)
65 }
66
67 sub &prefix:<!>($x) {
68 nqp::logical_not_int($x.Bool.Int, NQPInt)
69 }
70
71 sub &prefix:<?>($x) {
72 $x.Bool
73 }
d3865c1 @jnthn Add some more operators to the NQP setting.
authored
74
75 sub &infix:<+>($x, $y) {
76 nqp::add_int($x.Int, $y.Int, NQPInt);
77 }
78
79 sub &infix:<->($x, $y) {
80 nqp::sub_int($x.Int, $y.Int, NQPInt);
81 }
82
83 sub &infix:<*>($x, $y) {
84 nqp::mul_int($x.Int, $y.Int, NQPInt);
85 }
86
87 sub &infix:</>($x, $y) {
88 nqp::div_int($x.Int, $y.Int, NQPInt);
89 }
90
91 sub &infix:<%>($x, $y) {
92 nqp::mod_int($x.Int, $y.Int, NQPInt);
93 }
94
95 sub &infix:<~>($x, $y) {
96 nqp::concat($x.Str, $y.Str, NQPStr);
97 }
Something went wrong with that request. Please try again.