| 1 | package Data::Sah::Compiler::human::TH; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 45 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 45 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 45 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | #use Log::Any '$log'; | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 45 | ▶ | use Mo qw(build default); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 45 | ▶ | use Role::Tiny::With; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 45 | extends 'Data::Sah::Compiler::TH'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 45 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||
| 14 | 45 | our $DATE = '2024-02-16'; # DATE | |||||||||||||||||||||||||||||||||||||||||
| 15 | 45 | our $DIST = 'Data-Sah'; # DIST | |||||||||||||||||||||||||||||||||||||||||
| 16 | 45 | our $VERSION = '0.917'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1175 | ▶ | sub name { undef } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub handle_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my ($self, $cd) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $c = $self->compiler; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # give the class name | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $pkg = ref($self); | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $pkg =~ s/^Data::Sah::Compiler::human::TH:://; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $c->add_ccl($cd, {type=>'noun', fmt=>$pkg}); | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | # not translated | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 27 | ▶ | sub clause_name {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 27 | ▶ | sub clause_summary {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_summary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 27 | ▶ | sub clause_description {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_description: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub clause_comment {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_comment: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 27 | ▶ | sub clause_tags {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_tags: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub clause_examples {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_examples: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub clause_links {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_links: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | sub clause_prefilters {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_prefilters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub clause_postfilters {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_postfilters: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | # ignored | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 54 | ▶ | sub clause_ok {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_ok: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | # handled in after_all_clauses | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 486 | ▶ | sub clause_req {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_req: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 54 | ▶ | sub clause_forbidden {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_forbidden: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | # default implementation | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 90 | ▶ | sub clause_default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_default: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 90 | my ($self, $cd) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 90 | my $c = $self->compiler; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 90 | $c->add_ccl($cd, {expr=>1, | |||||||||||||||||||||||||||||||||||||||||
| 60 | fmt => 'default value %s'}); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 81 | ▶ | sub before_clause_clause { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before_clause_clause: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 81 | my ($self, $cd) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 81 | $cd->{CLAUSE_DO_MULTI} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 192 | ▶ | sub before_clause_clset { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before_clause_clset: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 192 | my ($self, $cd) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 192 | $cd->{CLAUSE_DO_MULTI} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 8 | ▶ | sub before_clause_if { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before_clause_if: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 8 | my ($self, $cd) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 8 | $cd->{CLAUSE_DO_MULTI} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 13 | ▶ | sub clause_if { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clause_if: called CC=4 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 13 | my ($self, $cd) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 13 | my $c = $self->compiler; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 13 | my $cv = $cd->{cl_value}; | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 13 | my ($cond, $then, $else) = @$cv; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 13 | ▶ | unless (!ref($cond) && ref($then) eq 'ARRAY' && !$else) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not ref $cond and ref $then eq "ARRAY" and not $else
not ref $cond and ref $then eq "ARRAY"
MC/DC0%0/3
not ref $cond and ref $then eq "ARRAY" and not $else
not ref $cond
ref $then eq "ARRAY"
not $else
Truth table25%1/4
not(A) and B and not(C)
A= not ref $condB= ref $then eq "ARRAY"C= not $else
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $c->_die($cd, "Sorry, for 'if' clause, I currently can only handle COND=str (expr), THEN=array (schema), and no ELSE"); | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | # temporary. currently it sucks because it plasters schema and expr directly | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 13 | $c->add_ccl($cd, { | |||||||||||||||||||||||||||||||||||||||||
| 91 | expr => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | vals => [$cond, $then], | ||||||||||||||||||||||||||||||||||||||||||
| 93 | fmt => 'if the expression %s is true then the schema %s must be followed', | ||||||||||||||||||||||||||||||||||||||||||
| 94 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 45 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 98 | # ABSTRACT: Base class for human type handlers | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | __END__ | ||||||||||||||||||||||||||||||||||||||||||