~ubuntu-branches/ubuntu/vivid/drizzle/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/randgen/lib/GenTest/Stack/Stack.pm

  • Committer: Package Import Robot
  • Author(s): Tobias Frost
  • Date: 2013-08-22 20:18:31 UTC
  • mto: (20.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20130822201831-gn3ozsh7o7wmc5tk
Tags: upstream-7.2.3
ImportĀ upstreamĀ versionĀ 7.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Sun Microsystems, Inc. All rights reserved.
2
 
# Use is subject to license terms.
3
 
#
4
 
# This program is free software; you can redistribute it and/or modify
5
 
# it under the terms of the GNU General Public License as published by
6
 
# the Free Software Foundation; version 2 of the License.
7
 
#
8
 
# This program is distributed in the hope that it will be useful, but
9
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
 
# General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
16
 
# USA
17
 
 
18
 
package GenTest::Stack::Stack;
19
 
 
20
 
require Exporter;
21
 
@ISA = qw(GenTest);
22
 
 
23
 
use strict;
24
 
use GenTest;
25
 
use GenTest::Stack::StackFrame;
26
 
use Data::Dumper;
27
 
 
28
 
use constant FRAME_NO   => 0;
29
 
use constant FRAMES     => 1;
30
 
 
31
 
1;
32
 
 
33
 
sub new {
34
 
        my $class = shift;
35
 
 
36
 
        my $stack = $class->SUPER::new({}, @_);
37
 
 
38
 
        $stack->[FRAME_NO] = 0;
39
 
 
40
 
        return $stack;
41
 
}
42
 
 
43
 
sub _current {
44
 
    return $_[0]->[FRAME_NO];
45
 
}
46
 
 
47
 
sub push {
48
 
    my ($self) = @_;
49
 
    my $arg;
50
 
    if ($self->_current() > 0) {
51
 
        $arg = $self->get("arg") if defined $self->get("arg");
52
 
    }
53
 
    $self->[FRAME_NO]++;
54
 
    $self->[$self->[FRAME_NO]]=GenTest::Stack::StackFrame->new();
55
 
    $self->set("arg",$arg) if defined $arg;
56
 
    return undef;
57
 
}
58
 
 
59
 
 
60
 
sub set {
61
 
    my ($self, $name, $value) = @_;
62
 
 
63
 
    $self->[$self->_current()]->set($name,$value);
64
 
    return undef;
65
 
    
66
 
}
67
 
 
68
 
sub get {
69
 
    my ($self, $name, $value) = @_;
70
 
    
71
 
    return $self->[$self->_current()]->get($name);
72
 
    
73
 
}
74
 
 
75
 
sub pop {
76
 
    my ($self,$result) = @_;
77
 
    $self->[FRAME_NO]--;
78
 
    ## Place the result on the callers frame
79
 
    $self->set("result",$result) if $self->[FRAME_NO] > 0;
80
 
    return undef;
81
 
}
82
 
 
83
 
1;