File tree Expand file tree Collapse file tree 3 files changed +48
-5
lines changed Expand file tree Collapse file tree 3 files changed +48
-5
lines changed Original file line number Diff line number Diff line change
1
+ knowhow NQPCurriedRoleHOW {
2
+ has $ ! curried_role ;
3
+ has @ ! pos_args ;
4
+
5
+ my $ archetypes := Archetypes. new ( : nominal(1 ), : composable(1 ), : parametric(1 ) );
6
+ method archetypes () {
7
+ $ archetypes
8
+ }
9
+
10
+ method new (: $ curried_role ! , : @ pos_args ! ) {
11
+ my $ obj := nqp ::create(self );
12
+ $ obj . BUILD(: $ curried_role , : @ pos_args );
13
+ $ obj
14
+ }
15
+
16
+ method BUILD (: $ curried_role ! , : @ pos_args ! ) {
17
+ $ ! curried_role := $ curried_role ;
18
+ @ ! pos_args := @ pos_args ;
19
+ }
20
+
21
+ method new_type ($ curried_role ! , * @ pos_args ) {
22
+ my $ meta := self . new (: curried_role($ curried_role ), : pos_args(@ pos_args ));
23
+ pir::repr_type_object_for__PPS($ meta , ' Uninstantiable' );
24
+ }
25
+
26
+ method specialize ($ obj , $ class_arg ) {
27
+ $ ! curried_role . HOW . specialize($ ! curried_role , $ class_arg , | @ ! pos_args );
28
+ }
29
+
30
+ method name ($ obj ) {
31
+ $ ! curried_role . HOW . name ($ ! curried_role )
32
+ }
33
+
34
+ method curried_role ($ obj ) {
35
+ $ ! curried_role
36
+ }
37
+ }
Original file line number Diff line number Diff line change @@ -108,13 +108,18 @@ knowhow NQPParametricRoleHOW {
108
108
method parametric ($ obj ) {
109
109
1
110
110
}
111
+
112
+ # Curries this parametric role with arguments.
113
+ method curry ($ obj , * @ args ) {
114
+ NQPCurriedRoleHOW. new_type($ obj , | @ args )
115
+ }
111
116
112
117
# This specializes the role for the given class and builds a concrete
113
118
# role.
114
- method specialize ($ obj , $ class_arg ) {
119
+ method specialize ($ obj , $ class_arg , * @ args ) {
115
120
# Run the body block to capture the arguments into the correct
116
121
# type argument context.
117
- $ ! body_block ($ class_arg );
122
+ $ ! body_block ($ class_arg , | @ args );
118
123
119
124
# Construct a new concrete role.
120
125
my $ irole := NQPConcreteRoleHOW. new_type(: name($ ! name ), : instance_of($ obj ));
Original file line number Diff line number Diff line change @@ -179,9 +179,10 @@ NQP_SOURCES = \
179
179
180
180
NQP_MO_SOURCES = src/how/Archetypes.pm src/how/RoleToRoleApplier.pm \
181
181
src/how/NQPConcreteRoleHOW.pm src/how/RoleToClassApplier.pm \
182
- src/how/NQPParametricRoleHOW.pm src/how/NQPClassHOW.pm \
183
- src/how/NQPNativeHOW.pm src/how/NQPAttribute.pm \
184
- src/how/NQPModuleHOW.pm src/how/EXPORTHOW.pm \
182
+ src/how/NQPCurriedRoleHOW.pm src/how/NQPParametricRoleHOW.pm \
183
+ src/how/NQPClassHOW.pm src/how/NQPNativeHOW.pm \
184
+ src/how/NQPAttribute.pm src/how/NQPModuleHOW.pm \
185
+ src/how/EXPORTHOW.pm \
185
186
186
187
NQP_MO_PBC = nqpmo.pbc
187
188
NQP_MO_PIR = gen/nqp-mo.pir
You can’t perform that action at this time.
0 commit comments