| 1 | package VoiceXML::Client::Engine::Component::Interpreter::Perl; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | 3 | ▶ | use base qw(VoiceXML::Client::Engine::Component::Interpreter); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | Copyright (C) 2007,2008 by Pat Deegan. | ||||||||||||||||||
| 13 | All rights reserved | ||||||||||||||||||
| 14 | http://voicexml.psychogenic.com | ||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | This library is released under the terms of the GNU GPL version 3, making it available only for | ||||||||||||||||||
| 17 | free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details). | ||||||||||||||||||
| 18 | Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to | ||||||||||||||||||
| 19 | acquire a distinct license for their application. This approach encourages the use of free software | ||||||||||||||||||
| 20 | while allowing for proprietary solutions that support further development. | ||||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | This file is part of VoiceXML::Client. | ||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | |||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | VoiceXML::Client is free software: you can redistribute it and/or modify | ||||||||||||||||||
| 28 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||
| 29 | the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||
| 30 | (at your option) any later version. | ||||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | VoiceXML::Client is distributed in the hope that it will be useful, | ||||||||||||||||||
| 33 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||
| 34 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||
| 35 | GNU General Public License for more details. | ||||||||||||||||||
| 36 | |||||||||||||||||||
| 37 | You should have received a copy of the GNU General Public License | ||||||||||||||||||
| 38 | along with VoiceXML::Client. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | =cut | ||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | |||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | =head2 new | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | =cut | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | 3 | ▶ | sub runtime { | ||||||||||||||||
|
Subroutine
runtime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 50 | 3 | my $self = shift; | |||||||||||||||||
| 51 | 3 | my $params = shift; | |||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | 3 | my $runtime = VoiceXML::Client::Engine::Component::Interpreter::Perl::RunTime->new(); | |||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | 3 | return $runtime; | |||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | } | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | |||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | package VoiceXML::Client::Engine::Component::Interpreter::Perl::Context; | ||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | 3 | ▶ | use base qw (VoiceXML::Client::Engine::Component::Interpreter::Context); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | 3 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | 0 | ▶ | sub eval { | ||||||||||||||||
|
Subroutine
eval: not called CC=7 SCAR=40.3
| |||||||||||||||||||
| 71 | 0 | my $self = shift; | |||||||||||||||||
| 72 | 0 | my $code = shift; | |||||||||||||||||
| 73 | |||||||||||||||||||
| 74 | 0 | my $comparisonOps = '==|>=?|<=?|!='; | |||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | 0 | $code =~ s/\s*$//; | |||||||||||||||||
| 77 | 0 | ▶ | if ($code =~ /^\s*([\w\d\_]+)\s+=\s*'([^']*)'\s*$/) | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 78 | { | ||||||||||||||||||
| 79 | 0 | my $var = $1; | |||||||||||||||||
| 80 | 0 | my $value = $2; | |||||||||||||||||
| 81 | 0 | $self->{'_perlinterp'}->{'stack'}->{$var} = $value; | |||||||||||||||||
| 82 | } elsif ($code =~ /^\s*([\w\d\_]+)\s+=\s*(.*)/) | ||||||||||||||||||
| 83 | { | ||||||||||||||||||
| 84 | |||||||||||||||||||
| 85 | # Assignment | ||||||||||||||||||
| 86 | 0 | my $var = $1; | |||||||||||||||||
| 87 | 0 | my $value = " $2"; | |||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | 0 | ▶ | if ($value =~ /[\s\+\*\/\-\|\&]+/) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 90 | { | ||||||||||||||||||
| 91 | 0 | $value =~ s/[^'\w](\w[\w\d\_]+)/$self->{'_perlinterp'}->{'stack'}->{$1}/g; | |||||||||||||||||
| 92 | 0 | my $result; | |||||||||||||||||
| 93 | 0 | my $evalStr = '$result = ' . $value; | |||||||||||||||||
| 94 | 0 | eval $evalStr; | |||||||||||||||||
| 95 | 0 | ▶ | if ($@) | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 96 | { | ||||||||||||||||||
| 97 | 0 | die "Error evaluating Code '$evalStr': $@"; | |||||||||||||||||
| 98 | } | ||||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | 0 | $self->{'_perlinterp'}->{'stack'}->{$var} = $result; | |||||||||||||||||
| 101 | } elsif ($value =~ /^\-?[\d\.]+/) | ||||||||||||||||||
| 102 | { | ||||||||||||||||||
| 103 | 0 | $self->{'_perlinterp'}->{'stack'}->{$var} = $value; | |||||||||||||||||
| 104 | } else { | ||||||||||||||||||
| 105 | 0 | $self->{'_perlinterp'}->{'stack'}->{$var} = ''; | |||||||||||||||||
| 106 | } | ||||||||||||||||||
| 107 | |||||||||||||||||||
| 108 | } elsif ($code =~ /$comparisonOps/) | ||||||||||||||||||
| 109 | { | ||||||||||||||||||
| 110 | 0 | my $evalStr = $code; | |||||||||||||||||
| 111 | ########## TODO ############# | ||||||||||||||||||
| 112 | } | ||||||||||||||||||
| 113 | |||||||||||||||||||
| 114 | 0 | return 1; | |||||||||||||||||
| 115 | |||||||||||||||||||
| 116 | |||||||||||||||||||
| 117 | } | ||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | |||||||||||||||||||
| 120 | package VoiceXML::Client::Engine::Component::Interpreter::Perl::RunTime; | ||||||||||||||||||
| 121 | |||||||||||||||||||
| 122 | 3 | ▶ | use base qw (VoiceXML::Client::Engine::Component::Interpreter::RunTime); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 123 | |||||||||||||||||||
| 124 | 3 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 125 | |||||||||||||||||||
| 126 | 4 | ▶ | sub create_context { | ||||||||||||||||
|
Subroutine
create_context: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 127 | 4 | my $self = shift; | |||||||||||||||||
| 128 | 4 | my $stacksize = shift; | |||||||||||||||||
| 129 | |||||||||||||||||||
| 130 | 4 | my $context = VoiceXML::Client::Engine::Component::Interpreter::Perl::Context->new(); | |||||||||||||||||
| 131 | |||||||||||||||||||
| 132 | 4 | return $context; | |||||||||||||||||
| 133 | |||||||||||||||||||
| 134 | } | ||||||||||||||||||
| 135 | |||||||||||||||||||
| 136 | 3 | 1; | |||||||||||||||||
| 137 | |||||||||||||||||||