/*! @file src/Ast/Stmt/StructDefStmt.hpp @brief 结构体定义 AST 节点 */ #pragma once #include #include namespace Fig { struct StructDefStmt final : public Stmt { struct Field { bool isPublic; bool typeInfer; String name; TypeExpr *type; Expr *initExpr; }; bool isPublic; String name; DynArray typeParameters; DynArray fields; DynArray methods; StructDefStmt() { type = AstType::StructDefStmt; } StructDefStmt(bool _p, String _n, DynArray _tp, DynArray _f, DynArray _m, SourceLocation _loc) : isPublic(_p), name(std::move(_n)), typeParameters(std::move(_tp)), fields(std::move(_f)), methods(std::move(_m)) { type = AstType::StructDefStmt; location = std::move(_loc); } virtual String toString() const override { String detail = name; if (!typeParameters.empty()) { detail += "<...>"; } return std::format("", detail); } }; } // namespace Fig