You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.0 KiB
51 lines
1.0 KiB
#ifndef _SYSYF_VALUE_H_
|
|
#define _SYSYF_VALUE_H_
|
|
|
|
#include <string>
|
|
#include <list>
|
|
#include <iostream>
|
|
|
|
class Type;
|
|
class Value;
|
|
|
|
struct Use
|
|
{
|
|
Value *val_;
|
|
unsigned arg_no_; // the no. of operand, e.g., func(a, b), a is 0, b is 1
|
|
Use(Value *val, unsigned no) : val_(val), arg_no_(no) {}
|
|
};
|
|
|
|
class Value
|
|
{
|
|
public:
|
|
explicit Value(Type *ty, const std::string &name = "");
|
|
~Value() = default;
|
|
|
|
Type *get_type() const { return type_; }
|
|
|
|
std::list<Use> &get_use_list() { return use_list_; }
|
|
|
|
void add_use(Value *val, unsigned arg_no = 0);
|
|
|
|
bool set_name(std::string name) {
|
|
if (name_ == "")
|
|
{
|
|
name_=name;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
std::string get_name() const;
|
|
|
|
void replace_all_use_with(Value *new_val);
|
|
void remove_use(Value *val);
|
|
|
|
virtual std::string print() = 0;
|
|
private:
|
|
Type *type_;
|
|
std::list<Use> use_list_; // who use this value
|
|
std::string name_; // should we put name field here ?
|
|
};
|
|
|
|
#endif // _SYSYF_VALUE_H_
|