Otawa  0.10
IfAST.h
Go to the documentation of this file.
1 /*
2  * IfAST class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2003, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef OTAWA_AST_IF_AST_H
22 #define OTAWA_AST_IF_AST_H
23 
24 #include <otawa/ast/AST.h>
25 
26 namespace otawa { namespace ast {
27 
28 // IfAST class
29 class IfAST: public AST {
31 protected:
32  virtual ~IfAST(void);
33 public:
34  IfAST(AST *condition, AST *then_part);
35  IfAST(AST *condition, AST *then_part, AST *else_part);
36  inline AST *condition(void) const { return cond; };
37  inline AST *thenPart(void) const { return tpart; };
38  inline AST *elsePart(void) const { return epart; };
39 
40  // AST overload
41  virtual Inst *first(void);
42  virtual ast_kind_t kind(void) const { return AST_If; };
43  virtual IfAST *toIf(void) { return this; };
44  virtual int countInstructions(void) const;
45 };
46 
47 } } // otawa::ast
48 
49 #endif // OTAWA_AST_IF_AST_H
virtual Inst * first(void)
Definition: IfAST.cpp:87
AST * tpart
Definition: IfAST.h:30
AST * cond
Definition: IfAST.h:30
virtual int countInstructions(void) const
Count the number of instructions in the ast block.
Definition: IfAST.cpp:94
Definition: AST.h:46
virtual ~IfAST(void)
Definition: IfAST.cpp:57
AST * epart
Definition: IfAST.h:30
virtual ast_kind_t kind(void) const
Get the kind of the AST.
Definition: IfAST.h:42
IfAST(AST *condition, AST *then_part)
Build a selection without else part.
Definition: IfAST.cpp:37
AST * condition(void) const
Get the condition of the selection.
Definition: IfAST.h:36
AST for representing selections.
Definition: IfAST.h:29
This is the base class for the representation of programs as Abstract Syntax Trees.
Definition: AST.h:53
This class represents assembly instruction of a piece of code.
Definition: Inst.h:62
AST * thenPart(void) const
Get the "then" part of the selection.
Definition: IfAST.h:37
AST * elsePart(void) const
Get the "else" part of the selection.
Definition: IfAST.h:38
ast_kind_t
Definition: AST.h:40
virtual IfAST * toIf(void)
Get the selection AST if this AST is a selection, null else.
Definition: IfAST.h:43