Otawa  0.10
Var.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * Var class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2005-07, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef OTAWA_ILP_VAR_H
23 #define OTAWA_ILP_VAR_H
24 
25 #include <elm/io.h>
26 
27 namespace otawa { namespace ilp {
28 
29 using namespace elm;
30 
31 class Alias;
32 class Expression;
33 class System;
34 
35 // Var class
36 class Var {
37 public:
38  typedef enum {
39  NO_TYPE = 0,
40  INT = 1,
41  BIN = 2,
42  FLOAT = 3
43  } type_t;
44 
45  virtual ~Var(void);
46  inline const string& name(void) const { return _name; }
47  inline type_t type(void) const { return _type; }
48  virtual void print(io::Output& out);
49  virtual Alias *toAlias(void);
50  virtual double eval(System *sys);
51 
52 protected:
53  inline Var(type_t type = INT): _type(type) { }
54  inline Var(cstring name, type_t type = INT): _name(name), _type(type) { }
55  inline Var(const string& name, type_t type = INT): _name(name), _type(type) { }
56 
57 private:
58  string _name;
60 };
61 
62 // Alias class
63 class Alias: public Var {
64 public:
65  Alias(Expression *expr);
66  Alias(string name, Expression *expr);
67  virtual ~Alias(void);
68  virtual Alias *toAlias(void);
69  virtual double eval(System *sys);
70  inline const Expression *expression(void) const { return _expr; }
71 private:
73 };
74 
75 // Output
76 inline io::Output& operator<<(io::Output& out, Var *var) { var->print(out); return out; }
77 inline io::Output& operator<<(io::Output& out, Var& var) { var.print(out); return out; }
79 
80 
81 } } // otawa::ilp
82 
83 #endif // OTAWA_ILP_VAR_H
An expression allows to represent a sum of terms and may be used to represent the value of an aliased...
Definition: Expression.h:43
Var(type_t type=INT)
Build an anonymous variable.
Definition: Var.h:53
const string & name(void) const
Get the name of the variable if any.
Definition: Var.h:46
string _name
Definition: Var.h:58
Definition: inst.h:95
Var(const string &name, type_t type=INT)
Build a variable with the given name.
Definition: Var.h:55
const Expression * expression(void) const
Definition: Var.h:70
virtual void print(io::Output &out)
Print the name of the variable.
Definition: ilp_Var.cpp:86
io::Output & operator<<(io::Output &out, Constraint::comparator_t comp)
Definition: ilp_Constraint.cpp:128
Var(cstring name, type_t type=INT)
Definition: Var.h:54
Expression * _expr
Definition: Var.h:72
type_t type(void) const
Get the type of the variable.
Definition: Var.h:47
sys::SystemOutStream & out
type_t _type
Definition: Var.h:59
An alias is a specific variable that represents an expressions.
Definition: Var.h:63
cstring name
Definition: odisasm.cpp:107
A variable is an identifier used for performing ILP computation.
Definition: Var.h:36
An ILP system is a colletion of ILP constraint that may maximize or minimize some object function...
Definition: System.h:42
const Type & type(void)
Definition: type.h:163
Encapsulation for ilp::Var pointers for {ilp} expr user-fiendly interface.
Definition: expr.h:29
type_t
Type of an ILP variable.
Definition: Var.h:38
type_t
Definition: features.h:57