| 1 | package Zuzu::AST::Stmt::Switch; | ||
| 2 | |||
| 3 | 78 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 78 | our $VERSION = '0.007002'; | |
| 6 | |||
| 7 | 78 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 78 | has 'value_expr' => ( is => 'rw' ); | |
| 10 | 78 | has 'comparator' => ( is => 'rw' ); | |
| 11 | 78 | has 'cases' => ( is => 'rw' ); | |
| 12 | 78 | has 'default_block' => ( is => 'rw' ); | |
| 13 | |||
| 14 | 78 | with 'Zuzu::AST::Role::Node'; | |
| 15 | |||
| 16 | 32 | ▶ | sub evaluate { $_[1]->eval_switch($_[0]) } |
|
Subroutine
evaluate: called CC=1 SCAR=0.0
Pod
documented
| |||
| 17 | |||
| 18 | =pod | ||
| 19 | |||
| 20 | =head1 NAME | ||
| 21 | |||
| 22 | Zuzu::AST::Stmt::Switch - AST node for switch statements | ||
| 23 | |||
| 24 | =head1 DESCRIPTION | ||
| 25 | |||
| 26 | Represents one statement form in the abstract syntax tree and | ||
| 27 | delegates execution to C<Zuzu::Runtime>. | ||
| 28 | |||
| 29 | =head1 INHERITANCE | ||
| 30 | |||
| 31 | Inherits from C<Moo::Object>. | ||
| 32 | |||
| 33 | =head1 ROLES | ||
| 34 | |||
| 35 | Consumes C<Zuzu::AST::Role::Node>. | ||
| 36 | |||
| 37 | =head1 ATTRIBUTES | ||
| 38 | |||
| 39 | =head2 value_expr | ||
| 40 | |||
| 41 | Type: B<ConsumerOf["Zuzu::AST::Role::Node"]>. | ||
| 42 | |||
| 43 | Expression that is compared against each case value. | ||
| 44 | |||
| 45 | =head2 comparator | ||
| 46 | |||
| 47 | Type: B<Str>. | ||
| 48 | |||
| 49 | Operator string used for case comparisons. | ||
| 50 | |||
| 51 | =head2 cases | ||
| 52 | |||
| 53 | Type: B<ArrayRef>. | ||
| 54 | |||
| 55 | Case definitions. Each item is a hashref containing C<values> and | ||
| 56 | C<body>. | ||
| 57 | |||
| 58 | =head2 default_block | ||
| 59 | |||
| 60 | Type: B<Maybe[InstanceOf["Zuzu::AST::Block"]]>. | ||
| 61 | |||
| 62 | Optional default case block. | ||
| 63 | |||
| 64 | =head1 METHODS | ||
| 65 | |||
| 66 | =head2 evaluate | ||
| 67 | |||
| 68 | Dispatches this AST node to the matching runtime evaluator. | ||
| 69 | |||
| 70 | =head1 SEE ALSO | ||
| 71 | |||
| 72 | C<Zuzu::AST::Role::Node>. | ||
| 73 | |||
| 74 | Subclasses: none in this distribution. | ||
| 75 | |||
| 76 | =head1 COPYRIGHT AND LICENCE | ||
| 77 | |||
| 78 | B<< Zuzu::AST::Stmt::Switch >> is copyright Toby Inkster. | ||
| 79 | |||
| 80 | It is free software; you may redistribute it and/or modify it under | ||
| 81 | the terms of either the Artistic License 1.0 or the GNU General Public | ||
| 82 | License version 2. | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | 78 | 1; | |