VAST/parameter.pm untested

filter: Statementstmt 0.0% 0 / 66 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 110 CC 15 SCAR 43.4
CC
15
Cov
0%
emit_m0ld
132.0
emit_m0ld_ahsig_BIND
30.0
BEGIN
2.0
CRAP 76.8
1 package VAST::parameter;
2 BEGIN {
3 $VAST::parameter::VERSION = '0.05';
4 }
5 use utf8;
6 use strict;
7 use warnings;
8 use Mildew::AST::Helpers;
9  
10 sub emit_m0ld_ahsig_BIND {
11 my ($m, $count) = @_;
12 if ($m->{param_var}) {
13 if ($m->{quant} eq '|') {
14 call 'STORE' => (call 'postcircumfix:{ }' => reg '$scope',
15 [ string $m->{param_var}{sigil}{SYM}.$m->{param_var}{name}[0]{TEXT}]),
16 [ reg '$capture' ];
17 } elsif ($m->{quant} eq '\\') {
18 call 'STORE' => (call 'postcircumfix:{ }' => reg '$scope',
19 [ string $m->{param_var}{sigil}{SYM}.$m->{param_var}{name}[0]{TEXT}]),
20 [call 'positional' => reg '$capture',[integer($count) ]];;
21 } else {
22 call 'BIND' => (call 'postcircumfix:{ }' => reg '$scope',
23 [ string $m->{param_var}{sigil}{SYM}.$m->{param_var}{name}[0]{TEXT}]),
24 [call 'positional' => reg '$capture',[integer($count) ]];
25 }
26 } elsif ($m->{named_param}) {
27 my $ident = $m->{named_param}{param_var}{name}[0]{TEXT};
28 my $sigil = $m->{named_param}{param_var}{sigil}{SYM};
29 call 'BIND' => (call 'postcircumfix:{ }' => reg '$scope',
30 [ string $sigil.$ident ]),
31 [call 'named' => reg '$capture',[string $ident ]];
32 } else {
33 XXX;
34 }
35 }
36 sub emit_m0ld {
37 my $m = shift;
38 my $type;
39 my $trait = $m->{trait}[0]{trait_mod}{longname}{name}{identifier}{TEXT} || 'readonly';
40 my $var;
41 if ($m->{param_var}) {
42 if ($m->{quant} eq '|') {
43 $type = 'WholeCaptureParam';
44 } elsif ($trait eq 'ref') {
45 $type = 'RefParam';
46 } elsif ($trait eq 'readonly') {
47 $type = 'ReadonlyParam';
48 } else {
49 die "unknow type of param $trait";
50 }
51 $var = $m->{param_var};
52 } elsif ($m->{named_param}) {
53 $type = 'NamedReadonlyParam';
54 $var = $m->{named_param}{param_var};
55 }
56 my $type_constraint = $m->{type_constraint}[0]{typename}{longname}{name}{identifier}{TEXT};
57 my $param = FETCH(call new => lookupf($type));
58 let $param, sub {
59 my $param = shift;
60 my $name = $var->{name}[0]{TEXT} || '';
61 my $sigil = $var->{sigil}{SYM};
62 my $default;
63 if ($m->{kind} eq '?') {
64 $default = call new => FETCH(lookup('Code')),[],
65 [ string 'mold' => Mildew::AST::Block->new(regs=>['interpreter','scope'],stmts=>
66 trailing_return([lookupf("False")])),
67 string 'outer' => reg '$scope',
68 string 'signature' => empty_sig];
69 }
70  
71 Mildew::AST::Seq->new(stmts => [
72 $name ? call(STORE => (call variable => $param),[ string $sigil.$name]) : (),
73 $name ? call(STORE => (call name => $param),[ string $name ]) : (),
74 $default ? call(STORE => (call default_value => $param),[ $default ]) : (),
75 $type_constraint ? call(STORE => (call type => $param),[ lookupf($type_constraint) ]) : (),
76 $param]
77 );
78 }
79 }
80  
81  
82 1;