summaryrefslogtreecommitdiff
path: root/src/astnode.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-12-27 00:04:28 -0700
committerMike Buland <eichlan@xagasoft.com>2011-12-27 00:04:28 -0700
commitf33fdd93ef93fdbb0e6b3a8e2ecb80b78f1b2816 (patch)
tree3e62207265b4efbbe1565ea885a615e5a910671c /src/astnode.cpp
parent32c32bc48c8fd7cffca301b8919fb26726f6467e (diff)
downloadstage-f33fdd93ef93fdbb0e6b3a8e2ecb80b78f1b2816.tar.gz
stage-f33fdd93ef93fdbb0e6b3a8e2ecb80b78f1b2816.tar.bz2
stage-f33fdd93ef93fdbb0e6b3a8e2ecb80b78f1b2816.tar.xz
stage-f33fdd93ef93fdbb0e6b3a8e2ecb80b78f1b2816.zip
Branch building has started.
Diffstat (limited to 'src/astnode.cpp')
-rw-r--r--src/astnode.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/astnode.cpp b/src/astnode.cpp
index 4e0f30e..2c94ca9 100644
--- a/src/astnode.cpp
+++ b/src/astnode.cpp
@@ -1,5 +1,11 @@
1#include "astnode.h" 1#include "astnode.h"
2 2
3#include <bu/formatter.h>
4
5#include "astleaf.h"
6#include "astleafliteral.h"
7#include "astbranch.h"
8
3AstNode::AstNode( AstNode::Type eType ) : 9AstNode::AstNode( AstNode::Type eType ) :
4 eType( eType ) 10 eType( eType )
5{ 11{
@@ -9,3 +15,52 @@ AstNode::~AstNode()
9{ 15{
10} 16}
11 17
18Bu::Formatter &operator<<( Bu::Formatter &f, AstNode::Type t )
19{
20 switch( t )
21 {
22 case AstNode::tLeaf: return f << "!tLeaf!";
23 case AstNode::tNot: return f << "tNot";
24 case AstNode::tComp: return f << "tComp";
25 case AstNode::tCompGt: return f << "tCompGt";
26 case AstNode::tCompLt: return f << "tCompLt";
27 case AstNode::tCompGtEq: return f << "tCompGtEq";
28 case AstNode::tCompLtEq: return f << "tCompLtEq";
29 case AstNode::tStore: return f << "tStore";
30 case AstNode::tAnd: return f << "tAnd";
31 case AstNode::tOr: return f << "tOr";
32
33 case AstNode::tLeafLiteral: return f << "!tLeafLiteral!";
34 case AstNode::tVarName: return f << "tVarName";
35 case AstNode::tLiteral: return f << "tLiteral";
36 case AstNode::tFuncName: return f << "tFuncName";
37
38 case AstNode::tBranch: return f << "!tBranch!";
39 case AstNode::tScope: return f << "tScope";
40 case AstNode::tIf: return f << "tIf";
41 case AstNode::tForEach: return f << "tForEach";
42 case AstNode::tWhile: return f << "tWhile";
43
44 case AstNode::tTypeMask: return f << "!tTypeMask!";
45 }
46
47 return f << "???";
48}
49
50Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n )
51{
52 switch( n.eType & AstNode::tTypeMask )
53 {
54 case AstNode::tLeaf:
55 return f << dynamic_cast<const AstLeaf &>(n);
56
57 case AstNode::tLeafLiteral:
58 return f << dynamic_cast<const AstLeafLiteral &>(n);
59
60 case AstNode::tBranch:
61 return f << dynamic_cast<const AstBranch &>(n);
62 }
63
64 return f << "!!!ERROR!!!";
65}
66