From b3c3b8d7ecc85fe2acc2b46fbea249eb86d00c56 Mon Sep 17 00:00:00 2001 From: wangziwenhk Date: Fri, 4 Oct 2024 15:43:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B8=B8=E9=87=8F=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Types/Statements.ixx | 46 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/src/Types/Statements.ixx b/src/Types/Statements.ixx index 107cb34..5df3b76 100644 --- a/src/Types/Statements.ixx +++ b/src/Types/Statements.ixx @@ -23,15 +23,18 @@ namespace Riddle { IntegerStmtID,// int 类型 FloatStmtID, // float 类型 + DoubleStmtID, + BoolStmtID, + NullStmtID, - NullStmtID,// 没有任何效果的语句 + NoneStmtID,// 没有任何效果的语句 }; protected: StmtTypeID StmtID; public: - BaseStmt(): StmtID(StmtTypeID::NullStmtID) {} + BaseStmt(): StmtID(StmtTypeID::NoneStmtID) {} explicit BaseStmt(const StmtTypeID stmtTypeID): StmtID(stmtTypeID) {} virtual ~BaseStmt() = default; @@ -62,13 +65,50 @@ namespace Riddle { /// @brief 存储int类型数据 class IntegerStmt final : public ConstantStmt { + protected: int value; public: - explicit IntegerStmt(const int value): ConstantStmt(StmtTypeID::IntegerStmtID), value(value){}; + explicit IntegerStmt(const int value): ConstantStmt(StmtTypeID::IntegerStmtID), value(value) {} [[nodiscard]] inline int getValue() const { return value; } }; + /// @brief 存储 float 数据类型 + class FloatStmt final : public ConstantStmt { + protected: + float value; + + public: + explicit FloatStmt(const float value): ConstantStmt(StmtTypeID::FloatStmtID), value(value) {} + [[nodiscard]] inline float getValue() const { return value; } + }; + + /// @brief 存储 Null 数据类型 + class NullStmt final : public ConstantStmt { + public: + NullStmt(): ConstantStmt(StmtTypeID::NullStmtID) {} + }; + + /// @brief 存储 double 数据类型 + class DoubleStmt final : public ConstantStmt { + protected: + double value; + + public: + explicit DoubleStmt(const double value): ConstantStmt(StmtTypeID::DoubleStmtID), value(value) {} + [[nodiscard]] inline double getValue() const { return value; } + }; + + /// @brief 存储 bool 数据类型 + class BoolStmt final : public ConstantStmt { + protected: + bool value; + + public: + explicit BoolStmt(const bool value): ConstantStmt(StmtTypeID::BoolStmtID), value(value) {} + [[nodiscard]] inline bool getValue() const { return value; } + }; + // todo 实现多个变量定义 /// @brief 用于存储变量定义