/
Parameter.pm
140 lines (118 loc) · 2.86 KB
/
Parameter.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Copyright (C) 2009, The Perl Foundation.
# $Id$
class Perl6::Compiler::Parameter;
has $!var_name;
has $!pos_slurpy;
has $!named_slurpy;
has $!optional;
has $!names;
has $!invocant;
has $!multi_invocant;
has $!default;
has $!default_from_outer;
has $!nom_type;
has $!cons_types;
has $!sub_signature;
has $!type_captures;
has $!is_rw;
has $!is_copy;
has $!is_parcel;
has $!is_capture;
has $!traits;
method var_name($var_name?) {
if $var_name { $!var_name := $var_name }
$!var_name
}
method sigil() {
my $check;
if $!var_name { $check := pir::substr($!var_name, 0, 1); }
unless $check eq '$' || $check eq '@' || $check eq '%' || $check eq '&' {
$check := '';
}
$check
}
method twigil() {
my $check;
if $!var_name { $check := pir::substr($!var_name, 1, 1); }
unless $check eq '!' || $check eq '.' || $check eq '*' {
$check := '';
}
$check
}
method pos_slurpy($pos_slurpy?) {
if $pos_slurpy { $!pos_slurpy := $pos_slurpy }
$!pos_slurpy
}
method named_slurpy($named_slurpy?) {
if $named_slurpy { $!named_slurpy := $named_slurpy }
$!named_slurpy
}
method optional($optional?) {
if $optional { $!optional := $optional }
$!optional
}
method names() {
unless $!names { $!names := PAST::Node.new() }
$!names
}
method multi_invocant($multi_invocant?) {
if $multi_invocant { $!multi_invocant := $multi_invocant }
$!multi_invocant
}
method invocant($invocant?) {
if $invocant { $!invocant := $invocant }
$!invocant
}
method default($default?) {
if $default { $!default := $default }
$!default
}
method default_from_outer($default_from_outer?) {
if $default_from_outer { $!default_from_outer := $default_from_outer }
$!default_from_outer
}
method nom_type($nom_type?) {
if $nom_type {
if $nom_type.isa(PAST::Op) && $nom_type.name() eq 'new' {
# It's a thunk (cretion of a new code block); we'll make this
# a constraint.
self.cons_types.push($nom_type)
}
else {
$!nom_type := $nom_type
}
}
$!nom_type
}
method cons_types() {
unless $!cons_types { $!cons_types := PAST::Node.new() }
$!cons_types
}
method sub_signature($sub_signature?) {
if pir::defined__IP($sub_signature) { $!sub_signature := $sub_signature }
$!sub_signature
}
method type_captures() {
unless $!type_captures { $!type_captures := PAST::Node.new() }
$!type_captures
}
method is_rw($is_rw?) {
if $is_rw { $!is_rw := $is_rw }
$!is_rw
}
method is_copy($is_copy?) {
if $is_copy { $!is_copy := $is_copy }
$!is_copy
}
method is_parcel($is_parcel?) {
if $is_parcel { $!is_parcel := $is_parcel }
$!is_parcel
}
method is_capture($is_capture?) {
if $is_capture { $!is_capture := $is_capture }
$!is_capture
}
method traits($traits?) {
if $traits { $!traits := $traits }
$!traits
}