2022-10-17 22:26:36 -03:00
|
|
|
#ifndef OBELISK_AST_VARIABLE_EXPRESSION_AST_H
|
|
|
|
#define OBELISK_AST_VARIABLE_EXPRESSION_AST_H
|
|
|
|
|
|
|
|
#include "ast/expression_ast.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace obelisk
|
|
|
|
{
|
2023-02-20 22:01:14 -03:00
|
|
|
/**
|
|
|
|
* @brief The variable expression AST node.
|
|
|
|
*
|
|
|
|
*/
|
2022-10-17 22:26:36 -03:00
|
|
|
class VariableExpressionAST : public ExpressionAST
|
|
|
|
{
|
|
|
|
private:
|
2023-02-20 22:01:14 -03:00
|
|
|
/**
|
|
|
|
* @brief The name of the variable.
|
|
|
|
*
|
|
|
|
*/
|
2022-10-17 22:26:36 -03:00
|
|
|
std::string name_;
|
2023-02-20 22:01:14 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the name of the variable.
|
|
|
|
*
|
|
|
|
* @return std::string Returns the name of the variable.
|
|
|
|
*/
|
2022-10-17 22:26:36 -03:00
|
|
|
std::string getName();
|
2023-02-20 22:01:14 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the name of the variable.
|
|
|
|
*
|
|
|
|
* @param[in] name The name of the variable.
|
|
|
|
*/
|
2022-10-17 22:26:36 -03:00
|
|
|
void setName(const std::string name);
|
|
|
|
|
|
|
|
public:
|
2023-02-20 22:01:14 -03:00
|
|
|
/**
|
|
|
|
* @brief Construct a new VariableExpressionAST object.
|
|
|
|
*
|
|
|
|
* @param[in] name The name of the variable.
|
|
|
|
*/
|
2022-10-17 22:26:36 -03:00
|
|
|
VariableExpressionAST(const std::string &name) :
|
|
|
|
name_(name)
|
|
|
|
{
|
|
|
|
}
|
2022-11-21 21:24:44 -03:00
|
|
|
|
2023-02-20 22:01:14 -03:00
|
|
|
/**
|
|
|
|
* @brief Generate the variable LLVM IR code.
|
|
|
|
*
|
|
|
|
* @return llvm::Value* Returns the generated IR code.
|
|
|
|
*/
|
2022-11-21 21:24:44 -03:00
|
|
|
llvm::Value *codegen() override;
|
2022-10-17 22:26:36 -03:00
|
|
|
};
|
2023-02-20 22:01:14 -03:00
|
|
|
} // namespace obelisk
|
2022-10-17 22:26:36 -03:00
|
|
|
|
|
|
|
#endif
|