File Coverage

blib/lib/VoiceXML/Client/Engine/Component/Interpreter/Perl.pm
Criterion Covered Total %
statement 26 48 54.1
branch 0 12 0.0
condition n/a
subroutine 8 9 88.8
pod 0 1 0.0
total 34 70 48.5


line stmt bran cond sub pod time code
1             package VoiceXML::Client::Engine::Component::Interpreter::Perl;
2              
3 3     3   20 use base qw(VoiceXML::Client::Engine::Component::Interpreter);
  3         6  
  3         2184  
4              
5 3     3   16 use strict;
  3         8  
  3         279  
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 .
39              
40              
41             =cut
42              
43              
44              
45             =head2 new
46              
47             =cut
48              
49             sub runtime {
50 3     3 0 24 my $self = shift;
51 3         8 my $params = shift;
52            
53 3         52 my $runtime = VoiceXML::Client::Engine::Component::Interpreter::Perl::RunTime->new();
54            
55 3         10 return $runtime;
56            
57             }
58              
59              
60              
61             package VoiceXML::Client::Engine::Component::Interpreter::Perl::Context;
62              
63 3     3   15 use base qw (VoiceXML::Client::Engine::Component::Interpreter::Context);
  3         7  
  3         3501  
64              
65 3     3   18 use strict;
  3         7  
  3         7207  
66              
67              
68              
69              
70             sub eval {
71 0     0   0 my $self = shift;
72 0         0 my $code = shift;
73              
74 0         0 my $comparisonOps = '==|>=?|<=?|!=';
75            
76 0         0 $code =~ s/\s*$//;
77 0 0       0 if ($code =~ /^\s*([\w\d\_]+)\s+=\s*'([^']*)'\s*$/)
    0          
    0          
78             {
79 0         0 my $var = $1;
80 0         0 my $value = $2;
81 0         0 $self->{'_perlinterp'}->{'stack'}->{$var} = $value;
82             } elsif ($code =~ /^\s*([\w\d\_]+)\s+=\s*(.*)/)
83             {
84            
85             # Assignment
86 0         0 my $var = $1;
87 0         0 my $value = " $2";
88            
89 0 0       0 if ($value =~ /[\s\+\*\/\-\|\&]+/)
    0          
90             {
91 0         0 $value =~ s/[^'\w](\w[\w\d\_]+)/$self->{'_perlinterp'}->{'stack'}->{$1}/g;
92 0         0 my $result;
93 0         0 my $evalStr = '$result = ' . $value;
94 0         0 eval $evalStr;
95 0 0       0 if ($@)
96             {
97 0         0 die "Error evaluating Code '$evalStr': $@";
98             }
99            
100 0         0 $self->{'_perlinterp'}->{'stack'}->{$var} = $result;
101             } elsif ($value =~ /^\-?[\d\.]+/)
102             {
103 0         0 $self->{'_perlinterp'}->{'stack'}->{$var} = $value;
104             } else {
105 0         0 $self->{'_perlinterp'}->{'stack'}->{$var} = '';
106             }
107            
108             } elsif ($code =~ /$comparisonOps/)
109             {
110 0         0 my $evalStr = $code;
111             ########## TODO #############
112             }
113            
114 0         0 return 1;
115            
116            
117             }
118              
119              
120             package VoiceXML::Client::Engine::Component::Interpreter::Perl::RunTime;
121              
122 3     3   30 use base qw (VoiceXML::Client::Engine::Component::Interpreter::RunTime);
  3         4  
  3         2878  
123              
124 3     3   18 use strict;
  3         8  
  3         239  
125              
126             sub create_context {
127 4     4   8 my $self = shift;
128 4         7 my $stacksize = shift;
129            
130 4         65 my $context = VoiceXML::Client::Engine::Component::Interpreter::Perl::Context->new();
131            
132 4         17 return $context;
133            
134             }
135              
136             1;
137