Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 163 lines (143 sloc) 3.531 kB
3e7ec36 @jnthn A little setting re-ordering; put NQPStr first, since we need strings…
authored
1 knowhow NQPStr is repr('P6str') {
2f806d3 @jnthn Here starteth the NQP setting.
authored
2 method new() {
3 nqp::instance_of(self.WHAT);
4 }
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
5 method Bool() {
3881965 @jnthn Turns out that the always pass ops type object for result type strate…
authored
6 nqp::logical_not_int(nqp::equal_strs(self, "")) &&
7 nqp::logical_not_int(nqp::equal_strs(self, "0"))
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
8 }
8c6b5ae @jnthn Add Str methods to setting for NQPNum and NQPInt.
authored
9 method Str() {
3e7ec36 @jnthn A little setting re-ordering; put NQPStr first, since we need strings…
authored
10 self
8c6b5ae @jnthn Add Str methods to setting for NQPNum and NQPInt.
authored
11 }
2f806d3 @jnthn Here starteth the NQP setting.
authored
12 }
13
3e7ec36 @jnthn A little setting re-ordering; put NQPStr first, since we need strings…
authored
14 knowhow NQPInt is repr('P6int') {
2f806d3 @jnthn Here starteth the NQP setting.
authored
15 method new() {
16 nqp::instance_of(self.WHAT);
17 }
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
18 method Bool() {
3881965 @jnthn Turns out that the always pass ops type object for result type strate…
authored
19 nqp::logical_not_int(nqp::equal_ints(self, 0))
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
20 }
3e7ec36 @jnthn A little setting re-ordering; put NQPStr first, since we need strings…
authored
21 method Int() {
2f806d3 @jnthn Here starteth the NQP setting.
authored
22 self
23 }
3e7ec36 @jnthn A little setting re-ordering; put NQPStr first, since we need strings…
authored
24 method Num() {
25 nqp::coerce_int_to_num(self, NQPNum)
26 }
27 method Str() {
28 nqp::coerce_int_to_str(self, NQPStr)
29 }
2f806d3 @jnthn Here starteth the NQP setting.
authored
30 }
31
32 knowhow NQPNum is repr('P6num') {
33 method new() {
34 nqp::instance_of(self.WHAT);
35 }
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
36 method Bool() {
3881965 @jnthn Turns out that the always pass ops type object for result type strate…
authored
37 nqp::logical_not_int(nqp::equal_nums(self, 0.0))
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
38 }
39 method Int() {
40 nqp::coerce_num_to_int(self, NQPStr)
41 }
2f806d3 @jnthn Here starteth the NQP setting.
authored
42 method Num() {
43 self
44 }
8c6b5ae @jnthn Add Str methods to setting for NQPNum and NQPInt.
authored
45 method Str() {
46 nqp::coerce_num_to_str(self, NQPStr)
47 }
2f806d3 @jnthn Here starteth the NQP setting.
authored
48 }
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
49
eae223f @jnthn Add a first cut of a P6list representation and a list sub that makes …
authored
50 knowhow NQPList is repr('P6list') {
d88a87b @jnthn Flesh out NQPList a little bit.
authored
51 method elems() {
52 nqp::lllist_elems(self)
53 }
54 method at_pos($idx) {
55 nqp::lllist_get_at_pos(self, $idx.Int)
56 }
eae223f @jnthn Add a first cut of a P6list representation and a list sub that makes …
authored
57 }
58
59 knowhow NQPArray is repr('P6list') {
60 }
61
b2f3bac @jnthn Add a (very primitive) KnowHOWAttribute knowhow to the setting, so we…
authored
62 # This is a little bit of a cheat. We only really need to keep
63 # hold of a name for the most basic attribute class, so we just
64 # use the string representation.
65 knowhow KnowHOWAttribute is repr('P6str') {
66 method new(:$name) {
67 nqp::box_str(nqp::unbox_str($name), KnowHOWAttribute)
68 }
69 method name() {
70 nqp::box_str(nqp::unbox_str(self), NQPStr)
71 }
72 }
73
10019ac @jnthn Start to add multi variants to the NQPSetting. Seems that even though…
authored
74 ## XXX Need coercive Any fallbacks too.
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
75
10019ac @jnthn Start to add multi variants to the NQPSetting. Seems that even though…
authored
76 proto sub &infix:<==>($x, $y) {
77 nqp::multi_dispatch_over_lexical_candidates("&infix:<==>");
78 }
79 multi sub &infix:<==>(NQPInt $x, NQPInt $y) {
80 nqp::equal_ints($x, $y)
81 }
82 multi sub &infix:<==>(NQPNum $x, NQPNum $y) {
83 nqp::equal_nums($x, $y)
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
84 }
85
10019ac @jnthn Start to add multi variants to the NQPSetting. Seems that even though…
authored
86 proto sub &infix:<!=>($x, $y) {
87 nqp::multi_dispatch_over_lexical_candidates("&infix:<!=>");
88 }
89 multi sub &infix:<!=>(NQPInt $x, NQPInt $y) {
dcf5ee5 @jnthn Make our != rather more efficient.
authored
90 nqp::logical_not_int(nqp::equal_ints($x, $y))
10019ac @jnthn Start to add multi variants to the NQPSetting. Seems that even though…
authored
91 }
92 multi sub &infix:<!=>(NQPNum $x, NQPNum $y) {
dcf5ee5 @jnthn Make our != rather more efficient.
authored
93 nqp::logical_not_int(nqp::equal_nums($x, $y))
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
94 }
95
96 sub &infix:<eq>($x, $y) {
3881965 @jnthn Turns out that the always pass ops type object for result type strate…
authored
97 nqp::equal_strs($x.Str, $y.Str)
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
98 }
99
100 sub &infix:<ne>($x, $y) {
3881965 @jnthn Turns out that the always pass ops type object for result type strate…
authored
101 !nqp::equal_strs($x.Str, $y.Str)
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
102 }
103
104 sub &prefix:<!>($x) {
3881965 @jnthn Turns out that the always pass ops type object for result type strate…
authored
105 nqp::logical_not_int($x.Bool)
5e82e89 @jnthn Fill out the setting with some more coercioin methods and a few equal…
authored
106 }
107
108 sub &prefix:<?>($x) {
109 $x.Bool
110 }
d3865c1 @jnthn Add some more operators to the NQP setting.
authored
111
10019ac @jnthn Start to add multi variants to the NQPSetting. Seems that even though…
authored
112 proto sub &infix:<+>($x, $y) {
113 nqp::multi_dispatch_over_lexical_candidates("&infix:<+>");
114 }
115 multi sub &infix:<+>(NQPInt $x, NQPInt $y) {
116 nqp::add_int($x, $y);
d3865c1 @jnthn Add some more operators to the NQP setting.
authored
117 }
118
10019ac @jnthn Start to add multi variants to the NQPSetting. Seems that even though…
authored
119 proto sub &infix:<->($x, $y) {
120 nqp::multi_dispatch_over_lexical_candidates("&infix:<->");
121 }
122 multi sub &infix:<->(NQPInt $x, NQPInt $y) {
123 nqp::sub_int($x, $y);
d3865c1 @jnthn Add some more operators to the NQP setting.
authored
124 }
125
10019ac @jnthn Start to add multi variants to the NQPSetting. Seems that even though…
authored
126 proto sub &infix:<*>($x, $y) {
127 nqp::multi_dispatch_over_lexical_candidates("&infix:<*>");
128 }
129 multi sub &infix:<*>(NQPInt $x, NQPInt $y) {
130 nqp::mul_int($x, $y);
d3865c1 @jnthn Add some more operators to the NQP setting.
authored
131 }
132
10019ac @jnthn Start to add multi variants to the NQPSetting. Seems that even though…
authored
133 proto sub &infix:</>($x, $y) {
134 nqp::multi_dispatch_over_lexical_candidates("&infix:</>");
135 }
136 multi sub &infix:</>(NQPInt $x, NQPInt $y) {
137 nqp::div_int($x, $y);
d3865c1 @jnthn Add some more operators to the NQP setting.
authored
138 }
139
10019ac @jnthn Start to add multi variants to the NQPSetting. Seems that even though…
authored
140 proto sub &infix:<%>($x, $y) {
141 nqp::multi_dispatch_over_lexical_candidates("&infix:<%>");
142 }
143 multi sub &infix:<%>(NQPInt $x, NQPInt $y) {
144 nqp::mod_int($x, $y);
d3865c1 @jnthn Add some more operators to the NQP setting.
authored
145 }
146
147 sub &infix:<~>($x, $y) {
3881965 @jnthn Turns out that the always pass ops type object for result type strate…
authored
148 nqp::concat($x.Str, $y.Str);
d3865c1 @jnthn Add some more operators to the NQP setting.
authored
149 }
a64ea75 @jnthn Implement plan and ok for getting us more tests.
authored
150
151 # For tests.
152 my $count := NQPInt.new();
153 sub plan($n) {
154 print("1..");
155 say($n);
156 }
3396e97 @jnthn Couple of fixes - ok needs a $diag arg and '0' should be false.
authored
157 sub ok($check, $diag) {
a64ea75 @jnthn Implement plan and ok for getting us more tests.
authored
158 $count := $count + 1;
159 unless $check { print("not ") }
160 print("ok ");
161 say($count);
162 }
Something went wrong with that request. Please try again.