#include "astnode.h" #include #include "astleaf.h" #include "astleafliteral.h" #include "astbranch.h" AstNode::AstNode( AstNode::Type eType ) : eType( eType ) { } AstNode::~AstNode() { } Bu::Formatter &operator<<( Bu::Formatter &f, AstNode::Type t ) { switch( t ) { case AstNode::tLeaf: return f << "!tLeaf!"; case AstNode::tNot: return f << "tNot"; case AstNode::tComp: return f << "tComp"; case AstNode::tCompGt: return f << "tCompGt"; case AstNode::tCompLt: return f << "tCompLt"; case AstNode::tCompGtEq: return f << "tCompGtEq"; case AstNode::tCompLtEq: return f << "tCompLtEq"; case AstNode::tStore: return f << "tStore"; case AstNode::tAnd: return f << "tAnd"; case AstNode::tOr: return f << "tOr"; case AstNode::tPlus: return f << "tPlus"; case AstNode::tMinus: return f << "tMinus"; case AstNode::tDivide: return f << "tDivide"; case AstNode::tMultiply: return f << "tMultiply"; case AstNode::tPlusStore: return f << "tPlusStore"; case AstNode::tMinusStore: return f << "tMinusStore"; case AstNode::tDivideStore: return f << "tDivideStore"; case AstNode::tMultiplyStore: return f << "tMultiplyStore"; case AstNode::tNegate: return f << "tNegate"; case AstNode::tIn: return f << "tIn"; case AstNode::tLeafLiteral: return f << "!tLeafLiteral!"; case AstNode::tVarName: return f << "tVarName"; case AstNode::tLiteral: return f << "tLiteral"; case AstNode::tFuncCall: return f << "tFuncCall"; case AstNode::tBranch: return f << "!tBranch!"; case AstNode::tScope: return f << "tScope"; case AstNode::tIf: return f << "tIf"; case AstNode::tForEach: return f << "tForEach"; case AstNode::tWhile: return f << "tWhile"; case AstNode::tTypeMask: return f << "!tTypeMask!"; } return f << "???"; } Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n ) { switch( n.eType & AstNode::tTypeMask ) { case AstNode::tLeaf: return f << dynamic_cast(n); case AstNode::tLeafLiteral: return f << dynamic_cast(n); case AstNode::tBranch: return f << dynamic_cast(n); } return f << "!!!ERROR!!!"; }