File: stack.h

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (51 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef INCLUDED_STACK_
#define INCLUDED_STACK_

#include <cstdint>
#include <vector>
#include <string>

class Variable;             // the abstract base class for Ints, Strings,
                            // and Lists.

    // conceptually the stack grows from high to low, but the vector
    // grows from low to high. For pushing and popping that's irrelevant,
    // but when accessing a stack element based on its index the
    // sign of the index is negated.

class Stack
{
    std::string d_bimFilename;

    std::vector<Variable> d_stack;
    unsigned d_BP = 0;

    public:
        Stack(unsigned idx, unsigned argc, char **argv);

        Variable &operator[](int index);

        void push(Variable &&tmp);                      // 1
        void push(Variable const &var);                 // 2

        Variable topMove() noexcept;
        Variable &top();                                // .f
        void pop();                                     // .f

        void pushBP();
        void popBP();

        void asp(uint16_t nElements);                   // .f

    private:
        void pushCharPtrPtr(char **src);
        void pushArgs(unsigned idx, unsigned argc, char **argv);
};

#include "asp.f"
#include "pop.f"
#include "top.f"

#endif