LOOS  v2.3.2
KernelStack.hpp
1 /*
2  This file is part of LOOS.
3 
4  LOOS (Lightweight Object-Oriented Structure library)
5  Copyright (c) 2008, Tod D. Romo, Alan Grossfield
6  Department of Biochemistry and Biophysics
7  School of Medicine & Dentistry, University of Rochester
8 
9  This package (LOOS) is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation under version 3 of the License.
12 
13  This package is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 
23 
24 
25 
26 #if !defined(LOOS_KERNELSTACK_HPP)
27 #define LOOS_KERNELSTACK_HPP
28 
29 
30 #include <iostream>
31 #include <string>
32 #include <stdexcept>
33 #include <vector>
34 
35 
36 #include <loos_defs.hpp>
37 #include <exceptions.hpp>
38 
39 #include "KernelValue.hpp"
40 
41 
42 namespace loos {
43 
44  namespace internal {
45 
46  class ValueStack {
47  std::vector<Value> values;
48 
49  void requireNotEmpty(void) const;
50 
51  public:
52  void push(const Value&);
53  Value pop(void);
54  void dup(void);
55  void drop(void);
56 
57  // Peek at the top value without popping it...
58  Value peek(int);
59 
60  unsigned int size(void) const;
61 
62  void clear(void);
63 
64  friend std::ostream& operator<<(std::ostream&, const ValueStack&);
65  };
66  }
67 }
68 
69 
70 #endif
Drop the top item from the stack.
Duplicate the top item on the stack.
Namespace for most things not already encapsulated within a class.
Value class for the LOOS Kernel (virtual machine)
Definition: KernelValue.hpp:51