/
NQPAttribute.pm
71 lines (58 loc) · 1.64 KB
/
NQPAttribute.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
knowhow NQPAttribute {
has $!name;
has $!type;
has $!has_type;
has $!box_target;
has $!default;
has $!has_default;
has $!positional_delegate;
has $!associative_delegate;
method new(:$name!, :$box_target, *%extra) {
my $attr := nqp::create(self);
$attr.BUILD(:name($name), |%extra, :box_target($box_target),
:has_type(nqp::existskey(%extra, 'type')),
:has_default(nqp::existskey(%extra, 'default')));
$attr
}
method BUILD(:$name, :$type, :$has_type, :$box_target, :$default, :$has_default) {
$!name := $name;
$!type := $type;
$!has_type := $has_type;
$!box_target := $box_target;
$!default := $default;
$!has_default := $has_default;
}
method name() {
$!name
}
method type() {
$!has_type ?? $!type !! nqp::null()
}
method has_accessor() {
0
}
method build_closure() {
0
}
method box_target() {
!nqp::isnull($!box_target) && $!box_target ?? 1 !! 0
}
method auto_viv_container() {
$!has_default ?? $!default !! nqp::null()
}
method set_positional_delegate($value) {
$!positional_delegate := $value;
}
method set_associative_delegate($value) {
$!associative_delegate := $value;
}
method positional_delegate() {
!nqp::isnull($!positional_delegate) && $!positional_delegate ?? 1 !! 0
}
method associative_delegate() {
!nqp::isnull($!associative_delegate) && $!associative_delegate ?? 1 !! 0
}
method compose($obj) {
$obj
}
}