File: Variables.h

package info (click to toggle)
basic256 2.0.0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 15,076 kB
  • sloc: cpp: 16,791; yacc: 3,979; lex: 1,446; makefile: 25
file content (73 lines) | stat: -rwxr-xr-x 1,560 bytes parent folder | download
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
61
62
63
64
65
66
67
68
69
70
71
72
73
// implement variables using a c++ map of the variable number and a pointer to the variable structure
// this will allow for a dynamically allocated number of variables
// 2010-12-13 j.m.reneau

#pragma once

#include "Error.h"
#include "DataElement.h"

#define MAX_RECURSE_LEVELS	1048576


class Variable
{
	public:
		Variable();
		~Variable();

		DataElement *data;
};


class Variables: public QObject
{
	Q_OBJECT;
	public:
		Variables(int);
		~Variables();
		//
		QString debug();
		void increaserecurse();
		void decreaserecurse();
		int getrecurse();
		//
		int type(int);
		//
		Variable* get(int, int);
		Variable* get(int);
		Variable* getAt(int, int);
		Variable* getAt(int);
		DataElement *getData(int);

		void setData(int, DataElement *);
		void setData(int, long);
		void setData(int, double);
		void setData(int, QString);
		void unassign(int);
		//
		void makeglobal(int);

		static int getError() {
			return getError(false);
		}

		static int getError(int clear) {
			int olde = e;
			if (clear) e = ERROR_NONE;
			return olde;
		}

	private:
		int real_varnum;		// set by get and getAt for the actual variable number and level returned (deref/global)
		int real_level;
		int numsyms;		// size of the symbol table
		int recurselevel;
		int maxrecurselevel;
		std::vector<Variable**> varmap;
		bool *isglobal;
		void allocateRecurseLevel();
		void clearRecurseLevel();
		void clearvariable(Variable *);
		static int e;		// error number thrown - will be 0 if no error
};