1 #ifndef TAN_SRC_AST_AST_ARG_DECL_H
2 #define TAN_SRC_AST_AST_ARG_DECL_H
5 #include "ast/ast_base.h"
6 #include "ast/ast_named.h"
14 bool is_lvalue()
override {
return true; }
15 void set_lvalue(
bool)
override { TAN_ASSERT(
false); }
16 [[nodiscard]] vector<ASTBase *>
get_children()
const override;
17 virtual bool is_type_decl()
const {
return false; }
19 [[nodiscard]]
bool is_public()
const;
20 void set_public(
bool is_public);
21 [[nodiscard]]
bool is_external()
const;
22 void set_external(
bool is_external);
28 bool _is_external =
false;
29 bool _is_public =
false;
59 bool is_public,
Stmt *body =
nullptr,
bool is_intrinsic =
false);
64 void set_body(
Stmt *body);
65 [[nodiscard]]
Stmt *get_body()
const;
67 [[nodiscard]]
size_t get_n_args()
const;
68 [[nodiscard]] str get_arg_name(
size_t i)
const;
69 void set_arg_names(
const vector<str> &names);
70 [[nodiscard]]
const vector<ArgDecl *> &get_arg_decls()
const;
71 void set_arg_decls(
const vector<ArgDecl *> &arg_decls);
73 bool is_intrinsic()
const;
74 void set_is_intrinsic(
bool is_intrinsic);
76 [[nodiscard]] vector<ASTBase *>
get_children()
const override;
79 bool _is_intrinsic =
false;
81 vector<str> _arg_names{};
82 vector<ArgDecl *> _arg_decls{};
84 Stmt *_body =
nullptr;
90 bool is_type_decl()
const override {
return true; }
101 const vector<Expr *> &get_member_decls()
const;
102 void set_member_decls(
const vector<Expr *> &member_decls);
104 Type *get_struct_member_ty(
int i)
const;
105 vector<Type *> get_member_types()
const;
107 int get_struct_member_index(
const str &name)
const;
108 void set_member_index(
const str &name,
int idx);
110 Expr *get_member_default_val(
int i)
const;
111 void set_member_default_val(
int i,
Expr *val);
119 vector<Expr *> _member_decls{};
120 umap<int, Expr *> _default_vals{};
121 umap<str, int> _member_indices{};
All named AST nodes should inherit this class.
vector< ASTBase * > get_children() const override
Get a ordered list of child nodes.
vector< ASTBase * > get_children() const override
Get a ordered list of child nodes.
str terminal_token() const override
Which terminal token is expected immediately after this node.
vector< ASTBase * > get_children() const override
Get a ordered list of child nodes.
str terminal_token() const override
Which terminal token is expected immediately after this node.
Different from SourceFile, TokenizedSourceFile manages the tokenized text of a source file.
Type is immutable once created. The exception is StructType. Its information is updated in multiple s...