-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stack.h
60 lines (52 loc) · 1.19 KB
/
Stack.h
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
52
53
54
55
56
57
58
59
60
#pragma once
#include <stack>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <QString>
#include "ErrorCodes.h"
#define BASIC256EPSILON 0.00000001
enum b_type {T_FLOAT, T_STRING, T_BOOL, T_ARRAY, T_STRARRAY, T_UNUSED, T_VARREF, T_VARREFSTR};
// stack types T_VARREF, T_VARREFSTR are to pass a variable reference to a subroutine or function (BYREF passing)
struct stackdata
{
b_type type;
QString string;
double floatval;
};
class Stack
{
public:
Stack();
~Stack();
void pushstring(QString);
void pushint(int);
void pushfloat(double);
void pushvarref(int);
void pushvarrefstr(int);
void swap();
void swap2();
void topto2();
void dup();
void dup2();
int peekType();
int popint();
double popfloat();
QString popstring();
void clear();
void debug();
int height();
int compareTopTwo();
int compareFloats(double, double);
int error();
private:
std::stack<stackdata*> stackstack;
int errornumber; // internal storage of last stack error
stackdata *popelement();
};