summaryrefslogtreecommitdiff
path: root/src/astnode.h
blob: 7b9e92881cc71d924c1109747928e2fdf944bbd6 (plain)
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
#ifndef AST_NODE_H
#define AST_NODE_H

#include <bu/list.h>

class AstNode
{
friend Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n );
public:
	enum Type
	{
		tLeaf				= 0x01000000,
		tNot				= 0x01000001,
		tComp				= 0x01000002,
		tCompGt				= 0x01000003,
		tCompLt				= 0x01000004,
		tCompGtEq			= 0x01000005,
		tCompLtEq			= 0x01000006,
		tStore				= 0x01000007,
		tAnd				= 0x01000008,
		tOr					= 0x01000009,
		tPlus				= 0x0100000A,
		tMinus				= 0x0100000B,
		tDivide				= 0x0100000C,
		tMultiply			= 0x0100000D,
		tPlusStore			= 0x0100000E,
		tMinusStore			= 0x0100000F,
		tDivideStore		= 0x01000010,
		tMultiplyStore		= 0x01000011,
		tNegate				= 0x01000012,
		tIn					= 0x01000013,
		tGoto				= 0x01000014,
		tSwap				= 0x01000015,
		tStoreRev			= 0x01000016,

		tLeafLiteral		= 0x02000000,
		tVarName			= 0x02000001,
		tLiteral			= 0x02000002,
		tFuncCall			= 0x02000003,

		tBranch				= 0x04000000,
		tScope				= 0x04000001,
		tIf					= 0x04000002,
		tForEach			= 0x04000003,
		tWhile				= 0x04000004,

		tTypeMask			= 0x07000000,
	};
	
	AstNode( Type eType );
	virtual ~AstNode();

	Type getType() const { return eType; }

private:
	Type eType;
};

Bu::Formatter &operator<<( Bu::Formatter &f, AstNode::Type t );
Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n );

#endif