-
-
Notifications
You must be signed in to change notification settings - Fork 372
/
LexPad.pm
37 lines (34 loc) · 926 Bytes
/
LexPad.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# probably wants to inherit from Stash, which is NYI
class LexPad is Associative {
has $!parrot_lexpad;
multi method postcircumfix:<{ }>($thing) {
Q:PIR {
.local pmc key
key = find_lex '$thing'
$P0 = find_lex 'self'
$P1 = getattribute $P0, '$!parrot_lexpad'
$P1 = descalarref $P1
%r = $P1[key]
unless null %r goto done
%r = get_hll_global 'Mu'
done:
}
}
method keys {
my @keys;
Q:PIR {
.local pmc self, it, res
self = find_lex 'self'
res = find_lex '@keys'
$P0 = getattribute self, '$!parrot_lexpad'
it = iter $P0
iter_loop:
unless it goto iter_end
$P0 = shift it
push res, $P0
goto iter_loop
iter_end:
};
@keys;
}
}