Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 390 lines (335 sloc) 8.038 kb
3e7ec365 »
2010-08-21 A little setting re-ordering; put NQPStr first, since we need strings…
1 knowhow NQPStr is repr('P6str') {
2f806d3b »
2010-08-17 Here starteth the NQP setting.
2 method new() {
3 nqp::instance_of(self.WHAT);
4 }
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
5 method Bool() {
3881965d »
2010-08-21 Turns out that the always pass ops type object for result type strate…
6 nqp::logical_not_int(nqp::equal_strs(self, "")) &&
7 nqp::logical_not_int(nqp::equal_strs(self, "0"))
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
8 }
ebb368a9 »
2010-10-19 [common] NQPArray.bind_pos plus some missing coercion methods.
9 method Int() {
10 nqp::coerce_str_to_int(self, NQPInt)
11 }
12 method Num() {
13 nqp::coerce_str_to_num(self, NQPNum)
14 }
cf07e791 »
2010-10-18 [common] Some initial cuts of prefix + and ~, Stringy and Numeric in …
15 method Numeric() {
16 nqp::coerce_str_to_num(self, NQPNum)
17 }
8c6b5aef »
2010-08-17 Add Str methods to setting for NQPNum and NQPInt.
18 method Str() {
3e7ec365 »
2010-08-21 A little setting re-ordering; put NQPStr first, since we need strings…
19 self
8c6b5aef »
2010-08-17 Add Str methods to setting for NQPNum and NQPInt.
20 }
cf07e791 »
2010-10-18 [common] Some initial cuts of prefix + and ~, Stringy and Numeric in …
21 method Stringy() {
22 self
23 }
ac08da5d »
2010-10-29 [common] Add .defined methods to the various built-in types.
24 method defined() {
25 nqp::repr_defined(self)
26 }
2f806d3b »
2010-08-17 Here starteth the NQP setting.
27 }
28
3e7ec365 »
2010-08-21 A little setting re-ordering; put NQPStr first, since we need strings…
29 knowhow NQPInt is repr('P6int') {
2f806d3b »
2010-08-17 Here starteth the NQP setting.
30 method new() {
31 nqp::instance_of(self.WHAT);
32 }
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
33 method Bool() {
3881965d »
2010-08-21 Turns out that the always pass ops type object for result type strate…
34 nqp::logical_not_int(nqp::equal_ints(self, 0))
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
35 }
3e7ec365 »
2010-08-21 A little setting re-ordering; put NQPStr first, since we need strings…
36 method Int() {
2f806d3b »
2010-08-17 Here starteth the NQP setting.
37 self
38 }
3e7ec365 »
2010-08-21 A little setting re-ordering; put NQPStr first, since we need strings…
39 method Num() {
40 nqp::coerce_int_to_num(self, NQPNum)
41 }
cf07e791 »
2010-10-18 [common] Some initial cuts of prefix + and ~, Stringy and Numeric in …
42 method Numeric() {
43 self
44 }
3e7ec365 »
2010-08-21 A little setting re-ordering; put NQPStr first, since we need strings…
45 method Str() {
46 nqp::coerce_int_to_str(self, NQPStr)
47 }
cf07e791 »
2010-10-18 [common] Some initial cuts of prefix + and ~, Stringy and Numeric in …
48 method Stringy() {
49 nqp::coerce_int_to_str(self, NQPStr)
50 }
ac08da5d »
2010-10-29 [common] Add .defined methods to the various built-in types.
51 method defined() {
52 nqp::repr_defined(self)
53 }
2f806d3b »
2010-08-17 Here starteth the NQP setting.
54 }
55
56 knowhow NQPNum is repr('P6num') {
57 method new() {
58 nqp::instance_of(self.WHAT);
59 }
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
60 method Bool() {
3881965d »
2010-08-21 Turns out that the always pass ops type object for result type strate…
61 nqp::logical_not_int(nqp::equal_nums(self, 0.0))
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
62 }
63 method Int() {
64 nqp::coerce_num_to_int(self, NQPStr)
65 }
2f806d3b »
2010-08-17 Here starteth the NQP setting.
66 method Num() {
67 self
68 }
cf07e791 »
2010-10-18 [common] Some initial cuts of prefix + and ~, Stringy and Numeric in …
69 method Numeric() {
70 self
71 }
8c6b5aef »
2010-08-17 Add Str methods to setting for NQPNum and NQPInt.
72 method Str() {
73 nqp::coerce_num_to_str(self, NQPStr)
74 }
cf07e791 »
2010-10-18 [common] Some initial cuts of prefix + and ~, Stringy and Numeric in …
75 method Stringy() {
76 nqp::coerce_num_to_str(self, NQPStr)
77 }
ac08da5d »
2010-10-29 [common] Add .defined methods to the various built-in types.
78 method defined() {
79 nqp::repr_defined(self)
80 }
2f806d3b »
2010-08-17 Here starteth the NQP setting.
81 }
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
82
2fd812db »
2010-10-31 [dotnet] Make sure at_pos and at_key never return null, but rather so…
83 # XXX Bad hack, we'll replace this later.
84 knowhow Any {
85 method defined() { 0 }
86 }
87
eae223f3 »
2010-08-22 Add a first cut of a P6list representation and a list sub that makes …
88 knowhow NQPList is repr('P6list') {
7e36dac7 »
2010-10-18 Give NQPList a .new method.
89 method new() {
90 nqp::instance_of(self.WHAT)
91 }
d88a87b1 »
2010-09-13 Flesh out NQPList a little bit.
92 method elems() {
93 nqp::lllist_elems(self)
94 }
ea3a9cb5 »
2010-10-19 [common] Lists and arrays numify to number of elements.
95 method Numeric() {
96 self.elems
97 }
d88a87b1 »
2010-09-13 Flesh out NQPList a little bit.
98 method at_pos($idx) {
2fd812db »
2010-10-31 [dotnet] Make sure at_pos and at_key never return null, but rather so…
99 nqp::vivify(nqp::lllist_get_at_pos(self, $idx.Int), Any)
d88a87b1 »
2010-09-13 Flesh out NQPList a little bit.
100 }
ac08da5d »
2010-10-29 [common] Add .defined methods to the various built-in types.
101 method defined() {
102 nqp::repr_defined(self)
103 }
eae223f3 »
2010-08-22 Add a first cut of a P6list representation and a list sub that makes …
104 }
105
106 knowhow NQPArray is repr('P6list') {
7e36dac7 »
2010-10-18 Give NQPList a .new method.
107 method new() {
108 nqp::instance_of(self.WHAT)
109 }
ea3a9cb5 »
2010-10-19 [common] Lists and arrays numify to number of elements.
110 method Numeric() {
111 self.elems
112 }
7e36dac7 »
2010-10-18 Give NQPList a .new method.
113 method elems() {
114 nqp::lllist_elems(self)
115 }
116 method at_pos($idx) {
2fd812db »
2010-10-31 [dotnet] Make sure at_pos and at_key never return null, but rather so…
117 nqp::vivify(nqp::lllist_get_at_pos(self, $idx.Int), Any)
7e36dac7 »
2010-10-18 Give NQPList a .new method.
118 }
ebb368a9 »
2010-10-19 [common] NQPArray.bind_pos plus some missing coercion methods.
119 method bind_pos($idx, $value) {
120 nqp::lllist_bind_at_pos(self, $idx.Int, $value)
121 }
ac08da5d »
2010-10-29 [common] Add .defined methods to the various built-in types.
122 method defined() {
123 nqp::repr_defined(self)
124 }
eae223f3 »
2010-08-22 Add a first cut of a P6list representation and a list sub that makes …
125 }
126
435bd243 »
2010-10-20 [common] Stub in NQPHash. Doesn't do anything yet other that .new.
127 knowhow NQPHash is repr('P6mapping') {
128 method new() {
129 nqp::instance_of(self.WHAT)
130 }
88190a82 »
2010-10-20 [common] Fill out NQPHash a bit and...we have basically functioning h…
131 method Numeric() {
132 self.elems
133 }
134 method elems() {
135 nqp::llmapping_elems(self)
136 }
137 method at_key($key) {
2fd812db »
2010-10-31 [dotnet] Make sure at_pos and at_key never return null, but rather so…
138 nqp::vivify(nqp::llmapping_get_at_key(self, $key.Str), Any)
88190a82 »
2010-10-20 [common] Fill out NQPHash a bit and...we have basically functioning h…
139 }
140 method bind_key($key, $value) {
141 nqp::llmapping_bind_at_key(self, $key.Str, $value)
142 }
ac08da5d »
2010-10-29 [common] Add .defined methods to the various built-in types.
143 method defined() {
144 nqp::repr_defined(self)
145 }
435bd243 »
2010-10-20 [common] Stub in NQPHash. Doesn't do anything yet other that .new.
146 }
147
3c156f0c »
2010-10-22 [common] Add a NQPCode with a leave method.
148 knowhow NQPCode is repr('RakudoCodeRef') {
149 method leave($with) {
150 nqp::leave_block(self, $with)
151 }
ac08da5d »
2010-10-29 [common] Add .defined methods to the various built-in types.
152 method defined() {
153 nqp::repr_defined(self)
154 }
3c156f0c »
2010-10-22 [common] Add a NQPCode with a leave method.
155 }
156
10019acd »
2010-08-23 Start to add multi variants to the NQPSetting. Seems that even though…
157 ## XXX Need coercive Any fallbacks too.
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
158
413bae8e »
2010-10-30 [common] Replace explicit multi-dispatcher ops with a proto with a pl…
159 proto sub &infix:<==>($x, $y) { * }
10019acd »
2010-08-23 Start to add multi variants to the NQPSetting. Seems that even though…
160 multi sub &infix:<==>(NQPInt $x, NQPInt $y) {
161 nqp::equal_ints($x, $y)
162 }
163 multi sub &infix:<==>(NQPNum $x, NQPNum $y) {
164 nqp::equal_nums($x, $y)
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
165 }
166
413bae8e »
2010-10-30 [common] Replace explicit multi-dispatcher ops with a proto with a pl…
167 proto sub &infix:<!=>($x, $y) { * }
10019acd »
2010-08-23 Start to add multi variants to the NQPSetting. Seems that even though…
168 multi sub &infix:<!=>(NQPInt $x, NQPInt $y) {
dcf5ee5e »
2010-08-24 Make our != rather more efficient.
169 nqp::logical_not_int(nqp::equal_ints($x, $y))
10019acd »
2010-08-23 Start to add multi variants to the NQPSetting. Seems that even though…
170 }
171 multi sub &infix:<!=>(NQPNum $x, NQPNum $y) {
dcf5ee5e »
2010-08-24 Make our != rather more efficient.
172 nqp::logical_not_int(nqp::equal_nums($x, $y))
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
173 }
174
175 sub &infix:<eq>($x, $y) {
3881965d »
2010-08-21 Turns out that the always pass ops type object for result type strate…
176 nqp::equal_strs($x.Str, $y.Str)
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
177 }
178
179 sub &infix:<ne>($x, $y) {
3881965d »
2010-08-21 Turns out that the always pass ops type object for result type strate…
180 !nqp::equal_strs($x.Str, $y.Str)
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
181 }
182
98e707b1 »
2010-10-18 [common] =:=
183 sub &infix:<=:=>($x, $y) {
184 nqp::equal_refs($x, $y)
185 }
186
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
187 sub &prefix:<!>($x) {
3881965d »
2010-08-21 Turns out that the always pass ops type object for result type strate…
188 nqp::logical_not_int($x.Bool)
5e82e893 »
2010-08-18 Fill out the setting with some more coercioin methods and a few equal…
189 }
190
191 sub &prefix:<?>($x) {
192 $x.Bool
193 }
d3865c1b »
2010-08-18 Add some more operators to the NQP setting.
194
cf07e791 »
2010-10-18 [common] Some initial cuts of prefix + and ~, Stringy and Numeric in …
195 sub &prefix:<~>($x) {
196 $x.Stringy
197 }
198
199 sub &prefix:<+>($x) {
200 $x.Numeric
201 }
202
413bae8e »
2010-10-30 [common] Replace explicit multi-dispatcher ops with a proto with a pl…
203 proto sub &infix:<+>($x, $y) { * }
10019acd »
2010-08-23 Start to add multi variants to the NQPSetting. Seems that even though…
204 multi sub &infix:<+>(NQPInt $x, NQPInt $y) {
205 nqp::add_int($x, $y);
d3865c1b »
2010-08-18 Add some more operators to the NQP setting.
206 }
207
413bae8e »
2010-10-30 [common] Replace explicit multi-dispatcher ops with a proto with a pl…
208 proto sub &infix:<->($x, $y) { * }
10019acd »
2010-08-23 Start to add multi variants to the NQPSetting. Seems that even though…
209 multi sub &infix:<->(NQPInt $x, NQPInt $y) {
210 nqp::sub_int($x, $y);
d3865c1b »
2010-08-18 Add some more operators to the NQP setting.
211 }
212
413bae8e »
2010-10-30 [common] Replace explicit multi-dispatcher ops with a proto with a pl…
213 proto sub &infix:<*>($x, $y) { * }
10019acd »
2010-08-23 Start to add multi variants to the NQPSetting. Seems that even though…
214 multi sub &infix:<*>(NQPInt $x, NQPInt $y) {
215 nqp::mul_int($x, $y);
d3865c1b »
2010-08-18 Add some more operators to the NQP setting.
216 }
217
413bae8e »
2010-10-30 [common] Replace explicit multi-dispatcher ops with a proto with a pl…
218 proto sub &infix:</>($x, $y) { * }
10019acd »
2010-08-23 Start to add multi variants to the NQPSetting. Seems that even though…
219 multi sub &infix:</>(NQPInt $x, NQPInt $y) {
220 nqp::div_int($x, $y);
d3865c1b »
2010-08-18 Add some more operators to the NQP setting.
221 }
222
413bae8e »
2010-10-30 [common] Replace explicit multi-dispatcher ops with a proto with a pl…
223 proto sub &infix:<%>($x, $y) { * }
10019acd »
2010-08-23 Start to add multi variants to the NQPSetting. Seems that even though…
224 multi sub &infix:<%>(NQPInt $x, NQPInt $y) {
225 nqp::mod_int($x, $y);
d3865c1b »
2010-08-18 Add some more operators to the NQP setting.
226 }
227
228 sub &infix:<~>($x, $y) {
3881965d »
2010-08-21 Turns out that the always pass ops type object for result type strate…
229 nqp::concat($x.Str, $y.Str);
d3865c1b »
2010-08-18 Add some more operators to the NQP setting.
230 }
a64ea75b »
2010-08-18 Implement plan and ok for getting us more tests.
231
6a07cb25 »
2010-10-22 [common] Stub in a simple NQPException exception object and a die sub.
232 # A basic, fairly bare-bones exception object.
233 knowhow NQPException {
234 has $!message;
235 has $!resumable;
236
237 method new($message) {
238 nqp::instance_of(self.WHAT).BUILD(:message($message))
239 }
240
241 method BUILD(:$message) {
242 $!message := $message;
243 $!resumable := 0;
244 self;
245 }
246
ac08da5d »
2010-10-29 [common] Add .defined methods to the various built-in types.
247 method defined() {
248 nqp::repr_defined(self)
249 }
250
6a07cb25 »
2010-10-22 [common] Stub in a simple NQPException exception object and a die sub.
251 method resumable() {
252 $!resumable
253 }
254
255 method resume() {
256 $!resumable := 1;
257 }
258
259 method Str() {
260 $!message
261 }
262 }
263
264 sub die($message) {
265 nqp::throw_dynamic(NQPException.new($message), 0)
266 }
267
a64ea75b »
2010-08-18 Implement plan and ok for getting us more tests.
268 # For tests.
269 my $count := NQPInt.new();
270 sub plan($n) {
271 print("1..");
272 say($n);
273 }
7e9d2b8d »
2010-10-21 [common] $diag arg of ok should be optional.
274 sub ok($check, $diag?) {
a64ea75b »
2010-08-18 Implement plan and ok for getting us more tests.
275 $count := $count + 1;
276 unless $check { print("not ") }
277 print("ok ");
278 say($count);
279 }
cbdd49b4 »
2010-10-19 [dotnet] Out with one bad hack, in with a slightly less bad one for u…
280
06d78a2f »
2010-10-22 [common] Start to stub in a very barebones ClassHOW. This is enough t…
281 # Here comes the start of a heavily under construction ClassHOW.
282 knowhow NQPClassHOW {
283 ##
284 ## Attributes
285 ##
286
287 # Name of the class.
288 has $!name;
289
290 # Attributes, methods, parents and roles directly added.
291 has %!attributes;
292 has %!methods;
293 has @!parents;
294 has @!roles;
295
296 # Vtable and mapping of method names to slots.
297 has @!vtable;
298 has %!method-vtable-slots;
299
300 # Have we been composed?
301 has $!composed;
302
303 # Cached MRO (list of the type objects).
304 has @!mro;
305
306 # Full list of roles that we do.
307 has @!done;
308
309 ##
310 ## Declarative.
311 ##
312
313 # Creates a new instance of this meta-class.
314 method new() {
315 nqp::instance_of(self).BUILD()
316 }
317
318 method BUILD() {
319 $!composed := 0;
4356d783 »
2010-10-23 [common] Add a VERY hacky but working version of method addition and …
320 %!methods := NQPHash.new;
06d78a2f »
2010-10-22 [common] Start to stub in a very barebones ClassHOW. This is enough t…
321 self;
322 }
323
324 # Create a new meta-class instance, and then a new type object
325 # to go with it, and return that.
326 # XXX TODO :$repr named parameter defaulting to P6opaque (don't
327 # have default values yet implemented).
328 method new_type() {
329 my $metaclass := self.new();
330 nqp::type_object_for($metaclass, 'P6opaque');
331 }
332
4356d783 »
2010-10-23 [common] Add a VERY hacky but working version of method addition and …
333 method add_method($obj, $name, $code_obj) {
2fd812db »
2010-10-31 [dotnet] Make sure at_pos and at_key never return null, but rather so…
334 if %!methods{$name}.defined {
335 die("This class already has a method named " ~ $name);
336 }
4356d783 »
2010-10-23 [common] Add a VERY hacky but working version of method addition and …
337 %!methods{$name} := $code_obj;
338 }
339
06d78a2f »
2010-10-22 [common] Start to stub in a very barebones ClassHOW. This is enough t…
340 method compose($obj) {
341 # XXX TODO: Compose roles, compose attributes.
342
343 # Some things we only do if we weren't already composed once, like
344 # building the MRO.
345 unless $!composed {
346 @!mro := compute_c3_mro($obj);
347 $!composed := 1;
348 }
349
350 $obj
351 }
352
353 # XXX TODO: Get enough working to bring over the C3 implementation that
354 # we run on 6model on Parrot.
355 sub compute_c3_mro($obj) {
356 my @mro;
357 @mro[0] := $obj;
358 @mro;
359 }
4356d783 »
2010-10-23 [common] Add a VERY hacky but working version of method addition and …
360
361 ##
362 ## Introspecty
363 ##
364
365 method method_table($obj) {
366 %!methods
367 }
368
ac08da5d »
2010-10-29 [common] Add .defined methods to the various built-in types.
369 method defined() {
370 nqp::repr_defined(self)
371 }
372
4356d783 »
2010-10-23 [common] Add a VERY hacky but working version of method addition and …
373 ##
374 ## Dispatchy
375 ##
376
377 method find_method($obj, $name) {
378 # XXX TODO Epic cheat, replace with that's in the ClassHOW that we
379 # run on Parrot. Needs auto-viv, .defined, return.
380 my %meths := @!mro[0].HOW.method_table($obj);
381 %meths{$name}
382 }
06d78a2f »
2010-10-22 [common] Start to stub in a very barebones ClassHOW. This is enough t…
383 }
384
4f3c7e01 »
2010-10-21 [common] Set up a GLOBAL.
385 # GLOBAL stash.
386 # (XXX Really want one per compilation unit and unify, but this will get us
387 # started. Also really want a stash type that knows its name rather than just
388 # a hash, I guess.)
389 ::GLOBAL := NQPHash.new();
Something went wrong with that request. Please try again.